Class DeviceFactoryHelper

java.lang.Object
com.diozero.sbc.DeviceFactoryHelper

public class DeviceFactoryHelper
extends Object
Helper class for automatically detecting the native device factory that will be used for provisioning I/O devices. Uses the Java ServiceLoader to detect NativeDeviceFactoryInterface implementations that are available on the class-path as defined in META-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 property diozero.devicefactory. The built-in device factory is used if the above logic fails to instantiate a device factory implementation.
  • Field Details

  • Constructor Details

    • DeviceFactoryHelper

      public DeviceFactoryHelper()
  • Method Details

    • getNativeDeviceFactory

      public static NativeDeviceFactoryInterface getNativeDeviceFactory()
      Auto-detect the native device factory class to be used for provisioning I/O devices in this lookup order:
      1. Command line property / environment variable diozero.devicefactory
      2. Java ServiceLoader using the class com.diozero.internal.provider.NativeDeviceFactoryInterface
      3. The built-in device factory
      Returns:
      the native device factory instance to use for provisioning I/O devices.