Package org.apache.felix.scr.impl
Class AbstractExtender
java.lang.Object
org.apache.felix.scr.impl.AbstractExtender
- All Implemented Interfaces:
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 Object
implements org.osgi.framework.BundleActivator, org.osgi.util.tracker.BundleTrackerCustomizer<org.osgi.framework.Bundle>, org.osgi.framework.SynchronousBundleListener
Base 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
FieldsModifier and TypeFieldDescriptionprivate org.osgi.framework.BundleContext
private final ConcurrentMap<org.osgi.framework.Bundle,
FutureTask<Void>> private final ConcurrentMap<org.osgi.framework.Bundle,
Activator.ScrExtension> private boolean
private boolean
private org.osgi.util.tracker.BundleTracker<org.osgi.framework.Bundle>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.osgi.framework.Bundle
addingBundle
(org.osgi.framework.Bundle bundle, org.osgi.framework.BundleEvent event) void
bundleChanged
(org.osgi.framework.BundleEvent event) protected Collection<org.osgi.framework.Bundle>
chooseBundlesToDestroy
(Set<org.osgi.framework.Bundle> bundles) protected ExecutorService
Create the executor used to start extensions asynchronously.private void
createExtension
(org.osgi.framework.Bundle bundle) protected abstract void
private void
destroyExtension
(org.osgi.framework.Bundle bundle) protected abstract Activator.ScrExtension
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()
org.osgi.framework.BundleContext
boolean
void
modifiedBundle
(org.osgi.framework.Bundle bundle, org.osgi.framework.BundleEvent event, org.osgi.framework.Bundle object) void
removedBundle
(org.osgi.framework.Bundle bundle, org.osgi.framework.BundleEvent event, org.osgi.framework.Bundle object) void
start
(org.osgi.framework.BundleContext context) protected void
void
stop
(org.osgi.framework.BundleContext context) protected void
protected abstract void
-
Field Details
-
extensions
-
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
-
-
Constructor Details
-
AbstractExtender
public AbstractExtender()
-
-
Method Details
-
getBundleContext
public org.osgi.framework.BundleContext getBundleContext() -
isStopping
public boolean isStopping() -
start
- Specified by:
start
in interfaceorg.osgi.framework.BundleActivator
- Throws:
Exception
-
stop
- Specified by:
stop
in interfaceorg.osgi.framework.BundleActivator
- Throws:
Exception
-
doStart
- Throws:
Exception
-
doStop
- Throws:
Exception
-
startTracking
protected void startTracking() -
stopTracking
protected void stopTracking() -
createExecutor
Create the executor used to start extensions asynchronously.- Returns:
- an
-
chooseBundlesToDestroy
protected Collection<org.osgi.framework.Bundle> chooseBundlesToDestroy(Set<org.osgi.framework.Bundle> bundles) -
bundleChanged
public void bundleChanged(org.osgi.framework.BundleEvent event) - Specified by:
bundleChanged
in interfaceorg.osgi.framework.BundleListener
-
addingBundle
public org.osgi.framework.Bundle addingBundle(org.osgi.framework.Bundle bundle, org.osgi.framework.BundleEvent event) - Specified by:
addingBundle
in 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:
modifiedBundle
in 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:
removedBundle
in 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 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:
Exception
- If something goes wrong
-
debug
-
warn
-