如何使用Blueprint将OSGi服务注入EJB

时间:2012-12-12 09:03:55

标签: java-ee ejb osgi blueprint-osgi

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

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

我一直试图用Aries Blueprint以及带有JBoss AS7的Gemini Blueprint来做这件事,但没有运气。

作为示例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();
  }
}

1 个答案:

答案 0 :(得分:1)

看来我问的是不可能的。

可能的是