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

java.lang.Object
  extended by at.ac.tuwien.infosys.sm4all.copal.api.osgi.GenericActivator
      extended by at.ac.tuwien.infosys.sm4all.copal.api.publisher.BasePublisher
          extended by at.ac.tuwien.infosys.sm4all.copal.api.publisher.PolledPublisher
All Implemented Interfaces:
DependencyTrackerCustomizer, ContextPublisher, Observer<RegistryObservable.RegistrationState,ContextEventType>, RegistryObservable.RegistryObserver<ContextEventType>, org.osgi.framework.BundleActivator

public abstract class PolledPublisher
extends BasePublisher

Implementation of ContextPublisher that polls periodically for a ContextEvents.

Author:
sanjin

Constructor Summary
protected PolledPublisher(long interval, java.lang.String sourceID, java.lang.String... polledTypes)
          Creates instance of polled ContextPublisher that has specified source ID and polls specified ContextEvent types at specified interval.
 
Method Summary
protected abstract  ContextEvent poll(ContextEventType eventType)
          This method is polled periodically (defined with poll interval in the PolledPublisher(long, String, String...) constructor) to produce a ContextEvent of specified ContextEventType that will be published.
protected  boolean start(ContextEventType eventType)
          This method is called when PublishingService becomes available for publishing @link ContextEvent}s of the specified ContextEventType.
protected  void stop(ContextEventType eventType)
          This method is called when PublishingService becomes unavailable for publishing ContextEvents of the specified ContextEventType.
 
Methods inherited from class at.ac.tuwien.infosys.sm4all.copal.api.publisher.BasePublisher
add, add, appendAction, getPublishedTypes, getSourceID, isStarted, publish, removeAuthorization, setPriority, setTTL, start, stop, unsetPriority, unsetTTL, update
 
Methods inherited from class at.ac.tuwien.infosys.sm4all.copal.api.osgi.GenericActivator
addingService, getDependency, modifiedService, register, register, removedService, start, stop, unregister
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PolledPublisher

protected PolledPublisher(long interval,
                          java.lang.String sourceID,
                          java.lang.String... polledTypes)
Creates instance of polled ContextPublisher that has specified source ID and polls specified ContextEvent types at specified interval.

Parameters:
interval - the poll interval.
sourceID - the source ID.
polledTypes - polled ContextEvent types.
Method Detail

poll

protected abstract ContextEvent poll(ContextEventType eventType)
                              throws ContextException
This method is polled periodically (defined with poll interval in the PolledPublisher(long, String, String...) constructor) to produce a ContextEvent of specified ContextEventType that will be published.

Parameters:
eventType - the type of polled ContextEvent.
Returns:
the ContextEvent
Throws:
ContextException - if polling fails.

start

protected boolean start(ContextEventType eventType)
Description copied from class: BasePublisher
This method is called when PublishingService becomes available for publishing @link ContextEvent}s of the specified ContextEventType. This method should be implemented by specific publishers and is meant as a notification that publisher can start publishing ContextEvents of this ContextEventType.

Specified by:
start in class BasePublisher
Parameters:
eventType - the ContextEventType of published events.
Returns:
if this BasePublisher has been successfully started for specified ContextEventType.

stop

protected void stop(ContextEventType eventType)
Description copied from class: BasePublisher
This method is called when PublishingService becomes unavailable for publishing ContextEvents of the specified ContextEventType. This method should be implemented by specific publishers and is meant as a notification that publisher should stop publishing ContextEvents of this ContextEventType.

Specified by:
stop in class BasePublisher
Parameters:
eventType - the ContextEventType of published ContextEvents.


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