Class NioChannelDelegateInvocationHandler

  • All Implemented Interfaces:
    java.lang.reflect.InvocationHandler

    public class NioChannelDelegateInvocationHandler
    extends AutoCloseableDelegateInvocationHandler
    Wraps a target instance and a Channel delegate into a proxy instance that closes both when wrapper close method called. The Channel.isOpen() call is invoked only on the delegate
    • Constructor Detail

      • NioChannelDelegateInvocationHandler

        public NioChannelDelegateInvocationHandler​(java.lang.Object proxyTarget,
                                                   java.nio.channels.Channel delegate)
    • Method Detail

      • getChannelDelegate

        public java.nio.channels.Channel getChannelDelegate()
      • 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:
        invoke in interface java.lang.reflect.InvocationHandler
        Overrides:
        invoke in class AutoCloseableDelegateInvocationHandler
        Throws:
        java.lang.Throwable
      • wrapDelegateChannel

        public static <T extends java.nio.channels.Channel> T wrapDelegateChannel​(java.lang.Object proxyTarget,
                                                                                  java.lang.Class<T> type,
                                                                                  java.nio.channels.Channel delegate)
        Wraps a target instance and a Channel delegate into a proxy instance that closes both when wrapper close method called. The Channel.isOpen() call is invoked only on the delegate
        Type Parameters:
        T - The generic Channel wrapping interface
        Parameters:
        proxyTarget - 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 interface
        delegate - The (never null) delegate to use. Note: the delegate is closed after the target instance.
        Returns:
        The wrapping proxy
      • isQueryOpenMethodInvocation

        public static boolean isQueryOpenMethodInvocation​(java.lang.reflect.Method m,
                                                          java.lang.Object[] args)
      • isQueryOpenMethodInvocation

        public static boolean isQueryOpenMethodInvocation​(java.lang.reflect.Method m)