Package org.apache.felix.framework
Class PackageAdminImpl
- java.lang.Object
-
- org.apache.felix.framework.PackageAdminImpl
-
- All Implemented Interfaces:
PackageAdmin
public class PackageAdminImpl extends java.lang.Object implements PackageAdmin
-
-
Field Summary
-
Fields inherited from interface org.osgi.service.packageadmin.PackageAdmin
BUNDLE_TYPE_FRAGMENT
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Bundle
getBundle(java.lang.Class clazz)
Returns the bundle associated with this class if the class was loaded from a bundle, otherwise returns null.Bundle[]
getBundles(java.lang.String symbolicName, java.lang.String versionRange)
Returns all bundles that have a specified symbolic name and whose version is in the specified version range.int
getBundleType(Bundle bundle)
Returns the special type of the specified bundle.ExportedPackage
getExportedPackage(java.lang.String name)
Returns the exported package associated with the specified package name.ExportedPackage[]
getExportedPackages(java.lang.String name)
Gets the exported packages for the specified package name.ExportedPackage[]
getExportedPackages(Bundle bundle)
Returns the packages exported by the specified bundle.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)
The OSGi specification states that refreshing packages is asynchronous; this method simply notifies the package admin thread to do a refresh.boolean
resolveBundles(Bundle[] bundles)
Resolve the specified bundles.
-
-
-
Method Detail
-
getBundle
public Bundle getBundle(java.lang.Class clazz)
Returns the bundle associated with this class if the class was loaded from a bundle, otherwise returns null.- Specified by:
getBundle
in interfacePackageAdmin
- Parameters:
clazz
- the class for which to determine its associated bundle.- Returns:
- the bundle associated with the specified class, otherwise null.
-
getBundles
public Bundle[] getBundles(java.lang.String symbolicName, java.lang.String versionRange)
Returns all bundles that have a specified symbolic name and whose version is in the specified version range. If no version range is specified, then all bundles with the specified symbolic name are returned. The array is sorted in descending version order.- Specified by:
getBundles
in interfacePackageAdmin
- Parameters:
symbolicName
- the target symbolic name.versionRange
- the target version range.- Returns:
- an array of matching bundles sorted in descending version order.
- See Also:
Constants.BUNDLE_VERSION_ATTRIBUTE
-
getBundleType
public int getBundleType(Bundle bundle)
Description copied from interface:PackageAdmin
Returns the special type of the specified bundle. The bundle type values are: A bundle may be more than one type at a time. A type code is used to identify the bundle type for future extendability.If a bundle is not one or more of the defined types then 0x00000000 is returned.
- Specified by:
getBundleType
in interfacePackageAdmin
- Parameters:
bundle
- The bundle for which to return the special type.- Returns:
- The special type of the bundle.
-
getExportedPackage
public ExportedPackage getExportedPackage(java.lang.String name)
Returns the exported package associated with the specified package name. If there are more than one version of the package being exported, then the highest version is returned.- Specified by:
getExportedPackage
in interfacePackageAdmin
- Parameters:
name
- the name of the exported package to find.- Returns:
- the exported package or null if no matching package was found.
- See Also:
PackageAdmin.getExportedPackages(String)
-
getExportedPackages
public ExportedPackage[] getExportedPackages(java.lang.String name)
Description copied from interface:PackageAdmin
Gets the exported packages for the specified package name.- Specified by:
getExportedPackages
in interfacePackageAdmin
- Parameters:
name
- The name of the exported packages to be returned.- Returns:
- An array of the exported packages, or
null
if no exported packages with the specified name exists.
-
getExportedPackages
public ExportedPackage[] getExportedPackages(Bundle bundle)
Returns the packages exported by the specified bundle.- Specified by:
getExportedPackages
in interfacePackageAdmin
- Parameters:
bundle
- the bundle whose exported packages are to be returned.- Returns:
- an array of packages exported by the bundle or null if the bundle does not export any packages.
-
getFragments
public Bundle[] getFragments(Bundle bundle)
Description copied from interface:PackageAdmin
Returns an array of attached fragment bundles for the specified bundle. If the specified bundle is a fragment thennull
is returned. If no fragments are attached to the specified bundle thennull
is returned.This method does not attempt to resolve the specified bundle. If the specified bundle is not resolved then
null
is returned.- Specified by:
getFragments
in interfacePackageAdmin
- Parameters:
bundle
- The bundle whose attached fragment bundles are to be returned.- Returns:
- An array of fragment bundles or
null
if the bundle does not have any attached fragment bundles or the bundle is not resolved.
-
getHosts
public Bundle[] getHosts(Bundle bundle)
Description copied from interface:PackageAdmin
Returns the host bundles to which the specified fragment bundle is attached.- Specified by:
getHosts
in interfacePackageAdmin
- Parameters:
bundle
- The fragment bundle whose host bundles are to be returned.- Returns:
- An array containing the host bundles to which the specified
fragment is attached or
null
if the specified bundle is not a fragment or is not attached to any host bundles.
-
getRequiredBundles
public RequiredBundle[] getRequiredBundles(java.lang.String symbolicName)
Description copied from interface:PackageAdmin
Returns an array of required bundles having the specified symbolic name.If
null
is specified, then all required bundles will be returned.- Specified by:
getRequiredBundles
in interfacePackageAdmin
- Parameters:
symbolicName
- The bundle symbolic name ornull
for all required bundles.- Returns:
- An array of required bundles or
null
if no required bundles exist for the specified symbolic name.
-
refreshPackages
public void refreshPackages(Bundle[] bundles) throws java.lang.SecurityException
The OSGi specification states that refreshing packages is asynchronous; this method simply notifies the package admin thread to do a refresh.- Specified by:
refreshPackages
in interfacePackageAdmin
- Parameters:
bundles
- array of bundles to refresh or null to refresh any bundles in need of refreshing.- Throws:
java.lang.SecurityException
- If the caller does not haveAdminPermission[System Bundle,RESOLVE]
and the Java runtime environment supports permissions.
-
resolveBundles
public boolean resolveBundles(Bundle[] bundles)
Description copied from interface:PackageAdmin
Resolve 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
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.- Specified by:
resolveBundles
in interfacePackageAdmin
- Parameters:
bundles
- The bundles to resolve ornull
to resolve all unresolved bundles installed in the Framework.- Returns:
true
if all specified bundles are resolved;
-
-