at.ac.tuwien.infosys.sm4all.copal.api.listener
Class ListenersActivator

java.lang.Object
  extended by at.ac.tuwien.infosys.sm4all.copal.api.listener.ListenersActivator
All Implemented Interfaces:
QueryObserver, Observer<QueryState,ContextQuery>, org.osgi.framework.BundleActivator

public class ListenersActivator
extends java.lang.Object
implements org.osgi.framework.BundleActivator, QueryObserver

Abstract helper class to be used as an OSGi BundleActivator for bundles that need to create ContextQuerys and register ContextListeners.

Author:
sanjin

Field Summary
static java.lang.String CONFIGURATION_FILE
          The name of configuration file that defines ContextQuerys used to register ContextListeners.
 
Constructor Summary
protected ListenersActivator()
          Creates instance of OSGi BundleActivator for bundles that to create ContextQuerys and register ContextListeners.
 
Method Summary
 ContextQuery getQuery(java.lang.String name)
          Returns created ProcessedEventQuery that has specified name defined in the CONFIGURATION_FILE.
 ProcessedEventQuery[] getRegisteredQueries()
          Returns all created ProcessedEventQuerys defined in the CONFIGURATION_FILE.
 void register(java.lang.String queryName, ContextListener listener)
          Register specified ContextListener with a ContextQuery that has specified name.
protected  void setFactory(ContextQueryFactory factory)
          Sets the ContextQueryFactory, destroys all previously created ContextQuerys and creates defined ContextQuerys and registers all ContextListeners if ContextQueryFactory is not null.
protected  void start()
          Called when bundle is started.
 void start(org.osgi.framework.BundleContext bundleContext)
           
protected  void start(ContextQueryFactory queryFactory)
          Called when ContextQueryFactory becomes available.
protected  void stop()
          Called when ContextQueryFactory becomes unavailable.
 void stop(org.osgi.framework.BundleContext bundleContext)
           
 void unregister(java.lang.String queryName, ContextListener listener)
          Do not register specified ContextListener with ContextQuery that has specified name.
 void update(QueryState state, ContextQuery query)
          Called when specified ContextQuery changes its QueryState .
 
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 ContextQuerys used to register ContextListeners.

See Also:
Constant Field Values
Constructor Detail

ListenersActivator

protected ListenersActivator()
Creates instance of OSGi BundleActivator for bundles that to create ContextQuerys and register ContextListeners.

Method Detail

start

protected void start()
Called when bundle is started.


start

protected void start(ContextQueryFactory queryFactory)
Called when ContextQueryFactory becomes available.

Parameters:
queryFactory - the ContextQueryFactory.

stop

protected void stop()
Called when ContextQueryFactory becomes unavailable.


getQuery

public ContextQuery getQuery(java.lang.String name)
Returns created ProcessedEventQuery that has specified name defined in the CONFIGURATION_FILE. If ProcessedEventQuery with specified name is not defined in the CONFIGURATION_FILE or the ProcessedEventQuery was not successfully created, the null value is returned.

Parameters:
name - the name of created ProcessedEventQuery.
Returns:
the created ProcessedEventQuery.

getRegisteredQueries

public ProcessedEventQuery[] getRegisteredQueries()
Returns all created ProcessedEventQuerys defined in the CONFIGURATION_FILE.

Returns:
all created ProcessedEventQuerys.

start

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

stop

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

register

public final void register(java.lang.String queryName,
                           ContextListener listener)
Register specified ContextListener with a ContextQuery that has specified name.

Parameters:
queryName - the name of the ContextQuery.
listener - the ContextListener.

unregister

public final void unregister(java.lang.String queryName,
                             ContextListener listener)
Do not register specified ContextListener with ContextQuery that has specified name.

Parameters:
queryName - the name of the ContextQuery.
listener - the ContextListener.

setFactory

protected void setFactory(ContextQueryFactory factory)
Sets the ContextQueryFactory, destroys all previously created ContextQuerys and creates defined ContextQuerys and registers all ContextListeners if ContextQueryFactory is not null.

Parameters:
factory - the ContextQueryFactory.

update

public void update(QueryState state,
                   ContextQuery query)
Description copied from interface: QueryObserver
Called when specified ContextQuery changes its QueryState .

Specified by:
update in interface QueryObserver
Specified by:
update in interface Observer<QueryState,ContextQuery>
Parameters:
state - the QueryState.
query - the ContextQuery.


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