at.ac.tuwien.infosys.sm4all.copal.api.helpers
Class AbstractContextPublisher

java.lang.Object
  extended by at.ac.tuwien.infosys.sm4all.copal.api.helpers.AbstractContextPublisher
All Implemented Interfaces:
ContextPublisher

public abstract class AbstractContextPublisher
extends Object
implements ContextPublisher

Helper class for implementing ContextPublishers.

Author:
sanjin

Constructor Summary
protected AbstractContextPublisher(String sourceID, String type)
          Use specified source ID and given event type as return values for getSourceID() and #getType() methods respectively.
 
Method Summary
 String getEventType()
           
 String getSourceID()
           
 boolean isStarted()
          Returns if this AbstractContextPublisher is started and can start publish events.
protected  boolean publish(Document document)
          Publish specified Document as an event.
protected  boolean publish(XMLContextEvent event)
          Publish given XMLContextEvent.
 boolean start(EventPublisher publisher, XMLContextEventType type)
          Callback method which notifies that the ContextPublisher can start publishing XMLContextEvents for specified XMLContextEventType using specified EventPublisher.
protected abstract  boolean start(XMLContextEventType type)
          This method is called when EventPublisher becomes available for publishing events of the specified XMLContextEventType.
 void stop(EventPublisher publisher, XMLContextEventType type)
          Callback method which notifies that the ContextPublisher has to stop publishing XMLContextEvents for specified XMLContextEventType using specified EventPublisher.
protected abstract  void stop(XMLContextEventType type)
          This method is called when EventPublisher becomes unavailable for publishing events of the specified XMLContextEventType.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractContextPublisher

protected AbstractContextPublisher(String sourceID,
                                   String type)
Use specified source ID and given event type as return values for getSourceID() and #getType() methods respectively.

Parameters:
sourceID - the source ID of context publisher.
type - the name of ContextEventType for published events.
Method Detail

start

protected abstract boolean start(XMLContextEventType type)
This method is called when EventPublisher becomes available for publishing events of the specified XMLContextEventType. This method should be implemented by specific publishers and should be used as a notification that publisher can, from now on, publish events.

Parameters:
type - the XMLContextEventType of published events.

stop

protected abstract void stop(XMLContextEventType type)
This method is called when EventPublisher becomes unavailable for publishing events of the specified XMLContextEventType. This method should be implemented by specific publishers and should be used as a notification that publisher should not publish any more events.

Parameters:
type - the XMLContextEventType of published events.

getSourceID

public final String getSourceID()
Specified by:
getSourceID in interface ContextPublisher
Returns:
the source ID of published XMLContextEvents.

getEventType

public final String getEventType()
Specified by:
getEventType in interface ContextPublisher
Returns:
the name of XMLContextEventType published by this ContextPublisher.

isStarted

public boolean isStarted()
Returns if this AbstractContextPublisher is started and can start publish events.

Returns:
if this AbstractContextPublisher is started and can start publish events.

start

public boolean start(EventPublisher publisher,
                     XMLContextEventType type)
Description copied from interface: ContextPublisher
Callback method which notifies that the ContextPublisher can start publishing XMLContextEvents for specified XMLContextEventType using specified EventPublisher.

Specified by:
start in interface ContextPublisher
Parameters:
publisher - the EventPublisher.
type - the XMLContextEventType.
Returns:
if this ContextPublisher has started successfully.

stop

public final void stop(EventPublisher publisher,
                       XMLContextEventType type)
Description copied from interface: ContextPublisher
Callback method which notifies that the ContextPublisher has to stop publishing XMLContextEvents for specified XMLContextEventType using specified EventPublisher.

Specified by:
stop in interface ContextPublisher
Parameters:
publisher - the EventPublisher.
type - the XMLContextEventType.

publish

protected final boolean publish(Document document)
                         throws MalformedDocumentException
Publish specified Document as an event.

Parameters:
document - the Document to be published.
Returns:
true> if publishing was successful; false otherwise.
Throws:
MalformedDocumentException - if specified Document is malformed for published ContextEventType.

publish

protected final boolean publish(XMLContextEvent event)
Publish given XMLContextEvent.

Parameters:
event - the XMLContextEvent to be published.
Returns:
true> if publishing was successful; false otherwise.


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