CDI - 将SessionBean注入ServletContextListener触发的服务

时间:2014-03-25 10:41:55

标签: java dependency-injection jboss7.x cdi servletcontextlistener

我有一个调用某个bean的ServletContextListener实现。我试图将会话bean注入该bean,但注入的会话bean始终为null

BeanManager执行期间,ServletContextListener是否尚未启动? CDI和听众是否有已知的限制?或者我在代码中遗漏了什么?

以下是我尝试注入的SessionBean的定义 -

@Stateless
@Local(MetricStubSessionLocal.class)
@Remote(MetricStubSessionRemote.class)
public class MetricStubSessionBean implements MetricStubSessionLocal,
    MetricStubSessionRemote {
    ...
}

以下是我试图注入的Bean -

public class MetricStubGeneratorJob implements IdpTimer {

    @Inject
    private MetricStubSession metricStubSession;

    private TimerStatus status;

    public MetricStubGeneratorJob() {
        super();
    }

    public MetricStubGeneratorJob(TimerStatus status) {
        this.status = status;
    }
    ...
}

提前致谢!

0 个答案:

没有答案