public class PackageAdminImpl extends Object implements PackageAdmin, FrameworkWiring
The term exported package (and the corresponding interface
ExportedPackage) refers to a package that has actually been
exported (as opposed to one that is available for export).
Note that the information about exported packages returned by this
service is valid only until the next time refreshPackages(org.osgi.framework.Bundle[]) is
called.
If an ExportedPackage becomes stale, (that is, the package it references
has been updated or removed as a result of calling
PackageAdmin.refreshPackages()),
its getName() and getSpecificationVersion() continue to return their
old values, isRemovalPending() returns true, and getExportingBundle()
and getImportingBundles() return null.
| Modifier and Type | Field and Description |
|---|---|
protected Framework |
framework
framework object
|
BUNDLE_TYPE_FRAGMENT| Modifier | Constructor and Description |
|---|---|
protected |
PackageAdminImpl(Framework framework)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
cleanup() |
protected void |
doResolveBundles(Bundle[] bundles,
boolean refreshPackages,
FrameworkListener[] listeners) |
Bundle |
getBundle()
Returns the
Bundle object associated with this
BundleReference. |
Bundle |
getBundle(Class clazz)
Returns the bundle from which the specified class is loaded.
|
Bundle[] |
getBundles(String symbolicName,
String versionRange)
Returns the bundles with the specified symbolic name whose bundle version
is within the specified version range.
|
int |
getBundleType(Bundle bundle)
Returns the special type of the specified bundle.
|
Collection<Bundle> |
getDependencyClosure(Collection<Bundle> bundles)
Returns the dependency closure for the specified bundles.
|
ExportedPackage |
getExportedPackage(String name)
Gets the exported package for the specified package name.
|
ExportedPackage[] |
getExportedPackages(Bundle bundle)
Gets the exported packages for the specified bundle.
|
ExportedPackage[] |
getExportedPackages(String name)
Gets the exported packages for the specified package name.
|
Bundle[] |
getFragments(Bundle bundle)
Returns an array of attached fragment bundles for the specified bundle.
|
Bundle[] |
getHosts(Bundle bundle)
Returns the host bundles to which the specified fragment bundle is
attached.
|
Collection<Bundle> |
getRemovalPendingBundles()
Returns the bundles that have
non-current, in use bundle wirings. |
RequiredBundle[] |
getRequiredBundles(String symbolicName)
Returns an array of required bundles having the specified symbolic name.
|
void |
refreshBundles(Collection<Bundle> bundles,
FrameworkListener... listeners)
Refreshes the specified bundles.
|
void |
refreshPackages(Bundle[] input)
Forces the update (replacement) or removal of packages exported by the
specified bundles.
|
void |
refreshPackages(Bundle[] input,
boolean synchronously,
FrameworkListener[] listeners) |
boolean |
resolveBundles(Bundle[] bundles)
Resolve the specified bundles.
|
boolean |
resolveBundles(Collection<Bundle> bundles)
Resolves the specified bundles.
|
protected void |
setResolvedBundles(InternalSystemBundle systemBundle) |
protected Framework framework
protected PackageAdminImpl(Framework framework)
framework - Framework object.public ExportedPackage[] getExportedPackages(Bundle bundle)
PackageAdmingetExportedPackages in interface PackageAdminbundle - The bundle whose exported packages are to be returned, or
null if all exported packages are to be returned. If
the specified bundle is the system bundle (that is, the bundle
with id zero), this method returns all the packages known to be
exported by the system bundle. This will include the package
specified by the org.osgi.framework.system.packages
system property as well as any other package exported by the
framework implementation.null if the
specified bundle has no exported packages.public ExportedPackage getExportedPackage(String name)
PackageAdminIf there are multiple exported packages with specified name, the exported package with the highest version will be returned.
getExportedPackage in interface PackageAdminname - The name of the exported package to be returned.null if no exported
package with the specified name exists.PackageAdmin.getExportedPackages(String)public ExportedPackage[] getExportedPackages(String name)
PackageAdmingetExportedPackages in interface PackageAdminname - The name of the exported packages to be returned.null if no
exported packages with the specified name exists.public void refreshPackages(Bundle[] input)
PackageAdminIf no bundles are specified, this method will update or remove any packages exported by any bundles that were previously updated or uninstalled since the last call to this method. The technique by which this is accomplished may vary among different Framework implementations. One 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:
UNINSTALLED bundles that are currently
still exporting packages.
ACTIVE state
will be stopped as described in the Bundle.stop method.
RESOLVED state
is unresolved and thus moved to the INSTALLED state. The
effect of this step is that bundles in the graph are no longer
RESOLVED.
UNINSTALLED
state is removed from the graph and is now completely removed from the
Framework.
ACTIVE state
prior to Step 2 is started as described in the Bundle.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 another bundle offering a compatible package for
export has been installed in the Framework.
FrameworkEvent.PACKAGES_REFRESHED is fired.
For any exceptions that are thrown during any of these steps, a
FrameworkEvent of type 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.
refreshPackages in interface PackageAdmininput - The bundles whose exported packages are to be updated or
removed, or null for all bundles updated or
uninstalled since the last call to this method.public void refreshPackages(Bundle[] input, boolean synchronously, FrameworkListener[] listeners)
public boolean resolveBundles(Bundle[] bundles)
PackageAdmin
If null is 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.
resolveBundles in interface PackageAdminbundles - The bundles to resolve or null to resolve all
unresolved bundles installed in the Framework.true if all specified bundles are resolved;protected void doResolveBundles(Bundle[] bundles, boolean refreshPackages, FrameworkListener[] listeners)
public RequiredBundle[] getRequiredBundles(String symbolicName)
PackageAdmin
If null is specified, then all required bundles will be
returned.
getRequiredBundles in interface PackageAdminsymbolicName - The bundle symbolic name or null for
all required bundles.null if no
required bundles exist for the specified symbolic name.public Bundle[] getBundles(String symbolicName, String versionRange)
PackageAdminnull is returned.
If a version range is specified, then only the bundles that have the
specified symbolic name and whose bundle versions belong to the specified
version range are returned. The returned bundles are ordered by version
in descending version order so that the first element of the array
contains the bundle with the highest version.getBundles in interface PackageAdminsymbolicName - The symbolic name of the desired bundles.versionRange - The version range of the desired bundles, or
null if all versions are desired.null if no bundles are found.Constants.BUNDLE_VERSION_ATTRIBUTEpublic Bundle[] getFragments(Bundle bundle)
PackageAdminnull is returned.
If no fragments are attached to the specified bundle then
null is returned.
This method does not attempt to resolve the specified bundle. If the
specified bundle is not resolved then null is returned.
getFragments in interface PackageAdminbundle - The bundle whose attached fragment bundles are to be
returned.null if the bundle
does not have any attached fragment bundles or the bundle is not
resolved.public Bundle[] getHosts(Bundle bundle)
PackageAdmingetHosts in interface PackageAdminbundle - The fragment bundle whose host bundles are to be returned.null if the specified bundle
is not a fragment or is not attached to any host bundles.public Bundle getBundle(Class clazz)
PackageAdminnull is returned.getBundle in interface PackageAdminclazz - The class object from which to locate the bundle.null if the class was not loaded by a bundle class
loader created by the same framework instance that registered
this PackageAdmin service.public int getBundleType(Bundle bundle)
PackageAdminIf a bundle is not one or more of the defined types then 0x00000000 is returned.
getBundleType in interface PackageAdminbundle - The bundle for which to return the special type.protected void cleanup()
protected void setResolvedBundles(InternalSystemBundle systemBundle)
public Bundle getBundle()
BundleReferenceBundle object associated with this
BundleReference.getBundle in interface BundleReferenceBundle object associated with this
BundleReference.public void refreshBundles(Collection<Bundle> bundles, FrameworkListener... listeners)
FrameworkWiringThe 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:
dependency
closure of the specified bundles. If no bundles are specified, compute
the dependency closure of the removal
pending bundles.
ACTIVE
state will be stopped as described in the Bundle.stop method.
RESOLVED
state is unresolved and thus moved to the INSTALLED state. The
effect of this step is that bundles in the dependency closure are no
longer RESOLVED.
UNINSTALLED state is removed from the dependency closure and is
now completely removed from the Framework.
ACTIVE
state prior to Step 2 is started as described in the Bundle.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 specified FrameworkListeners 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 specified FrameworkListeners are notified
in the order specified. Each specified FrameworkListener will be
called with a Framework event of type
FrameworkEvent.PACKAGES_REFRESHED.
refreshBundles in interface FrameworkWiringbundles - The bundles to be refreshed, or null to refresh
the removal 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.public boolean resolveBundles(Collection<Bundle> bundles)
FrameworkWiringIf 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.
resolveBundles in interface FrameworkWiringbundles - The bundles to resolve or null to resolve all
unresolved bundles installed in the Framework.true if all specified bundles are resolved; false
otherwise.public Collection<Bundle> getRemovalPendingBundles()
FrameworkWiringnon-current, in use bundle wirings. This
is typically the bundles which have been updated or uninstalled since the
last call to FrameworkWiring.refreshBundles(Collection, FrameworkListener...).getRemovalPendingBundles in interface FrameworkWiringBundles which
have non-current, in use BundleWirings, or an empty
collection if there are no such bundles.public Collection<Bundle> getDependencyClosure(Collection<Bundle> bundles)
FrameworkWiring
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 are
removal pending.
getDependencyClosure in interface FrameworkWiringbundles - The initial bundles for which to generate the dependency
closure.Copyright © 2007–2016 The Apache Software Foundation. All rights reserved.