at.ac.tuwien.infosys.sm4all.copal.core.internal
Class ContextQueryFactoryImpl

java.lang.Object
  extended by at.ac.tuwien.infosys.sm4all.copal.api.util.BaseObservable<QueryState,ContextQuery,QueryObserver>
      extended by at.ac.tuwien.infosys.sm4all.copal.core.internal.ContextQueryFactoryImpl
All Implemented Interfaces:
ContextQueryFactory, Observable<QueryState,ContextQuery,QueryObserver>, org.osgi.framework.BundleActivator

public class ContextQueryFactoryImpl
extends BaseObservable<QueryState,ContextQuery,QueryObserver>
implements ContextQueryFactory, org.osgi.framework.BundleActivator

Implementation of the ContextQueryFactory interface.

Author:
sanjin

Constructor Summary
ContextQueryFactoryImpl()
           
 
Method Summary
 void attach(QueryObserver observer)
          Attaches specified Observer so it will in future receive notifications on changes.
 ProcessedEventQuery create(java.lang.String name, java.lang.String listenedType)
          Create instance of ProcessedEventQuery with specified globally unique name which catches all events with specified name of ContextEventType.
 ProcessedEventQuery create(java.lang.String name, java.lang.String listenedType, java.lang.String criteria)
          Create instance of ProcessedEventQuery with specified globally unique name which catches all events with specified name ContextEventType for which specified criteria evaluates to true.
 ActionQuery createActionQuery(java.lang.String listenedType, java.lang.String actionName)
          Create instance of ActionQuery for ContextEvents that have name of their ContextEventType equal to specified listened type and have name of their CurrentAction equal to specified action name
 void detach(QueryObserver observer)
          Detach specified Observer so it will not receive any future notifications on changes.
 ContextQuery[] getQueries()
          Returns all currently non-destroyed ContextQuerys.
 ContextQuery[] getQueries(java.lang.String eventType)
           
 ContextQuery getQuery(java.lang.String name)
           
 boolean isStarted()
          Returns if this ContextQueryFactory has been started by an OSGi framework.
protected  void remove(java.lang.String queryName)
          Remove query with specified name.
 void start(org.osgi.framework.BundleContext bundleContext)
           
 void stop(org.osgi.framework.BundleContext bundleContext)
           
 
Methods inherited from class at.ac.tuwien.infosys.sm4all.copal.api.util.BaseObservable
detachAll, getObservers, notifyAll
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ContextQueryFactoryImpl

public ContextQueryFactoryImpl()
Method Detail

isStarted

public boolean isStarted()
Returns if this ContextQueryFactory has been started by an OSGi framework.

Returns:
if this ContextQueryFactory has been started by an OSGi framework.

start

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

stop

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

attach

public void attach(QueryObserver observer)
Description copied from class: BaseObservable
Attaches specified Observer so it will in future receive notifications on changes.

Specified by:
attach in interface Observable<QueryState,ContextQuery,QueryObserver>
Overrides:
attach in class BaseObservable<QueryState,ContextQuery,QueryObserver>
Parameters:
observer - the Observer.

detach

public void detach(QueryObserver observer)
Description copied from class: BaseObservable
Detach specified Observer so it will not receive any future notifications on changes.

Specified by:
detach in interface Observable<QueryState,ContextQuery,QueryObserver>
Overrides:
detach in class BaseObservable<QueryState,ContextQuery,QueryObserver>
Parameters:
observer - the QueryObserver.

createActionQuery

public ActionQuery createActionQuery(java.lang.String listenedType,
                                     java.lang.String actionName)
Description copied from interface: ContextQueryFactory
Create instance of ActionQuery for ContextEvents that have name of their ContextEventType equal to specified listened type and have name of their CurrentAction equal to specified action name

Specified by:
createActionQuery in interface ContextQueryFactory
Parameters:
listenedType - the name of listened ContextEventType.
actionName - the name of handled CurrentAction.
Returns:
the action query.
See Also:
ActionQuery.ActionQuery(String, String)

create

public ProcessedEventQuery create(java.lang.String name,
                                  java.lang.String listenedType)
                           throws RedefinitionOfQueryException
Description copied from interface: ContextQueryFactory
Create instance of ProcessedEventQuery with specified globally unique name which catches all events with specified name of ContextEventType. If a query with same name was previously created the instance of ContextQuery created in first call will be returned, thus caller of this method has to ensure that specified event type in both calls is same.

Specified by:
create in interface ContextQueryFactory
Parameters:
name - the globally unique name of the ProcessedEventQuery.
listenedType - the name of listened ContextEventType.
Returns:
the context query.
Throws:
RedefinitionOfQueryException - if query with same name and different event type is already created.
See Also:
ProcessedEventQuery.ProcessedEventQuery(String, String)

create

public ProcessedEventQuery create(java.lang.String name,
                                  java.lang.String listenedType,
                                  java.lang.String criteria)
                           throws RedefinitionOfQueryException
Description copied from interface: ContextQueryFactory
Create instance of ProcessedEventQuery with specified globally unique name which catches all events with specified name ContextEventType for which specified criteria evaluates to true. Criteria is a logical expression using event's properties to further separate the events of interest. If a query with same name was previously created the instance of ContextQuery created in first call will be returned, thus caller of this method has to ensure that specified event type and criteria in both calls are same.

Specified by:
create in interface ContextQueryFactory
Parameters:
name - the globally unique name of the ProcessedEventQuery.
listenedType - the name of listened ContextEventType.
criteria - the logical expression.
Returns:
the context query.
Throws:
RedefinitionOfQueryException - if query with same name and different event type or criteria is already created.
See Also:
ProcessedEventQuery.ProcessedEventQuery(String, String, String)

getQueries

public ContextQuery[] getQueries()
Description copied from interface: ContextQueryFactory
Returns all currently non-destroyed ContextQuerys.

Specified by:
getQueries in interface ContextQueryFactory
Returns:
all currently non-destroyed ContextQuerys.

getQuery

public ContextQuery getQuery(java.lang.String name)
Specified by:
getQuery in interface ContextQueryFactory
Parameters:
name - the name of a ContextQuery.
Returns:
the ContextQuery used in creation; or null if there is no non-destroyed ContextQuery with specified name.

getQueries

public ContextQuery[] getQueries(java.lang.String eventType)
Specified by:
getQueries in interface ContextQueryFactory
Parameters:
eventType - the name of the ContextEventType.
Returns:
all ContextQuerys which listen on events of ContextEventType that has name equal to specified eventType.

remove

protected void remove(java.lang.String queryName)
Remove query with specified name.

Parameters:
queryName - the name of the query.


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