org.escot
Class ReplicatingFeatureRegistry

java.lang.Object
  |
  +--org.escot.FeatureRegistry
        |
        +--org.escot.ReplicatingFeatureRegistry
All Implemented Interfaces:
BeanWiringListener

public class ReplicatingFeatureRegistry
extends FeatureRegistry
implements BeanWiringListener

This is a utility class that may be used by beans which are ExplicitFeatureProviders that need to duplicate features when they are wired and remove them when they are unwired. You can use an instance of this class as a member field of your bean and delegate wiring listening to it. The bean should implement BeanWiringListener.


Field Summary
protected  com.sun.java.util.collections.HashSet mReplicators
           
 
Constructor Summary
ReplicatingFeatureRegistry(ExplicitFeatureProvider bean)
           
 
Method Summary
 void addReplicatingFeature(Object feature)
          Adds a class of instances that should be duplicated when wired and removed when unwired.
 String determineUniqueName(String desiredName)
          Cycles through the registered features to determine if the given name is unique.
 void removeFeature(Object feat)
          Removes a feature from the list of replicating features as well as from the non-replicating list.
protected  void renameFeature(EscotFeature targetFeature, EscotFeature associatedFeature)
          Expands the feature set when a feature belonging to the bean that is an instance of one of the classes designated for expansion, has been wired.
 void wireAdded(BeanWiringEvent evt)
          Invoked when a wire has been added involving the bean.
 void wireRemoved(BeanWiringEvent evt)
          Invoked when a wire has been removed involving the bean.
 
Methods inherited from class org.escot.FeatureRegistry
addFeature, addFeatureListener, featureCount, features, notifyFeatureAdded, notifyFeatureRemoved, removeAllFeatures, removeFeatureListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mReplicators

protected com.sun.java.util.collections.HashSet mReplicators
Constructor Detail

ReplicatingFeatureRegistry

public ReplicatingFeatureRegistry(ExplicitFeatureProvider bean)
Method Detail

addReplicatingFeature

public void addReplicatingFeature(Object feature)
Adds a class of instances that should be duplicated when wired and removed when unwired.

removeFeature

public void removeFeature(Object feat)
Removes a feature from the list of replicating features as well as from the non-replicating list.
Overrides:
removeFeature in class FeatureRegistry

wireAdded

public void wireAdded(BeanWiringEvent evt)
Invoked when a wire has been added involving the bean. Calls expandFeatureSet to expand the number of features.
Specified by:
wireAdded in interface BeanWiringListener

wireRemoved

public void wireRemoved(BeanWiringEvent evt)
Invoked when a wire has been removed involving the bean. If the bean is the subscriber in the wire and the subscriber feature is an expandable feature class, the feature is removed from the registry using unregisterFeature.
Specified by:
wireRemoved in interface BeanWiringListener

renameFeature

protected void renameFeature(EscotFeature targetFeature,
                             EscotFeature associatedFeature)
Expands the feature set when a feature belonging to the bean that is an instance of one of the classes designated for expansion, has been wired. Renames the feature, getting the new name by calling generateWiredFeatureName, creates a duplicate feature by calling newFeature, and adds it to the registry by calling registerFeature.

determineUniqueName

public String determineUniqueName(String desiredName)
Cycles through the registered features to determine if the given name is unique. If it is, it returns it, otherwise it appends a number to the name to make it unique (ie number, number1, number2, etc)