Hi,

I am just experimenting a little bit with the implementation.osgi stuff
taking some samples as start...

I would like to have the following scenario. Two bundles are started in the
OSGi framework and are registered in for SCA. One bundle is consuming a
service that is implemented by the other bundle. I do not get an idea how
this can be done or maybe it is not possible.

So from the samples I have an OSGI-INF/sca folder with a bundle.composite
and a bundle.componentType file.

bundle.composite:

<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912";
    xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1";
    xmlns:xsd="http://www.w3.org/2001/XMLSchema";
    targetNamespace="http://calculator.dosgi";
    name="SMSComposite">

    <component name="SMSComponent">
        <tuscany:implementation.osgi
bundleSymbolicName="DeveloperGardenSDK.SMS" bundleVersion="0.0.1" />
        <service name="smsService">
            <binding.ws uri="http://localhost:8082/SMSService"/>
        </service>
    </component>   
</composite>

bundle.componentType:

<componentType xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912";
               xmlns:xsd="http://www.w3.org/2001/XMLSchema";
               xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1";>
    <service name="smsService">
        <interface.java
interface="de.fhg.fokus.ngni.xposer.see.developergarden.sms.SMS"/>
    </service>
</componentType>

Furthermore the service is registered in the Activator class. The
registration is working and I am also able to consume the service via SOAP.
Now I want to have a second bundle that is able to consume the service.
Following files are created:

bundle.composite:

<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912";
    xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1";
    xmlns:xsd="http://www.w3.org/2001/XMLSchema";
    targetNamespace="http://calculator.dosgi";
    name="ReminderComposite">
    <component name="ReminderComponent">
        <tuscany:implementation.osgi bundleSymbolicName="Reminder_SCA"
bundleVersion="1.0" />
        <service name="ReminderService">
            <binding.ws uri="http://localhost:8082/ReminderService"/>
        </service>
        <reference name="smsService">
            <binding.ws uri="http://localhost:8082/SMSService"/>
        </reference>
    </component>   
</composite>

bundle.componentType:

<componentType xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912";
               xmlns:xsd="http://www.w3.org/2001/XMLSchema";
               xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1";>
    <service name="ReminderService">
        <interface.java
interface="de.fhg.fokus.ngni.xposer.see.service.sca.reminder.ReminderService
"/>
    </service>
    <reference name="smsService">
        <interface.java
interface="de.fhg.fokus.ngni.xposer.see.developergarden.sms.SMS"/>
    </reference>
</componentType>

Again this service is registered via the Activator class. How I am getting
now the SMS service in the Java Code? I tried some things I have found in
other samples.
So the ReminderService implementation looks like that:

public class ReminderServiceImpl implements ReminderService {        private
SMS smsService;        @Reference    public void setSmsService(SMS
smsService){        this.smsService = smsService;    }     @Override
public boolean startReminder(String user) {        return
smsService.sendSMS("xy", "number", "Hallo", "Reminder");    } }

This structure is taken from another sample I looked at. The smsService is
null at this point.
I know that I could get the SMS service over OSGi reference stuff but I want
to use SCA stuff.

Please tell me if my scenario is wrong (or stupid) or if this is just not
working.

Thanks in advance.

greetings,
Alex 

Reply via email to