public class WebContainerManager extends Object implements org.osgi.framework.BundleListener, org.osgi.util.tracker.ServiceTrackerCustomizer<org.ops4j.pax.web.service.WebContainer,org.osgi.framework.ServiceReference<org.ops4j.pax.web.service.WebContainer>>
This class combines a BundleListener and ServiceListener to
manage at least two scenarios:
Web-ContextPath manifest headers. Here, by design, single
bundle is equivalent to single web application (possibly with the support of bundle
fragments or embedded JARs).WebContainer
OSGi service is available. Thus this class coordinates the above conditions.
This listener manages a (bundle-scoped) reference to current WebContainer
and binding to its lifecycle processes the information obtained from multiple client bundles that try
to install Web Application related elements/components into the current web container.
Before Pax Web 8, this was managed in pax-web-extender-war by
org.ops4j.pax.web.extender.war.internal.tracker.ReplaceableService. In Pax Web 8, for
pax-web-extender-whiteboard, initially I used separate ServiceListener, but I think it's
a good idea to unify this functionality inside pax-web-spi bundle.
| Modifier and Type | Field and Description |
|---|---|
static org.slf4j.Logger |
LOG |
| Constructor and Description |
|---|
WebContainerManager(org.osgi.framework.BundleContext context,
WebContainerListener listener)
Creates a manager that delivers service events synchronously (for test purposes).
|
WebContainerManager(org.osgi.framework.BundleContext context,
WebContainerListener listener,
String threadName)
Creates a manager to handle:
the lifecycle of
WebContainer service reference(s)
the lifecycles of bundles that want to interact with a
WebContainer.
|
| Modifier and Type | Method and Description |
|---|---|
org.osgi.framework.ServiceReference<org.ops4j.pax.web.service.WebContainer> |
addingService(org.osgi.framework.ServiceReference<org.ops4j.pax.web.service.WebContainer> reference) |
void |
bundleChanged(org.osgi.framework.BundleEvent event) |
org.ops4j.pax.web.service.WebContainer |
container(org.osgi.framework.Bundle bundle,
org.osgi.framework.ServiceReference<org.ops4j.pax.web.service.WebContainer> ref) |
<T extends org.ops4j.pax.web.service.views.PaxWebContainerView> |
containerView(org.osgi.framework.Bundle bundle,
org.osgi.framework.ServiceReference<org.ops4j.pax.web.service.WebContainer> ref,
Class<T> viewClass)
Helper method that makes it easier to obtain a
PaxWebContainerView using passed
BundleContext and ServiceReference to a WebContainer |
org.osgi.framework.ServiceReference<org.ops4j.pax.web.service.WebContainer> |
currentWebContainerReference() |
void |
initialize()
Initialization sets up bundle and service listeners assuming there are dedicated observers (to get customized
notification) registered.
|
void |
modifiedService(org.osgi.framework.ServiceReference<org.ops4j.pax.web.service.WebContainer> reference,
org.osgi.framework.ServiceReference<org.ops4j.pax.web.service.WebContainer> service) |
void |
releaseContainer(org.osgi.framework.Bundle bundle)
Helper method to release cached
PaxWebContainerView for the passed BundleContext and
current reference to a WebContainer service. |
void |
releaseContainer(org.osgi.framework.Bundle bundle,
org.osgi.framework.ServiceReference<org.ops4j.pax.web.service.WebContainer> ref)
Helper method to release cached
PaxWebContainerView |
void |
removedService(org.osgi.framework.ServiceReference<org.ops4j.pax.web.service.WebContainer> reference,
org.osgi.framework.ServiceReference<org.ops4j.pax.web.service.WebContainer> service) |
void |
shutdown()
Cleans up internal trackers and thread pools.
|
WhiteboardWebContainerView |
whiteboardView(org.osgi.framework.Bundle bundle)
Returns a
WhiteboardWebContainerView for the passed BundleContext and current
reference to WebContainer service. |
WhiteboardWebContainerView |
whiteboardView(org.osgi.framework.Bundle bundle,
org.osgi.framework.ServiceReference<org.ops4j.pax.web.service.WebContainer> ref)
Returns a
WhiteboardWebContainerView for the passed BundleContext and the passed
reference to WebContainer service. |
public WebContainerManager(org.osgi.framework.BundleContext context,
WebContainerListener listener)
context - listener - public WebContainerManager(org.osgi.framework.BundleContext context,
WebContainerListener listener,
String threadName)
Creates a manager to handle:
WebContainer service reference(s)bundles that want to interact with a
WebContainer.context - nothing can be done without itlistener - a required instance of high-level listener to get notified about lifecycle changesthreadName - a name of the thread in which the instance of WebContainer service reference will
be passed. If null, then events will be delivered synchronously.public void initialize()
public void shutdown()
public org.osgi.framework.ServiceReference<org.ops4j.pax.web.service.WebContainer> currentWebContainerReference()
public <T extends org.ops4j.pax.web.service.views.PaxWebContainerView> T containerView(org.osgi.framework.Bundle bundle,
org.osgi.framework.ServiceReference<org.ops4j.pax.web.service.WebContainer> ref,
Class<T> viewClass)
PaxWebContainerView using passed
BundleContext and ServiceReference to a WebContainerbundle - ref - viewClass - public org.ops4j.pax.web.service.WebContainer container(org.osgi.framework.Bundle bundle,
org.osgi.framework.ServiceReference<org.ops4j.pax.web.service.WebContainer> ref)
public WhiteboardWebContainerView whiteboardView(org.osgi.framework.Bundle bundle)
WhiteboardWebContainerView for the passed BundleContext and current
reference to WebContainer service.bundle - public WhiteboardWebContainerView whiteboardView(org.osgi.framework.Bundle bundle, org.osgi.framework.ServiceReference<org.ops4j.pax.web.service.WebContainer> ref)
WhiteboardWebContainerView for the passed BundleContext and the passed
reference to WebContainer service.bundle - ref - public void releaseContainer(org.osgi.framework.Bundle bundle)
PaxWebContainerView for the passed BundleContext and
current reference to a WebContainer service.bundle - public void releaseContainer(org.osgi.framework.Bundle bundle,
org.osgi.framework.ServiceReference<org.ops4j.pax.web.service.WebContainer> ref)
PaxWebContainerViewbundle - ref - public void bundleChanged(org.osgi.framework.BundleEvent event)
bundleChanged in interface org.osgi.framework.BundleListenerpublic org.osgi.framework.ServiceReference<org.ops4j.pax.web.service.WebContainer> addingService(org.osgi.framework.ServiceReference<org.ops4j.pax.web.service.WebContainer> reference)
addingService in interface org.osgi.util.tracker.ServiceTrackerCustomizer<org.ops4j.pax.web.service.WebContainer,org.osgi.framework.ServiceReference<org.ops4j.pax.web.service.WebContainer>>public void modifiedService(org.osgi.framework.ServiceReference<org.ops4j.pax.web.service.WebContainer> reference,
org.osgi.framework.ServiceReference<org.ops4j.pax.web.service.WebContainer> service)
modifiedService in interface org.osgi.util.tracker.ServiceTrackerCustomizer<org.ops4j.pax.web.service.WebContainer,org.osgi.framework.ServiceReference<org.ops4j.pax.web.service.WebContainer>>public void removedService(org.osgi.framework.ServiceReference<org.ops4j.pax.web.service.WebContainer> reference,
org.osgi.framework.ServiceReference<org.ops4j.pax.web.service.WebContainer> service)
removedService in interface org.osgi.util.tracker.ServiceTrackerCustomizer<org.ops4j.pax.web.service.WebContainer,org.osgi.framework.ServiceReference<org.ops4j.pax.web.service.WebContainer>>Copyright © 2006–2024 OPS4J - Open Participation Software for Java. All rights reserved.