OSGI Blueprint Issues
charlie7 Feb 1, 2013 4:42 AMThis is my current Architecture
1. SiApp is an OSGI project which contains two interfaces EchoService and BounceService.
2. SIExampleService is an OSGI project :: contains EchoServiceImpl which is the implementaion class of the Interface : EchoService and this is configured via blueprint
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
<bean id="echoservice"
class="com.clink.services.echo.EchoServiceImpl">
</bean>
<service ref="echoservice"
interface="com.clink.services.interfaces.EchoService" />
</blueprint>
3. SIExampleService2 is an OSGI project :: contains BounceServiceImpl which is the implementaion class of the Interface : BounceService
BounceServiceImpl also contains a reference to EchoService which is configured via blueprint
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
<reference id="echoservice"
interface="com.clink.services.interfaces.EchoService" />
<bean id="bounceservice"
class="com.clink.services.bounce.BounceServiceImpl">
<property name="echoService" ref="echoservice" />
</bean>
<service ref="bounceservice"
interface="com.clink.services.interfaces.BounceService" />
</blueprint>
4. SIWeb is a Webpp which contains a servlet-- MainServlet
MainServlet contains instances of both EchoService and BounceService
These are configured via BundleContext.
private EchoService echoService;
private BounceService bounceService;
@Resource
private BundleContext context;
ServiceReference sref = context.getServiceReference(EchoService.class.getName());
echoService = (EchoService)context.getService(sref);
For the Main servlet we use both the instances and print it out
String message = echoService.quack("ECHO");
message = message + bounceService.ping("BOUNCE");
PrintWriter out = response.getWriter();
out.println(message);
out.close();
The output is ECHO--ECHOBOUNCE
BounceServiceImpl internally again calls EchoService as mentioned in point no 3 , hence ECHOBOUNCE
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Issue : 1
=======
Now If I change the implementaion class EchoServiceImpl inside SIExampleService to add something ,build it, deploy it start the bundle
When I run MainServlet again I get the output as
ECHO--ECHOCHANGEBOUNCE
The new bundle of SIExampleService is only reflected for SIExampleService2 called via bounceService.ping("BOUNCE")
and not in the instance of MainServlet which is called via echoService.quack("ECHO");
Shouldn't it auomatically get reflected in both the scenarios?
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Issue : 2
=======
Now If I change the implementaion class BounceServiceImpl inside SIExampleService2 , I get the following Exception
org.osgi.service.blueprint.container.ServiceUnavailableException: The Blueprint container is being or has been destroyed
org.apache.aries.blueprint.container.ReferenceRecipe.getService(ReferenceRecipe.java:197)
org.apache.aries.blueprint.container.ReferenceRecipe.access$000(ReferenceRecipe.java:50)
org.apache.aries.blueprint.container.ReferenceRecipe$ServiceDispatcher.call(ReferenceRecipe.java:227)
org.apache.aries.proxy.impl.ProxyHandler$1.invoke(ProxyHandler.java:54)
org.apache.aries.proxy.impl.ProxyHandler.invoke(ProxyHandler.java:119)
$Proxy13.quack(Unknown Source)
com.clink.services.bounce.BounceServiceImpl.ping(BounceServiceImpl.java:25)
com.clink.servlet.MainServlet.doGet(MainServlet.java:54)
javax.servlet.http.HttpServlet.service(HttpServlet.java:734)
javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:62).
I did not find anything about this Exception ,This exception goes away if I remove the reference in the config.xml to echoService
Please do help me out in these two issue
Thanks in Advance