Class PluginsConfigurator.Builder
- java.lang.Object
-
- org.eclipse.keyple.core.service.resource.PluginsConfigurator.Builder
-
- Enclosing class:
- PluginsConfigurator
public static class PluginsConfigurator.Builder extends java.lang.Object
Builder ofPluginsConfigurator
.- Since:
- 2.0.0
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PluginsConfigurator.Builder
addPlugin(org.eclipse.keyple.core.service.Plugin plugin, ReaderConfiguratorSpi readerConfiguratorSpi)
Adds aPlugin
orObservablePlugin
to the default list of all card profiles.PluginsConfigurator.Builder
addPluginWithMonitoring(org.eclipse.keyple.core.service.Plugin plugin, ReaderConfiguratorSpi readerConfiguratorSpi, org.eclipse.keyple.core.service.spi.PluginObservationExceptionHandlerSpi pluginObservationExceptionHandlerSpi, org.calypsonet.terminal.reader.spi.CardReaderObservationExceptionHandlerSpi readerObservationExceptionHandlerSpi)
Adds aPlugin
orObservablePlugin
to the default list of all card profiles with background auto monitoring of reader connections/disconnections and/or card insertions/removals.PluginsConfigurator
build()
Creates a new instance ofPluginsConfigurator
using the current configuration.PluginsConfigurator.Builder
withAllocationStrategy(PluginsConfigurator.AllocationStrategy allocationStrategy)
Specifies the allocation strategy to perform when a card resource is requested.PluginsConfigurator.Builder
withUsageTimeout(int usageTimeoutMillis)
Specifies the timeout to use after that an allocated card resource can be automatically reallocated by card resource service to a new thread if requested.
-
-
-
Method Detail
-
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
- ThePluginsConfigurator.AllocationStrategy
to use.- Returns:
- The current builder instance.
- Throws:
java.lang.IllegalArgumentException
- If the provided strategy is null.java.lang.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 reallocated 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:
java.lang.IllegalArgumentException
- If the provided value is less or equal to 0.java.lang.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 aPlugin
orObservablePlugin
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:
java.lang.IllegalArgumentException
- If the provided plugin or reader configurator is null or if the plugin is not an instance of Plugin or ObservablePlugin.java.lang.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.calypsonet.terminal.reader.spi.CardReaderObservationExceptionHandlerSpi readerObservationExceptionHandlerSpi)
Adds aPlugin
orObservablePlugin
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:
java.lang.IllegalArgumentException
- If the provided plugin or reader configurator is null or if the plugin is not an instance of Plugin or ObservablePlugin.java.lang.IllegalStateException
- If the plugin has already been configured.- Since:
- 2.0.0
-
build
public PluginsConfigurator build()
Creates a new instance ofPluginsConfigurator
using the current configuration.- Returns:
- A new instance.
- Throws:
java.lang.IllegalStateException
- If no plugin has been configured.- Since:
- 2.0.0
-
-