Class FrameworkWiringImpl
- All Implemented Interfaces:
Runnable
,BundleReference
,FrameworkWiring
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Felix
private ServiceRegistration
<PackageAdmin> private final ServiceRegistry
private final List
<FrameworkListener[]> private final List
<Collection<Bundle>> private Thread
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfindProviders
(Requirement requirement) Find bundle capabilities that match the given requirement.Returns theBundle
object associated with thisBundleReference
.getDependencyClosure
(Collection<Bundle> targets) Returns the dependency closure for the specified bundles.Returns the bundles that havenon-current
,in use
bundle wirings.void
refreshBundles
(Collection<Bundle> bundles, FrameworkListener... listeners) Refreshes the specified bundles.boolean
resolveBundles
(Collection<Bundle> bundles) Resolves the specified bundles.void
run()
The OSGi specification states that package refreshes happen asynchronously; this is the run() method for the package refreshing thread.(package private) void
start()
(package private) void
stop()
Stops the FelixFrameworkWiring thread on system shutdown.
-
Field Details
-
m_felix
-
m_registry
-
m_requests
-
m_requestListeners
-
m_paReg
-
m_thread
-
-
Constructor Details
-
FrameworkWiringImpl
-
-
Method Details
-
start
void start() -
stop
void stop()Stops the FelixFrameworkWiring thread on system shutdown. Shutting down the thread explicitly is required in the embedded case, where Felix may be stopped without the Java VM being stopped. In this case the FelixFrameworkWiring thread must be stopped explicitly.This method is called by the
invalid reference
PackageAdminActivator#stop(BundleContext)
-
getBundle
Description copied from interface:BundleReference
Returns theBundle
object associated with thisBundleReference
.- Specified by:
getBundle
in interfaceBundleReference
- Returns:
- The
Bundle
object associated with thisBundleReference
.
-
refreshBundles
Description copied from interface:FrameworkWiring
Refreshes the specified bundles. This forces the update (replacement) or removal of packages exported by the specified bundles.The technique by which the framework refreshes bundles may vary among different framework implementations. A permissible implementation is to stop and restart the framework.
This method returns to the caller immediately and then performs the following steps on a separate thread:
- Compute the
dependency closure
of the specified bundles. If no bundles are specified, compute the dependency closure of theremoval pending
bundles. - Each bundle in the dependency closure that is in the
ACTIVE
state will be stopped as described in theBundle.stop
method. - Each bundle in the dependency closure that is in the
RESOLVED
state is unresolved and thus moved to theINSTALLED
state. The effect of this step is that bundles in the dependency closure are no longerRESOLVED
. - Each bundle in the dependency closure that is in the
UNINSTALLED
state is removed from the dependency closure and is now completely removed from the Framework. - Each bundle in the dependency closure that was in the
ACTIVE
state prior to Step 2 is started as described in theBundle.start
method, causing all bundles required for the restart to be resolved. It is possible that, as a result of the previous steps, packages that were previously exported no longer are. Therefore, some bundles may be unresolvable until bundles satisfying the dependencies have been installed in the Framework.
For any exceptions that are thrown during any of these steps, a framework event of type
FrameworkEvent.ERROR
is fired containing the exception. The source bundle for these events should be the specific bundle to which the exception is related. If no specific bundle can be associated with the exception then the System Bundle must be used as the source bundle for the event. All framework events fired by this method are also delivered to the specifiedFrameworkListener
s in the order they are specified.When this process completes after the bundles are refreshed, the Framework will fire a Framework event of type
FrameworkEvent.PACKAGES_REFRESHED
to announce it has completed the bundle refresh. The specifiedFrameworkListener
s are notified in the order specified. Each specifiedFrameworkListener
will be called with a Framework event of typeFrameworkEvent.PACKAGES_REFRESHED
.- Specified by:
refreshBundles
in interfaceFrameworkWiring
- Parameters:
bundles
- The bundles to be refreshed, ornull
to refresh theremoval pending
bundles.listeners
- Zero or more listeners to be notified when the bundle refresh has been completed. The specified listeners do not need to be otherwise registered with the framework. If a specified listener is already registered with the framework, it will be notified twice.
- Compute the
-
resolveBundles
Description copied from interface:FrameworkWiring
Resolves the specified bundles. The Framework must attempt to resolve the specified bundles that are unresolved. Additional bundles that are not included in the specified bundles may be resolved as a result of calling this method. A permissible implementation of this method is to attempt to resolve all unresolved bundles installed in the framework.If no bundles are specified, then the Framework will attempt to resolve all unresolved bundles. This method must not cause any bundle to be refreshed, stopped, or started. This method will not return until the operation has completed.
- Specified by:
resolveBundles
in interfaceFrameworkWiring
- Parameters:
bundles
- The bundles to resolve ornull
to resolve all unresolved bundles installed in the Framework.- Returns:
true
if all specified bundles are resolved;false
otherwise.
-
getRemovalPendingBundles
Description copied from interface:FrameworkWiring
Returns the bundles that havenon-current
,in use
bundle wirings. This is typically the bundles which have been updated or uninstalled since the last call toFrameworkWiring.refreshBundles(Collection, FrameworkListener...)
.- Specified by:
getRemovalPendingBundles
in interfaceFrameworkWiring
- Returns:
- A collection containing a snapshot of the
Bundle
s which have non-current, in useBundleWiring
s, or an empty collection if there are no such bundles.
-
getDependencyClosure
Description copied from interface:FrameworkWiring
Returns the dependency closure for the specified bundles.A graph of bundles is computed starting with the specified bundles. The graph is expanded by adding any bundle that is either wired to a package that is currently exported by a bundle in the graph or requires a bundle in the graph. The graph is fully constructed when there is no bundle outside the graph that is wired to a bundle in the graph. The graph may contain
UNINSTALLED
bundles that areremoval pending
.- Specified by:
getDependencyClosure
in interfaceFrameworkWiring
- Parameters:
targets
- The initial bundles for which to generate the dependency closure.- Returns:
- A collection containing a snapshot of the dependency closure of the specified bundles, or an empty collection if there were no specified bundles.
-
run
public void run()The OSGi specification states that package refreshes happen asynchronously; this is the run() method for the package refreshing thread. -
findProviders
Description copied from interface:FrameworkWiring
Find bundle capabilities that match the given requirement.The returned collection contains
BundleCapability
objects where the revision must be thedeclaring revision
of the capability and the revision must either be the current bundle revision or anin use
bundle revision.Each returned capability must match the given requirement. This means that the filter in the requirement must match as well as any namespace specific directives. For example, the mandatory attributes for the osgi.wiring.package namespace.
The returned collection has not been filtered to remove capabilities that are non-effective, substituted or for which the providing bundle does not have permission to provide. No resolve hooks are called to filter matching capabilities.
- Specified by:
findProviders
in interfaceFrameworkWiring
- Parameters:
requirement
- The requirement to find matching bundle capabilities. Must not benull
.- Returns:
- A collection of
BundleCapability
objects that match the specified requirement. - See Also:
-