Package org.apache.felix.scr.impl
Class AbstractExtender
- java.lang.Object
-
- org.apache.felix.scr.impl.AbstractExtender
-
- All Implemented Interfaces:
java.util.EventListener,org.osgi.framework.BundleActivator,org.osgi.framework.BundleListener,org.osgi.framework.SynchronousBundleListener,org.osgi.util.tracker.BundleTrackerCustomizer<org.osgi.framework.Bundle>
- Direct Known Subclasses:
Activator
public abstract class AbstractExtender extends java.lang.Object implements org.osgi.framework.BundleActivator, org.osgi.util.tracker.BundleTrackerCustomizer<org.osgi.framework.Bundle>, org.osgi.framework.SynchronousBundleListenerBase class to write bundle extenders. This extender tracks started bundles (or starting if they have a lazy activation policy) and will create an extension for each of them to manage it. The extender will handle all concurrency and synchronization issues. 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.
-
-
Field Summary
Fields Modifier and Type Field Description private org.osgi.framework.BundleContextcontextprivate java.util.concurrent.ConcurrentMap<org.osgi.framework.Bundle,java.util.concurrent.FutureTask<java.lang.Void>>destroyingprivate java.util.concurrent.ConcurrentMap<org.osgi.framework.Bundle,Activator.ScrExtension>extensionsprivate booleanstoppedprivate booleanstoppingprivate org.osgi.util.tracker.BundleTracker<org.osgi.framework.Bundle>tracker
-
Constructor Summary
Constructors Constructor Description AbstractExtender()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description org.osgi.framework.BundleaddingBundle(org.osgi.framework.Bundle bundle, org.osgi.framework.BundleEvent event)voidbundleChanged(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.ExecutorServicecreateExecutor()Create the executor used to start extensions asynchronously.private voidcreateExtension(org.osgi.framework.Bundle bundle)protected abstract voiddebug(org.osgi.framework.Bundle bundle, java.lang.String msg)private voiddestroyExtension(org.osgi.framework.Bundle bundle)protected abstract Activator.ScrExtensiondoCreateExtension(org.osgi.framework.Bundle bundle)Create the extension for the given bundle, or null if the bundle is not to be extended.protected voiddoStart()protected voiddoStop()org.osgi.framework.BundleContextgetBundleContext()booleanisStopping()voidmodifiedBundle(org.osgi.framework.Bundle bundle, org.osgi.framework.BundleEvent event, org.osgi.framework.Bundle object)voidremovedBundle(org.osgi.framework.Bundle bundle, org.osgi.framework.BundleEvent event, org.osgi.framework.Bundle object)voidstart(org.osgi.framework.BundleContext context)protected voidstartTracking()voidstop(org.osgi.framework.BundleContext context)protected voidstopTracking()protected abstract voidwarn(org.osgi.framework.Bundle bundle, java.lang.String msg, java.lang.Throwable t)
-
-
-
Field Detail
-
extensions
private final java.util.concurrent.ConcurrentMap<org.osgi.framework.Bundle,Activator.ScrExtension> extensions
-
destroying
private final java.util.concurrent.ConcurrentMap<org.osgi.framework.Bundle,java.util.concurrent.FutureTask<java.lang.Void>> destroying
-
stopping
private volatile boolean stopping
-
stopped
private volatile boolean stopped
-
context
private org.osgi.framework.BundleContext context
-
tracker
private org.osgi.util.tracker.BundleTracker<org.osgi.framework.Bundle> tracker
-
-
Method Detail
-
getBundleContext
public org.osgi.framework.BundleContext getBundleContext()
-
isStopping
public boolean isStopping()
-
start
public void start(org.osgi.framework.BundleContext context) throws java.lang.Exception- Specified by:
startin interfaceorg.osgi.framework.BundleActivator- Throws:
java.lang.Exception
-
stop
public void stop(org.osgi.framework.BundleContext context) throws java.lang.Exception- Specified by:
stopin interfaceorg.osgi.framework.BundleActivator- Throws:
java.lang.Exception
-
doStart
protected void doStart() throws java.lang.Exception- Throws:
java.lang.Exception
-
doStop
protected void doStop() throws java.lang.Exception- Throws:
java.lang.Exception
-
startTracking
protected void startTracking()
-
stopTracking
protected void stopTracking()
-
createExecutor
protected java.util.concurrent.ExecutorService createExecutor()
Create the executor used to start extensions asynchronously.- Returns:
- an
-
chooseBundlesToDestroy
protected java.util.Collection<org.osgi.framework.Bundle> chooseBundlesToDestroy(java.util.Set<org.osgi.framework.Bundle> bundles)
-
bundleChanged
public void bundleChanged(org.osgi.framework.BundleEvent event)
- Specified by:
bundleChangedin interfaceorg.osgi.framework.BundleListener
-
addingBundle
public org.osgi.framework.Bundle addingBundle(org.osgi.framework.Bundle bundle, org.osgi.framework.BundleEvent event)- Specified by:
addingBundlein interfaceorg.osgi.util.tracker.BundleTrackerCustomizer<org.osgi.framework.Bundle>
-
modifiedBundle
public void modifiedBundle(org.osgi.framework.Bundle bundle, org.osgi.framework.BundleEvent event, org.osgi.framework.Bundle object)- Specified by:
modifiedBundlein interfaceorg.osgi.util.tracker.BundleTrackerCustomizer<org.osgi.framework.Bundle>
-
removedBundle
public void removedBundle(org.osgi.framework.Bundle bundle, org.osgi.framework.BundleEvent event, org.osgi.framework.Bundle object)- Specified by:
removedBundlein interfaceorg.osgi.util.tracker.BundleTrackerCustomizer<org.osgi.framework.Bundle>
-
createExtension
private void createExtension(org.osgi.framework.Bundle bundle)
-
destroyExtension
private void destroyExtension(org.osgi.framework.Bundle bundle)
-
doCreateExtension
protected abstract Activator.ScrExtension doCreateExtension(org.osgi.framework.Bundle bundle) throws java.lang.Exception
Create the extension for the given bundle, or null if the bundle is not to be extended.- Parameters:
bundle- the bundle to extend- Returns:
- The extension
- Throws:
java.lang.Exception- If something goes wrong
-
debug
protected abstract void debug(org.osgi.framework.Bundle bundle, java.lang.String msg)
-
warn
protected abstract void warn(org.osgi.framework.Bundle bundle, java.lang.String msg, java.lang.Throwable t)
-
-