Class ConfigSerialNumberProvider

All Implemented Interfaces:
ConfigAware<ConfigSerialNumberProviderConfig>, ContextHandleAware, HandleAware, Ready, ReadyAndReadyListener, ReadyListener, SerialNumberProvider

public class ConfigSerialNumberProvider extends AbstractConfigurable<ConfigSerialNumberProviderConfig> implements SerialNumberProvider, ContextHandleAware
A SerialNumberProvider implementation that uses a config property to hold the serial number. This should not be used for production systems as swapping the board will result in loss of the serial number. Considering using CriticalDataSerialNumberProvider in conjunction with CriticalData for a more robust solution to storing a serial number that can be recovered in the event of a board swap.

This implementation is useful for testing and allows the serial number api to be used without anything other than creating this instance, registering it with the Device and adding it to the BeanContext.

Version:
2024-10-29
  • Constructor Details

    • ConfigSerialNumberProvider

      public ConfigSerialNumberProvider()
  • Method Details

    • getSerialNumber

      public String getSerialNumber() throws Exception
      Description copied from interface: SerialNumberProvider
      Return the serial number of the device.
      Specified by:
      getSerialNumber in interface SerialNumberProvider
      Throws:
      Exception
    • setSerialNumber

      public void setSerialNumber(String serialNumber) throws Exception
      Description copied from interface: SerialNumberProvider
      Set the serial number of the device.
      Specified by:
      setSerialNumber in interface SerialNumberProvider
      Parameters:
      serialNumber - the new device serial number
      Throws:
      Exception
    • getHandlePrefix

      public String getHandlePrefix()
      Description copied from interface: ContextHandleAware
      Returns the prefix for the object to be used when the handle is allocated by the context. The prefix typically reflects the type of the object, such that two objects with the same name but different types are uniquely identified. This value should be the name of the getter if this object was to be fetched from a parent object. For example, if class was Pump there may be two instances: water and carb. The prefix for the water pump may be "water" while the prefix for carb may be "carb", as this distinguishes them. In cases where there is a single getter, it's not uncommon for the prefix to be the type of the object or null. The default implementation returns null.
      Specified by:
      getHandlePrefix in interface ContextHandleAware