>
>
>>
>> We have registered the RegistryProvider inside the* 
>> registry.ws.client*bundle and trying to get that registered service at
>> *registry.core*.
>> But that service is going to fetch at the MountHandler before register it
>> at  WSClientServiceComponent. ?? We need some OSGI magic to fix this issue.
>>
>> 1) Register service.
>> [1]
>> https://svn.wso2.org/repos/wso2/carbon/platform/trunk/components/registry/org.wso2.carbon.registry.ws.client/src/main/java/org/wso2/carbon/registry/ws/client/internal/WSClientServiceComponent.java
>>
>>         *ht.put("type", "ws");*
>> *        serviceRegistration =*
>> *
>> context.getBundleContext().registerService(RegistryProvider.class.getName(),
>> *
>> *                        provider, ht);*
>>
>>
>> 2) Get registered service.
>>
>> [2]
>> https://svn.wso2.org/repos/wso2/carbon/kernel/trunk/core/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/core/jdbc/handlers/builtin/MountHandler.java
>>
>> * ServiceTracker tracker =*
>> *                            new ServiceTracker(bundleContext,
>> RegistryProvider.class.getName(),*
>> *                                    null);*
>> *                    tracker.open();*
>> *                    ServiceReference[] references =
>> tracker.getServiceReferences();*
>> *                    if (references != null) {*
>> *                        for (ServiceReference reference : references) {*
>> *                            if
>> (registryType.equals(reference.getProperty("type"))) {*
>> *                                registryProvider = (RegistryProvider)
>> tracker.getService(reference);*
>> *                                break;*
>> *                            }*
>> *                        } *
>>
>>
>>

service trackers is used to (as the name implies) track services. When you
are open the service tracker, it just starts the tracking. It does not mean
service is available, just because you start tracking it. When we are
creating a service tracker, we can give a call back handler for tracking
service events. For an example the if a service got added for the
particular service name, then the callback gets called.


In the above scenario, we are passing null as the callback to the
serviceTracker. So nothing happens.
we got to execute service-retrieval code within the bundle life-cycle
methods, (Start/Stop). we just can't retrieve services whenever we want
using Servicetrackers. (yes we can, but the the result depends on the
bundle start order.)

thanks,
--Pradeep
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to