Hi Kasun, Thanks for the Info. PrivilegedCarbonContext.getThreadLocalCarbonContext().getOSGiService() does fill the requirement. Will be going with that approach.
Thanks, Supun On Sat, Feb 7, 2015 at 8:31 PM, Nirmal Fernando <nir...@wso2.com> wrote: > Thanks Kasun! > > On Sat, Feb 7, 2015 at 7:53 PM, KasunG Gajasinghe <kas...@wso2.com> wrote: > >> >> How about adding the actual logic to an osgi bundle, and then keep only >> the jax-rs resource class inside the webapp? Then the webapp will invoke >> the bundle, and that bundle can access the service references as required. >> > > I think we could follow the above approach. > >> >> You could also use PrivilegedCarbonContext#getOSGiServices() method if >> you need to access osgi services within a webapp. >> >> Dataholders are only supposed to be used within a component, and is not >> supposed to be exposed to other components. >> >> >> On Sat, Feb 7, 2015 at 7:30 PM, Nirmal Fernando <nir...@wso2.com> wrote: >> >>> One other way that I can think of is, by introducing a service component >>> which has references to all OSGi service we require and then accessing the >>> data holder via web app. >>> >>> On Sat, Feb 7, 2015 at 7:24 PM, Supun Sethunga <sup...@wso2.com> wrote: >>> >>>> Hi, >>>> >>>> Im trying to expose some OSGI services as REST API's. (Please refer >>>> mail thread "[Architecture] REST API for Machine Learner") >>>> For that, i want to access the Service References of the services which >>>> were registered in the OSGI context by their respective bundle activators, >>>> from the web app (.war). >>>> >>>> I tried the following methods [1] and [2], But both returns a NULL >>>> bundle contexts. >>>> (Here 'Project.class' is the web app's class name) >>>> >>>> [1] BundleContext bundleContext = >>>> FrameworkUtil.getBundle(Project.class).getBundleContext(); >>>> >>>> [2] @Context >>>> ServletContext servletContext; >>>> BundleContext bundleContext = (BundleContext) >>>> servletContext.getAttribute("osgi-bundlecontext"); >>>> >>>> AFAIU this happens because the 'Project.class' is not loaded by an OSGi >>>> bundle class loader, because it is bundled as an web app. >>>> >>>> Is there a different apporach to expose the OSGi servioce as REST >>>> API's? Can anyone please shed some light here? >>>> >>>> -- >>>> *Supun Sethunga* >>>> Software Engineer >>>> WSO2, Inc. >>>> lean | enterprise | middleware >>>> Mobile : +94 716546324 >>>> >>> >>> >>> >>> -- >>> >>> Thanks & regards, >>> Nirmal >>> >>> Senior Software Engineer- Platform Technologies Team, WSO2 Inc. >>> Mobile: +94715779733 >>> Blog: http://nirmalfdo.blogspot.com/ >>> >>> >>> >> >> >> -- >> >> *Kasun Gajasinghe*Senior Software Engineer, WSO2 Inc. >> email: kasung AT spamfree wso2.com >> linked-in: http://lk.linkedin.com/in/gajasinghe >> blog: http://kasunbg.org >> >> >> > > > > -- > > Thanks & regards, > Nirmal > > Senior Software Engineer- Platform Technologies Team, WSO2 Inc. > Mobile: +94715779733 > Blog: http://nirmalfdo.blogspot.com/ > > > -- *Supun Sethunga* Software Engineer WSO2, Inc. lean | enterprise | middleware Mobile : +94 716546324
_______________________________________________ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev