FileDocCategorySizeDatePackage
JavassistProxy.javaAPI DocJBoss 4.2.14108Fri Jul 13 20:53:52 BST 2007org.jboss.ejb3.stateless

JavassistProxy

public class JavassistProxy extends Object implements Serializable
Comment
author
Carlo de Wolf
version
$Revision: 60233 $

Fields Summary
private static final long
serialVersionUID
private MethodHandler
handler
private Class[]
interfaces
Constructors Summary
Methods Summary
protected static voidpokeInterfaces(org.jboss.ejb3.stateless.JavassistProxy proxy, java.lang.Class[] interfaces)
With this method you can directly poke interfaces into the proxy without setting of the method handler.

param
proxy
param
interfaces

   
//   /**
//    * Public because of classloading? 
//    */
//   public static class JavassistProxyReplacement extends JavassistProxy
//   {
//      public void setHandler(MethodHandler handler)
//      {
//         throw new RuntimeException("should never happen");
//      }
//   }
//   
                             
          
      proxy.interfaces = interfaces;
   
private java.lang.ObjectreadResolve()

      System.err.println("JavassistProxy.readResolve");
      try {
         ProxyFactory proxyFactory = new ProxyFactory() {
            protected ClassLoader getClassLoader()
            {
               return Thread.currentThread().getContextClassLoader();
            }
         };
         proxyFactory.setInterfaces(interfaces);
         proxyFactory.setSuperclass(JavassistProxy.class);
         Class proxyClass = proxyFactory.createClass();
         Constructor proxyConstructor = proxyClass.getConstructor((Class[]) null);
         JavassistProxy proxy = (JavassistProxy) proxyConstructor.newInstance((Object[]) null);
         proxy.setMethodHandler(this.handler);
         proxy.interfaces = this.interfaces;
         return proxy;
      }
      catch (NoSuchMethodException e)
      {
         throw new RuntimeException(e);
      }
      catch (InstantiationException e)
      {
         throw new RuntimeException(e);
      }
      catch (IllegalAccessException e)
      {
         throw new RuntimeException(e);
      }
      catch (InvocationTargetException e)
      {
         throw new RuntimeException(e.getTargetException());
      }
   
protected voidsetInterfaces(java.lang.Class[] interfaces)

      // TODO: check whether I get true interfaces
      this.interfaces = interfaces;
   
protected voidsetMethodHandler(javassist.util.proxy.MethodHandler handler)

      // LOL
      ((ProxyObject) this).setHandler(handler);
      this.handler = handler;
   
private java.lang.ObjectwriteReplace()

      System.err.println("JavassistProxy.writeReplace");
      JavassistProxy replacement = new JavassistProxyReplacement();
      replacement.handler = this.handler;
      replacement.interfaces = this.interfaces;
      return replacement;