[webbeans-commits] Webbeans SVN: r3701 - in ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans: builder/sorter and 1 other directory.

webbeans-commits at lists.jboss.org webbeans-commits at lists.jboss.org
Thu Sep 17 16:45:33 EDT 2009


Author: kabir.khan at jboss.com
Date: 2009-09-17 16:45:33 -0400 (Thu, 17 Sep 2009)
New Revision: 3701

Added:
   ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/builder/sorter/ManagedBeanDeploymentItem.java
   ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/builder/sorter/SessionBeanDeploymentItem.java
Removed:
   ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/builder/sorter/EjbDeploymentItem.java
   ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/builder/sorter/SimpleDeploymentItem.java
Modified:
   ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java
   ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/builder/sorter/DecoratorDeploymentItem.java
   ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/builder/sorter/DeploymentItem.java
   ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/builder/sorter/DeploymentSorterAction.java
   ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/builder/sorter/Sorter.java
Log:
Tidy up the Sorter + DeploymentItem hierarchy

Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java	2009-09-17 18:34:45 UTC (rev 3700)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java	2009-09-17 20:45:33 UTC (rev 3701)
@@ -31,8 +31,8 @@
 import org.jboss.webbeans.builder.sorter.DecoratorDeploymentItem;
 import org.jboss.webbeans.builder.sorter.DeploymentItem;
 import org.jboss.webbeans.builder.sorter.DeploymentSorterAction;
-import org.jboss.webbeans.builder.sorter.EjbDeploymentItem;
-import org.jboss.webbeans.builder.sorter.SimpleDeploymentItem;
+import org.jboss.webbeans.builder.sorter.SessionBeanDeploymentItem;
+import org.jboss.webbeans.builder.sorter.ManagedBeanDeploymentItem;
 import org.jboss.webbeans.builder.sorter.Sorter;
 import org.jboss.webbeans.ejb.EjbDescriptors;
 import org.jboss.webbeans.event.ObserverMethodImpl;
