Package java.lang.reflect

Examples of java.lang.reflect.InvocationHandler


         {
            // Handle map specially
            if (clazz.isAssignableFrom(Map.class))
               return unwrapCompositeMap(compositeValue);

            InvocationHandler handler = createCompositeValueInvocationHandler(compositeValue);
            Class<?>[] interfaces = new Class[]{clazz};
            return Proxy.newProxyInstance(clazz.getClassLoader(), interfaces, handler);           
         }
         else if(clazz.isAssignableFrom(ObjectName.class))
         {
View Full Code Here


   }

   private static Annotation createAnnotation(final Class<? extends Annotation> annotationType)
   {
      return (Annotation)Proxy.newProxyInstance(annotationType.getClassLoader(), annotationType.getInterfaces(),
         new InvocationHandler()
         {
            public Object invoke(Object proxy, Method method, Object[] args)
            {
               if ("hashCode".equals(method.getName()))
               {
View Full Code Here

            Class completerClass = Class.forName("org.gnu.readline.ReadlineCompleter");

            Method setCompleterMethod = readlineClass.getMethod("setCompleter", new Class[]{completerClass});

            InvocationHandler handler = new NativeCompletionHandler();
            Object completer = Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[]{completerClass}, handler);

            // Setup a completer proxy
            setCompleterMethod.invoke(readlineClass, new Object[]{completer});
        }
View Full Code Here

       * We must temporary remove the method proxy when invoking the
       * invocation handler because if the invocation handler delegates
       * the call we will end up here again and we'll get a
       * StackOverflowError.
       */
      final InvocationHandler invocationHandler = MockRepository.removeMethodProxy(method);
      try {
        returnValue = invocationHandler.invoke(object, method, args);
      } finally {
        // Set the method proxy again after the invocation
        MockRepository.putMethodProxy(method, invocationHandler);
      }

View Full Code Here

            for (PackageDoc p : orig) {
                // wrap the package
                ClassLoader loader = WonderlandDoclet.class.getClassLoader();
                Class<?>[] interfaces = new Class<?>[] { PackageDoc.class };
                InvocationHandler handler = new PackageDocWrapper(p, "ExperimentalAPI");
                PackageDoc pkg =
                        (PackageDoc) Proxy.newProxyInstance(loader, interfaces, handler);
                if (pkg.allClasses().length > 0) {
                    wrapped.add(pkg);
                }
View Full Code Here

      Serializable sessionId = null;

      // If coming from ejb3-proxy-impl
      if (Proxy.isProxyClass(proxy.getClass()))
      {
         InvocationHandler handler = Proxy.getInvocationHandler(proxy);
         assert handler instanceof SessionProxyInvocationHandler : "Requires "
               + SessionProxyInvocationHandler.class.getName();
         SessionProxyInvocationHandler sHandler = (SessionProxyInvocationHandler) handler;
         sessionId = (Serializable) sHandler.getTarget();
      }
View Full Code Here

         {
            // postpone the inevitable
            //ClassLoader cl = AccessController.doPrivileged(currentContextClassLoader());
            ClassLoader cl = Thread.currentThread().getContextClassLoader();
            Class<?> interfaces[] = { Context.class };
            InvocationHandler handler = new InvocationHandler() {
               public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
               {
                  try
                  {
                     if(encFactory == null)
View Full Code Here

      {
         return false;
      }

      // Get the InvocationHandlers
      InvocationHandler proxyHandler = this.getInvocationHandler(proxy);
      InvocationHandler argumentHandler = Proxy.getInvocationHandler(argument);

      // If argument handler is not SLSB Handler
      if (!(argumentHandler instanceof StatelessProxyInvocationHandlerBase))
      {
         return false;
View Full Code Here

   // Internal Helper Methods ------------------------------------------------------||
   // ------------------------------------------------------------------------------||

   protected StatelessProxyInvocationHandlerBase getInvocationHandler(Object proxy)
   {
      InvocationHandler handler = Proxy.getInvocationHandler(proxy);
      assert handler instanceof StatelessProxyInvocationHandlerBase : "Expected "
            + InvocationHandler.class.getSimpleName() + " of type "
            + StatelessProxyInvocationHandlerBase.class.getName() + ", but instead was " + handler;
      return (StatelessProxyInvocationHandlerBase) handler;
   }
View Full Code Here

         }
         return false;
      }

      // Get Invocation Handlers
      InvocationHandler proxyHandler = this.getInvocationHandler(proxy);
      InvocationHandler argumentHandler = Proxy.getInvocationHandler(argument);

      // If argument handler is not SLSB Handler
      if (!(argumentHandler instanceof StatefulProxyInvocationHandlerBase))
      {
         return false;
View Full Code Here

TOP

Related Classes of java.lang.reflect.InvocationHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.