Class MetadataBundleListener

  • All Implemented Interfaces:
    EventListener, org.osgi.framework.BundleListener

    public class MetadataBundleListener
    extends Object
    implements org.osgi.framework.BundleListener
    A BundleListener that listens for BundleEvent and searches for ProviderMetadata and ApiMetadata in newly installed Bundles. This is used as a workaround for OSGi environments where the ServiceLoader cannot cross bundle boundaries.
    • Constructor Detail

      • MetadataBundleListener

        public MetadataBundleListener()
    • Method Detail

      • start

        public void start​(org.osgi.framework.BundleContext bundleContext)
        Starts the listener. Checks the bundles that are already active and registers ProviderMetadata and ApiMetadata found. Registers the itself as a BundleListener.
        Parameters:
        bundleContext -
      • stop

        public void stop​(org.osgi.framework.BundleContext bundleContext)
        Stops the listener. Removes itself from the BundleListeners. Clears metadata maps and listeners lists.
        Parameters:
        bundleContext -
      • bundleChanged

        public void bundleChanged​(org.osgi.framework.BundleEvent event)
        Specified by:
        bundleChanged in interface org.osgi.framework.BundleListener
      • listProviderMetadata

        public Iterable<ProviderMetadata> listProviderMetadata​(org.osgi.framework.Bundle bundle)
        Creates an instance of ProviderMetadata from the Bundle.
        Parameters:
        bundle -
        Returns:
      • listApiMetadata

        public Iterable<ApiMetadata> listApiMetadata​(org.osgi.framework.Bundle bundle)
        Creates an instance of ApiMetadata from the Bundle.
        Parameters:
        bundle -
        Returns:
      • addApiListenerListener

        public void addApiListenerListener​(ApiListener listener)
        Adds a ApiListener and notifies it of existing ApiMetadata.
        Parameters:
        listener -
      • removeApiListenerListener

        public void removeApiListenerListener​(ApiListener listener)
        Removes the ApiListener
        Parameters:
        listener -