Take a look at servicetracker or better jet use DeclarativeSerices for that kind of stuff. Waiting for a service inside an activator is waiting for bad things happen ;-)

Am 11.09.2018 um 19:10 schrieb Nhut Thai Le:
Hello,
 I'm trying to create a shared httpContext so i can use it across multiple bundles so in one of my bundle activator I have:

|
publicvoidstart(BundleContextcontext)throwsException{
|
ServiceReference<WebContainer> webContainerReference = null;
do {
webContainerReference = context.getServiceReference(WebContainer.class);
}
while (webContainerReference == null);

WebContainer webContainer = context.getService(webContainerReference);

SharedWebContainerContext httpContext = webContainer.createDefaultSharedHttpContext();

String sharedContext = "sharedContext";
Dictionary<String, String> properties = new Hashtable<String, String>();
properties.put("httpContext.id", sharedContext); //$NON-NLS-1$
properties.put("httpContext.shared", "true"); //$NON-NLS-1$ //$NON-NLS-2$
httpContextRegistration = context.registerService(HttpContext.class, httpContext, properties);

However, when I start the osgi env (equinox), i got stuck in the do..while loop, since the bundle context cannot get the ref to WebContainer. Is there anything I am missing ? I'm using pax-web-jetty 7.2 with pax-web-extender-whiteboard

Thai

--
--
------------------
OPS4J - http://www.ops4j.org - [email protected]

---
You received this message because you are subscribed to the Google Groups "OPS4J" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected] <mailto:[email protected]>.
For more options, visit https://groups.google.com/d/optout.

--
--
------------------
OPS4J - http://www.ops4j.org - [email protected]

--- You received this message because you are subscribed to the Google Groups "OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to