提交 3b39c308 编写于 作者: K Kohsuke Kawaguchi

Inject parameters from Guice when we can.

This allows @Initializer to have parameter injection
上级 fccc3498
package hudson.init;
import com.google.inject.Injector;
import hudson.model.Hudson;
import jenkins.model.Jenkins;
import org.jvnet.hudson.annotation_indexer.Index;
......@@ -116,6 +117,12 @@ abstract class TaskMethodFinder<T extends Annotation> extends TaskBuilder {
private Object lookUp(Class<?> type) {
if (type==Jenkins.class || type==Hudson.class)
return Jenkins.getInstance();
Jenkins j = Jenkins.getInstance();
if (j!=null) {
Injector i = j.getInjector();
if (i!=null)
return i.getInstance(type);
}
throw new IllegalArgumentException("Unable to inject "+type);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册