1

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?

Anthony
  • 12,177
  • 9
  • 69
  • 105
  • I don't know anything about WAS, but this certainly should be possible. It's kind of the point of OSGi Services: you don't care about the internal implementation details of the Service provider. – Neil Bartlett Nov 30 '13 at 08:01
  • Yeah, I think I saw somewhere that the declarative services(ds) is just a bundle you load in order to use it, but I guess another question that I have is, is ds already a part of WAS's internal OSGI framework implementation? I would think it is since, to my understanding, WAS uses equinox and I believe that ds is a part of equinox. And so I'm thinking… if this is the case, I shouldn't have to include a separate ds bundle, but that it should already be in place within the server. But the code I put in place bombed. I think I bit off too much and should focus on getting just a ds service to run. – Luke DeRienzo Nov 30 '13 at 14:45
  • "Equinox" is an OSGi Framework but the DS implementation is not part of the core framework. DS is an ordinary bundle, which must be installed and started. Of course, WAS contains many more bundles than just the core OSGi Framework, but I do not know if DS is included in those bundles. If not, you can simply add it yourself. – Neil Bartlett Dec 01 '13 at 20:32
  • Also you said "the code I put in place bombed". This isn't a very helpful error report! What happened exactly? If you write a bundle using DS but the DS bundle is not present, then basically nothing will happen. – Neil Bartlett Dec 01 '13 at 20:33
  • Maybe you should: bring back the problem to the smallest possible problem (which often solves it), then withdraw this question and post another. On the question itself there are no practical restrictions in size. – Peter Kriens Dec 02 '13 at 08:44
  • Sorry I can't read this. The best way to add new information to a question is to edit the question. – Neil Bartlett Dec 02 '13 at 11:45
  • Ok guys, again my apologies, still learning the ropes here :). I will take your suggestions. Thank you much again. – Luke DeRienzo Dec 02 '13 at 14:20

0 Answers0