bundleContext = (BundleContext) sc.getAttribute("osgi-bundlecontext");
PrintWriter pw = response.getWriter();
if (bundleContext != null) {
ServiceReference sr = bundleContext.getServiceReference(HelloService.class.getName());
if (sr != null) {
HelloService sm = (HelloService) bundleContext.getService(sr);
pw.println(sm.sayHello());
bundleContext.ungetService(sr);
}
} else {
pw.println("Bundle Context is Null");
}
//JNDI Lookup via osgi:service
HelloService sm = (HelloService) getOSGIService(HelloService.class.getName(),null);
if(sm != null){
pw.println(sm.sayHello());
}else {
pw.println("Service Lookup is Null");
}