public class AutoCloseableDelegateInvocationHandler extends Object implements InvocationHandler
AutoCloseable delegate into a proxy instance that closes both when wrapper
close method called.| Constructor and Description |
|---|
AutoCloseableDelegateInvocationHandler(Object proxyTarget,
AutoCloseable delegate) |
| Modifier and Type | Method and 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> |
wrapDelegateCloseable(Object proxyTarget,
Class<T> type,
AutoCloseable delegate)
Wraps a target instance and an
AutoCloseable delegate into a proxy instance that closes both when wrapper
close method called. |
public AutoCloseableDelegateInvocationHandler(Object proxyTarget, AutoCloseable delegate)
public Object getProxyTarget()
public AutoCloseable getAutoCloseableDelegate()
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
invoke in interface InvocationHandlerThrowablepublic static <T extends AutoCloseable> T wrapDelegateCloseable(Object proxyTarget, Class<T> type, AutoCloseable delegate)
AutoCloseable delegate into a proxy instance that closes both when wrapper
close method called.T - The generic AutoCloseable wrapping interfaceproxyTarget - The (never null) target instance - if not AutoCloseable then it's
close() method will not be invoked (i.e., only the delegate)type - The target wrapping interfacedelegate - The (never null) delegate to close. Note: the delegate is closed after
the target instance.public static boolean isCloseMethod(Method m)
Copyright © 2018–2024 The Apache Software Foundation. All rights reserved.