Class UdevService

All Implemented Interfaces:
CtxEventListener, ContextHandleAware, HandleAware, Ready, ReadyListener

public final class UdevService extends AbstractService
Service that manages events from udev adapter.
Since:
1.0
Version:
2023-08-31
  • Method Details

    • onBeanReady

      public boolean onBeanReady()
      Description copied from class: ReadyBean
      Override in subclasses to be notified when all dependencies are ready. Return true to indicate that this bean is also ready. If the bean needs to call setReady() later due to some async processing, return false to prevent setReady() from being called automatically.

      It is recommended to override this method rather than onDependenciesReady() as a majority of the time it requires calling super.onDependneciesReady() or explicitly calling setReady() which defaults to a failure mode.

      Overrides:
      onBeanReady in class ReadyBean
      Returns:
    • addListener

      public void addListener(UdevDeviceListener listener)
      Add a device listener. This will cause all devices to be passed to the new listener, including both onDeviceAdd() and if not owned, onDeviceAvailable() .
    • removeListener

      public void removeListener(UdevDeviceListener listener)
      Remove a device listener.
    • claimDevice

      public void claimDevice(UdevDevice device, UdevDeviceOwner owner)
      Claim ownership of a device. If claimed during onDeviceAdd() callback, the remaining listeners will still be notified. Listeners will only receive onDeviceAvailable() callbacks until the device is owned.
      Parameters:
      device - the device being claimed
      owner - the object claiming ownership
      Throws:
      IllegalStateException - if device is already owned
    • releaseDevice

      public void releaseDevice(UdevDevice device)
      Release ownership of a device. This will cause all listeners to be notified that the device is available.
      Parameters:
      device - the device to release
    • removeOwner

      public void removeOwner(UdevDeviceOwner owner)
      Release all devices claimed by the owner.