at.ac.tuwien.infosys.sm4all.copal.api.util
Class Register<K,U,V extends U>

java.lang.Object
  extended by at.ac.tuwien.infosys.sm4all.copal.api.util.Register<K,U,V>
Type Parameters:
K - the type of keys maintained by the Registry.
U - the type of values maintained by the Registry.
V - the type of registered values.
Direct Known Subclasses:
ProcessorsActivator, PublishersActivator

public abstract class Register<K,U,V extends U>
extends java.lang.Object

The abstract class which can be used as base class for any class that needs to register and unregister values with a Registry.

Author:
sanjin

Constructor Summary
Register()
           
 
Method Summary
protected abstract  K getKey(V value)
          Returns the key for specified value.
protected  Registry<K,U> getRegistry()
          Returns the Registry.
 void register(V value)
          Register specified value when Registry becomes available (or immediately if it is already available).
protected  void setRegistry(Registry<K,U> registry)
          Sets the new Registry, unregisters all values from previously set Registry if it was not null and registers all values with specified Registry if it is not null.
 void unregister(V value)
          Do not register specified value when Registry becomes available (and unregister it immediately if it is already available).
protected abstract  void update(RegistryObservable.RegistrationState state, V value)
          Called when specified value changes its RegistryObservable.RegistrationState.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Register

public Register()
Method Detail

update

protected abstract void update(RegistryObservable.RegistrationState state,
                               V value)
Called when specified value changes its RegistryObservable.RegistrationState.

Parameters:
state - the RegistryObservable.RegistrationState
value - the value.

getKey

protected abstract K getKey(V value)
Returns the key for specified value.

Parameters:
value - the value.
Returns:
the key.

register

public void register(V value)
              throws ContextException
Register specified value when Registry becomes available (or immediately if it is already available).

Parameters:
value - the value to register.
Throws:
ContextException - if registration fails.

unregister

public void unregister(V value)
                throws ContextException
Do not register specified value when Registry becomes available (and unregister it immediately if it is already available).

Parameters:
value - the value to unregister.
Throws:
ContextException - if unregistration fails.

getRegistry

protected Registry<K,U> getRegistry()
Returns the Registry.

Returns:
the Registry

setRegistry

protected void setRegistry(Registry<K,U> registry)
Sets the new Registry, unregisters all values from previously set Registry if it was not null and registers all values with specified Registry if it is not null.

Parameters:
registry - the new Registry.


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