Class AutoCloseableDelegateInvocationHandler
java.lang.Object
org.apache.sshd.common.util.closeable.AutoCloseableDelegateInvocationHandler
- All Implemented Interfaces:
InvocationHandler
- Direct Known Subclasses:
NioChannelDelegateInvocationHandler
Wraps a target instance and an
AutoCloseable delegate into a proxy instance that closes both when wrapper
close method called.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Object[]private final AutoCloseableprivate final Object -
Constructor Summary
ConstructorsConstructorDescriptionAutoCloseableDelegateInvocationHandler(Object proxyTarget, AutoCloseable delegate) -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanstatic 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.
-
Field Details
-
proxyTarget
-
delegate
-
closers
-
-
Constructor Details
-
AutoCloseableDelegateInvocationHandler
-
-
Method Details
-
getProxyTarget
-
getAutoCloseableDelegate
-
invoke
- 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
-
isCloseMethodInvocation
-
isCloseMethod
-