Package org.jclouds.osgi
Class MetadataBundleListener
java.lang.Object
org.jclouds.osgi.MetadataBundleListener
- All Implemented Interfaces:
EventListener
,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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
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) listApiMetadata
(org.osgi.framework.Bundle bundle) Creates an instance ofApiMetadata
from theBundle
.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.
-
Constructor Details
-
MetadataBundleListener
public MetadataBundleListener()
-
-
Method Details
-
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
Creates an instance ofProviderMetadata
from theBundle
.- Parameters:
bundle
-- Returns:
-
listApiMetadata
Creates an instance ofApiMetadata
from theBundle
.- Parameters:
bundle
-- Returns:
-
addProviderListener
Adds aProviderListener
and notifies it of existingProviderMetadata
.- Parameters:
listener
- The listener.
-
removeProviderListener
Removes theProviderListener
- Parameters:
listener
- The listener
-
addApiListenerListener
Adds aApiListener
and notifies it of existingApiMetadata
.- Parameters:
listener
-
-
removeApiListenerListener
Removes theApiListener
- Parameters:
listener
-
-