Class PluginsConfigurator.Builder

java.lang.Object
org.eclipse.keyple.core.service.resource.PluginsConfigurator.Builder
Enclosing class:
PluginsConfigurator

public static final class PluginsConfigurator.Builder extends Object
Since:
2.0.0
  • Method Details

    • withAllocationStrategy

      public PluginsConfigurator.Builder withAllocationStrategy(PluginsConfigurator.AllocationStrategy allocationStrategy)
      Specifies the allocation strategy to perform when a card resource is requested.

      Default value: PluginsConfigurator.AllocationStrategy.FIRST

      Parameters:
      allocationStrategy - The PluginsConfigurator.AllocationStrategy to use.
      Returns:
      The current builder instance.
      Throws:
      IllegalArgumentException - If the provided strategy is null.
      IllegalStateException - If the strategy has already been configured.
      Since:
      2.0.0
    • withUsageTimeout

      public PluginsConfigurator.Builder withUsageTimeout(int usageTimeoutMillis)
      Specifies the timeout to use after that an allocated card resource can be automatically re-allocated by card resource service to a new thread if requested.

      Default value: infinite

      Parameters:
      usageTimeoutMillis - The max usage duration of a card resource (in milliseconds).
      Returns:
      The current builder instance.
      Throws:
      IllegalArgumentException - If the provided value is less or equal to 0.
      IllegalStateException - If the timeout has already been configured.
      Since:
      2.0.0
    • addPlugin

      public PluginsConfigurator.Builder addPlugin(org.eclipse.keyple.core.service.Plugin plugin, ReaderConfiguratorSpi readerConfiguratorSpi)
      Adds a Plugin or ObservablePlugin to the default list of all card profiles.

      Note: The order of the plugins is important because it will be kept during the allocation process unless redefined by card profiles.

      Parameters:
      plugin - The plugin to add.
      readerConfiguratorSpi - The reader configurator to use when a reader is connected and accepted by at leas one card resource profile.
      Returns:
      The current builder instance.
      Throws:
      IllegalArgumentException - If the provided plugin or reader configurator is null or if the plugin is not an instance of Plugin or ObservablePlugin.
      IllegalStateException - If the plugin has already been configured.
      Since:
      2.0.0
    • addPluginWithMonitoring

      public PluginsConfigurator.Builder addPluginWithMonitoring(org.eclipse.keyple.core.service.Plugin plugin, ReaderConfiguratorSpi readerConfiguratorSpi, org.eclipse.keyple.core.service.spi.PluginObservationExceptionHandlerSpi pluginObservationExceptionHandlerSpi, org.eclipse.keypop.reader.spi.CardReaderObservationExceptionHandlerSpi readerObservationExceptionHandlerSpi)
      Adds a Plugin or ObservablePlugin to the default list of all card profiles with background auto monitoring of reader connections/disconnections and/or card insertions/removals.

      Note: The order of the plugins is important because it will be kept during the allocation process unless redefined by card profiles.

      The plugin or readers must be observable for the monitoring operations to have an effect.

      Parameters:
      plugin - The plugin to add.
      readerConfiguratorSpi - The reader configurator to use when a reader is connected and accepted by at leas one card resource profile.
      pluginObservationExceptionHandlerSpi - If not null, then activates the monitoring of the plugin and specifies the exception handler to use in case of error occurs during the asynchronous observation process.
      readerObservationExceptionHandlerSpi - If not null, then activates the monitoring of the readers and specifies the exception handler to use in case of error occurs during the asynchronous observation process.
      Returns:
      The current builder instance.
      Throws:
      IllegalArgumentException - If the provided plugin or reader configurator is null or if the plugin is not an instance of Plugin or ObservablePlugin.
      IllegalStateException - If the plugin has already been configured.
      Since:
      2.0.0
    • build

      public PluginsConfigurator build()
      Creates a new instance of PluginsConfigurator using the current configuration.
      Returns:
      A new instance.
      Throws:
      IllegalStateException - If no plugin has been configured.
      Since:
      2.0.0