Re: What should ProvidingManager.provide() return if not supported?


Randall Wood <rhwood@...>
 

The requirement (and this is an *absolute* requirement) for NamedBeans is that the user name is optional, and the system name is the only name that’s needed.

User Names are set by the user, and only by the user, not by system connections (unless the message in the system contains both something that can be a system name and something that can be a user name).

This is because devices on a connection (like LocoNet) can *only* be addressed by data encoded in the system name.

If you can’t work with that constraint then you don’t have a usable design (especially for a device on the LocoNet).

Put another way, you can’t create a discovered LocoNet device with a user name, because the LocoNet did not provide a user name to use, just an address that is encoded into the system name.

ProvidingManagers are designed to work with system connected devices to allow a flow like LocoNet traffic handler on connection “L”, sees message from thing at address 42->reads message, determines thing is Turnout->requests bean for turnout at address 42 (I.e. requests bean LT42) be provided->ProvidingManager returns that bean, creating it if needed.

If you *really* need to add LocoNet devices that can’t be provided implement ProxyManager instead of extending AbstractProxyManager.

But I would first reconsider your requirement that user names be assigned, since that’s not possible on the LocoNet itself.

Randall

On Jan 5, 2020, at 08:56, danielb987 <db123@...> wrote:

I'm implementing managers for AnalogIO and StringIO. I'm going to add a generic ProxyManager and a specific LocoNet manager for these.

AbstractProxyManager implements ProvidingManager, so I must add the method provide() in the ProxyManager. But I cannot create an AnalogIO or a StringIO from only a system name, so this method should always fail, at least for the LocoNet manager. What is the proper way to handle this? Throw an IllegalArgumentException("not supported") or throw an UnsupportedOperationException("not supported") ?

Daniel


Join jmri@jmri-developers.groups.io to automatically receive all group messages.