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 anAutoCloseabledelegate into a proxy instance that closes both when wrapperclosemethod 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 AutoCloseablegetAutoCloseableDelegate()ObjectgetProxyTarget()Objectinvoke(Object proxy, Method method, Object[] args)static booleanisCloseMethod(Method m)static booleanisCloseMethodInvocation(Method m, Object[] args)static <T extends AutoCloseable>
TwrapDelegateCloseable(Object proxyTarget, Class<T> type, AutoCloseable delegate)Wraps a target instance and anAutoCloseabledelegate into a proxy instance that closes both when wrapperclosemethod 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:
invokein interfaceInvocationHandler- Throws:
Throwable
-
wrapDelegateCloseable
public static <T extends AutoCloseable> T wrapDelegateCloseable(Object proxyTarget, Class<T> type, AutoCloseable delegate)
Wraps a target instance and anAutoCloseabledelegate into a proxy instance that closes both when wrapperclosemethod called.- Type Parameters:
T- The genericAutoCloseablewrapping interface- Parameters:
proxyTarget- The (nevernull) target instance - if notAutoCloseablethen 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)
-
-