Package org.eclipse.jetty.ee10.osgi.boot
Class PackageAdminServiceTracker
java.lang.Object
org.eclipse.jetty.ee10.osgi.boot.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-ee9-osgi-boot-jsp fragment bundle that uses this facility.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected 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
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()
-
Field Details
-
INSTANCE
-
-
Constructor Details
-
PackageAdminServiceTracker
- Throws:
Exception
-
-
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 interfaceorg.osgi.framework.ServiceListener
- Parameters:
event
- TheServiceEvent
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 bundleadmin
- the admin packagedeps
- 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 bundleadmin
- the admin packagedeps
- 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.
-