com.inline.feature.common
Class AbstractResourceListener

java.lang.Object
  |
  +--com.inline.feature.common.AbstractResourceListener
Direct Known Subclasses:
AbstractFeature, AbstractFeatureSet

public abstract class AbstractResourceListener
extends java.lang.Object
implements ResourceSetListener, java.beans.PropertyChangeListener

A common base class for AbstractFeature and AbstractFeatureSet. Its responsibility is to manage sets of listeners and dependencies and the state of being active/passive.

A subclass of AbstractResourceListener overrided the registerDepencies() method to register interest in resources and resource sets. Most implementations of the registerDependencies() method call the AbstractResourceListener's methods registerResourceAdapter() and registerResourceSetAdapter() methods. For example,

   protected void registerDependencies(){
       classDescriptorAdapter = 
           registerResourceAdapter(
               new ResourceReference(Constants.CLASS_DESCRIPTOR_RESOURCE_TYPE, "com.acme.MyClass"));

       sourceDocumentSetAdapter = 
           registerResourceSetAdapter(Constants.SOURCE_DOCUMENT_RESOURCE_TYPE, 
               new ResourceSuffixQualifier(".doc"));
   }
  


Field Summary
protected  boolean active
           
protected  FeatureModel featureModel
           
protected  Feature parent
           
protected  com.sun.java.util.collections.Set resourceAdapters
           
protected  com.sun.java.util.collections.Set resourceSetAdapters
           
protected  boolean revalidate
           
 
Constructor Summary
  AbstractResourceListener(Feature parent)
           
protected AbstractResourceListener(FeatureModel featureModel)
          Only use this for the root feature
 
Method Summary
protected  void activate()
          Registers this object as an observer on all registered resource adapters and resource set adapters, then it calls invalidate() on self to restart the resource parsing process.
 FeatureModel getFeatureModel()
           
 Feature getParent()
           
 void invalidate()
          Restarts the resource parsing process.
protected  void passivate()
          Unregisters this object as an observer from all registered resource adapters and resource set adapters.
 void propertyChange(java.beans.PropertyChangeEvent event)
          Event handler for resource adapter.
protected  void registerDependencies()
          Override to register all resource adapters this feature set depends upon.
protected  void registerResourceAdapter(ResourceAdapter adapter)
           
protected  ResourceAdapter registerResourceAdapter(com.inline.resources.ResourceReference reference)
          Acquires the ResourceAdapter for the specified reference from the FeatureModel and calls registerResourceAdapter(adapter)
protected  void registerResourceSetAdapter(ResourceSetAdapter adapter)
           
protected  ResourceSetAdapter registerResourceSetAdapter(java.lang.String type, com.inline.resources.ResourceQualifier qualifier)
          Acquires the ResourceSetAdapter for the specified type and qualifier from the FeatureModel and calls registerResourceSetAdapter(adapter)
 void release()
          If the object is active, passivates it.
 void resourceAdded(ResourceSetAdapter source, com.inline.resources.ResourceReference ref)
          Event handler for resource set adapters.
protected  void resourceChanged(ResourceAdapter adapter, java.lang.String property, java.lang.Object oldValue, java.lang.Object newValue)
          Event handler for resource adapters.
 void resourceRemoved(ResourceSetAdapter source, com.inline.resources.ResourceReference ref)
          Event handler for resource set adapters.
protected  void unregisterResourceAdapter(ResourceAdapter adapter)
           
protected  void unregisterResourceSetAdapter(ResourceSetAdapter adapter)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parent

protected Feature parent

featureModel

protected FeatureModel featureModel

active

protected boolean active

revalidate

protected boolean revalidate

resourceSetAdapters

protected com.sun.java.util.collections.Set resourceSetAdapters

resourceAdapters

protected com.sun.java.util.collections.Set resourceAdapters
Constructor Detail

AbstractResourceListener

public AbstractResourceListener(Feature parent)

AbstractResourceListener

protected AbstractResourceListener(FeatureModel featureModel)
Only use this for the root feature
Method Detail

getFeatureModel

public FeatureModel getFeatureModel()

getParent

public Feature getParent()

registerDependencies

protected void registerDependencies()
Override to register all resource adapters this feature set depends upon. Call registerResourceAdapter(reference) for each resource adapter and registerResourceSetAdapter(type, qualifier) for each resource set adapter. AbstractResourceListener will make the feature an observer of events from those adapters as needed.

registerResourceSetAdapter

protected ResourceSetAdapter registerResourceSetAdapter(java.lang.String type,
                                                        com.inline.resources.ResourceQualifier qualifier)
Acquires the ResourceSetAdapter for the specified type and qualifier from the FeatureModel and calls registerResourceSetAdapter(adapter)

registerResourceAdapter

protected ResourceAdapter registerResourceAdapter(com.inline.resources.ResourceReference reference)
Acquires the ResourceAdapter for the specified reference from the FeatureModel and calls registerResourceAdapter(adapter)

registerResourceSetAdapter

protected void registerResourceSetAdapter(ResourceSetAdapter adapter)

registerResourceAdapter

protected void registerResourceAdapter(ResourceAdapter adapter)

unregisterResourceSetAdapter

protected void unregisterResourceSetAdapter(ResourceSetAdapter adapter)

unregisterResourceAdapter

protected void unregisterResourceAdapter(ResourceAdapter adapter)

activate

protected void activate()
Registers this object as an observer on all registered resource adapters and resource set adapters, then it calls invalidate() on self to restart the resource parsing process.
See Also:
AbstractFeature.addPropertyChangeListener(PropertyChangeListener), AbstractFeatureSet.addFeatureSetListener(FeatureSetListener)

passivate

protected void passivate()
Unregisters this object as an observer from all registered resource adapters and resource set adapters.
See Also:
AbstractFeature.removePropertyChangeListener(PropertyChangeListener), AbstractFeatureSet.removeFeatureSetListener(FeatureSetListener)

invalidate

public void invalidate()
Restarts the resource parsing process.

release

public void release()
If the object is active, passivates it.

resourceAdded

public void resourceAdded(ResourceSetAdapter source,
                          com.inline.resources.ResourceReference ref)
Event handler for resource set adapters. Calls this.invalidate().
Specified by:
resourceAdded in interface ResourceSetListener

resourceRemoved

public void resourceRemoved(ResourceSetAdapter source,
                            com.inline.resources.ResourceReference ref)
Event handler for resource set adapters. Calls this.invalidate().
Specified by:
resourceRemoved in interface ResourceSetListener

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent event)
Event handler for resource adapter. Calls this.resourceChanged(...)
Specified by:
propertyChange in interface java.beans.PropertyChangeListener

resourceChanged

protected void resourceChanged(ResourceAdapter adapter,
                               java.lang.String property,
                               java.lang.Object oldValue,
                               java.lang.Object newValue)
Event handler for resource adapters. Calls this.invalidate().