Injecting blueprint OSGi service into JSF/PrimeFaces bean -
i have project built on top osgi , karaf server. dependency injection using aries blueprint. main part of project apache camel routes , integration things, need create maintenance web interface. give try jsf - primefaces implementation. able create demo, works in osgi under karaf, that's ok.
now i'd know if it's possible use blueprint here, reference existing osgi services have , inject service jsf bean, can benefit written code.
can me, please?
we solved in following way:
- we created listener that:
- creates servicetracker tracks blueprintcontainer service attached same bundle
- puts servicetracker servletcontext attributes
- we created elresolver uses servicetracker , if there blueprintcontainer available uses getcomponentinstance of value
- the listener opens servicetracer during application initialization , closes during application destroy
our listener class: https://source.everit.biz/svn/everit-util/trunk/core/src/main/java/org/everit/util/core/servlet/serviceloaderlistener.java
our el resolver class: https://source.everit.biz/svn/everit-util/trunk/core/src/main/java/org/everit/util/core/el/osgielresolver.java
user/pass: guest/guest
after registered custom el-resolver el-expressions evaluated in way id-s of component instances searched inside blueprint container. in case have bean-property in faces-config.xml value #{mycomponent} searched inside blueprintcontainer.
Comments
Post a Comment