org.escot
Class Broker

java.lang.Object
  |
  +--org.escot.Broker
Direct Known Subclasses:
DefaultBroker

public abstract class Broker
extends Object

A Broker manages a set of beans, the wires between them, and the set of features for each bean.


Field Summary
protected  com.sun.java.util.collections.List mBeanListeners
           
protected  com.sun.java.util.collections.List mBeanWiringListeners
           
protected  com.sun.java.util.collections.List mFeatureListeners
           
protected  com.sun.java.util.collections.List mWiringListeners
           
 
Constructor Summary
Broker()
           
 
Method Summary
abstract  void addBean(Object bean)
          Adds bean to the set of beans brokered by this Broker instance.
abstract  void addBean(Object bean, String id)
          Adds bean to the set of beans brokered by this Broker instance.
 void addBeanWiringListener(BeanWiringListener listener)
          Adds a listener to be notified of BeanWiringEvents.
 void addBrokerBeanListener(BrokerBeanListener listener)
          Adds a listener to be notified of BrokerBeanEvents.
 void addBrokerFeatureListener(FeatureListener listener)
          Adds a listener to be notified of FeatureEvents which are fired when a dynamic feature is added to or removed from a bean.
 void addBrokerWiringListener(WiringListener listener)
          Adds a listener to be notified of WiringEvents.
abstract  boolean addEventBinding(Object source, Object target, String eventName)
          Binds target as a listener to source for the specified event.
abstract  boolean canWire(Object publisher, String publisherPropName, Object subscriber, String subscriberPropName)
          Returns whether the features may be connected.
abstract  Wire findWire(Object publisher, String publisherPropName, Object subscriber, String subscriberPropName)
          Returns the wire between a published property and subscribing property, or null if it does not exist.
abstract  Object getBean(String id)
          Returns the bean corresponding to the specified id.
abstract  com.sun.java.util.collections.Collection getBeans()
          Returns a Collection of the beans brokered by this Broker instance.
abstract  com.sun.java.util.collections.Collection getExplicitFeatures(Object bean)
          Returns a Collection of dynamic EscotFeatures.
abstract  EscotFeature getFeatureByName(Object bean, String name)
          Returns a EscotFeature corresponding to the specified name.
abstract  FeatureDescriptor getFeatureDescriptor(Object bean, String name)
          Returns the FeatureDescriptor corresponding to the named feature for the specified bean.
abstract  com.sun.java.util.collections.Collection getFeatures(Object bean)
          Returns a Collection of EscotFeatures.
abstract  String getID(Object bean)
          Returns the id corresponding to the specified bean.
abstract  com.sun.java.util.collections.Vector getWires()
          Returns a Collection of Wires.
abstract  com.sun.java.util.collections.Collection getWires(Object bean, String featureName)
          Returns a Collection of Wires involving the specified bean.
abstract  boolean hasEventBinding(Object source, Object target, String eventName)
          Returns whether target is bound as a listener to source for the specified event.
 boolean isWired(Object publisher, String publisherPropName, Object subscriber, String subscriberPropName)
          Returns whether the features are connected.
protected  void notifyBeanAdded(Object bean)
           
protected  void notifyBeanRemoved(Object bean)
           
protected  void notifyWireAdded(Wire wire)
           
protected  void notifyWireRemoved(Wire wire)
           
abstract  void removeAllBeans()
          Removes all beans.
abstract  void removeBean(Object bean)
          Removes bean from the set of beans brokered by this Broker instance.
 void removeBean(String id)
          Removes bean from the set of beans brokered by this Broker instance.
 void removeBeanWiringListener(BeanWiringListener listener)
          Removes a listener which is notified of BeanWiringEvents.
 void removeBrokerBeanListener(BrokerBeanListener listener)
          Removes a listener which is notified of BrokerBeanEvents.
 void removeBrokerFeatureListener(FeatureListener listener)
          Removes a listener which is notified of FeatureEvents.
 void removeBrokerWiringListener(WiringListener listener)
          Removes a listener which is notified of WiringEvents.
