Szymon Pietrzak wrote:I can see multitude of examples, but still have some questions:
1. Can an EJB be registered as OSGi service without use of BundleActivator and direct call to OSGi APIs (for instance via annotation)? From your reply I understand that each EJB is automatically registered as OSGi service on GlassFish - am I correct?
2. Can an OSGi service which is EJB be referred to from another module only via use of annotations (@Injected @OSGiService) or do I have to create BundleActivator and use ServiceTracked to find the service in the context?
Answer to first question is YES - that's why I call it one kind of declarative service. To use this automatics registration feature, you have to package your EJBs in an OSGi bundle - you can basically turn your existing ejb-jar to an OSGi bundle. You then have to add a manifest entry called Export-EJB which can have values like "ALL" to indicate export all EJBs or comma separated names of EJBs that need to be exported. Currently the implementation supports only registration of Statelss or Singleton EJBs with local business interfaces, i.e, you can't export EJBs with remote interfaces or stateful EJBs.
Answer to second question is also yes. Once the EJB is exported as a service, you can consume it however you like including but not limited to via @Inject @OSGiService.
Please use
[email protected] while starting any new
thread - you will get faster responses as well as responses from other users.
Thanks,
Sahoo