Class PackageAdminServiceTracker

java.lang.Object
org.eclipse.jetty.osgi.boot.utils.internal.PackageAdminServiceTracker
All Implemented Interfaces:
EventListener, org.osgi.framework.ServiceListener

public class PackageAdminServiceTracker extends Object implements org.osgi.framework.ServiceListener
PackageAdminServiceTracker

When the PackageAdmin service is activated we can look for the fragments attached to this bundle and do a fake "activate" on them.

See particularly the jetty-osgi-boot-jsp fragment bundle that uses this facility.

  • Field Details

  • Constructor Details

    • PackageAdminServiceTracker

      public PackageAdminServiceTracker(org.osgi.framework.BundleContext context)
  • Method Details

    • serviceChanged

      public void serviceChanged(org.osgi.framework.ServiceEvent event)
      Invokes the optional BundleActivator in each fragment. By convention the bundle activator for a fragment must be in the package that is defined by the symbolic name of the fragment and the name of the class must be 'FragmentActivator'.
      Specified by:
      serviceChanged in interface org.osgi.framework.ServiceListener
      Parameters:
      event - The ServiceEvent object.
    • getFragments

      public org.osgi.framework.Bundle[] getFragments(org.osgi.framework.Bundle bundle)
      Helper to access the PackageAdmin and return the fragments hosted by a bundle. when we drop the support for the older versions of OSGi, we will stop using the PackageAdmin service.
      Parameters:
      bundle - the bundle
      Returns:
      the bundle fragment list
    • getFragmentsAndRequiredBundles

      public org.osgi.framework.Bundle[] getFragmentsAndRequiredBundles(org.osgi.framework.Bundle bundle)
      Returns the fragments and the required-bundles of a bundle. Recursively collect the required-bundles and fragment when the directive visibility:=reexport is added to a required-bundle.
      Parameters:
      bundle - the bundle
      Returns:
      the bundle fragment and required list
    • collectFragmentsAndRequiredBundles

      protected void collectFragmentsAndRequiredBundles(org.osgi.framework.Bundle bundle, org.osgi.service.packageadmin.PackageAdmin admin, Map<String,org.osgi.framework.Bundle> deps, boolean onlyReexport)
      Returns the fragments and the required-bundles. Collects them transitively when the directive 'visibility:=reexport' is added to a required-bundle.
      Parameters:
      bundle - the bundle
      admin - the admin package
      deps - The map of fragment and required bundles associated to the value of the jetty-web attribute.
      onlyReexport - true to collect resources and web-fragments transitively if and only if the directive visibility is reexport.
    • collectRequiredBundles

      protected void collectRequiredBundles(org.osgi.framework.Bundle bundle, org.osgi.service.packageadmin.PackageAdmin admin, Map<String,org.osgi.framework.Bundle> deps, boolean onlyReexport)
      A simplistic but good enough parser for the Require-Bundle header. Parses the version range attribute and the visibility directive.
      Parameters:
      bundle - the bundle
      admin - the admin package
      deps - The map of required bundles associated to the value of the jetty-web attribute.
      onlyReexport - true to collect resources and web-fragments transitively if and only if the directive visibility is reexport.
    • stop

      public void stop()
    • frameworkHasCompletedAutostarts

      public boolean frameworkHasCompletedAutostarts()
      Returns:
      true if the framework has completed all the start levels.