public class BundleComponentActivator extends java.lang.Object implements ComponentActivator
| Modifier and Type | Class and Description |
|---|---|
private static class |
BundleComponentActivator.ListenerInfo |
| Modifier and Type | Field and Description |
|---|---|
private ConfigAdminTracker |
configAdminTracker |
private java.util.Map<java.lang.String,BundleComponentActivator.ListenerInfo> |
listenerMap |
private java.util.concurrent.atomic.AtomicBoolean |
m_active |
private org.osgi.framework.Bundle |
m_bundle |
private java.util.concurrent.CountDownLatch |
m_closeLatch |
private ComponentActorThread |
m_componentActor |
private ComponentRegistry |
m_componentRegistry |
private ScrConfiguration |
m_configuration |
private org.osgi.framework.BundleContext |
m_context |
private java.util.List<ComponentHolder<?>> |
m_holders |
private SimpleLogger |
m_logger |
private org.osgi.util.tracker.ServiceTracker<org.osgi.service.log.LogService,org.osgi.service.log.LogService> |
m_logService |
| Constructor and Description |
|---|
BundleComponentActivator(SimpleLogger logger,
ComponentRegistry componentRegistry,
ComponentActorThread componentActor,
org.osgi.framework.BundleContext context,
ScrConfiguration configuration)
Called upon starting of the bundle.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addServiceListener(java.lang.String classNameFilter,
org.osgi.framework.Filter eventFilter,
ExtendedServiceListener<ExtendedServiceEvent> listener) |
void |
disableComponent(java.lang.String name)
Implements the
ComponentContext.disableComponent(String)
method by first finding the component(s) for the name and
disabling them. |
(package private) void |
dispose(int reason)
Dispose of this component activator instance and all the component
managers.
|
void |
enableComponent(java.lang.String name)
Implements the
ComponentContext.enableComponent(String)
method by first finding the component(s) for the name and
enabling them. |
<T> boolean |
enterCreate(org.osgi.framework.ServiceReference<T> serviceReference) |
(package private) static java.net.URL[] |
findDescriptors(org.osgi.framework.Bundle bundle,
java.lang.String descriptorLocation)
Finds component descriptors based on descriptor location.
|
org.osgi.framework.BundleContext |
getBundleContext()
Returns the BundleContext
|
ScrConfiguration |
getConfiguration() |
private java.util.List<ComponentHolder<?>> |
getSelectedComponents(java.lang.String name)
Returns an array of
ComponentHolder instances which match the
name. |
(package private) void |
initialEnable()
Called outside the constructor so that the m_managers field is completely initialized.
|
protected void |
initialize(java.lang.String descriptorLocations)
Gets the MetaData location, parses the meta data and requests the processing
of binder instances
|
boolean |
isActive()
Returns
|
boolean |
isLogEnabled(int level)
Returns
true if logging for the given level is enabled. |
<T> void |
leaveCreate(org.osgi.framework.ServiceReference<T> serviceReference) |
private void |
loadDescriptor(java.net.URL descriptorURL) |
void |
log(int level,
java.lang.String message,
ComponentMetadata metadata,
java.lang.Long componentId,
java.lang.Throwable ex)
Method to actually emit the log message.
|
void |
log(int level,
java.lang.String pattern,
java.lang.Object[] arguments,
ComponentMetadata metadata,
java.lang.Long componentId,
java.lang.Throwable ex)
Method to actually emit the log message.
|
<T> void |
missingServicePresent(org.osgi.framework.ServiceReference<T> serviceReference) |
long |
registerComponentId(AbstractComponentManager<?> componentManager) |
<S,T> void |
registerMissingDependency(DependencyManager<S,T> dependencyManager,
org.osgi.framework.ServiceReference<T> serviceReference,
int trackingCount) |
void |
removeServiceListener(java.lang.String className,
org.osgi.framework.Filter filter,
ExtendedServiceListener<ExtendedServiceEvent> listener) |
void |
schedule(java.lang.Runnable task)
Schedules the given
task for asynchrounous execution or
synchronously runs the task if the thread is not running. |
RegionConfigurationSupport |
setRegionConfigurationSupport(org.osgi.framework.ServiceReference<org.osgi.service.cm.ConfigurationAdmin> reference) |
void |
unregisterComponentId(AbstractComponentManager<?> componentManager) |
void |
unsetRegionConfigurationSupport(RegionConfigurationSupport rcs) |
private final ComponentRegistry m_componentRegistry
private final org.osgi.framework.Bundle m_bundle
private final org.osgi.framework.BundleContext m_context
private final java.util.List<ComponentHolder<?>> m_holders
private final org.osgi.util.tracker.ServiceTracker<org.osgi.service.log.LogService,org.osgi.service.log.LogService> m_logService
private final ComponentActorThread m_componentActor
private final java.util.concurrent.atomic.AtomicBoolean m_active
private final java.util.concurrent.CountDownLatch m_closeLatch
private final ScrConfiguration m_configuration
private final ConfigAdminTracker configAdminTracker
private final java.util.Map<java.lang.String,BundleComponentActivator.ListenerInfo> listenerMap
private final SimpleLogger m_logger
public BundleComponentActivator(SimpleLogger logger, ComponentRegistry componentRegistry, ComponentActorThread componentActor, org.osgi.framework.BundleContext context, ScrConfiguration configuration) throws org.osgi.service.component.ComponentException
componentRegistry - The ComponentRegistry used to
register components with to ensure uniqueness of component names
and to ensure configuration updates.context - The bundle context owning the componentsorg.osgi.service.component.ComponentException - if any error occurrs initializing this classpublic void addServiceListener(java.lang.String classNameFilter,
org.osgi.framework.Filter eventFilter,
ExtendedServiceListener<ExtendedServiceEvent> listener)
addServiceListener in interface ExtendedServiceListenerContext<ExtendedServiceEvent>public void removeServiceListener(java.lang.String className,
org.osgi.framework.Filter filter,
ExtendedServiceListener<ExtendedServiceEvent> listener)
removeServiceListener in interface ExtendedServiceListenerContext<ExtendedServiceEvent>protected void initialize(java.lang.String descriptorLocations)
descriptorLocations - A comma separated list of locations of
component descriptors. This must not be null.java.lang.IllegalStateException - If the bundle has already been uninstalled.void initialEnable()
static java.net.URL[] findDescriptors(org.osgi.framework.Bundle bundle,
java.lang.String descriptorLocation)
bundle - bundle to search for descriptor filesdescriptorLocation - descriptor locationprivate void loadDescriptor(java.net.URL descriptorURL)
void dispose(int reason)
public boolean isActive()
disposing this instance.isActive in interface ComponentActivatorpublic org.osgi.framework.BundleContext getBundleContext()
getBundleContext in interface ComponentActivatorpublic ScrConfiguration getConfiguration()
getConfiguration in interface ComponentActivatorpublic void enableComponent(java.lang.String name)
ComponentContext.enableComponent(String)
method by first finding the component(s) for the name and
enabling them. The enable method will schedule activation.
enableComponent in interface ComponentActivatorname - The name of the component to enable or null to
enable all components.public void disableComponent(java.lang.String name)
ComponentContext.disableComponent(String)
method by first finding the component(s) for the name and
disabling them. The disable method will schedule deactivation
disableComponent in interface ComponentActivatorname - The name of the component to disable or null to
disable all components.private java.util.List<ComponentHolder<?>> getSelectedComponents(java.lang.String name)
ComponentHolder instances which match the
name. If the name is null an
array of all currently known component managers is returned. Otherwise
an array containing a single component manager matching the name is
returned if one is registered. Finally, if no component manager with the
given name is registered, null is returned.name - The name of the component manager to return or
null to return an array of all component managers.name parameter or null if no
component manager with the given name is currently registered.public long registerComponentId(AbstractComponentManager<?> componentManager)
registerComponentId in interface ComponentActivatorpublic void unregisterComponentId(AbstractComponentManager<?> componentManager)
unregisterComponentId in interface ComponentActivatorpublic void schedule(java.lang.Runnable task)
task for asynchrounous execution or
synchronously runs the task if the thread is not running. If this instance
is not active, the task is not executed.schedule in interface ComponentActivatortask - The component task to executepublic boolean isLogEnabled(int level)
true if logging for the given level is enabled.isLogEnabled in interface Loggerpublic void log(int level,
java.lang.String pattern,
java.lang.Object[] arguments,
ComponentMetadata metadata,
java.lang.Long componentId,
java.lang.Throwable ex)
log in interface Loggerlevel - The log level to log the message atpattern - The java.text.MessageFormat message format
string for preparing the messagearguments - The format arguments for the pattern
string.componentId - ex - An optional Throwable whose stack trace is written,metadata - component metadata if knownpublic void log(int level,
java.lang.String message,
ComponentMetadata metadata,
java.lang.Long componentId,
java.lang.Throwable ex)
log in interface Loggerlevel - The log level to log the message atmessage - The message to logcomponentId - ex - An optional Throwable whose stack trace is written,metadata - The ComponentMetadata whose processing caused
the message. This may be null if the component
metadata is not known or applicable.public <T> boolean enterCreate(org.osgi.framework.ServiceReference<T> serviceReference)
enterCreate in interface ComponentActivatorpublic <T> void leaveCreate(org.osgi.framework.ServiceReference<T> serviceReference)
leaveCreate in interface ComponentActivatorpublic <T> void missingServicePresent(org.osgi.framework.ServiceReference<T> serviceReference)
missingServicePresent in interface ComponentActivatorpublic <S,T> void registerMissingDependency(DependencyManager<S,T> dependencyManager, org.osgi.framework.ServiceReference<T> serviceReference, int trackingCount)
registerMissingDependency in interface ComponentActivatorpublic RegionConfigurationSupport setRegionConfigurationSupport(org.osgi.framework.ServiceReference<org.osgi.service.cm.ConfigurationAdmin> reference)
setRegionConfigurationSupport in interface ComponentActivatorpublic void unsetRegionConfigurationSupport(RegionConfigurationSupport rcs)
unsetRegionConfigurationSupport in interface ComponentActivator