Hi Sahoo, Siver,
Now, my integration has supported Service<T> and @ServiceFilter
Features. Among them,
① Service<T> : It represents a service instance producer parametrized by
the service to inject. It has the same behavior than CDI
javax.enterprise.inject.Instance except that it represents only OSGi
service beans.
Related JIRA RFE:
http://java.net/jira/browse/GLASSFISH-16805
②@ServiceFilter : This annotation qualifies an injection point that
represents a LDAP filtered service.It allows to specify the LDAP filter,
as a required String.
Related JIRA RFE:
http://java.net/jira/browse/GLASSFISH-18978
Normally, @ServiceFilter is used combined with Service<T> in order to
select matched osgi services.
For example:
1 Service Provider1
@Publish({
@Property(name="country", value="EN")
})
public class SimpleStockQuoteServiceImpl implements StockQuoteService{
...
2 Service Provider2
@Publish({
@Property(name="country", value="CN")
})
public class OtherStockQuoteServiceImpl implements StockQuoteService{
...
3 Service Consumer
@WebServlet(urlPatterns = "/list")
public class StockQuoteServlet extends HttpServlet {
@Inject @ServiceFilter("(country=CN)") Service<StockQuoteService> sqses;
...
for (Iterator<StockQuoteService> it = sqses.iterator(); it.hasNext();){
StockQuoteService sqs = it.next();
for(String sym: sqs.getSymbols()){
out.println("<tr>");
out.println("<td>" + sym + "</td>");
out.println("<td>" + sqs.getQuote(sym) + "</td>");
out.println("</tr>");
}
}
...
On the above case, StockQuoteServlet will get osgi services matched
"(country=CN)".
DEMO/Sample:
see
https://github.com/tangyong/gf-cdi-osgi-integration/tree/master/samples/%5BRFP146%5DCDI004
[ToDo]
★Integration CDI event and OSGi event
Wish sahoo and siver can have time to review and discuss with me.
Thanks.
--Tang