public class MetadataBundleListener extends Object implements org.osgi.framework.BundleListener
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 and Description |
---|
MetadataBundleListener() |
Modifier and Type | Method and Description |
---|---|
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.
|
public void start(org.osgi.framework.BundleContext bundleContext)
ProviderMetadata
and
ApiMetadata
found. Registers the itself as a BundleListener
.bundleContext
- public void stop(org.osgi.framework.BundleContext bundleContext)
BundleListener
s. Clears metadata maps and listeners lists.bundleContext
- public void bundleChanged(org.osgi.framework.BundleEvent event)
bundleChanged
in interface org.osgi.framework.BundleListener
public Iterable<ProviderMetadata> listProviderMetadata(org.osgi.framework.Bundle bundle)
ProviderMetadata
from the Bundle
.bundle
- public Iterable<ApiMetadata> listApiMetadata(org.osgi.framework.Bundle bundle)
ApiMetadata
from the Bundle
.bundle
- public void addProviderListener(ProviderListener listener)
ProviderListener
and notifies it of existing ProviderMetadata
.listener
- The listener.public void removeProviderListener(ProviderListener listener)
ProviderListener
listener
- The listenerpublic void addApiListenerListener(ApiListener listener)
ApiListener
and notifies it of existing ApiMetadata
.listener
- public void removeApiListenerListener(ApiListener listener)
ApiListener
listener
- Copyright © 2009-2016 The Apache Software Foundation. All Rights Reserved.