@@ -142,12 +142,12 @@
    
    private class DeploymentItemDeployerAction implements DeploymentSorterAction
    {
-      public Object execute(EjbDeploymentItem<?> deploymentItem)
+      public Object execute(SessionBeanDeploymentItem<?> deploymentItem)
       {
          return deployBean(deploymentItem);
       }
 
-      public Object execute(SimpleDeploymentItem<?> deploymentItem)
+      public Object execute(ManagedBeanDeploymentItem<?> deploymentItem)
       {
          return deployBean(deploymentItem);
       }

Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/builder/sorter/DecoratorDeploymentItem.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/builder/sorter/DecoratorDeploymentItem.java	2009-09-17 18:34:45 UTC (rev 3700)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/builder/sorter/DecoratorDeploymentItem.java	2009-09-17 20:45:33 UTC (rev 3701)
@@ -21,7 +21,6 @@
 */ 
 package org.jboss.webbeans.builder.sorter;
 
-import java.util.Collections;
 import java.util.HashSet;
 import java.util.Set;
 
@@ -41,15 +40,14 @@
  */
 public class DecoratorDeploymentItem<T> extends DeploymentItem<T>
 {
-   DecoratorDeploymentItem(Set<DeploymentItem<?>> allItems, WBClass<T> clazz)
+   private DecoratorDeploymentItem(WBClass<T> clazz)
    {
-      super(allItems, clazz);
+      super(clazz);
    }
-
-   @Override
-   DeploymentItem<T> getSuperClassDependency()
+   
+   static <T> DecoratorDeploymentItem<T> createItem(WBClass<T> clazz)
    {
-      return null;
+      return new DecoratorDeploymentItem<T>(clazz);
    }
 
    @Override

Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/builder/sorter/DeploymentItem.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/builder/sorter/DeploymentItem.java	2009-09-17 18:34:45 UTC (rev 3700)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/builder/sorter/DeploymentItem.java	2009-09-17 20:45:33 UTC (rev 3701)
@@ -21,12 +21,9 @@
 */ 
 package org.jboss.webbeans.builder.sorter;
 
-import java.util.ArrayList;
 import java.util.Collections;
-import java.util.List;
 import java.util.Set;
 
-import javax.enterprise.inject.Produces;
 import javax.enterprise.inject.Specializes;
 import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.ObserverMethod;
@@ -34,7 +31,6 @@
 import org.jboss.webbeans.BeanManagerImpl;
 import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
 import org.jboss.webbeans.introspector.WBClass;
-import org.jboss.webbeans.introspector.WBMethod;
 
 /**
  * 
@@ -43,12 +39,6 @@
  */
 public abstract class DeploymentItem<T>
 {
-   private final Set<DeploymentItem<?>> allItems;
-   
-   private boolean initialized;
-   
-   private List<DeploymentItem<?>> dependencies = Collections.emptyList();
-   
    private WBClass<T> clazz;
 
    private volatile int hashCode;
@@ -60,74 +50,16 @@
    
    Set<ObserverMethod<T, ?>> observers;
    
-   DeploymentItem(Set<DeploymentItem<?>> allItems, WBClass<T> clazz)
+   DeploymentItem(WBClass<T> clazz)
    {
-      this.allItems = allItems;
       this.clazz = clazz;
    }
 
-   void initialize()
-   {
-      if (!initialized)
-      {
-         if (isSpecializing())
-         {
-            addDependency(getSuperClassDependency());
-         }
-         else
-         {
-            Set<WBMethod<?, ?>> producerMethods = getWBClass().getDeclaredWBAnnotatedMethods(Produces.class);
-            if (!producerMethods.isEmpty())
-            {
-               for (WBMethod<?, ?> producerMethod : producerMethods)
-               {
-                  if (producerMethod.getAnnotation(Specializes.class) != null)
-                  {
-                     addDependency(getSuperClassDependency());
-                     break;
-                  }
-               }
-            }
-         }
-            
-         initialized = true;
-      }
-   }
-   
-   
-   
-   void addDependency(DeploymentItem<?> dependency)
-   {
-      if (dependencies == Collections.EMPTY_LIST)
-         dependencies = new ArrayList<DeploymentItem<?>>();
-      
-      dependencies.add(dependency);
-   }
-   
-   
-   <X> DeploymentItem<X> findDeploymentItem(DeploymentItem<X> item)
-   {
-      for (DeploymentItem<?> candidate : allItems)
-      {
-         if (candidate.equals(item))
-            return (DeploymentItem<X>)candidate;
-      }
-      return null;
-   }
-   
-   abstract DeploymentItem<? super T> getSuperClassDependency();
-   
    public WBClass<T> getWBClass()
    {
       return clazz;
    }
    
-   List<DeploymentItem<?>> getDependencies()
-   {
-      initialize();
-      return dependencies;
-   }
-   
    boolean isSpecializing()
    {
       return clazz.isAnnotationPresent(Specializes.class);

Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/builder/sorter/DeploymentSorterAction.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/builder/sorter/DeploymentSorterAction.java	2009-09-17 18:34:45 UTC (rev 3700)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/builder/sorter/DeploymentSorterAction.java	2009-09-17 20:45:33 UTC (rev 3701)
@@ -28,9 +28,9 @@
  */
 public interface DeploymentSorterAction
 {
-   Object execute(EjbDeploymentItem<?> deploymentItem);
+   Object execute(SessionBeanDeploymentItem<?> deploymentItem);
    
-   Object execute(SimpleDeploymentItem<?> deploymentItem);
+   Object execute(ManagedBeanDeploymentItem<?> deploymentItem);
    
    Object execute(DecoratorDeploymentItem<?> deploymentItem);
 }

Deleted: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/builder/sorter/EjbDeploymentItem.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/builder/sorter/EjbDeploymentItem.java	2009-09-17 18:34:45 UTC (rev 3700)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/builder/sorter/EjbDeploymentItem.java	2009-09-17 20:45:33 UTC (rev 3701)
@@ -1,93 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source.
-* Copyright 2006, Red Hat Middleware LLC, and individual contributors
-* as indicated by the @author tags. See the copyright.txt file in the
-* distribution for a full listing of individual contributors. 
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/ 
-package org.jboss.webbeans.builder.sorter;
-
-import java.util.Collections;
-import java.util.Set;
-
-import javax.enterprise.inject.spi.Bean;
-import javax.enterprise.inject.spi.ObserverMethod;
-
-import org.jboss.webbeans.BeanManagerImpl;
-import org.jboss.webbeans.DefinitionException;
-import org.jboss.webbeans.bean.builder.spi.BeanBuilderFactory;
-import org.jboss.webbeans.bean.builder.spi.EnterpriseBeanBuilder;
-import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
-import org.jboss.webbeans.ejb.EjbDescriptors;
-import org.jboss.webbeans.ejb.InternalEjbDescriptor;
-import org.jboss.webbeans.introspector.WBClass;
-
-/**
- * 
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision: 1.1 $
- */
-public class EjbDeploymentItem<T> extends DeploymentItem<T>
-{
-   private InternalEjbDescriptor<T> ejbDescriptor;
-   private EjbDescriptors allDescriptors;
-   
-   private Set<Bean<?>> beans;
-   private ObserverMethod<T, ?> observerMethods;
-   
-   EjbDeploymentItem(Set<DeploymentItem<?>> allItems, EjbDescriptors allDescriptors, WBClass<T> clazz, InternalEjbDescriptor<T> ejbDescriptor)
-   {
-      super(allItems, clazz);
-      this.ejbDescriptor = ejbDescriptor;
-      this.allDescriptors = allDescriptors;
-   }
-
-   DeploymentItem<? super T> getSuperClassDependency()
-   {
-      //This needs revisiting
-      Class<?> superClass = getWBClass().getWBSuperclass().getJavaClass();
-      for (InternalEjbDescriptor<?> ejb : allDescriptors)
-      {
-         if (ejb.getBeanClass().equals(superClass))
-         {
-            @SuppressWarnings("unchecked")
-            DeploymentItem<? super T> item = new EjbDeploymentItem(null, null, getWBClass().getWBSuperclass(), ejb);
-            DeploymentItem<? super T> found = findDeploymentItem(item);
-            if (found == null || found instanceof EjbDeploymentItem == false)
-            {
-               throw new DefinitionException(toString() + " annotation defined specializing EJB must have EJB superclass " + ejbDescriptor.getEjbName() + "(" + ejbDescriptor.getBeanClass() + ")");
-            }
-            return found;
-         }
-      }
-            
-      throw new DefinitionException(toString() + " does not specialize an EJB " + ejbDescriptor.getEjbName() + "(" + ejbDescriptor.getBeanClass() + ")");
-   }
-
-   @Override
-   public void initialiseBeans(BeanManagerImpl manager, BeanDeployerEnvironment environment)
-   {
-      EnterpriseBeanBuilder<T> builder = BeanBuilderFactory.getInstance().getEnterpriseBeanBuilder(manager, ejbDescriptor);
-      setValues(builder.getBeans(), builder.getObserverMethods());
-   }
-
-   @Override
-   public void executeAction(DeploymentSorterAction action)
-   {
-      action.execute(this);
-   }
-}

Copied: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/builder/sorter/ManagedBeanDeploymentItem.java (from rev 3698, ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/builder/sorter/SimpleDeploymentItem.java)
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/builder/sorter/ManagedBeanDeploymentItem.java	                        (rev 0)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/builder/sorter/ManagedBeanDeploymentItem.java	2009-09-17 20:45:33 UTC (rev 3701)
@@ -0,0 +1,71 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors. 
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/ 
+package org.jboss.webbeans.builder.sorter;
+
+import org.jboss.webbeans.BeanManagerImpl;
+import org.jboss.webbeans.DefinitionException;
+import org.jboss.webbeans.bean.builder.spi.BeanBuilderFactory;
+import org.jboss.webbeans.bean.builder.spi.SimpleBeanBuilder;
+import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
+import org.jboss.webbeans.introspector.WBClass;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ManagedBeanDeploymentItem<T> extends ClassBeanDeploymentItem<T>
+{
+   private ManagedBeanDeploymentItem(Sorter sorter, WBClass<T> clazz)
+   {
+      super(sorter, clazz);
+   }
+
+   static <T> ManagedBeanDeploymentItem<T> createItem(Sorter sorter,  WBClass<T> clazz)
+   {
+      return new ManagedBeanDeploymentItem<T>(sorter, clazz);
+   }
+   
+   ClassBeanDeploymentItem<? super T> getSuperClassDependency()
+   {
+      ClassBeanDeploymentItem<? super T> found = findDeploymentItem(getWBClass().getWBSuperclass());
+      if (found == null || found instanceof ManagedBeanDeploymentItem == false)
+      {
+         throw new DefinitionException("Simple bean must specialize a simple bean " + getWBClass());
+      }
+
+      return found;
+   }
+
+   @Override
+   public void initialiseBeans(BeanManagerImpl manager, BeanDeployerEnvironment environment)
+   {
+      SimpleBeanBuilder<T> builder = BeanBuilderFactory.getInstance().getSimpleBeanBuilder(manager, getWBClass());
+      setValues(builder.getBeans(), builder.getObserverMethods());
+   }
+
+   @Override
+   public void executeAction(DeploymentSorterAction action)
+   {
+      action.execute(this);
+   }
+}

Copied: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/builder/sorter/SessionBeanDeploymentItem.java (from rev 3698, ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/builder/sorter/EjbDeploymentItem.java)
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/builder/sorter/SessionBeanDeploymentItem.java	                        (rev 0)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/builder/sorter/SessionBeanDeploymentItem.java	2009-09-17 20:45:33 UTC (rev 3701)
@@ -0,0 +1,78 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors. 
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/ 
+package org.jboss.webbeans.builder.sorter;
+
+import org.jboss.webbeans.BeanManagerImpl;
+import org.jboss.webbeans.Container;
+import org.jboss.webbeans.DefinitionException;
+import org.jboss.webbeans.bean.builder.spi.BeanBuilderFactory;
+import org.jboss.webbeans.bean.builder.spi.EnterpriseBeanBuilder;
+import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
+import org.jboss.webbeans.ejb.InternalEjbDescriptor;
+import org.jboss.webbeans.introspector.WBClass;
+import org.jboss.webbeans.resources.ClassTransformer;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class SessionBeanDeploymentItem<T> extends ClassBeanDeploymentItem<T>
+{
+   private InternalEjbDescriptor<T> ejbDescriptor;
+   
+   private static final ClassTransformer classTransformer = Container.instance().deploymentServices().get(ClassTransformer.class);
+   
+   private SessionBeanDeploymentItem(Sorter sorter, WBClass<T> clazz, InternalEjbDescriptor<T> ejbDescriptor)
+   {
+      super(sorter, clazz);
+      this.ejbDescriptor = ejbDescriptor;
+   }
+
+   static <T> SessionBeanDeploymentItem<T> createItem(Sorter sorter, InternalEjbDescriptor<T> ejbDescriptor)
+   {
+      return new SessionBeanDeploymentItem<T>(sorter, classTransformer.loadClass(ejbDescriptor.getBeanClass()), ejbDescriptor);
+   }
+   
+   ClassBeanDeploymentItem<? super T> getSuperClassDependency()
+   {
+      ClassBeanDeploymentItem<? super T> found = findDeploymentItem(getWBClass().getWBSuperclass());
+      if (found == null || found instanceof SessionBeanDeploymentItem == false)
+      {
+         throw new DefinitionException(toString() + " annotation defined specializing EJB must have EJB superclass " + ejbDescriptor.getEjbName() + "(" + ejbDescriptor.getBeanClass() + ")");
+      }
+      return found;
+   }
+
+   @Override
+   public void initialiseBeans(BeanManagerImpl manager, BeanDeployerEnvironment environment)
+   {
+      EnterpriseBeanBuilder<T> builder = BeanBuilderFactory.getInstance().getEnterpriseBeanBuilder(manager, ejbDescriptor);
+      setValues(builder.getBeans(), builder.getObserverMethods());
+   }
+
+   @Override
+   public void executeAction(DeploymentSorterAction action)
+   {
+      action.execute(this);
+   }
+}

Deleted: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/builder/sorter/SimpleDeploymentItem.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/builder/sorter/SimpleDeploymentItem.java	2009-09-17 18:34:45 UTC (rev 3700)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/builder/sorter/SimpleDeploymentItem.java	2009-09-17 20:45:33 UTC (rev 3701)
@@ -1,69 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source.
-* Copyright 2006, Red Hat Middleware LLC, and individual contributors
-* as indicated by the @author tags. See the copyright.txt file in the
-* distribution for a full listing of individual contributors. 
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/ 
-package org.jboss.webbeans.builder.sorter;
-
-import java.util.Set;
-
-import org.jboss.webbeans.BeanManagerImpl;
-import org.jboss.webbeans.DefinitionException;
-import org.jboss.webbeans.bean.builder.spi.BeanBuilderFactory;
-import org.jboss.webbeans.bean.builder.spi.SimpleBeanBuilder;
-import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
-import org.jboss.webbeans.introspector.WBClass;
-
-/**
- * 
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision: 1.1 $
- */
-public class SimpleDeploymentItem<T> extends DeploymentItem<T>
-{
-   SimpleDeploymentItem(Set<DeploymentItem<?>> allItems, WBClass<T> clazz)
-   {
-      super(allItems, clazz);
-   }
-
-   DeploymentItem<? super T> getSuperClassDependency()
-   {
-      DeploymentItem<? super T> item = new SimpleDeploymentItem(null, getWBClass().getWBSuperclass());
-      DeploymentItem<? super T> found = findDeploymentItem(item);
-      if (found == null || found instanceof SimpleDeploymentItem == false)
-      {
-         throw new DefinitionException("Simple bean must specialize a simple bean " + getWBClass());
-      }
-
-      return found;
-   }
-
-   @Override
-   public void initialiseBeans(BeanManagerImpl manager, BeanDeployerEnvironment environment)
-   {
-      SimpleBeanBuilder<T> builder = BeanBuilderFactory.getInstance().getSimpleBeanBuilder(manager, getWBClass());
-      setValues(builder.getBeans(), builder.getObserverMethods());
-   }
-
-   @Override
-   public void executeAction(DeploymentSorterAction action)
-   {
-      action.execute(this);
-   }
-}

Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/builder/sorter/Sorter.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/builder/sorter/Sorter.java	2009-09-17 18:34:45 UTC (rev 3700)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/builder/sorter/Sorter.java	2009-09-17 20:45:33 UTC (rev 3701)
@@ -22,9 +22,8 @@
 package org.jboss.webbeans.builder.sorter;
 
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.HashSet;
-import java.util.LinkedHashSet;
+import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Set;
 
@@ -38,7 +37,6 @@
 import org.jboss.webbeans.ejb.InternalEjbDescriptor;
 import org.jboss.webbeans.introspector.WBClass;
 import org.jboss.webbeans.jsf.JsfApiAbstraction;
-import org.jboss.webbeans.resources.ClassTransformer;
 import org.jboss.webbeans.servlet.ServletApiAbstraction;
 import org.jboss.webbeans.util.Reflections;
 
@@ -53,8 +51,6 @@
    
    private final EjbDescriptors ejbDescriptors;
 
-   private final ClassTransformer classTransformer;
-   
    private final EJBApiAbstraction ejbApiAbstraction;
    
    private final JsfApiAbstraction jsfApiAbstraction;
@@ -63,17 +59,16 @@
    
    private final List<DeploymentItem<?>> decoratorItems = new ArrayList<DeploymentItem<?>>();
    
-   private final LinkedHashSet<DeploymentItem<?>> unsortedItems = new LinkedHashSet<DeploymentItem<?>>();
+   private final LinkedHashMap<WBClass<?>, ClassBeanDeploymentItem<?>> unsortedClassBeanItems = new LinkedHashMap<WBClass<?>, ClassBeanDeploymentItem<?>>();
 
    private final List<DeploymentItem<?>> sortedItems = new ArrayList<DeploymentItem<?>>();
    
    private final List<DeploymentItem<?>> visitedItems = new ArrayList<DeploymentItem<?>>();
    
-   private Sorter(Set<WBClass<?>> classes, EjbDescriptors ejbDescriptors, ClassTransformer classTransformer,
+   private Sorter(Set<WBClass<?>> classes, EjbDescriptors ejbDescriptors, 
          EJBApiAbstraction ejbApiAbstraction, JsfApiAbstraction jsfApiAbstraction, ServletApiAbstraction servletApiAbstraction)
    {
       this.classes = classes;
-      this.classTransformer = classTransformer;
       this.ejbDescriptors = ejbDescriptors;
       this.ejbApiAbstraction = ejbApiAbstraction;
       this.jsfApiAbstraction = jsfApiAbstraction;
@@ -82,18 +77,17 @@
    
    public static Sorter createSorter(BeanManagerImpl beanManager, Set<WBClass<?>> classes, EjbDescriptors ejbDescriptors)
    {
-      ClassTransformer classTransformer = beanManager.getServices().get(ClassTransformer.class);
       EJBApiAbstraction ejbApiAbstraction = beanManager.getServices().get(EJBApiAbstraction.class);
       JsfApiAbstraction jsfApiAbstraction = beanManager.getServices().get(JsfApiAbstraction.class);
       ServletApiAbstraction servletApiAbstraction = beanManager.getServices().get(ServletApiAbstraction.class);
 
-      Sorter sorter = new Sorter(classes, ejbDescriptors, classTransformer, ejbApiAbstraction, jsfApiAbstraction, servletApiAbstraction);
-      sorter.createDeploymentItems();
+      Sorter sorter = new Sorter(classes, ejbDescriptors, ejbApiAbstraction, jsfApiAbstraction, servletApiAbstraction);
+      sorter.initialiseDeploymentItems();
       
       return sorter;
    }
    
-   private void createDeploymentItems()
+   private void initialiseDeploymentItems()
    {
       for (WBClass<?> clazz : classes)
       {
@@ -102,7 +96,7 @@
          {
             if (clazz.isAnnotationPresent(Decorator.class))
             {
-               decoratorItems.add(new DecoratorDeploymentItem(Collections.unmodifiableSet(unsortedItems), clazz));
+               decoratorItems.add(DecoratorDeploymentItem.createItem(clazz));
             }
             else if (clazz.isAnnotationPresent(Interceptor.class))
             {
@@ -110,24 +104,23 @@
             }
             else if (!clazz.isAbstract())
             {
-               unsortedItems.add(new SimpleDeploymentItem(Collections.unmodifiableSet(unsortedItems), clazz));
+               unsortedClassBeanItems.put(clazz, ManagedBeanDeploymentItem.createItem(this, clazz));
             }
          }
       }
       for (InternalEjbDescriptor<?> ejb : ejbDescriptors)
       {
-         WBClass<?> clazz = classTransformer.loadClass(ejb.getBeanClass());
-         unsortedItems.add(new EjbDeploymentItem(Collections.unmodifiableSet(unsortedItems), ejbDescriptors, clazz, ejb));
+         SessionBeanDeploymentItem<?> item = SessionBeanDeploymentItem.createItem(this, ejb);
+         unsortedClassBeanItems.put(item.getWBClass(), item);
       }
    }
    
    public List<DeploymentItem<?>> sort()
    {
       //No need to sort the disposal method beans anymore since the disposal method must be in the same bean 
-      
-      for (DeploymentItem<?> item : unsortedItems)
+      for (ClassBeanDeploymentItem<?> item : unsortedClassBeanItems.values())
       {
-         Set<DeploymentItem<?>> cycles = new HashSet<DeploymentItem<?>>();
+         Set<ClassBeanDeploymentItem<?>> cycles = new HashSet<ClassBeanDeploymentItem<?>>();
          visit(item, cycles);
       }
       
@@ -138,7 +131,7 @@
       return result;
    }
    
-   private void visit(DeploymentItem<?> item, Set<DeploymentItem<?>> cycles)
+   private void visit(ClassBeanDeploymentItem<?> item, Set<ClassBeanDeploymentItem<?>> cycles)
    {
       if (cycles.contains(item))
          throw new RuntimeException("Cycle for " + item);
@@ -148,7 +141,7 @@
       {
          visitedItems.add(item);
          
-         for (DeploymentItem<?> dependencyItem : item.getDependencies())
+         for (ClassBeanDeploymentItem<?> dependencyItem : item.getDependencies())
          {
             visit(dependencyItem, cycles);
          }
@@ -184,4 +177,9 @@
       //FIXME duplicates AbstractBeanDeployer.hasSimpleWebBeanConstructor() - extract utility method
       return type.getNoArgsWBConstructor() != null || type.getAnnotatedWBConstructors(Inject.class).size() > 0;
    }
+   
+   <T> ClassBeanDeploymentItem<T> findDeploymentItem(WBClass<?> clazz)
+   {
+      return (ClassBeanDeploymentItem<T>)unsortedClassBeanItems.get(clazz);
+   }
 }




More information about the weld-commits mailing list