Package org.jclouds.osgi
Class MetadataBundleListener
- java.lang.Object
-
- org.jclouds.osgi.MetadataBundleListener
-
- All Implemented Interfaces:
EventListener
,org.osgi.framework.BundleListener
public class MetadataBundleListener extends Object implements org.osgi.framework.BundleListener
ABundleListener
that listens forBundleEvent
and searches forProviderMetadata
andApiMetadata
in newly installed Bundles. This is used as a workaround for OSGi environments where the ServiceLoader cannot cross bundle boundaries.
-
-
Constructor Summary
Constructors Constructor Description MetadataBundleListener()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addApiListenerListener(ApiListener listener)
Adds aApiListener
and notifies it of existingApiMetadata
.void
addProviderListener(ProviderListener listener)
Adds aProviderListener
and notifies it of existingProviderMetadata
.void
bundleChanged(org.osgi.framework.BundleEvent event)
Iterable<ApiMetadata>
listApiMetadata(org.osgi.framework.Bundle bundle)
Creates an instance ofApiMetadata
from theBundle
.Iterable<ProviderMetadata>
listProviderMetadata(org.osgi.framework.Bundle bundle)
Creates an instance ofProviderMetadata
from theBundle
.void
removeApiListenerListener(ApiListener listener)
Removes theApiListener
void
removeProviderListener(ProviderListener listener)
Removes theProviderListener
void
start(org.osgi.framework.BundleContext bundleContext)
Starts the listener.void
stop(org.osgi.framework.BundleContext bundleContext)
Stops the listener.
-
-
-
Method Detail
-
start
public void start(org.osgi.framework.BundleContext bundleContext)
Starts the listener. Checks the bundles that are already active and registersProviderMetadata
andApiMetadata
found. Registers the itself as aBundleListener
.- Parameters:
bundleContext
-
-
stop
public void stop(org.osgi.framework.BundleContext bundleContext)
Stops the listener. Removes itself from theBundleListener
s. Clears metadata maps and listeners lists.- Parameters:
bundleContext
-
-
bundleChanged
public void bundleChanged(org.osgi.framework.BundleEvent event)
- Specified by:
bundleChanged
in interfaceorg.osgi.framework.BundleListener
-
listProviderMetadata
public Iterable<ProviderMetadata> listProviderMetadata(org.osgi.framework.Bundle bundle)
Creates an instance ofProviderMetadata
from theBundle
.- Parameters:
bundle
-- Returns:
-
listApiMetadata
public Iterable<ApiMetadata> listApiMetadata(org.osgi.framework.Bundle bundle)
Creates an instance ofApiMetadata
from theBundle
.- Parameters:
bundle
-- Returns:
-
addProviderListener
public void addProviderListener(ProviderListener listener)
Adds aProviderListener
and notifies it of existingProviderMetadata
.- Parameters:
listener
- The listener.
-
removeProviderListener
public void removeProviderListener(ProviderListener listener)
Removes theProviderListener
- Parameters:
listener
- The listener
-
addApiListenerListener
public void addApiListenerListener(ApiListener listener)
Adds aApiListener
and notifies it of existingApiMetadata
.- Parameters:
listener
-
-
removeApiListenerListener
public void removeApiListenerListener(ApiListener listener)
Removes theApiListener
- Parameters:
listener
-
-
-