Package com.tccc.kos.core.service.udev
Class UdevService
java.lang.Object
com.tccc.kos.commons.util.ready.ReadyBean
com.tccc.kos.commons.core.service.AbstractService
com.tccc.kos.core.service.udev.UdevService
- All Implemented Interfaces:
CtxEventListener
,ContextHandleAware
,HandleAware
,Ready
,ReadyListener
Service that manages events from udev adapter.
- Since:
- 1.0
- Version:
- 2023-08-31
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addListener
(UdevDeviceListener listener) Add a device listener.void
claimDevice
(UdevDevice device, UdevDeviceOwner owner) Claim ownership of a device.boolean
Override in subclasses to be notified when all dependencies are ready.void
releaseDevice
(UdevDevice device) Release ownership of a device.void
removeListener
(UdevDeviceListener listener) Remove a device listener.void
removeOwner
(UdevDeviceOwner owner) Release all devices claimed by the owner.Methods inherited from class com.tccc.kos.commons.core.service.AbstractService
getHandle, getHandlePrefix
Methods inherited from class com.tccc.kos.commons.util.ready.ReadyBean
getReady, onDependenciesReady
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.tccc.kos.commons.core.context.CtxEventListener
onCtxAutowiringCompleted, onCtxDestroyed, onCtxPhaseCompleted
Methods inherited from interface com.tccc.kos.commons.core.service.handle.HandleAware
addHandleChild, getName, getPath
Methods inherited from interface com.tccc.kos.commons.util.ready.ReadyListener
onDependenciesGroupReady
-
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 callsetReady()
later due to some async processing, return false to preventsetReady()
from being called automatically.It is recommended to override this method rather than
onDependenciesReady()
as a majority of the time it requires callingsuper.onDependneciesReady()
or explicitly callingsetReady()
which defaults to a failure mode.- Overrides:
onBeanReady
in classReadyBean
- Returns:
-
addListener
Add a device listener. This will cause all devices to be passed to the new listener, including bothonDeviceAdd()
and if not owned,onDeviceAvailable()
. -
removeListener
Remove a device listener. -
claimDevice
Claim ownership of a device. If claimed duringonDeviceAdd()
callback, the remaining listeners will still be notified. Listeners will only receiveonDeviceAvailable()
callbacks until the device is owned.- Parameters:
device
- the device being claimedowner
- the object claiming ownership- Throws:
IllegalStateException
- if device is already owned
-
releaseDevice
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
Release all devices claimed by the owner.
-