Package com.diozero.sbc
Class DeviceFactoryHelper
- java.lang.Object
-
- com.diozero.sbc.DeviceFactoryHelper
-
public class DeviceFactoryHelper extends Object
Helper class for automatically detecting thenative device factory
that will be used for provisioning I/O devices. Uses the JavaServiceLoader
to detect NativeDeviceFactoryInterface implementations that are available on the class-path as defined inMETA-INF/services/com.diozero.internal.provider.NativeDeviceFactoryInterface
. The first entry is used if there are multiple implementations present on the class-path. Alternatively you can specify the class to use via the command line or environment propertydiozero.devicefactory
. Thebuilt-in device factory
is used if the above logic fails to instantiate a device factory implementation.
-
-
Field Summary
Fields Modifier and Type Field Description static String
DEVICE_FACTORY_PROP
-
Constructor Summary
Constructors Constructor Description DeviceFactoryHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static NativeDeviceFactoryInterface
getNativeDeviceFactory()
Auto-detect the native device factory class to be used for provisioning I/O devices in this lookup order: Command lineproperty / environment
variablediozero.devicefactory
JavaServiceLoader
using the classcom.diozero.internal.provider.NativeDeviceFactoryInterface
Thebuilt-in device factory
static void
registerForShutdown(AutoCloseable... closeableArray)
Register an object to be shutdown in the case of abnormal shutdownstatic void
shutdown()
-
-
-
Field Detail
-
DEVICE_FACTORY_PROP
public static final String DEVICE_FACTORY_PROP
- See Also:
- Constant Field Values
-
-
Method Detail
-
getNativeDeviceFactory
public static NativeDeviceFactoryInterface getNativeDeviceFactory()
Auto-detect the native device factory class to be used for provisioning I/O devices in this lookup order:- Command line
property / environment
variablediozero.devicefactory
- Java
ServiceLoader
using the classcom.diozero.internal.provider.NativeDeviceFactoryInterface
- The
built-in device factory
- Returns:
- the native device factory instance to use for provisioning I/O devices.
- Command line
-
registerForShutdown
public static void registerForShutdown(AutoCloseable... closeableArray)
Register an object to be shutdown in the case of abnormal shutdown- Parameters:
closeableArray
- Array of closeable objects to close on shutdown
-
shutdown
public static void shutdown()
-
-