Class DynamicGlue


  • final class DynamicGlue
    extends java.lang.Object
    Utility methods for generating dynamic Provider-based proxies.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private DynamicGlue()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static byte[] generateProxyClass​(java.lang.String proxyName, java.lang.Class<?> facade)
      Generates a dynamic Provider-based proxy that reflects the given facade.
      private static java.lang.String[] getInternalNames​(java.lang.Class<?>... clazzes)
      Returns the internal names of the given classes.
      private static java.util.Collection<java.lang.reflect.Method> getWrappableMethods​(java.lang.Class<?> clazz)
      Returns the methods that should be wrapped for delegation in the given class.
      private static void init​(ClassWriter cw, java.lang.String superName, java.lang.String proxyName)
      Generates a constructor that accepts a Provider and stores it in an internal field.
      private static boolean isWrappable​(java.lang.reflect.Method method)
      Returns true if the given method should be wrapped; otherwise false.
      private static java.lang.String signatureKey​(java.lang.reflect.Method method)
      Returns a signature-based key that identifies the given method in the current class.
      private static void wrap​(ClassWriter cw, java.lang.String proxyName, java.lang.reflect.Method method)
      Generates a wrapper that dereferences the stored Provider and invokes the given method.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • PROVIDER_NAME

        private static final java.lang.String PROVIDER_NAME
      • PROVIDER_DESC

        private static final java.lang.String PROVIDER_DESC
      • OBJECT_NAME

        private static final java.lang.String OBJECT_NAME
      • OBJECT_DESC

        private static final java.lang.String OBJECT_DESC
      • ILLEGAL_STATE_NAME

        private static final java.lang.String ILLEGAL_STATE_NAME
      • OBJECT_METHOD_MAP

        private static final java.util.Map<java.lang.String,​java.lang.reflect.Method> OBJECT_METHOD_MAP
    • Constructor Detail

      • DynamicGlue

        private DynamicGlue()
    • Method Detail

      • generateProxyClass

        public static byte[] generateProxyClass​(java.lang.String proxyName,
                                                java.lang.Class<?> facade)
        Generates a dynamic Provider-based proxy that reflects the given facade.
        Parameters:
        proxyName - The proxy name
        facade - The expected facade
        Returns:
        Generated proxy bytes
      • init

        private static void init​(ClassWriter cw,
                                 java.lang.String superName,
                                 java.lang.String proxyName)
        Generates a constructor that accepts a Provider and stores it in an internal field.
      • wrap

        private static void wrap​(ClassWriter cw,
                                 java.lang.String proxyName,
                                 java.lang.reflect.Method method)
        Generates a wrapper that dereferences the stored Provider and invokes the given method.
      • getInternalNames

        private static java.lang.String[] getInternalNames​(java.lang.Class<?>... clazzes)
        Returns the internal names of the given classes.
      • getWrappableMethods

        private static java.util.Collection<java.lang.reflect.Method> getWrappableMethods​(java.lang.Class<?> clazz)
        Returns the methods that should be wrapped for delegation in the given class.
      • isWrappable

        private static boolean isWrappable​(java.lang.reflect.Method method)
        Returns true if the given method should be wrapped; otherwise false.
      • signatureKey

        private static java.lang.String signatureKey​(java.lang.reflect.Method method)
        Returns a signature-based key that identifies the given method in the current class.