WAS 8.5 - Can a blueprint managed OSGI service have a reference to a declarative services managed OSGI service?

654 views Asked by At

We use WebSphere 8.5 (NON-Liberty Profile… just straight-up WAS) and we have a Spring 3.2 web app that is accessing an OSGI service which is using the blueprint component model via an SCA service bridge. We did this this way because to our understanding, this was the only way to be able to access the OSGI services layer from within our current architecture. If anyone might know of another/better way, I'm also all-ears on this as well.

From within this blueprint managed service, we'd like to have a reference to another service. This other service(and any service references within it) we'd like to have managed by the declarative services component model.

My question is… is this possible? Does anyone know if this mixing of these two component models from within WAS 8.5 is do-able in any way, shape, or form??

And if it is possible, might anyone be able to point me in the right direction on how to approach this?

Edit - Dec 5th

So the approach I decided to take was to first, build a small proof-of-concept application that uses three different OSGI bundles all using blueprint. Then once I have this working, take one of the blueprint managed services, and attempt to convert it to a ds managed service.

Here's what I've got so far: I have ran through and created the tutorial located here. I currently have the CounterApp OSGI bundle Application containing the following bundles as application content:

  • CounterServiceBundle
  • CounterWebBundle
  • CounterWorldBundle

As is stated in the tutorial, all of the above are tied together using the blueprint component model via the blueprint.xml files.

So it all breaks down as follows:

From within the doGet method of the CounterWebBundle's CounterServlet I have a Greet service being used in the following manner:

    Greet greet;
    try {
        InitialContext ic = new InitialContext();
        greet = (Greet) ic.lookup("osgi:service/"+Greet.class.getName());
        String greetText = greet.getText();
        String output = "greet.getText()="+greetText;           
        response.getOutputStream().println(output);
    } catch (NamingException e) {
        e.printStackTrace(System.out);
    }

This "greet" service is defined in the blueprint xml as "GreetBeanService". Now, within its implementation class it has references to two other services, "CounterBean" and "WorldRef".

Here is the blueprint.xml file to clarify:

<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">

<bean id="CounterBean" class="com.ibm.ws.eba.counter.CounterImpl"
    init-method="init"></bean>

<service id="CounterBeanService" ref="CounterBean"
    interface="com.ibm.ws.eba.counter.Counter" />

<bean id="GreetBean" class="com.ibm.ws.eba.counter.GreetImpl"
    init-method="init">
    <property name="counter" ref="CounterBean"/>
    <property name="worldBean" ref="WorldRef"/>
</bean>

<service id="GreetBeanService" ref="GreetBean"
    interface="com.ibm.ws.eba.counter.Greet" />

<reference id="WorldRef" interface="com.ibm.ws.eba.world.World" />

</blueprint>

So the thing is this:

I'm aiming to convert the "WorldRef" service to a DS managed service with a component.xml file and the following added to the MANIFEST.MF header Service-Component: OSGi-INF/component.xml of the implementation Class, not the API Class if I'm understanding correctly.

Would this be all I would need to do for the conversion? Or do I also need to add an Activator for the Class? Also, would I need to add 'activate' and 'deactivate' methods in the API implementation Class?

Also I'm of the understanding that I have to somehow include the service component runtime, as a separate bundle and include it in the "CounterApp" application, how exactly would I do this? Do I have to create a separate bundle project consisting of the following bundle/jars

  • org.eclipse.equinox.util
  • org.eclipse.equinox.ds
  • org.eclipse.osgi.services

where I would then re-export all of the exported interfaces from all of these jars? Or do I have to define some sort of service to export that exposes the SCR?

Edit - Dec 6th

I went ahead and created a new DS OSGI bundle/jar containing all of the above mentioned jar files required to provide the equinox DS implementation, then just passed on the exports of each jar in this new bundle. I then added this DS bundle to my CounterApp application and imported each of these DS bundle exports into the bundle containing the WorldRef service.

This is where I appear to be getting hung up:

The OSGI framework is loading the bundle containing the WorldRef service but the service is not being added to the registry, which suggests that the component.xml file defining the service isn't being read, which, intern suggests that the SCR is not running because it is what reads that file to my understanding.

So still stuck on the ability to get the SCR running. I am under a very tight deadline (I know… who isn't, right?

0

There are 0 answers