Class PackageAdminImpl

  • All Implemented Interfaces:
    PackageAdmin

    public class PackageAdminImpl
    extends java.lang.Object
    implements PackageAdmin
    • 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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 interface PackageAdmin
        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 interface PackageAdmin
        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 interface PackageAdmin
        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 interface PackageAdmin
        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 interface PackageAdmin
        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 interface PackageAdmin
        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 then 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.

        Specified by:
        getFragments in interface PackageAdmin
        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 interface PackageAdmin
        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 interface PackageAdmin
        Parameters:
        symbolicName - The bundle symbolic name or null 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 interface PackageAdmin
        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 have AdminPermission[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 interface PackageAdmin
        Parameters:
        bundles - The bundles to resolve or null to resolve all unresolved bundles installed in the Framework.
        Returns:
        true if all specified bundles are resolved;