Class AutoCloseableDelegateInvocationHandler
- java.lang.Object
-
- org.apache.sshd.common.util.closeable.AutoCloseableDelegateInvocationHandler
-
- All Implemented Interfaces:
java.lang.reflect.InvocationHandler
- Direct Known Subclasses:
NioChannelDelegateInvocationHandler
public class AutoCloseableDelegateInvocationHandler extends java.lang.Object implements java.lang.reflect.InvocationHandlerWraps a target instance and anAutoCloseabledelegate into a proxy instance that closes both when wrapperclosemethod called.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Object[]closersprivate java.lang.AutoCloseabledelegateprivate java.lang.ObjectproxyTarget
-
Constructor Summary
Constructors Constructor Description AutoCloseableDelegateInvocationHandler(java.lang.Object proxyTarget, java.lang.AutoCloseable delegate)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.AutoCloseablegetAutoCloseableDelegate()java.lang.ObjectgetProxyTarget()java.lang.Objectinvoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args)static booleanisCloseMethod(java.lang.reflect.Method m)static booleanisCloseMethodInvocation(java.lang.reflect.Method m, java.lang.Object[] args)static <T extends java.lang.AutoCloseable>
TwrapDelegateCloseable(java.lang.Object proxyTarget, java.lang.Class<T> type, java.lang.AutoCloseable delegate)Wraps a target instance and anAutoCloseabledelegate into a proxy instance that closes both when wrapperclosemethod called.
-
-
-
Method Detail
-
getProxyTarget
public java.lang.Object getProxyTarget()
-
getAutoCloseableDelegate
public java.lang.AutoCloseable getAutoCloseableDelegate()
-
invoke
public java.lang.Object invoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args) throws java.lang.Throwable- Specified by:
invokein interfacejava.lang.reflect.InvocationHandler- Throws:
java.lang.Throwable
-
wrapDelegateCloseable
public static <T extends java.lang.AutoCloseable> T wrapDelegateCloseable(java.lang.Object proxyTarget, java.lang.Class<T> type, java.lang.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
-
isCloseMethodInvocation
public static boolean isCloseMethodInvocation(java.lang.reflect.Method m, java.lang.Object[] args)
-
isCloseMethod
public static boolean isCloseMethod(java.lang.reflect.Method m)
-
-