org.eclipse.jetty.osgi.boot.utils.internal
Class PackageAdminServiceTracker

java.lang.Object
  extended by 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

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


Field Summary
static PackageAdminServiceTracker INSTANCE
           
 
Constructor Summary
PackageAdminServiceTracker(org.osgi.framework.BundleContext context)
           
 
Method Summary
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.
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.
 boolean frameworkHasCompletedAutostarts()
           
 org.osgi.framework.Bundle[] getFragments(org.osgi.framework.Bundle bundle)
          Helper to access the PackageAdmin and return the fragments hosted by a bundle.
 org.osgi.framework.Bundle[] getFragmentsAndRequiredBundles(org.osgi.framework.Bundle bundle)
          Returns the fragments and the required-bundles of a bundle.
 void serviceChanged(org.osgi.framework.ServiceEvent event)
          Invokes the optional BundleActivator in each fragment.
 void stop()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INSTANCE

public static PackageAdminServiceTracker INSTANCE
Constructor Detail

PackageAdminServiceTracker

public PackageAdminServiceTracker(org.osgi.framework.BundleContext context)
Method Detail

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 -
Returns:

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 -
webFragOrAnnotationOrResources -
Returns:

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 -
webFragOrAnnotationOrResources -

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:
onlyReexport - true to collect resources and web-fragments transitively if and only if the directive visibility is reexport.
bundle -

stop

public void stop()

frameworkHasCompletedAutostarts

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


Copyright © 1995-2011 Mort Bay Consulting. All Rights Reserved.