public abstract class AbstractExtender
extends java.lang.Object
implements org.osgi.framework.BundleActivator, org.osgi.util.tracker.BundleTrackerCustomizer, org.osgi.framework.SynchronousBundleListener
Extension
for each of them to manage it.
The extender will handle all concurrency and synchronization issues, see
Extension
for more information about the additional constraints.
The extender guarantee that all extensions will be stopped synchronously with
the STOPPING event of a given bundle and that all extensions will be stopped
before the extender bundle is stopped.Modifier and Type | Field and Description |
---|---|
private org.osgi.framework.BundleContext |
context |
private java.util.concurrent.ConcurrentMap<org.osgi.framework.Bundle,java.util.concurrent.FutureTask> |
destroying |
private java.util.concurrent.ExecutorService |
executors |
private java.util.concurrent.ConcurrentMap<org.osgi.framework.Bundle,Extension> |
extensions |
private boolean |
preemptiveShutdown |
private boolean |
stopped |
private boolean |
stopping |
private boolean |
synchronous |
private org.osgi.util.tracker.BundleTracker |
tracker |
Constructor and Description |
---|
AbstractExtender() |
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
addingBundle(org.osgi.framework.Bundle bundle,
org.osgi.framework.BundleEvent event) |
void |
bundleChanged(org.osgi.framework.BundleEvent event) |
protected java.util.Collection<org.osgi.framework.Bundle> |
chooseBundlesToDestroy(java.util.Set<org.osgi.framework.Bundle> bundles) |
protected java.util.concurrent.ExecutorService |
createExecutor()
Create the executor used to start extensions asynchronously.
|
private void |
createExtension(org.osgi.framework.Bundle bundle) |
protected abstract void |
debug(org.osgi.framework.Bundle bundle,
java.lang.String msg) |
private void |
destroyExtension(org.osgi.framework.Bundle bundle) |
protected abstract Extension |
doCreateExtension(org.osgi.framework.Bundle bundle)
Create the extension for the given bundle, or null if the bundle is not to be extended.
|
protected void |
doStart() |
protected void |
doStop() |
protected abstract void |
error(java.lang.String msg,
java.lang.Throwable t) |
org.osgi.framework.BundleContext |
getBundleContext() |
java.util.concurrent.ExecutorService |
getExecutors() |
boolean |
isPreemptiveShutdown()
Check if the extender performs a preemptive shutdown
of all extensions when the framework is being stopped.
|
boolean |
isStopping() |
boolean |
isSynchronous()
Check if the extender is synchronous or not.
|
void |
modifiedBundle(org.osgi.framework.Bundle bundle,
org.osgi.framework.BundleEvent event,
java.lang.Object object) |
void |
removedBundle(org.osgi.framework.Bundle bundle,
org.osgi.framework.BundleEvent event,
java.lang.Object object) |
void |
setPreemptiveShutdown(boolean preemptiveShutdown) |
void |
setSynchronous(boolean synchronous) |
void |
start(org.osgi.framework.BundleContext context) |
protected void |
startTracking() |
void |
stop(org.osgi.framework.BundleContext context) |
protected void |
stopTracking() |
protected abstract void |
warn(org.osgi.framework.Bundle bundle,
java.lang.String msg,
java.lang.Throwable t) |
private final java.util.concurrent.ConcurrentMap<org.osgi.framework.Bundle,Extension> extensions
private final java.util.concurrent.ConcurrentMap<org.osgi.framework.Bundle,java.util.concurrent.FutureTask> destroying
private volatile boolean stopping
private volatile boolean stopped
private boolean synchronous
private boolean preemptiveShutdown
private org.osgi.framework.BundleContext context
private java.util.concurrent.ExecutorService executors
private org.osgi.util.tracker.BundleTracker tracker
public boolean isSynchronous()
public boolean isPreemptiveShutdown()
public org.osgi.framework.BundleContext getBundleContext()
public java.util.concurrent.ExecutorService getExecutors()
public void setSynchronous(boolean synchronous)
public void setPreemptiveShutdown(boolean preemptiveShutdown)
public boolean isStopping()
public void start(org.osgi.framework.BundleContext context) throws java.lang.Exception
start
in interface org.osgi.framework.BundleActivator
java.lang.Exception
public void stop(org.osgi.framework.BundleContext context) throws java.lang.Exception
stop
in interface org.osgi.framework.BundleActivator
java.lang.Exception
protected void doStart() throws java.lang.Exception
java.lang.Exception
protected void doStop() throws java.lang.Exception
java.lang.Exception
protected void startTracking()
protected void stopTracking()
protected java.util.concurrent.ExecutorService createExecutor()
protected java.util.Collection<org.osgi.framework.Bundle> chooseBundlesToDestroy(java.util.Set<org.osgi.framework.Bundle> bundles)
public void bundleChanged(org.osgi.framework.BundleEvent event)
bundleChanged
in interface org.osgi.framework.BundleListener
public java.lang.Object addingBundle(org.osgi.framework.Bundle bundle, org.osgi.framework.BundleEvent event)
addingBundle
in interface org.osgi.util.tracker.BundleTrackerCustomizer
public void modifiedBundle(org.osgi.framework.Bundle bundle, org.osgi.framework.BundleEvent event, java.lang.Object object)
modifiedBundle
in interface org.osgi.util.tracker.BundleTrackerCustomizer
public void removedBundle(org.osgi.framework.Bundle bundle, org.osgi.framework.BundleEvent event, java.lang.Object object)
removedBundle
in interface org.osgi.util.tracker.BundleTrackerCustomizer
private void createExtension(org.osgi.framework.Bundle bundle)
private void destroyExtension(org.osgi.framework.Bundle bundle)
protected abstract Extension doCreateExtension(org.osgi.framework.Bundle bundle) throws java.lang.Exception
bundle
- the bundle to extendjava.lang.Exception
- If something goes wrongprotected abstract void debug(org.osgi.framework.Bundle bundle, java.lang.String msg)
protected abstract void warn(org.osgi.framework.Bundle bundle, java.lang.String msg, java.lang.Throwable t)
protected abstract void error(java.lang.String msg, java.lang.Throwable t)