[jboss-cvs] jboss-seam/src/main/org/jboss/seam ...

Gavin King gavin.king at jboss.com
Mon Mar 5 23:35:45 EST 2007


  User: gavin   
  Date: 07/03/05 23:35:45

  Modified:    src/main/org/jboss/seam  Component.java
  Log:
  JBSEAM-989
  
  Revision  Changes    Path
  1.243     +26 -23    jboss-seam/src/main/org/jboss/seam/Component.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Component.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/Component.java,v
  retrieving revision 1.242
  retrieving revision 1.243
  diff -u -b -r1.242 -r1.243
  --- Component.java	3 Mar 2007 18:22:41 -0000	1.242
  +++ Component.java	6 Mar 2007 04:35:45 -0000	1.243
  @@ -45,13 +45,14 @@
   import java.util.Set;
   import java.util.StringTokenizer;
   
  +import javassist.util.proxy.MethodFilter;
  +import javassist.util.proxy.MethodHandler;
  +import javassist.util.proxy.ProxyFactory;
  +import javassist.util.proxy.ProxyObject;
  +
   import javax.naming.NamingException;
   import javax.servlet.http.HttpSessionActivationListener;
   
  -import net.sf.cglib.proxy.Enhancer;
  -import net.sf.cglib.proxy.Factory;
  -import net.sf.cglib.proxy.MethodInterceptor;
  -
   import org.jboss.seam.annotations.Asynchronous;
   import org.jboss.seam.annotations.Begin;
   import org.jboss.seam.annotations.BeginTask;
  @@ -177,7 +178,7 @@
      private List<Field> logFields = new ArrayList<Field>();
      private List<org.jboss.seam.log.Log> logInstances = new ArrayList<org.jboss.seam.log.Log>();
   
  -   private Class<Factory> factory;
  +   private Class<ProxyObject> factory;
   
      //only used for tests
      public Component(Class<?> clazz)
  @@ -1139,14 +1140,14 @@
      /**
       * Wrap a CGLIB interceptor around an instance of the component
       */
  -   public Object wrap(Object bean, MethodInterceptor interceptor) throws Exception
  +   public Object wrap(Object bean, MethodHandler interceptor) throws Exception
      {
  -      Factory proxy = getProxyFactory().newInstance();
  -      proxy.setCallback(0, interceptor);
  +      ProxyObject proxy = getProxyFactory().newInstance();
  +      proxy.setHandler(interceptor);
         return proxy;
      }
   
  -   private synchronized Class<Factory> getProxyFactory()
  +   private synchronized Class<ProxyObject> getProxyFactory()
      {
         if (factory==null)
         {
  @@ -1957,19 +1958,8 @@
         return "Component(" + name + ")";
      }
   
  -   public static Class<Factory> createProxyFactory(ComponentType type, final Class beanClass, Collection<Class> businessInterfaces)
  -   {
  -      Enhancer en = new Enhancer();
  -      en.setUseCache(false);
  -      en.setInterceptDuringConstruction(false);
  -      en.setCallbackType(MethodInterceptor.class);
  -      en.setSuperclass( type==JAVA_BEAN ? beanClass : Object.class );
  -      /*en.setNamingPolicy( new NamingPolicy() {
  -         public String getClassName(String prefix, String source, Object key, Predicate names)
  +   public static Class<ProxyObject> createProxyFactory(ComponentType type, final Class beanClass, Collection<Class> businessInterfaces)
            {
  -            return beanClass.getName() + "SeamProxy";
  -         }
  -      });*/
         Set<Class> interfaces = new HashSet<Class>();
         if ( type.isSessionBean() )
         {
  @@ -1981,9 +1971,22 @@
            interfaces.add(Mutable.class);
         }
         interfaces.add(Proxy.class);
  -      en.setInterfaces( interfaces.toArray( new Class[0] ) );
  -      return en.createClass();
  +
  +      ProxyFactory factory = new ProxyFactory();
  +      factory.setSuperclass( type==JAVA_BEAN ? beanClass : Object.class );
  +      factory.setInterfaces( interfaces.toArray( new Class[0] ) );
  +      factory.setFilter(FINALIZE_FILTER);
  +      return factory.createClass();
  +   }
  +
  +   private static final MethodFilter FINALIZE_FILTER = new MethodFilter() 
  +   {
  +      public boolean isHandled(Method method) 
  +      {
  +         // skip finalize methods
  +         return method.getParameterTypes().length!=0 || !method.getName().equals( "finalize" );
      }
  +   };
   
      public InterceptionType getInterceptionType()
      {
  
  
  



More information about the jboss-cvs-commits mailing list