org.jclouds.osgi
Class MetadataBundleListener

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

Author:
iocanel

Constructor Summary
MetadataBundleListener()
           
 
Method Summary
 void addApiListenerListener(ApiListener listener)
          Adds a ApiListener and notifies it of existing ApiMetadata.
 void addProviderListener(ProviderListener listener)
          Adds a ProviderListener and notifies it of existing ProviderMetadata.
 void bundleChanged(org.osgi.framework.BundleEvent event)
           
 Iterable<ApiMetadata> listApiMetadata(org.osgi.framework.Bundle bundle)
          Creates an instance of ApiMetadata from the Bundle.
 Iterable<ProviderMetadata> listProviderMetadata(org.osgi.framework.Bundle bundle)
          Creates an instance of ProviderMetadata from the Bundle.
 void removeApiListenerListener(ApiListener listener)
          Removes the ApiListener
 void removeProviderListener(ProviderListener listener)
          Removes the ProviderListener
 void start(org.osgi.framework.BundleContext bundleContext)
          Starts the listener.
 void stop(org.osgi.framework.BundleContext bundleContext)
          Stops the listener.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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:

addProviderListener

public void addProviderListener(ProviderListener listener)
Adds a ProviderListener and notifies it of existing ProviderMetadata.

Parameters:
listener - The listener.

removeProviderListener

public void removeProviderListener(ProviderListener listener)
Removes the ProviderListener

Parameters:
listener - The listener

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 -


Copyright © 2009-2013 jclouds. All Rights Reserved.