abstract  void removeEventBinding(Object source, Object target, String eventName)
          Removes binding of target as a listener to source for the specified event.
abstract  void unwire(Object publisher, String publisherPropName, Object subscriber, String subscriberPropName)
          Disconnects a published property from a subscribing property.
abstract  void unwire(Wire wire)
          Disconnects the properties specified in the Wire.
abstract  void unwireAll()
          Disconnects everything.
 void unwireAll(Object bean)
          Disconnects features of specified bean from everything else.
 void unwireAll(Object bean, String featureName)
          Disconnects a feature of a bean from everything.
abstract  void wire(Object publisher, String publisherPropName, Object subscriber, String subscriberPropName)
          Connects a published property to a subscribing property.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mBeanListeners

protected com.sun.java.util.collections.List mBeanListeners

mWiringListeners

protected com.sun.java.util.collections.List mWiringListeners

mBeanWiringListeners

protected com.sun.java.util.collections.List mBeanWiringListeners

mFeatureListeners

protected com.sun.java.util.collections.List mFeatureListeners
Constructor Detail

Broker

public Broker()
Method Detail

addBrokerBeanListener

public void addBrokerBeanListener(BrokerBeanListener listener)
Adds a listener to be notified of BrokerBeanEvents.
Parameters:
listener - the listener to add.

removeBrokerBeanListener

public void removeBrokerBeanListener(BrokerBeanListener listener)
Removes a listener which is notified of BrokerBeanEvents.
Parameters:
listener - the listener to remove.

addBrokerWiringListener

public void addBrokerWiringListener(WiringListener listener)
Adds a listener to be notified of WiringEvents.
Parameters:
listener - the listener to add.

removeBrokerWiringListener

public void removeBrokerWiringListener(WiringListener listener)
Removes a listener which is notified of WiringEvents.
Parameters:
listener - the listener to remove.

addBeanWiringListener

public void addBeanWiringListener(BeanWiringListener listener)
Adds a listener to be notified of BeanWiringEvents.
Parameters:
listener - the listener to add.

removeBeanWiringListener

public void removeBeanWiringListener(BeanWiringListener listener)
Removes a listener which is notified of BeanWiringEvents.
Parameters:
listener - the listener to remove.

addBrokerFeatureListener

public void addBrokerFeatureListener(FeatureListener listener)
Adds a listener to be notified of FeatureEvents which are fired when a dynamic feature is added to or removed from a bean.
Parameters:
listener - the listener to add.

removeBrokerFeatureListener

public void removeBrokerFeatureListener(FeatureListener listener)
Removes a listener which is notified of FeatureEvents.
Parameters:
listener - the listener to remove.

getBean

public abstract Object getBean(String id)
Returns the bean corresponding to the specified id.
Returns:
the bean corresponding to the specified id

getID

public abstract String getID(Object bean)
Returns the id corresponding to the specified bean.
Returns:
the id corresponding to the specified bean

addBean

public abstract void addBean(Object bean)
Adds bean to the set of beans brokered by this Broker instance.
Parameters:
bean - the bean to add.

addBean

public abstract void addBean(Object bean,
                             String id)
Adds bean to the set of beans brokered by this Broker instance.
Parameters:
bean - the bean to add
id - an id to associate with the bean

notifyBeanAdded

protected void notifyBeanAdded(Object bean)

removeBean

public abstract void removeBean(Object bean)
Removes bean from the set of beans brokered by this Broker instance.
Parameters:
bean - the bean to remove

removeBean

public void removeBean(String id)
Removes bean from the set of beans brokered by this Broker instance.
Parameters:
id - id of the bean to remove

notifyBeanRemoved

protected void notifyBeanRemoved(Object bean)

removeAllBeans

public abstract void removeAllBeans()
Removes all beans.

getBeans

public abstract com.sun.java.util.collections.Collection getBeans()
Returns a Collection of the beans brokered by this Broker instance.

findWire

