org.universAAL.middleware.context
Class ContextSubscriber

Package class diagram package ContextSubscriber
java.lang.Object
  extended by org.universAAL.middleware.bus.member.BusMember
      extended by org.universAAL.middleware.bus.member.Subscriber
          extended by org.universAAL.middleware.context.ContextSubscriber
Direct Known Subclasses:
AdapterUserLocation, ContextEventRecorder, ContextHistorySubscriber, CSubscriber, CSubscriber2, CSubsMulti, DefaultContextSubscriber, DeviceContextListener, LightingConsumer, LightingConsumer, LightingConsumer, MobileHistorySubscriber, MyActivityHubContextListener, ReliabilityReasonerSubscriber, SituationMonitorImpl, Subscriber, Subscriber, Suscriber, UIPreferencesBufferSubscriptor, UtilSubscriber, WrapperC

public abstract class ContextSubscriber
extends Subscriber

Provides the interface to be implemented by context subscribers together with shared code. Only instances of this class can subscribe for context events. The convention of the context bus regarding the registration parameters is the following:

Author:
mtazari - Saied Tazari

Field Summary
 
Fields inherited from class org.universAAL.middleware.bus.member.BusMember
busResourceURI, owner, theBus
 
Constructor Summary
protected ContextSubscriber(ModuleContext connectingModule, ContextEventPattern[] initialSubscriptions)
          Creates a Context Subscriber and immediately registers a set of Context Event Patterns for it, so it receives the matching events.
 
Method Summary
protected  void addNewRegParams(ContextEventPattern[] newSubscriptions)
          Registers more ContextEventPattern for this Subscriber in addition to those that might have passed initially
 void busDyingOut(AbstractBus b)
          This method is called when the bus is stopped to announce this to the bus members.
abstract  void communicationChannelBroken()
          Method to be called when the communication of the Subsccriber with the Context Bus is lost.
 ContextEventPattern[] getAllProvisions()
          Returns all provisions registered by all ContextPublishers on all instances of context bus in the current AAL Space.
 String getMyID()
           
abstract  void handleContextEvent(ContextEvent event)
          Method to be called when an Event forwarded in the Context Bus matches one of the Patterns registered by this Subscriber.
 void handleEvent(BusMessage m)
           
protected  void removeMatchingRegParams(ContextEventPattern[] oldSubscriptions)
          Unregisters a set of ContextEventPattern that had been previously registered for this Subscriber.
 
Methods inherited from class org.universAAL.middleware.bus.member.BusMember
close, getType, getURI
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ContextSubscriber

protected ContextSubscriber(ModuleContext connectingModule,
                            ContextEventPattern[] initialSubscriptions)
Creates a Context Subscriber and immediately registers a set of Context Event Patterns for it, so it receives the matching events.

Parameters:
connectingModule - The module context of the module creating the Publisher
initialSubscriptions - Array of ContextEventPattern that are immediately registered for this Subscriber
Throws:
NullPointerException - if newSubscriptions is null or one of the elements of that array is null
Method Detail

addNewRegParams

protected final void addNewRegParams(ContextEventPattern[] newSubscriptions)
Registers more ContextEventPattern for this Subscriber in addition to those that might have passed initially

Parameters:
newSubscriptions - The additional array of ContextEventPattern
Throws:
NullPointerException - if newSubscriptions is null or one of the elements of that array is null

removeMatchingRegParams

protected final void removeMatchingRegParams(ContextEventPattern[] oldSubscriptions)
Unregisters a set of ContextEventPattern that had been previously registered for this Subscriber. The Subscriber will no longer receive Events matching these Patterns.

Parameters:
oldSubscriptions -

communicationChannelBroken

public abstract void communicationChannelBroken()
Method to be called when the communication of the Subsccriber with the Context Bus is lost.


busDyingOut

public final void busDyingOut(AbstractBus b)
Description copied from class: BusMember
This method is called when the bus is stopped to announce this to the bus members.

Specified by:
busDyingOut in class BusMember
Parameters:
b - bus on which this member has been registered
See Also:
AbstractBus

getAllProvisions

public ContextEventPattern[] getAllProvisions()
Returns all provisions registered by all ContextPublishers on all instances of context bus in the current AAL Space.


handleContextEvent

public abstract void handleContextEvent(ContextEvent event)
Method to be called when an Event forwarded in the Context Bus matches one of the Patterns registered by this Subscriber.

Parameters:
event - The Context Event that matched the registered Patterns
Throws:
NullPointerException - if the event is null

handleEvent

public final void handleEvent(BusMessage m)

getMyID

public String getMyID()


Copyright © 2014 universAAL Consortium. All Rights Reserved.