org.glassfish.jersey.process.internal
Class RequestExecutorFactory

java.lang.Object
  extended by org.glassfish.jersey.process.internal.RequestExecutorFactory

public abstract class RequestExecutorFactory
extends Object

Request executors provider aggregator used by client and server-side run-times to provide support for pluggable managed/async executor services.

Instances of RequestExecutorFactory use the configured request executors provider to lazily retrieve and cache an instance of request executor service when getExecutor() method is invoked. The retrieved executor service is then cached and returned from the getExecutor() method on subsequent calls.

It is expected that the ExecutorFactory's close() method will be called on any executor factory instance that is no longer use. Upon the call to close() method, the factory will release the cached

Author:
Miroslav Fuksa (miroslav.fuksa at oracle.com), Marek Potociar (marek.potociar at oracle.com)

Constructor Summary
RequestExecutorFactory(org.glassfish.hk2.api.ServiceLocator locator, Object... args)
          Creates new instance.
 
Method Summary
 void close()
          Close the executor factory and release any associated executor service resources.
protected abstract  RequestExecutorProvider getDefaultProvider(Object... initArgs)
          Get the default request executor provider.
 ExecutorService getExecutor()
          Get the request processing executor using the underlying RequestExecutorProvider configured in the executor factory instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RequestExecutorFactory

public RequestExecutorFactory(org.glassfish.hk2.api.ServiceLocator locator,
                              Object... args)
Creates new instance.

Parameters:
locator - Injected HK2 locator.
args - additional arguments that will be passed into the getDefaultProvider(Object...) when/if invoked.
Method Detail

getDefaultProvider

protected abstract RequestExecutorProvider getDefaultProvider(Object... initArgs)
Get the default request executor provider.

This method is invoked from the RequestExecutorFactory constructor if no custom RequestExecutorProvider registration is found. The returned default provider will be then used to provide the default request executor implementation.

Concrete implementations of this class are expected to provide implementation of this method. Note that since the method is used from the RequestExecutorFactory constructor, the implementation of this method must not rely on initialization of any non-static fields of the overriding sub-class. Instead, the necessary initialization arguments may be passed via super constructor.

Parameters:
initArgs - initialization arguments passed via constructor of this class.
Returns:
default request executor provider to be used if no custom provider has been registered.

getExecutor

public final ExecutorService getExecutor()
Get the request processing executor using the underlying RequestExecutorProvider configured in the executor factory instance.

Returns:
request processing executor. Must not return null.
Throws:
IllegalStateException - in case the factory instance has been closed already.

close

public final void close()
Close the executor factory and release any associated executor service resources.



Copyright © 2007-2014, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.