|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.iparelan.util.ConcurrencyTools.ThreadPoolProxyInvocationHandler<T>
T
- The type of the proxied object.private static final class ConcurrencyTools.ThreadPoolProxyInvocationHandler<T>
Dispatches proxied method invocations through a thread pool.
SHUTDOWN_METHOD_NAME
from "close"
to "shutdown"
.
ThreadPoolExecutor
).
Field Summary | |
---|---|
private ThreadPoolExecutor |
executorService
The ExecutorService on which method
invocations are dispatched. |
private T |
proxied
The object proxied by the dynamic proxy. |
Constructor Summary | |
---|---|
ConcurrencyTools.ThreadPoolProxyInvocationHandler(String poolName,
T proxied)
Creates a ThreadPoolProxyInvocationHandler . |
Method Summary | |
---|---|
private Method |
getMethod(Class<?> proxiedType,
String methodName,
Class<?>... parameterTypes)
Produced the named Method on the
specified type or null if the type has no such Method . |
Object |
invoke(Object proxy,
Method method,
Object[] args)
Invokes method on the proxied object with args . |
private Object |
invokeNonShutdownable(Method method,
Object[] args)
|
private Object |
invokeShutdownable(Method method,
Object[] args)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private final T proxied
private final ThreadPoolExecutor executorService
ExecutorService
on which method
invocations are dispatched.
Constructor Detail |
---|
ConcurrencyTools.ThreadPoolProxyInvocationHandler(String poolName, T proxied)
ThreadPoolProxyInvocationHandler
.
poolName
- The name of the thread pool. May be neither null
nor
the empty string.proxied
- The object on which to invoke proxied methods. May not be
null
.
IllegalArgumentException
- Iff proxied is null
.newThreadPoolProxy(String, T, Class>...)
param exceptionType (final Class super Throwable> exceptionType)
The type of exception to throw if there is an error
during reflective proxy method invocation. May be null
in which case a ProxyException
is thrown.
corePoolSize
, maximumPoolSize
,
keepAliveTime
.
Method Detail |
---|
@UnknownNullness public Object invoke(Object proxy, Method method, Object[] args)
method
on the proxied object with args
. If
method
is a method of the ConcurrencyTools.Shutdownable
interface,
then the method is dispatched to the ExecutorService
associated to this InvocationHandler
first, then to the proxied
object as appropriate.
For example, ConcurrencyTools.Shutdownable.isShutdown()
is dispatched to
the ExecutorService
and if the result is true
, then
it is dispatched to the proxied object and that value is produced.
invoke
in interface InvocationHandler
proxy
- method
- args
-
ProxyException
- Iff method
cannot be invoked on the proxied object
with args
.@UnknownNullness private Object invokeNonShutdownable(Method method, Object[] args)
@UnknownNullness private Object invokeShutdownable(Method method, Object[] args)
@Nullable private Method getMethod(Class<?> proxiedType, String methodName, Class<?>... parameterTypes)
Method
on the
specified type or null
if the type has no such Method
.
proxiedType
- The type from which to retrieve the named Method
. May not be null
.methodName
- The name of the Method
to get from proxiedType
. May be neither null
nor the empty
string.parameterTypes
- The method parameter types. May be null
or an empty
array to express a method.
Method
of proxiedType
or null
if proxiedType
does not have a Method
named methodName
with parameter types of parameterTypes
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |