|
Version: 3.5.0 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface PropertyChannel
PropertyChannel is an interface describing a device that can be used to exchange data and events between components, and to store them in a shareable storage.
The basic rule is that all components that wish to communicate together (exchanging data or events) have to share an instance implementing this interface. There is no rule, however, limiting an application to use only one property channel: different kind of components can talk together using separate instance of a property channel.
The second rule is that all exchanging data are passed as
java.beans.PropertyChangeEvent - which allow to send any
data. Note, however, that in concrete situations the components
exchanging data need to agree on some subset of possible data
types. For example, the GCP data consumers consume data as
java.util.List with element types defined in the GCP
Domain model. Or, the GCP data transformers informs about their
transformations using events defined in the package org.generationcp.core.events.
The basic functions of a property channel is similar to functions
of a Hashtable (actually the DefaultPropertyChannel extends
java.util.Hashtable). The components are sending
properties to a channel by calling method put.
Additionally, whenever a value is added to a channel, or updated, the channel also fires an event to inform about it its listeners. In other words, this channel provides its stored properties in two ways:
fire(java.lang.String, java.lang.Object), and
Additionally, it also serves as a
java.beans.PropertyChangeSupport object: it can register
and deregister java.beans.PropertyChangeListeners, and it
can fire an event to them on behalf of other components. The other
components either identify themselves (see method fire(Object,String,Object)), or they use this channel for firing
anonymous messages (see method fire(String,Object)) - in
which case the message source will be the property channel
itself.
The events that were put here (those coming by the put(java.lang.Object, java.lang.Object)
method) are stored here under their names. That means that you can
always get the last stored event of a particular name. Concrete
property names are of no interest for the channel, but they are
definitely needed to be agreed on (using controlled vocabularies) -
see, for example, ontologies defined in DataConsumer.
| Method Summary | |
|---|---|
void |
addPropertyChangeListener(java.beans.PropertyChangeListener l)
Register a listener. |
boolean |
containsKey(java.lang.Object key)
Return true if this channel contains property with the given 'key'. |
void |
fire(java.lang.Object source,
java.lang.String key,
java.lang.Object value)
Fire an event to any registered listeners. |
void |
fire(java.lang.String key,
java.lang.Object value)
Fire an event to any registered listeners. |
java.lang.Object |
get(java.lang.Object key)
Returns a value stored in this channel under given 'key'. |
boolean |
getBoolean(java.lang.Object key,
boolean defaultValue)
A convenient method returning a boolean value of the given property. |
java.lang.String |
getString(java.lang.Object key)
A convenient method returning value of the given property as a string. |
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value)
Maps the specified key to the specified value in the channel. |
java.lang.Object |
put(java.lang.Object source,
java.lang.Object key,
java.lang.Object value)
Maps the specified key to the specified value in this channel. |
java.lang.Object |
remove(java.lang.Object key)
Remove a property given by 'key' from this channel. |
void |
removePropertyChangeListener(java.beans.PropertyChangeListener l)
Unregister a listener. |
| Method Detail |
|---|
java.lang.Object put(java.lang.Object key,
java.lang.Object value)
The given value, apart from being stored, is also propagated by
firing a property change event (this is called a channel
push style). The event is anonymous. If a component needs
to identify itself as the source of the message, it uses
instead put(Object,Object,Object).
key - is a property namevalue - is a property value
java.lang.Object put(java.lang.Object source,
java.lang.Object key,
java.lang.Object value)
The given value, apart from being stored, is also propagated by
firing a property change event (this is called a channel
push style). The event contains also its 'source'. For
event sent anonymously, use instead put(Object,Object).
source - is a component that is putting here this propertykey - is a property namekeyvalue - is a property value
java.lang.Object get(java.lang.Object key)
key - is a property name
boolean containsKey(java.lang.Object key)
key - is a property namejava.lang.Object remove(java.lang.Object key)
key - is a property name
java.lang.String getString(java.lang.Object key)
key - is a property name
boolean getBoolean(java.lang.Object key,
boolean defaultValue)
key - is a property namedefaultValue - to be returned in some cases
void fire(java.lang.String key,
java.lang.Object value)
Note that this event is just fired but not stored here. If you
need to store it, as well, use the put(Object,Object)
method.
key - is a name of the fired eventvalue - is a value associated with this event
void fire(java.lang.Object source,
java.lang.String key,
java.lang.Object value)
Note that this event is just fired but not stored here. If you
need to store it, as well, use the put(Object,Object,Object)
method.
source - that initiated the eventkey - is a name of the fired eventvalue - is a value associated with this eventvoid addPropertyChangeListener(java.beans.PropertyChangeListener l)
void removePropertyChangeListener(java.beans.PropertyChangeListener l)
|
Version: 3.5.0 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||