at.ac.tuwien.infosys.sm4all.copal.api.publisher
Class PublishersActivator

java.lang.Object
  extended by at.ac.tuwien.infosys.sm4all.copal.api.util.Register<java.lang.String,ContextPublisher,BasePublisher>
      extended by at.ac.tuwien.infosys.sm4all.copal.api.publisher.PublishersActivator
All Implemented Interfaces:
org.osgi.framework.BundleActivator

public class PublishersActivator
extends Register<java.lang.String,ContextPublisher,BasePublisher>
implements org.osgi.framework.BundleActivator

Class to be used as an OSGi BundleActivator for bundles that need to register BasePublishers.

Author:
sanjin

Field Summary
static java.lang.String CONFIGURATION_FILE
          The name of configuration file that defines ContextEventTypes used by the registered ContextPublishers.
 
Constructor Summary
protected PublishersActivator()
          Creates instance of OSGi BundleActivator for bundles that need to register BasePublishers.
 
Method Summary
protected  java.lang.String getKey(BasePublisher publisher)
          Returns the key for specified value.
 SimplePublisher getPublisher(java.lang.String sourceID, java.lang.String publishedType)
          Returns a SimplePublisher with specified source ID and name of published ContextEventType.
 ContextEventType getRegisteredEventType(java.lang.String name)
          Returns registered ContextEventType that has specified name defined in the CONFIGURATION_FILE.
 ContextEventType[] getRegisteredEventTypes()
          Returns all registered ContextEventTypes defined in the CONFIGURATION_FILE.
 void register(BasePublisher publisher)
          Register specified BasePublisher when ContextPublisherRegistry becomes available (or immediately if it is already available).
protected  void setRegistry(ContextPublisherRegistry registry)
          Sets the new ContextPublisherRegistry, unregisters all BasePublishers from previously set ContextPublisherRegistry if it was not null and registers all BasePublishers with specified ContextPublisherRegistry if it is not null.
protected  void start()
          Called when bundle is started.
 void start(org.osgi.framework.BundleContext context)
           
protected  void start(ContextPublisherRegistry publisherRegistry)
          Called when a ContextPublisherRegistry becomes available.
 void stop(org.osgi.framework.BundleContext context)
           
 void unregister(BasePublisher publisher)
          Do not register specified BasePublisher when ContextPublisherRegistry becomes available (and unregister it immediately if it is already available).
protected  void update(RegistryObservable.RegistrationState state, BasePublisher publisher)
          Called when specified value changes its RegistryObservable.RegistrationState.
 
Methods inherited from class at.ac.tuwien.infosys.sm4all.copal.api.util.Register
getRegistry, setRegistry
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONFIGURATION_FILE

public static final java.lang.String CONFIGURATION_FILE
The name of configuration file that defines ContextEventTypes used by the registered ContextPublishers.

See Also:
Constant Field Values
Constructor Detail

PublishersActivator

protected PublishersActivator()
Creates instance of OSGi BundleActivator for bundles that need to register BasePublishers.

Method Detail

start

protected void start()
Called when bundle is started.


start

protected void start(ContextPublisherRegistry publisherRegistry)
Called when a ContextPublisherRegistry becomes available.

Parameters:
publisherRegistry - the ContextPublisherRegistry.

getRegisteredEventType

public ContextEventType getRegisteredEventType(java.lang.String name)
Returns registered ContextEventType that has specified name defined in the CONFIGURATION_FILE. If ContextEventType with specified name is not defined in the CONFIGURATION_FILE or the ContextEventType was not successfully registered, the null value is returned.

Parameters:
name - the name of registered ContextEventType.
Returns:
the registered ContextEventType.

getRegisteredEventTypes

public ContextEventType[] getRegisteredEventTypes()
Returns all registered ContextEventTypes defined in the CONFIGURATION_FILE.

Returns:
all registered ContextEventTypes.

getPublisher

public SimplePublisher getPublisher(java.lang.String sourceID,
                                    java.lang.String publishedType)
Returns a SimplePublisher with specified source ID and name of published ContextEventType. The SimplePublisher is already registered with this PublishersActivator.

Parameters:
sourceID - the source ID for SimplePublisher.
publishedType - the name of published ContextEventType
Returns:
the SimplePublisher.
Throws:
java.lang.IllegalArgumentException - if specified name of published ContextEventType is not registered with this PublishersActivator.

start

public final void start(org.osgi.framework.BundleContext context)
Specified by:
start in interface org.osgi.framework.BundleActivator

stop

public final void stop(org.osgi.framework.BundleContext context)
Specified by:
stop in interface org.osgi.framework.BundleActivator

register

public final void register(BasePublisher publisher)
Register specified BasePublisher when ContextPublisherRegistry becomes available (or immediately if it is already available).

Overrides:
register in class Register<java.lang.String,ContextPublisher,BasePublisher>
Parameters:
publisher - the BasePublisher to register.

unregister

public final void unregister(BasePublisher publisher)
Do not register specified BasePublisher when ContextPublisherRegistry becomes available (and unregister it immediately if it is already available).

Overrides:
unregister in class Register<java.lang.String,ContextPublisher,BasePublisher>
Parameters:
publisher - the BasePublisher to unregister.

setRegistry

protected void setRegistry(ContextPublisherRegistry registry)
Sets the new ContextPublisherRegistry, unregisters all BasePublishers from previously set ContextPublisherRegistry if it was not null and registers all BasePublishers with specified ContextPublisherRegistry if it is not null.

Parameters:
registry - the new ContextPublisherRegistry.

getKey

protected java.lang.String getKey(BasePublisher publisher)
Description copied from class: Register
Returns the key for specified value.

Specified by:
getKey in class Register<java.lang.String,ContextPublisher,BasePublisher>
Parameters:
publisher - the value.
Returns:
the key.

update

protected void update(RegistryObservable.RegistrationState state,
                      BasePublisher publisher)
Description copied from class: Register
Called when specified value changes its RegistryObservable.RegistrationState.

Specified by:
update in class Register<java.lang.String,ContextPublisher,BasePublisher>
Parameters:
state - the RegistryObservable.RegistrationState
publisher - the value.


Copyright © 2010 Distributed Systems Group, Vienna University of Technology. All Rights Reserved.