Package ej.ecom

Class DeviceManager


  • public class DeviceManager
    extends Object
    The DeviceManager holds the Device registry. It allows to register, unregister, list devices. Registered RegistrationListener are notified when a device is registered or unregistered.
    • Method Detail

      • addRegistrationListener

        public static <D extends Device> void addRegistrationListener​(RegistrationListener<D> listener,
                                                                      Class<D> deviceType)
        Adds the given RegistrationListener to be notified when a device of the given type is registered or unregistered. If there is a security manager, its SecurityManager.checkPermission(java.security.Permission) method is called with the DeviceManagerPermission.READ name and the device type. The listener may be registered multiple times on different device types.
        Type Parameters:
        D - the type of the devices to be listened for
        Parameters:
        listener - the registration listener
        deviceType - the type of the devices to be listened for
        Throws:
        SecurityException - if a security manager exists and it does not allow the caller to listen to devices registered with the given type
      • removeRegistrationListener

        public static <D extends Device> void removeRegistrationListener​(RegistrationListener<D> listener)
        Removes the given RegistrationListener from the list of listeners that are notified when a device is registered or unregistered. The listener may have been registered multiple times on different device types.
        Type Parameters:
        D - the type of the device listened for
        Parameters:
        listener - the registration listener
      • list

        public static <D extends DeviceIterator<D> list​(Class<D> deviceType)
        List all registered devices such as the given type is assignable from the device class. If there is a security manager, its SecurityManager.checkPermission(java.security.Permission) method is called with DeviceManagerPermission.READ action and the device type.
        Type Parameters:
        D - the type of devices to list
        Parameters:
        deviceType - the type of the device to be registered
        Returns:
        an iterator of all registered devices of the given type
        Throws:
        SecurityException - if a security manager exists and it doesn't allow the caller to list devices of the given type