【问题标题】:How to inject OSGi service to EJB with Blueprint如何使用 Blueprint 将 OSGi 服务注入 EJB
【发布时间】:2012-11-29 22:44:49
【问题描述】:

我知道可以使用ServiceTracker 将 OSGi 服务注入 EJB。

但是,我应该如何使用OSGi Blueprint XML configuration 将服务注入标准 EJB,以便在其他地方使用 EJB 时可以使用服务? 还是真的不可能,因为 EJB 在它们自己的层中工作?

我一直在尝试使用 Aries Blueprint 和 Gemini Blueprint 以及 JBoss AS7 来做到这一点,但没有运气。

以 bean 为例:

import javax.annotation.PostConstruct;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;

import org.osgi.framework.BundleContext;

@Stateless
@LocalBean
public class SimpleStatelessSessionBean {

  InformationService service; // how'd I go about to get this populated?

  @PostConstruct
  public void init() {

  }

  public String getMessage() {

    if (service == null)
      throw new IllegalStateException("Service not available");

    return "EJB:" + service.getMessage();
  }
}

【问题讨论】:

标签: jakarta-ee ejb osgi blueprint-osgi


【解决方案1】:

看来我问的不太可能。

什么是可能的

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-06-29
    • 2011-03-02
    • 1970-01-01
    • 1970-01-01
    • 2013-06-14
    • 2013-10-09
    • 2012-11-21
    • 2013-07-31
    相关资源
    最近更新 更多