Class AbstractProvidingProxyManager<E extends NamedBean>
- java.lang.Object
-
- jmri.beans.PropertyChangeSupport
-
- jmri.beans.VetoableChangeSupport
-
- jmri.managers.AbstractProxyManager<E>
-
- jmri.managers.AbstractProvidingProxyManager<E>
-
- Type Parameters:
E
- the supported type of NamedBean
- All Implemented Interfaces:
java.beans.PropertyChangeListener
,java.util.EventListener
,PropertyChangeFirer
,PropertyChangeProvider
,SilenceablePropertyChangeProvider
,VetoableChangeFirer
,VetoableChangeProvider
,Manager<E>
,Manager.ManagerDataListener<E>
,ProvidingManager<E>
,ProxyManager<E>
- Direct Known Subclasses:
ProxyIdTagManager
,ProxyLightManager
,ProxyReporterManager
,ProxySensorManager
,ProxyTurnoutManager
public abstract class AbstractProvidingProxyManager<E extends NamedBean> extends AbstractProxyManager<E> implements ProvidingManager<E>
Implementation of a Manager that can serves as a proxy for multiple system-specific implementations.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
-
Fields inherited from class jmri.managers.AbstractProxyManager
defaultManager, listeners, silenceableProperties, silencedProperties
-
Fields inherited from class jmri.beans.VetoableChangeSupport
vetoableChangeSupport
-
Fields inherited from class jmri.beans.PropertyChangeSupport
propertyChangeSupport
-
Fields 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, REPORTERS, ROUTES, SECTIONS, SENSORGROUPS, SENSORS, SIGNALGROUPS, SIGNALHEADS, SIGNALMASTLOGICS, SIGNALMASTS, STRINGIOS, TIMEBASE, TRANSITS, TURNOUTS, WARRANTS
-
-
Constructor Summary
Constructors Constructor Description AbstractProvidingProxyManager()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract E
makeBean(Manager<E> manager, java.lang.String systemName, java.lang.String userName)
Defer creation of the proper type to the subclass.E
newNamedBean(java.lang.String systemName, java.lang.String userName)
Return an instance with the specified user or system name.protected E
provideNamedBean(java.lang.String name)
Locate via user name, then system name if needed.-
Methods inherited from class jmri.managers.AbstractProxyManager
addDataListener, addManager, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, addVetoableChangeListener, contentsChanged, createSystemManager, createSystemName, createSystemName, deleteBean, deregister, dispose, getBySystemName, getByUserName, getDefaultManager, getDisplayOrderManagerList, getEntryToolTip, getInternalManager, getKnownBeanProperties, getManager, getManagerList, getManagerOrDefault, getMemo, getNamedBean, getNamedBeanSet, getNextValidSystemName, getObjectCount, getSystemPrefix, initInternal, intervalAdded, intervalRemoved, makeInternalManager, makeSystemName, propertyChange, recomputeNamedBeanSet, register, removeDataListener, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, removeVetoableChangeListener, setDataListenerMute, setPropertyChangesSilenced, typeLetter, validateSystemNameFormat, validSystemNameFormat
-
Methods inherited from class jmri.beans.VetoableChangeSupport
fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, getVetoableChangeListeners, getVetoableChangeListeners
-
Methods inherited from class jmri.beans.PropertyChangeSupport
fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getPropertyChangeListeners, getPropertyChangeListeners
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jmri.Manager
addDataListener, deleteBean, deregister, dispose, getBeanTypeHandled, getBeanTypeHandled, getBySystemName, getByUserName, getEntryToolTip, getKnownBeanProperties, getMemo, getNamedBean, getNamedBeanClass, getNamedBeanSet, getObjectCount, getSubSystemNamePrefix, getSystemNamePrefix, getSystemPrefix, getXMLOrder, isValidSystemNameFormat, makeSystemName, makeSystemName, makeSystemName, register, removeDataListener, setDataListenerMute, typeLetter, validateBadCharsInSystemNameFormat, validateIntegerSystemNameFormat, validateNmraAccessorySystemNameFormat, validateSystemNameFormat, validateSystemNameFormat, validateSystemNameFormatOnlyNumeric, validateSystemNamePrefix, validateTrimmedMin1NumberSystemNameFormat, validateTrimmedSystemNameFormat, validateUppercaseTrimmedSystemNameFormat, validSystemNameFormat
-
Methods inherited from interface jmri.beans.PropertyChangeProvider
addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
-
Methods inherited from interface jmri.ProvidingManager
provide
-
Methods inherited from interface jmri.beans.SilenceablePropertyChangeProvider
setPropertyChangesSilenced
-
Methods inherited from interface jmri.beans.VetoableChangeProvider
addVetoableChangeListener, addVetoableChangeListener, getVetoableChangeListeners, getVetoableChangeListeners, removeVetoableChangeListener, removeVetoableChangeListener
-
-
-
-
Constructor Detail
-
AbstractProvidingProxyManager
public AbstractProvidingProxyManager()
-
-
Method Detail
-
provideNamedBean
@Nonnull protected E provideNamedBean(java.lang.String name) throws java.lang.IllegalArgumentException
Locate via user name, then system name if needed. If that fails, create a new NamedBean: If the name is a valid system name, it will be used for the new NamedBean. Otherwise, the makeSystemName method will attempt to turn it into a valid system name. Subclasses use this to create provider methods such as getSensor or getTurnout via casts.- Parameters:
name
- the user name or system name of the bean- Returns:
- an existing or new NamedBean
- Throws:
java.lang.IllegalArgumentException
- if name is not usable in a bean
-
newNamedBean
@Nonnull public E newNamedBean(@Nonnull java.lang.String systemName, java.lang.String userName) throws java.lang.IllegalArgumentException
Return an instance with the specified user or system name.Lookup by UserName, then provide by System Name.
Note that two calls with the same arguments will get the same instance; there is i.e. only one Sensor object representing a given physical sensor and therefore only one with a specific system or user name.
This will always return a valid object reference for a valid request; a new object will be created if necessary. In that case:
- If a null reference is given for user name, no user name will be associated with the NamedBean object created; a valid system name must be provided
- If both names are provided, the system name defines the hardware access of the desired turnout, and the user address is associated with it.
- If a matching UserName is located, that will be returned.
- Else If a matching SystemName is located, that will be returned.
- Else A New Bean will be created with the given System Name. The UserName will be added to the New Bean if no existing.
If the System Name contains the start of a specified Manager, that will be used, else the default manager will be used.
- Parameters:
systemName
- the system nameuserName
- the user name- Returns:
- requested NamedBean object (never null)
- Throws:
java.lang.IllegalArgumentException
- See Also:
AbstractProxyManager.getManager(java.lang.String)
-
makeBean
@Nonnull protected abstract E makeBean(Manager<E> manager, @Nonnull java.lang.String systemName, java.lang.String userName) throws java.lang.IllegalArgumentException
Defer creation of the proper type to the subclass.- Parameters:
manager
- the manager to invokesystemName
- the system nameuserName
- the user name- Returns:
- a bean
- Throws:
java.lang.IllegalArgumentException
- if unable to make.
-
-