Class AbstractProxyManager<E extends NamedBean>
- Type Parameters:
E- the supported type of NamedBean
- All Implemented Interfaces:
PropertyChangeListener,EventListener,PropertyChangeFirer,PropertyChangeProvider,SilenceablePropertyChangeProvider,VetoableChangeFirer,VetoableChangeProvider,Manager<E>,Manager.ManagerDataListener<E>,ProxyManager<E>
- Direct Known Subclasses:
AbstractProvidingProxyManager,ProxyAnalogIOManager,ProxyMeterManager
Automatically includes an Internal system, which need not be separately added any more.
Encapsulates access to the "Primary" manager, used by default, which is the first one provided.
Internally, this is done by using an ordered list of all non-Internal managers, plus a separate reference to the internal manager and default manager.
-
Nested Class Summary
Nested classes/interfaces inherited from interface jmri.Manager
Manager.ManagerDataEvent<E extends NamedBean>, Manager.ManagerDataListener<E extends NamedBean>, Manager.NameValidity -
Field Summary
FieldsFields inherited from class jmri.beans.VetoableChangeSupport
vetoableChangeSupportFields inherited from class jmri.beans.PropertyChangeSupport
propertyChangeSupportFields inherited from interface jmri.Manager
ANALOGIOS, AUDIO, BLOCKBOSS, BLOCKS, CONDITIONALS, CTCDATA, ENTRYEXIT, IDTAGS, LAYOUTBLOCKS, LIGHTS, LOGIXNG_ANALOG_ACTIONS, LOGIXNG_ANALOG_EXPRESSIONS, LOGIXNG_CONDITIONALNGS, LOGIXNG_DIGITAL_ACTIONS, LOGIXNG_DIGITAL_BOOLEAN_ACTIONS, LOGIXNG_DIGITAL_EXPRESSIONS, LOGIXNG_GLOBAL_VARIABLES, LOGIXNG_MODULES, LOGIXNG_STRING_ACTIONS, LOGIXNG_STRING_EXPRESSIONS, LOGIXNG_TABLES, LOGIXNGS, LOGIXS, MEMORIES, METERFRAMES, METERS, OBLOCKS, PANELFILES, PROPERTY_BEANS, PROPERTY_CAN_DELETE, PROPERTY_DISPLAY_LIST_NAME, PROPERTY_DO_DELETE, PROPERTY_DO_NOT_DELETE, PROPERTY_LENGTH, REPORTERS, ROUTES, SECTIONS, SENSORGROUPS, SENSORS, SIGNALGROUPS, SIGNALHEADS, SIGNALMASTLOGICS, SIGNALMASTS, STRINGIOS, TIMEBASE, TRANSITS, TURNOUTS, WARRANTS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidRegister aManager.ManagerDataListenerto hear about adding or removing items from the list of NamedBeans.voidaddManager(Manager<E> m) Add a Manager to the collection of Managers.voidAdd aPropertyChangeListenerto the listener list.voidaddPropertyChangeListener(String propertyName, PropertyChangeListener listener) Add aPropertyChangeListenerfor a specific property.voidAdd aVetoableChangeListenerto the listener list.voidaddVetoableChangeListener(String propertyName, VetoableChangeListener listener) Add aVetoableChangeListenerfor a specific property.voidSent when the contents of the list has changed in a way that's too complex to characterize with the previous methods.Try to create a system manager.createSystemName(String curAddress, String prefix) (package private) StringcreateSystemName(String curAddress, String prefix, Class<?> beanType) Shared method to create a systemName based on the address base, the prefix and manager class.voiddeleteBean(E s, String property) Method for a UI to delete a bean.voidderegister(E s) Forget a NamedBean Object created outside the manager.voiddispose()Free resources when no longer used.getBySystemName(String systemName) Locate an existing instance based on a system name.getByUserName(String userName) Locate an existing instance based on a user name.Get the default manager or the internal manager if no default manager has been set.Get a list of all managers, with the default as the first item and internal default as the last item.Get the Default Manager ToolTip.Return the descriptors for the system-specific properties of the NamedBeans that are kept in this manager.getManager(String systemName) Get the manager for the given system name.Returns a list of all managers, including the internal manager.getManagerOrDefault(String systemName) Get the manager for the given system name or the default manager if there is no matching manager.getMemo()Get the system connection for this manager.getNamedBean(String name) Locate an existing instance based on a name.Provide an unmodifiable SortedSet of NamedBeans in system-name order.getNextValidSystemName(NamedBean currentBean) intGet the count of managed objects.Provide access to the system prefix string.voidSent after the indices in the index0,index1 interval have been inserted in the data model.voidSent after the indices in the index0,index1 interval have been removed from the data model.Create specific internal manager as needed for concrete type.Create a SystemName by prepending the system name prefix to the name if not already present.voidprotected voidvoidRemember a NamedBean Object created outside the manager.voidUnregister a previously-addedManager.ManagerDataListener.voidRemove the specified listener from this object.voidremovePropertyChangeListener(String propertyName, PropertyChangeListener listener) Remove the specified listener of the specified property from this object.voidRemove the specified listener from this object.voidremoveVetoableChangeListener(String propertyName, VetoableChangeListener listener) Remove the specified listener of the specified property from this object.voidsetDataListenerMute(boolean m) Temporarily suppress DataListener notifications.voidsetPropertyChangesSilenced(String propertyName, boolean silenced) Suppress sendingPropertyChangeEvents for the named property.charvalidateSystemNameFormat(String systemName, Locale locale) Validate the format of name, returning it unchanged if valid.validSystemNameFormat(String systemName) Validate system name format.Methods inherited from class jmri.beans.VetoableChangeSupport
fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, getVetoableChangeListeners, getVetoableChangeListenersMethods inherited from class jmri.beans.PropertyChangeSupport
fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getPropertyChangeListeners, getPropertyChangeListenersMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface jmri.Manager
getBeanTypeHandled, getBeanTypeHandled, getNamedBeanClass, getSubSystemNamePrefix, getSystemNamePrefix, getXMLOrder, isValidSystemNameFormat, makeSystemName, makeSystemName, validateBadCharsInSystemNameFormat, validateIntegerSystemNameFormat, validateNmraAccessorySystemNameFormat, validateSystemNameFormat, validateSystemNameFormatOnlyNumeric, validateSystemNamePrefix, validateTrimmedMin1NumberSystemNameFormat, validateTrimmedSystemNameFormat, validateUppercaseTrimmedSystemNameFormatMethods inherited from interface jmri.beans.PropertyChangeProvider
getPropertyChangeListeners, getPropertyChangeListenersMethods inherited from interface jmri.beans.VetoableChangeProvider
getVetoableChangeListeners, getVetoableChangeListeners
-
Field Details
-
silencedProperties
-
silenceableProperties
-
defaultManager
-
listeners
-
-
Constructor Details
-
AbstractProxyManager
public AbstractProxyManager()
-
-
Method Details
-
getManagerList
Returns a list of all managers, including the internal manager. This is not a live list, but it is in alpha order (don't assume default is at front)- Specified by:
getManagerListin interfaceProxyManager<E extends NamedBean>- Returns:
- the list of managers
-
getDisplayOrderManagerList
Get a list of all managers, with the default as the first item and internal default as the last item.- Specified by:
getDisplayOrderManagerListin interfaceProxyManager<E extends NamedBean>- Returns:
- the list of managers
-
getInternalManager
-
getDefaultManager
Get the default manager or the internal manager if no default manager has been set.- Specified by:
getDefaultManagerin interfaceProxyManager<E extends NamedBean>- Returns:
- the default manager or the internal manager
-
addManager
Add a Manager to the collection of Managers.- Specified by:
addManagerin interfaceProxyManager<E extends NamedBean>- Parameters:
m- the Manager to add; if manager has already been added, it will not be added again
-
initInternal
-
makeInternalManager
Create specific internal manager as needed for concrete type.- Returns:
- an internal manager
-
getNamedBean
Locate an existing instance based on a name.- Specified by:
getNamedBeanin interfaceManager<E extends NamedBean>- Parameters:
name- User Name or System Name of the required NamedBean- Returns:
- requested NamedBean object or null if none exists
-
getBySystemName
Locate an existing instance based on a system name.- Specified by:
getBySystemNamein interfaceManager<E extends NamedBean>- Parameters:
systemName- System Name of the required NamedBean- Returns:
- requested NamedBean object or null if none exists
-
getByUserName
Locate an existing instance based on a user name.- Specified by:
getByUserNamein interfaceManager<E extends NamedBean>- Parameters:
userName- System Name of the required NamedBean- Returns:
- requested NamedBean object or null if none exists
-
validateSystemNameFormat
Validate the format of name, returning it unchanged if valid.Although further restrictions may be added by system-specific implementations, at a minimum, the implementation must consider a name that does not start with the System Name prefix for this manager to be invalid, and must consider a name that is the same as the System Name prefix to be invalid.
Overriding implementations may rely on
Manager.validSystemNameFormat(java.lang.String), however they must provide an actionable message in the thrown exception if that method does not returnManager.NameValidity.VALID. When overriding implementations of this method rely on validSystemNameFormat(), implementations of that method must not throw an exception, log an error, or otherwise disrupt the user.This implementation locates a specific Manager based on the system name and validates against that. If no matching Manager exists, the default Manager attempts to validate the system name.
- Specified by:
validateSystemNameFormatin interfaceManager<E extends NamedBean>- Parameters:
systemName- the system name to validatelocale- the locale for a localized exception; this is needed for the JMRI web server, which supports multiple locales- Returns:
- the unchanged value of the name parameter
-
validSystemNameFormat
Validate system name format. Locate a system specific Manager based on a system name.- Specified by:
validSystemNameFormatin interfaceManager<E extends NamedBean>- Parameters:
systemName- the system name- Returns:
- if a manager is found, return its determination of validity of system name format. Return INVALID if no manager exists.
-
dispose
Free resources when no longer used. Specifically, remove all references to and from this object, so it can be garbage-collected. -
getManager
Get the manager for the given system name.- Parameters:
systemName- the given name- Returns:
- the requested manager or null if there is no matching manager
-
getManagerOrDefault
Get the manager for the given system name or the default manager if there is no matching manager.- Parameters:
systemName- the given name- Returns:
- the requested manager or the default manager if there is no matching manager
-
createSystemName
Shared method to create a systemName based on the address base, the prefix and manager class.- Parameters:
curAddress- base address to useprefix- system prefix to usebeanType- Bean Type for manager (method is used for Turnout and Sensor Managers)- Returns:
- a valid system name for this connection
- Throws:
JmriException- if systemName cannot be created
-
createSystemName
@Nonnull public String createSystemName(@Nonnull String curAddress, @Nonnull String prefix) throws JmriException - Throws:
JmriException
-
getNextValidSystemName
- Throws:
JmriException
-
deleteBean
Method for a UI to delete a bean.The UI should first request a "CanDelete", this will return a list of locations (and descriptions) where the bean is in use via throwing a VetoException, then if that comes back clear, or the user agrees with the actions, then a "DoDelete" can be called which inform the listeners to delete the bean, then it will be deregistered and disposed of.
If a property name of "DoNotDelete" is thrown back in the VetoException then the delete process should be aborted.
- Specified by:
deleteBeanin interfaceManager<E extends NamedBean>- Parameters:
s- The NamedBean to be deletedproperty- The programmatic name of the request. "CanDelete" will enquire with all listeners if the item can be deleted. "DoDelete" tells the listener to delete the item- Throws:
PropertyVetoException- If the recipients wishes the delete to be aborted (see above)
-
createSystemManager
Try to create a system manager. If this proxy manager is able to create a system manager, the concrete class must implement this method.- Parameters:
memo- the system connection memo for this connection- Returns:
- the new manager or null if it's not possible to create the manager
-
getEntryToolTip
Get the Default Manager ToolTip. Get a manager-specific tool tip for adding an entry to the manager.- Specified by:
getEntryToolTipin interfaceManager<E extends NamedBean>- Returns:
- the tool tip or null to disable the tool tip
-
register
Remember a NamedBean Object created outside the manager.The non-system-specific SignalHeadManagers use this method extensively.
Forwards the register request to the matching system.
-
deregister
Forget a NamedBean Object created outside the manager.The non-system-specific RouteManager uses this method.
Forwards the deregister request to the matching system.
- Specified by:
deregisterin interfaceManager<E extends NamedBean>- Parameters:
s- the name
-
getKnownBeanProperties
Return the descriptors for the system-specific properties of the NamedBeans that are kept in this manager. List does not contain duplicates.- Specified by:
getKnownBeanPropertiesin interfaceManager<E extends NamedBean>- Returns:
- list of known properties, or empty list if there are none
-
addPropertyChangeListener
Add aPropertyChangeListenerto the listener list.- Specified by:
addPropertyChangeListenerin interfacePropertyChangeProvider- Overrides:
addPropertyChangeListenerin classPropertyChangeSupport- Parameters:
l- The PropertyChangeListener to be added
-
removePropertyChangeListener
@OverridingMethodsMustInvokeSuper public void removePropertyChangeListener(PropertyChangeListener l) Remove the specified listener from this object.- Specified by:
removePropertyChangeListenerin interfacePropertyChangeProvider- Overrides:
removePropertyChangeListenerin classPropertyChangeSupport- Parameters:
l- ThePropertyChangeListenerto remove.
-
addPropertyChangeListener
@OverridingMethodsMustInvokeSuper public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) Add aPropertyChangeListenerfor a specific property.- Specified by:
addPropertyChangeListenerin interfacePropertyChangeProvider- Overrides:
addPropertyChangeListenerin classPropertyChangeSupport- Parameters:
propertyName- The name of the property to listen on.listener- The PropertyChangeListener to be added
-
removePropertyChangeListener
@OverridingMethodsMustInvokeSuper public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) Remove the specified listener of the specified property from this object.- Specified by:
removePropertyChangeListenerin interfacePropertyChangeProvider- Overrides:
removePropertyChangeListenerin classPropertyChangeSupport- Parameters:
propertyName- The name of the property to stop listening to.listener- ThePropertyChangeListenerto remove.
-
addVetoableChangeListener
Add aVetoableChangeListenerto the listener list.- Specified by:
addVetoableChangeListenerin interfaceVetoableChangeProvider- Overrides:
addVetoableChangeListenerin classVetoableChangeSupport- Parameters:
l- The VetoableChangeListener to be added
-
removeVetoableChangeListener
@OverridingMethodsMustInvokeSuper public void removeVetoableChangeListener(VetoableChangeListener l) Remove the specified listener from this object.- Specified by:
removeVetoableChangeListenerin interfaceVetoableChangeProvider- Overrides:
removeVetoableChangeListenerin classVetoableChangeSupport- Parameters:
l- TheVetoableChangeListenerto remove.
-
addVetoableChangeListener
@OverridingMethodsMustInvokeSuper public void addVetoableChangeListener(String propertyName, VetoableChangeListener listener) Add aVetoableChangeListenerfor a specific property.- Specified by:
addVetoableChangeListenerin interfaceVetoableChangeProvider- Overrides:
addVetoableChangeListenerin classVetoableChangeSupport- Parameters:
propertyName- The name of the property to listen on.listener- The VetoableChangeListener to be added
-
removeVetoableChangeListener
@OverridingMethodsMustInvokeSuper public void removeVetoableChangeListener(String propertyName, VetoableChangeListener listener) Remove the specified listener of the specified property from this object.- Specified by:
removeVetoableChangeListenerin interfaceVetoableChangeProvider- Overrides:
removeVetoableChangeListenerin classVetoableChangeSupport- Parameters:
propertyName- The name of the property to stop listening to.listener- TheVetoableChangeListenerto remove.
-
propertyChange
- Specified by:
propertyChangein interfacePropertyChangeListener
-
getMemo
Get the system connection for this manager.- Specified by:
getMemoin interfaceManager<E extends NamedBean>- Returns:
- The system connection memo for the manager returned by
getDefaultManager(), or the Internal system connection memo if there is no default manager
-
getSystemPrefix
Description copied from interface:ManagerProvide access to the system prefix string. This was previously called the "System letter"- Specified by:
getSystemPrefixin interfaceManager<E extends NamedBean>- Returns:
- The system-specific prefix letter for the primary implementation
-
typeLetter
- Specified by:
typeLetterin interfaceManager<E extends NamedBean>- Returns:
- The type letter for for the primary implementation
-
makeSystemName
Create a SystemName by prepending the system name prefix to the name if not already present.Note: implementations must call
Manager.validateSystemNameFormat(java.lang.String, java.util.Locale)to ensure the returned name is valid.- Specified by:
makeSystemNamein interfaceManager<E extends NamedBean>- Parameters:
s- the item to make the system name for- Returns:
- A system name from a user input, typically a number.
-
getObjectCount
Get the count of managed objects.- Specified by:
getObjectCountin interfaceManager<E extends NamedBean>- Returns:
- the number of managed objects
-
recomputeNamedBeanSet
-
getNamedBeanSet
Provide an unmodifiable SortedSet of NamedBeans in system-name order.Note: This is the fastest of the accessors, and is the only long-term form.
Note: This is a live set; the contents are kept up to date
- Specified by:
getNamedBeanSetin interfaceManager<E extends NamedBean>- Returns:
- Unmodifiable access to a SortedSet of NamedBeans
-
setPropertyChangesSilenced
@OverridingMethodsMustInvokeSuper public void setPropertyChangesSilenced(String propertyName, boolean silenced) Suppress sendingPropertyChangeEvents for the named property.Stopping the suppression of sending change events may send a PropertyChangeEvent if the property changed while silenced, but otherwise should not fire a PropertyChangeEvent.
- Specified by:
setPropertyChangesSilencedin interfaceSilenceablePropertyChangeProvider- Parameters:
propertyName- the name of the property to mutesilenced- true if events are to be suppressed; false otherwise
-
addDataListener
Register aManager.ManagerDataListenerto hear about adding or removing items from the list of NamedBeans.- Specified by:
addDataListenerin interfaceManager<E extends NamedBean>- Parameters:
e- the data listener to add
-
removeDataListener
Unregister a previously-addedManager.ManagerDataListener.- Specified by:
removeDataListenerin interfaceManager<E extends NamedBean>- Parameters:
e- the data listener to remove- See Also:
-
contentsChanged
Sent when the contents of the list has changed in a way that's too complex to characterize with the previous methods. From Manager.ManagerDataListener, receives notifications from underlying managers.- Specified by:
contentsChangedin interfaceManager.ManagerDataListener<E extends NamedBean>- Parameters:
e- encapsulates event information
-
intervalAdded
Sent after the indices in the index0,index1 interval have been inserted in the data model. From Manager.ManagerDataListener, receives notifications from underlying managers.- Specified by:
intervalAddedin interfaceManager.ManagerDataListener<E extends NamedBean>- Parameters:
e- encapsulates the event information
-
intervalRemoved
Sent after the indices in the index0,index1 interval have been removed from the data model. From Manager.ManagerDataListener, receives notifications from underlying managers.- Specified by:
intervalRemovedin interfaceManager.ManagerDataListener<E extends NamedBean>- Parameters:
e- encapsulates the event information
-
setDataListenerMute
Temporarily suppress DataListener notifications.This avoids O(N^2) behavior when doing bulk updates, i.e. when loading lots of Beans. Note that this is (1) optional, in the sense that the manager is not required to mute and (2) if present, its' temporary, in the sense that the manager must do a cumulative notification when done.
- Specified by:
setDataListenerMutein interfaceManager<E extends NamedBean>- Parameters:
m- true if notifications should be suppressed; false otherwise
-