public class PackageAdminImpl extends java.lang.Object implements PackageAdmin
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.
PackageAdmin
BUNDLE_TYPE_FRAGMENT
限定符和类型 | 方法和说明 |
---|---|
Bundle |
getBundle(java.lang.Class clazz)
Returns the bundle from which the specified class is loaded.
|
Bundle[] |
getBundles(java.lang.String symbolicName,
java.lang.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.
|
ExportedPackage |
getExportedPackage(java.lang.String name)
Gets the ExportedPackage with the specified package name.
|
ExportedPackage[] |
getExportedPackages(Bundle bundle)
Gets the packages exported by the specified bundle.
|
ExportedPackage[] |
getExportedPackages(java.lang.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.
|
RequiredBundle[] |
getRequiredBundles(java.lang.String symbolicName)
Returns an array of required bundles having the specified symbolic name.
|
void |
refreshPackages(Bundle[] bundles)
Forces the update (replacement) or removal of packages exported by the
specified bundles.
|
boolean |
resolveBundles(Bundle[] bundles)
Resolve the specified bundles.
|
public ExportedPackage[] getExportedPackages(Bundle bundle)
getExportedPackages
在接口中 PackageAdmin
bundle
- The bundle whose exported packages are to be returned, or
null if all the packages currently exported in the
framework are to be returned. If the specified bundle is the
system bundle (that is, the bundle with id 0), this method returns
all the packages on the system classpath whose name does not start
with "java.". In an environment where the exhaustive list of
packages on the system classpath is not known in advance, this
method will return all currently known packages on the system
classpath, that is, all packages on the system classpath that
contains one or more classes that have been loaded.public ExportedPackage[] getExportedPackages(java.lang.String name)
getExportedPackages
在接口中 PackageAdmin
name
- The name of the exported packages to be returned.null
if no
exported packages with the specified name exists.public ExportedPackage getExportedPackage(java.lang.String name)
getExportedPackage
在接口中 PackageAdmin
name
- The name of the exported package to be returned.PackageAdmin.getExportedPackages(String)
public void refreshPackages(Bundle[] bundles)
refreshPackages
在接口中 PackageAdmin
bundles
- 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.PackageAdmin.refreshPackages(org.osgi.framework.Bundle[])
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
在接口中 PackageAdmin
bundles
- The bundles to resolve or null
to resolve all
unresolved bundles installed in the Framework.true
if all specified bundles are resolved;public RequiredBundle[] getRequiredBundles(java.lang.String symbolicName)
PackageAdmin
If null
is specified, then all required bundles will be
returned.
getRequiredBundles
在接口中 PackageAdmin
symbolicName
- The bundle symbolic name or null
for
all required bundles.null
if no
required bundles exist for the specified symbolic name.public Bundle[] getBundles(java.lang.String symbolicName, java.lang.String versionRange)
PackageAdmin
null
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
在接口中 PackageAdmin
symbolicName
- 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_ATTRIBUTE
public Bundle[] getFragments(Bundle bundle)
PackageAdmin
null
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
在接口中 PackageAdmin
bundle
- 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)
PackageAdmin
getHosts
在接口中 PackageAdmin
bundle
- 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(java.lang.Class clazz)
PackageAdmin
null
is returned.getBundle
在接口中 PackageAdmin
clazz
- 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)
PackageAdmin
If a bundle is not one or more of the defined types then 0x00000000 is returned.
getBundleType
在接口中 PackageAdmin
bundle
- The bundle for which to return the special type.