public final class ControllerFactory extends Object
Controller
s in a number of common configurations. The most useful
configurations are:
createSimple()
: for one-time processing and quick experiments with the
code;createCachingPooling(Class...)
: for long-running applications (e.g. web
applications) handling repeated (cacheable) requests.Modifier and Type | Method and Description |
---|---|
static Controller |
create(boolean componentPooling,
Class<? extends IProcessingComponent>... cachedProcessingComponents)
Creates a controller with the specified pooling and caching settings.
|
static Controller |
create(int instancePoolSize,
Class<? extends IProcessingComponent>... cachedProcessingComponents)
Creates a controller with the specified fixed-size pooling and caching settings.
|
static Controller |
createCaching(Class<? extends IProcessingComponent>... cachedProcessingComponents)
Creates a controller with no processing component pooling but with results caching.
|
static Controller |
createCachingPooling(Class<? extends IProcessingComponent>... cachedProcessingComponents)
Creates a controller with processing component pooling and results caching.
|
static Controller |
createPooling()
Creates a controller with processing component pooling but with no results caching.
|
static Controller |
createPooling(int instancePoolSize)
Creates a controller with processing component pooling but with no results caching.
|
static Controller |
createSimple()
Creates a controller with no processing component pooling and no results caching.
|
public static Controller createSimple()
This controller is useful for one-time processing or fast experiments with the code. For long-running applications (e.g. web applications), consider using a controller with component pooling and/or caching.
public static Controller createPooling()
Use this controller in long-running applications and when your processing components are expensive to create. For applications that handle large numbers of repeated requests, consider using a caching and pooling controller.
create(boolean, Class...)
,
createPooling(int)
public static Controller createPooling(int instancePoolSize)
Use this controller in long-running applications and when your processing components are expensive to create. For applications that handle large numbers of repeated requests, consider using a caching and pooling controller.
instancePoolSize
- Number of instances created for a single component
class-ID pair. For computational components it is sensible to set this pool to the
number of CPU cores available on the machine.create(int, Class...)
,
createPooling()
,
Runtime.availableProcessors()
@SafeVarargs public static Controller createCaching(Class<? extends IProcessingComponent>... cachedProcessingComponents)
Uses of this specific controller are rather limited. Use it if your application is handling large numbers of repeated requests but you don't want to have the components pooled for some reason. Make sure the processing components are cheap to create, otherwise performance will suffer.
cachedProcessingComponents
- classes of components whose output should be cached
by the controller. If a superclass is provided here, e.g.
IDocumentSource
, all its subclasses will be subject to caching.
If IProcessingComponent
is provided here, output of all
components will be cached.@SafeVarargs public static Controller createCachingPooling(Class<? extends IProcessingComponent>... cachedProcessingComponents)
Use this component in long-running applications that handle repeated requests.
cachedProcessingComponents
- classes of components whose output should be cached
by the controller. If a superclass is provided here, e.g.
IDocumentSource
, all its subclasses will be subject to caching.
If IProcessingComponent
is provided here, output of all
components will be cached.@SafeVarargs public static Controller create(boolean componentPooling, Class<? extends IProcessingComponent>... cachedProcessingComponents)
componentPooling
- if true
, component pooling
will be performed (soft pool), otherwise no component pool will be used.cachedProcessingComponents
- classes of components whose output should be cached
by the controller. If a superclass is provided here, e.g.
IDocumentSource
, all its subclasses will be subject to caching.
If IProcessingComponent
is provided here, output of all
components will be cached.@SafeVarargs public static Controller create(int instancePoolSize, Class<? extends IProcessingComponent>... cachedProcessingComponents)
instancePoolSize
- Number of instances created for a single component class-ID
pair. For computational components it is sensible to set this pool to
the number of CPU cores available on the machine.cachedProcessingComponents
- classes of components whose output should be
cached by the controller. If a superclass is provided here, e.g.
IDocumentSource
, all its subclasses will be subject to caching.
If IProcessingComponent
is provided here, output of all
components will be cached.