graphlab.platform.core
Class BlackBoard
java.lang.Object
graphlab.platform.core.BlackBoard
public class BlackBoard
- extends java.lang.Object
BlackBoard is just like a blackboard. Anyone can write on anywhere of it, Any one can read anywhere of it,
and anyone can look for changes in anewhere of it. It's the environment of anyone, just like the air.
Structurally BlackBoard is a listanable hashmap. So it makes a usefull environment in plugable applications.
here you don't have extension points. all you have is some data which stores in BlackBoard as a hash map,
and some events which occurs on changing of data. (normally most places in BlackBoard are event place holders)
BlackBoard is where plugins (and almost everything in the GraphLab ui) connect together. It is the only common thing between all plugins. So if you want to share some data between your plugins (or perhaps inside a plugin) you can safely use blackboard:
//here you save your data
blackboard.setData("mydata", data);
//here you load it
data = blackboard.getData("mydata");
Also every place in blackboard is listenable, this means that you can listen to change of any data in the blackboard. suppose you want to listen to the change of "mydata"
blackboard.addListener("mydata", new Listener() {
public void keyChanged(String key, Object value) {
System.out.println(String.valueOf(value));
}
});
so every time that some one set "mydata" on blackboard keyChanged will be called.
The difference between a NotifiableAttributeSet and a BlackBoard is that, NotifiableAttributeSet is designed
for a small set of attributes, so for example getAttributeListeners() will return all listeners of all attributes,
but BlackBoard is for a bigger set of attributes, and there you can give listeners for just one key at a time.
- Author:
- rouzbeh Ebrahimi some minor revisions, removing getEvent, ..., azin azadi
Method Summary |
void |
addListener(java.lang.String key,
Listener listener)
adds a listener to the Data , which when the data changed, will be notified |
boolean |
contains(java.lang.String key)
|
protected void |
fireListeners(java.lang.String key,
java.lang.Object newValue)
|
|
getData(java.lang.String key)
|
java.util.HashSet<Listener> |
getListeners(java.lang.String key)
|
void |
removeListener(java.lang.String key,
Listener listener)
see addAttributeListener |
void |
setData(java.lang.String key,
java.lang.Object value)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
BlackBoard
public BlackBoard()
getData
public <T> T getData(java.lang.String key)
- Parameters:
eventName
- value
- - See Also:
BlackBoard#setEvent(graphlab.platform.core.Event,Object)
setData
public void setData(java.lang.String key,
java.lang.Object value)
- Parameters:
key
- value
-
contains
public boolean contains(java.lang.String key)
addListener
public void addListener(java.lang.String key,
Listener listener)
- adds a listener to the Data , which when the data changed, will be notified
- Parameters:
key
- listener
-
removeListener
public void removeListener(java.lang.String key,
Listener listener)
- see addAttributeListener
- Parameters:
listener
-
getListeners
public java.util.HashSet<Listener> getListeners(java.lang.String key)
fireListeners
protected void fireListeners(java.lang.String key,
java.lang.Object newValue)
- Parameters:
key
-