Hi Rasika, With Carbon-JNDI approach we provide a way to access osgi services from the service registry. The OSGi url scheme syntax is different from java URL scheme.
The syntax is : "osgi:service/<service-class>/<filter>" Eg : If you have a service registered in the service registry with a class name "org.wso2.carbon.jndi.osgi.services.FooService", you should be able to get the object with JNDI lookup : Object service = context.lookup(" osgi:service/org.wso2.carbon.jndi.osgi.services.FooService"); Please find the samples and documentation from [1]. [1] https://github.com/wso2/carbon-jndi/ Thanks, Nipuni On Tue, Apr 26, 2016 at 4:46 PM, Rasika Perera <rasi...@wso2.com> wrote: > Hi Aruna & All, > > The requirement is that we need to provide a simple API to invoke a method > in an OSGi Service from the JavaScript(Nashorn). As per the offline > discussion with Aruna, JNDI is the recommended way to invoke OSGi services > in C5. > > @Nipuni > On the JNDI approach; are all OSGi services getting registered through a > unique URI(eg. "java:comp/env/osgi-service-a") at the service startup? > > Thanks, > Rasika > > On Tue, Apr 26, 2016 at 1:31 PM, Aruna Karunarathna <ar...@wso2.com> > wrote: > >> >> >> On Tue, Apr 26, 2016 at 12:33 PM, Rasika Perera <rasi...@wso2.com> wrote: >> >>> Hi All, >>> >>> Before C5, we had a method "getOSGiService(Class clazz, >>> Hashtable<String, String> props) to retrieve an OSGi service[1]. In latest >>> C5, I couldn't find any similar feature in [2]. >>> >> >> Can you elaborate more on your requirement here?. AFAIK there is no such >> way in C5 to retrieve OSGi services as in [1] >> >>> >>> What is the correct way to retrieve an OSGi service in C5? >>> >>> Or do we need to get it through directly from a "ServiceTracker" ? >>> >>> [1] >>> https://github.com/wso2/carbon-kernel/blob/4.4.x/core/org.wso2.carbon.utils/src/main/java/org/wso2/carbon/context/CarbonContext.java#L322 >>> [2] >>> https://github.com/wso2/carbon-kernel/blob/master/core/src/main/java/org/wso2/carbon/kernel/context/PrivilegedCarbonContext.java >>> >>> >>> -- >>> With Regards, >>> >>> *Rasika Perera* >>> Software Engineer >>> M: +94 71 680 9060 E: rasi...@wso2.com >>> LinkedIn: http://lk.linkedin.com/in/rasika90 >>> >>> WSO2 Inc. www.wso2.com >>> lean.enterprise.middleware >>> >> >> >> >> -- >> >> *Aruna Sujith Karunarathna * >> WSO2, Inc | lean. enterprise. middleware. >> #20, Palm Grove, Colombo 03, Sri Lanka >> Mobile: +94 71 9040362 | Work: +94 112145345 >> Email: ar...@wso2.com | Web: www.wso2.com >> >> >> On Tue, Apr 26, 2016 at 12:33 PM, Rasika Perera <rasi...@wso2.com> wrote: >> >>> Hi All, >>> >>> Before C5, we had a method "getOSGiService(Class clazz, >>> Hashtable<String, String> props) to retrieve an OSGi service[1]. In latest >>> C5, I couldn't find any similar feature in [2]. >>> >>> What is the correct way to retrieve an OSGi service in C5? >>> >>> Or do we need to get it through directly from a "ServiceTracker" ? >>> >>> [1] >>> https://github.com/wso2/carbon-kernel/blob/4.4.x/core/org.wso2.carbon.utils/src/main/java/org/wso2/carbon/context/CarbonContext.java#L322 >>> [2] >>> https://github.com/wso2/carbon-kernel/blob/master/core/src/main/java/org/wso2/carbon/kernel/context/PrivilegedCarbonContext.java >>> >>> >>> -- >>> With Regards, >>> >>> *Rasika Perera* >>> Software Engineer >>> M: +94 71 680 9060 E: rasi...@wso2.com >>> LinkedIn: http://lk.linkedin.com/in/rasika90 >>> >>> WSO2 Inc. www.wso2.com >>> lean.enterprise.middleware >>> >> >> >> >> -- >> >> *Aruna Sujith Karunarathna * >> WSO2, Inc | lean. enterprise. middleware. >> #20, Palm Grove, Colombo 03, Sri Lanka >> Mobile: +94 71 9040362 | Work: +94 112145345 >> Email: ar...@wso2.com | Web: www.wso2.com >> >> > > > > -- > With Regards, > > *Rasika Perera* > Software Engineer > M: +94 71 680 9060 E: rasi...@wso2.com > LinkedIn: http://lk.linkedin.com/in/rasika90 > > WSO2 Inc. www.wso2.com > lean.enterprise.middleware > -- Nipuni Perera Software Engineer; WSO2 Inc.; http://wso2.com Email: nip...@wso2.com Git hub profile: https://github.com/nipuni Blog : http://nipunipererablog.blogspot.com/ Mobile: +94 (71) 5626680 <http://wso2.com>
_______________________________________________ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev