本文整理了Java中jenkins.model.Jenkins.getInjector()
方法的一些代码示例,展示了Jenkins.getInjector()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Jenkins.getInjector()
方法的具体详情如下:
包路径:jenkins.model.Jenkins
类名称:Jenkins
方法名:getInjector
[英]Gets the dependency injection container that hosts all the extension implementations and other components in Jenkins.
[中]获取托管Jenkins中所有扩展实现和其他组件的依赖项注入容器。
代码示例来源:origin: jenkinsci/jenkins
/**
* Determines the parameter injection of the initialization method.
*/
private Object lookUp(Class<?> type) {
Jenkins j = Jenkins.getInstance();
assert j != null : "This method is only invoked after the Jenkins singleton instance has been set";
if (type==Jenkins.class || type==Hudson.class)
return j;
Injector i = j.getInjector();
if (i!=null)
return i.getInstance(type);
throw new IllegalArgumentException("Unable to inject "+type);
}
代码示例来源:origin: jenkinsci/configuration-as-code-plugin
@Override
protected AdminWhitelistRule instance(Mapping mapping, ConfigurationContext context) {
Injector injector = Jenkins.getInstance().getInjector();
return injector.getInstance(AdminWhitelistRule.class);
}
代码示例来源:origin: jenkinsci/configuration-as-code-plugin
@Override
public Set<Attribute<Jenkins,?>> describe() {
final Set<Attribute<Jenkins,?>> attributes = super.describe();
// Add remoting security, all legwork will be done by a configurator
attributes.add(new Attribute<Jenkins, AdminWhitelistRule>("remotingSecurity", AdminWhitelistRule.class)
.getter( j -> j.getInjector().getInstance(AdminWhitelistRule.class) )
.setter( noop() ));
// Override "nodes" getter so we don't export Nodes registered by Cloud plugins
Attribute.<Jenkins,List<Node>>get(attributes, "nodes").ifPresent(a ->
a.getter(j -> j.getNodes().stream()
.filter(node -> node.getDescriptor().isInstantiable())
.collect(Collectors.toList())
)
);
return attributes;
}
代码示例来源:origin: jenkinsci/jenkins
long running = Jenkins.getInstance().getInjector().getInstance(Uptime.class).getUptime();
long remaining = TimeUnit.MINUTES.toMillis(10)-running;
if (remaining>0 && /* this logic breaks tests of polling */!Functions.getIsUnitTest()) {
代码示例来源:origin: jenkinsci/jenkins
jenkins.getInjector().getInstance(AdminWhitelistRule.class)
.setMasterKillSwitch(false);
代码示例来源:origin: jenkinsci/configuration-as-code-plugin
@Test
@Issue("Issue #28")
@ConfiguredWithCode("AdminWhitelistRuleConfigurator/Agent2MasterSecurityKillSwitch_disabled.yml")
public void checkM2ASecurityKillSwitch_enabled() throws Exception {
final Jenkins jenkins = Jenkins.getInstance();
AdminWhitelistRule rule = jenkins.getInjector().getInstance(AdminWhitelistRule.class);
Assert.assertTrue("MasterToAgent Security should be enabled", rule.getMasterKillSwitch());
}
代码示例来源:origin: jenkinsci/configuration-as-code-plugin
@Test
@Issue("Issue #28")
@ConfiguredWithCode("AdminWhitelistRuleConfigurator/Agent2MasterSecurityKillSwitch_enabled.yml")
public void checkM2ASecurityKillSwitch_disabled() throws Exception {
final Jenkins jenkins = Jenkins.getInstance();
AdminWhitelistRule rule = jenkins.getInjector().getInstance(AdminWhitelistRule.class);
Assert.assertFalse("MasterToAgent Security should be disabled", rule.getMasterKillSwitch());
}
代码示例来源:origin: jenkinsci/jenkins-test-harness
@Override
public void evaluate() throws Throwable {
j.jenkins.getInjector().injectMembers(step);
j.jenkins.getInjector().injectMembers(target);
step.evaluate();
}
}, expectedToStartCorrectly);
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
/**
* Determines the parameter injection of the initialization method.
*/
private Object lookUp(Class<?> type) {
Jenkins j = Jenkins.getInstance();
assert j != null : "This method is only invoked after the Jenkins singleton instance has been set";
if (type==Jenkins.class || type==Hudson.class)
return j;
Injector i = j.getInjector();
if (i!=null)
return i.getInstance(type);
throw new IllegalArgumentException("Unable to inject "+type);
}
代码示例来源:origin: io.jenkins/configuration-as-code
@Override
protected AdminWhitelistRule instance(Mapping mapping, ConfigurationContext context) {
Injector injector = Jenkins.getInstance().getInjector();
return injector.getInstance(AdminWhitelistRule.class);
}
代码示例来源:origin: jenkinsci/jenkins-test-harness
@Override
public void evaluate() throws Throwable {
j.jenkins.getInjector().injectMembers(step);
j.jenkins.getInjector().injectMembers(target);
step.evaluate();
simulateAbruptShutdown();
}
}, true);
代码示例来源:origin: KostyaSha/yet-another-docker-plugin
public static DockerGlobalConfiguration dockerGlobalConfig() {
return Jenkins.getInstance().getInjector().getInstance(DockerGlobalConfiguration.class);
}
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
public static DownloadSettings get() {
return Jenkins.getInstance().getInjector().getInstance(DownloadSettings.class);
}
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
public static QueueItemAuthenticatorConfiguration get() {
return Jenkins.getInstance().getInjector().getInstance(QueueItemAuthenticatorConfiguration.class);
}
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
public static ArtifactManagerConfiguration get() {
return Jenkins.getInstance().getInjector().getInstance(ArtifactManagerConfiguration.class);
}
代码示例来源:origin: org.jenkins-ci.plugins.workflow/workflow-step-api
/**
* Creates an {@link Injector} that performs injection to {@link Inject} and {@link StepContextParameter}.
*/
protected static Injector prepareInjector(final StepContext context, @Nullable final Step step) {
return Jenkins.getActiveInstance().getInjector().createChildInjector(new ContextParameterModule(step,context));
}
}
代码示例来源:origin: jenkinsci/workflow-step-api-plugin
/**
* Creates an {@link Injector} that performs injection to {@link Inject} and {@link StepContextParameter}.
*/
protected static Injector prepareInjector(final StepContext context, @Nullable final Step step) {
return Jenkins.getActiveInstance().getInjector().createChildInjector(new ContextParameterModule(step,context));
}
}
代码示例来源:origin: io.jenkins/configuration-as-code
@Override
public Set<Attribute<Jenkins,?>> describe() {
final Set<Attribute<Jenkins,?>> attributes = super.describe();
// Add remoting security, all legwork will be done by a configurator
attributes.add(new Attribute<Jenkins, AdminWhitelistRule>("remotingSecurity", AdminWhitelistRule.class)
.getter( j -> j.getInjector().getInstance(AdminWhitelistRule.class) )
.setter( noop() ));
// Override "nodes" getter so we don't export Nodes registered by Cloud plugins
Attribute.<Jenkins,List<Node>>get(attributes, "nodes").ifPresent(a ->
a.getter(j -> j.getNodes().stream()
.filter(node -> node.getDescriptor().isInstantiable())
.collect(Collectors.toList())
)
);
return attributes;
}
代码示例来源:origin: jenkinsci/workflow-cps-plugin
@Before public void setUp() throws Exception {
jenkins.jenkins.getInjector().injectMembers(this);
rootDir = tmp.newFolder();
TEST = this;
}
代码示例来源:origin: jenkinsci/workflow-step-api-plugin
@Before
public void setUp() {
j.getInstance().getInjector().injectMembers(this);
}
内容来源于网络,如有侵权,请联系作者删除!