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 AutoCloseable
private final Object
-
Constructor Summary
ConstructorsConstructorDescriptionAutoCloseableDelegateInvocationHandler
(Object proxyTarget, AutoCloseable delegate) -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
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.
-
Field Details
-
proxyTarget
-
delegate
-
closers
-
-
Constructor Details
-
AutoCloseableDelegateInvocationHandler
-
-
Method Details
-
getProxyTarget
-
getAutoCloseableDelegate
-
invoke
- 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
-
isCloseMethodInvocation
-
isCloseMethod
-