public abstract Wire findWire(Object publisher,
                              String publisherPropName,
                              Object subscriber,
                              String subscriberPropName)
Returns the wire between a published property and subscribing property, or null if it does not exist.
Returns:
a Wire

wire

public abstract void wire(Object publisher,
                          String publisherPropName,
                          Object subscriber,
                          String subscriberPropName)
                   throws WiringException
Connects a published property to a subscribing property. Does nothing if the wire already exists. Throws a BrokerException if the features cannot be wired.
Parameters:
publisher - a bean which publishes a property
publisherPropName - name of a property of the publisher
subscriber - a bean which subscribes to a property
subscriberPropName - name of a property of the subscriber

notifyWireAdded

protected void notifyWireAdded(Wire wire)

unwire

public abstract void unwire(Object publisher,
                            String publisherPropName,
                            Object subscriber,
                            String subscriberPropName)
Disconnects a published property from a subscribing property. Does nothing if there was no wire.
Parameters:
publisher - a bean which publishes a property
publisherPropName - name of a property of the publisher
subscriber - a bean which subscribes to a property
subscriberPropName - name of a property of the subscriber

unwire

public abstract void unwire(Wire wire)
Disconnects the properties specified in the Wire.

notifyWireRemoved

protected void notifyWireRemoved(Wire wire)

unwireAll

public void unwireAll(Object bean)
Disconnects features of specified bean from everything else.

unwireAll

public void unwireAll(Object bean,
                      String featureName)
Disconnects a feature of a bean from everything.

unwireAll

public abstract void unwireAll()
Disconnects everything.

canWire

public abstract boolean canWire(Object publisher,
                                String publisherPropName,
                                Object subscriber,
                                String subscriberPropName)
Returns whether the features may be connected.
Parameters:
publisher - a bean which publishes a property
publisherPropName - name of a property of the publisher
subscriber - a bean which subscribes to a property
subscriberPropName - name of a property of the subscriber

isWired

public boolean isWired(Object publisher,
                       String publisherPropName,
                       Object subscriber,
                       String subscriberPropName)
Returns whether the features are connected.
Parameters:
publisher - a bean which publishes a property
publisherPropName - name of a property of the publisher
subscriber - a bean which subscribes to a property
subscriberPropName - name of a property of the subscriber

getWires

public abstract com.sun.java.util.collections.Vector getWires()
Returns a Collection of Wires. !! Note: for now, we return a java.util.Vector, but we should return an immutable java.util.Collection. Unfortunately, this wouldn't compile under 1.1. A java.util.Collection is necessary instead of com.sun.java.util.collections.Collection, so the data can be saved by archiver.

getWires

public abstract com.sun.java.util.collections.Collection getWires(Object bean,
                                                                  String featureName)
Returns a Collection of Wires involving the specified bean.

getFeatureByName

public abstract EscotFeature getFeatureByName(Object bean,
                                              String name)
                                       throws IntrospectionException
Returns a EscotFeature corresponding to the specified name. The default implementation calls the Introspector on the bean.

getFeatureDescriptor

public abstract FeatureDescriptor getFeatureDescriptor(Object bean,
                                                       String name)
                                                throws IntrospectionException
Returns the FeatureDescriptor corresponding to the named feature for the specified bean.

getFeatures

public abstract com.sun.java.util.collections.Collection getFeatures(Object bean)
Returns a Collection of EscotFeatures.

getExplicitFeatures

public abstract com.sun.java.util.collections.Collection getExplicitFeatures(Object bean)
Returns a Collection of dynamic EscotFeatures.

addEventBinding

public abstract boolean addEventBinding(Object source,
                                        Object target,
                                        String eventName)
Binds target as a listener to source for the specified event. Returns whether event binding succeeded.

removeEventBinding

public abstract void removeEventBinding(Object source,
                                        Object target,
                                        String eventName)
Removes binding of target as a listener to source for the specified event.

hasEventBinding

public abstract boolean hasEventBinding(Object source,
                                        Object target,
                                        String eventName)
Returns whether target is bound as a listener to source for the specified event.