Class FeatureListenerManager
- Object
-
- FeatureListenerManager
-
public class FeatureListenerManager extends Object
This class is used by DataStore implementations to provide FeatureListener support for the FeatureSources they create.FeatureWriters created by the DataStore will need to make use of this class to provide the required FeatureEvents. This class has been updated to store listeners using weak references in order to cut down on memory leaks.
- Author:
- Jody Garnett, Refractions Research
-
-
Constructor Summary
Constructors Constructor Description FeatureListenerManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addFeatureListener(FeatureSource<? extends FeatureType,? extends Feature> featureSource, FeatureListener featureListener)
Used by FeaureSource implementations to provide listener support.void
cleanListenerList(FeatureSource<? extends FeatureType,? extends Feature> featureSource)
void
fireChanged(String typeName, Transaction transaction, boolean commit)
Notify all listeners that have registered interest for notification on this event type.void
fireEvent(String typeName, Transaction transaction, FeatureEvent event)
Provided event will be used as a template for notifying all FeatureSources for the provided typeName.void
fireFeaturesAdded(String typeName, Transaction transaction, ReferencedEnvelope bounds, boolean commit)
Notify all listeners that have registered interest for notification on this event type.void
fireFeaturesChanged(String typeName, Transaction transaction, ReferencedEnvelope bounds, boolean commit)
Notify all listeners that have registered interest for notification on this event type.void
fireFeaturesRemoved(String typeName, Transaction transaction, ReferencedEnvelope bounds, boolean commit)
Notify all listeners that have registered interest for notification on this event type.void
removeFeatureListener(FeatureSource<? extends FeatureType,? extends Feature> featureSource, FeatureListener featureListener)
Used by SimpleFeatureSource implementations to provide listener support.
-
-
-
Method Detail
-
addFeatureListener
public void addFeatureListener(FeatureSource<? extends FeatureType,? extends Feature> featureSource, FeatureListener featureListener)
Used by FeaureSource implementations to provide listener support.
-
removeFeatureListener
public void removeFeatureListener(FeatureSource<? extends FeatureType,? extends Feature> featureSource, FeatureListener featureListener)
Used by SimpleFeatureSource implementations to provide listener support.
-
cleanListenerList
public void cleanListenerList(FeatureSource<? extends FeatureType,? extends Feature> featureSource)
-
fireFeaturesAdded
public void fireFeaturesAdded(String typeName, Transaction transaction, ReferencedEnvelope bounds, boolean commit)
Notify all listeners that have registered interest for notification on this event type.This method is called by:
- FeatureWriter.next() with FeatureWriter.hasNext() == false
- when an existing Feature is removed with Tranasaction.AUTO_COMMIT all listeners registered with SimpleFeatureSource of typeName will be notified. - FeatureWriter.next()with FeatureWriter.hasNext() == false
- when an existing Feature is removed with a Transaction all listeners registered with SimpleFeatureSource of typeName and with the same Transaction will be notified.
NOTE requiring to fire this event at FeatureWriter.next() is quite a gap inherited from an old API when
FeatureWriter.write()
didn't exist yet. It's a good idea though to fire the event at FeatureWriter.write() instead of FeatureWriter.next() so there are actually changes to notify for.- Parameters:
typeName
- typeName being modifiedtransaction
- Transaction used for changebounds
- BoundingBox of changes (may benull
if unknown)commit
- true if
- FeatureWriter.next() with FeatureWriter.hasNext() == false
-
fireEvent
public void fireEvent(String typeName, Transaction transaction, FeatureEvent event)
Provided event will be used as a template for notifying all FeatureSources for the provided typeName.
-
fireFeaturesChanged
public void fireFeaturesChanged(String typeName, Transaction transaction, ReferencedEnvelope bounds, boolean commit)
Notify all listeners that have registered interest for notification on this event type.This method is called by:
- FeatureWriter.next() with FeatureWriter.hasNext() == true
- when an existing Feature is modified with Tranasaction.AUTO_COMMIT all listeners registered with SimpleFeatureSource of typeName will be notified. - FeatureWriter.next()with FeatureWriter.hasNext() == true
- when an existing Feature is modified, with a Transaction all listeners registered with SimpleFeatureSource of typeName and with the same Transaction will be notified.
NOTE requiring to fire this event at FeatureWriter.next() is quite a gap inherited from an old API when
FeatureWriter.write()
didn't exist yet. It's a good idea though to fire the event at FeatureWriter.write() instead of FeatureWriter.next() so there are actually changes to notify for.- Parameters:
typeName
- typeName being modifiedtransaction
- Transaction used for changebounds
- BoundingBox of changes (may benull
if unknown)
- FeatureWriter.next() with FeatureWriter.hasNext() == true
-
fireChanged
public void fireChanged(String typeName, Transaction transaction, boolean commit)
Notify all listeners that have registered interest for notification on this event type.This method is called by:
- Transaction.commit()
- when changes have occured on a Transaction all listeners registered with SimpleFeatureSource of typeName will be notified except those with the Same Transaction - Transaction.rollback()
- when changes have been reverted only those listeners registered with SimpleFeatureSource of typeName and with the same Transaction will be notified.
- Parameters:
typeName
- typeName being modifiedtransaction
- Transaction used for changecommit
-true
forcommit
,false
forrollback
- Transaction.commit()
-
fireFeaturesRemoved
public void fireFeaturesRemoved(String typeName, Transaction transaction, ReferencedEnvelope bounds, boolean commit)
Notify all listeners that have registered interest for notification on this event type.This method is called by:
- FeatureWrtier.remove() - when an existing Feature is removed with Tranasaction.AUTO_COMMIT all listeners registered with SimpleFeatureSource of typeName will be notified.
- FeatureWrtier.remove() - when an existing Feature is removed with a Transaction all listeners registered with SimpleFeatureSource of typeName and with the same Transaction will be notified.
- Parameters:
typeName
- typeName being modifiedtransaction
- Transaction used for changebounds
- BoundingBox of changes (may benull
if unknown)
-
-