/** * Creates a controller with the specified pooling and caching settings. * * @param componentPooling if <code>true</code>, component pooling * will be performed (soft pool), otherwise no component pool will be used. * @param cachedProcessingComponents classes of components whose output should be cached * by the controller. If a superclass is provided here, e.g. * {@link IDocumentSource}, all its subclasses will be subject to caching. * If {@link IProcessingComponent} is provided here, output of all * components will be cached. */ @SafeVarargs public static Controller create(boolean componentPooling, Class<? extends IProcessingComponent>... cachedProcessingComponents) { final IProcessingComponentManager baseManager = (componentPooling ? new PoolingProcessingComponentManager() : new SimpleProcessingComponentManager()); return new Controller(addCachingManager(baseManager, cachedProcessingComponents)); }
/** * Creates a controller with the specified fixed-size pooling and caching settings. * * @param 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. * @param cachedProcessingComponents classes of components whose output should be * cached by the controller. If a superclass is provided here, e.g. * {@link IDocumentSource}, all its subclasses will be subject to caching. * If {@link IProcessingComponent} is provided here, output of all * components will be cached. */ @SafeVarargs public static Controller create(int instancePoolSize, Class<? extends IProcessingComponent>... cachedProcessingComponents) { if (instancePoolSize <= 0) throw new IllegalArgumentException("Instance pool size must be greater than zero: " + instancePoolSize); final IProcessingComponentManager baseManager = new PoolingProcessingComponentManager( new FixedSizePool<IProcessingComponent, String>(instancePoolSize)); return new Controller(addCachingManager(baseManager, cachedProcessingComponents)); }