Class AutoCloseableDelegateInvocationHandler
- java.lang.Object
-
- org.apache.sshd.common.util.closeable.AutoCloseableDelegateInvocationHandler
-
- All Implemented Interfaces:
InvocationHandler
- Direct Known Subclasses:
NioChannelDelegateInvocationHandler
public class AutoCloseableDelegateInvocationHandler extends Object implements InvocationHandler
Wraps a target instance and anAutoCloseable
delegate into a proxy instance that closes both when wrapperclose
method called.- Author:
- Apache MINA SSHD Project
-
-
Constructor Summary
Constructors Constructor Description AutoCloseableDelegateInvocationHandler(Object proxyTarget, AutoCloseable delegate)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description AutoCloseable
getAutoCloseableDelegate()
Object
getProxyTarget()
Object
invoke(Object proxy, Method method, Object[] args)
static boolean
isCloseMethod(Method m)
static boolean
isCloseMethodInvocation(Method m, Object[] args)
static <T extends AutoCloseable>
TwrapDelegateCloseable(Object proxyTarget, Class<T> type, AutoCloseable delegate)
Wraps a target instance and anAutoCloseable
delegate into a proxy instance that closes both when wrapperclose
method called.
-
-
-
Constructor Detail
-
AutoCloseableDelegateInvocationHandler
public AutoCloseableDelegateInvocationHandler(Object proxyTarget, AutoCloseable delegate)
-
-
Method Detail
-
getProxyTarget
public Object getProxyTarget()
-
getAutoCloseableDelegate
public AutoCloseable getAutoCloseableDelegate()
-
invoke
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
- Specified by:
invoke
in interfaceInvocationHandler
- Throws:
Throwable
-
wrapDelegateCloseable
public static <T extends AutoCloseable> T wrapDelegateCloseable(Object proxyTarget, Class<T> type, AutoCloseable delegate)
Wraps a target instance and anAutoCloseable
delegate into a proxy instance that closes both when wrapperclose
method called.- Type Parameters:
T
- The genericAutoCloseable
wrapping interface- Parameters:
proxyTarget
- The (nevernull
) target instance - if notAutoCloseable
then it'sclose()
method will not be invoked (i.e., only the delegate)type
- The target wrapping interfacedelegate
- The (nevernull
) delegate to close. Note: the delegate is closed after the target instance.- Returns:
- The wrapping proxy
-
isCloseMethod
public static boolean isCloseMethod(Method m)
-
-