[webbeans-commits] Webbeans SVN: r3668 - in ri/branches/kabir-builder: api/src/main/java/javax/enterprise/inject/spi and 18 other directories.

webbeans-commits at lists.jboss.org webbeans-commits at lists.jboss.org
Tue Sep 15 09:31:17 EDT 2009


Author: kabir.khan at jboss.com
Date: 2009-09-15 09:31:15 -0400 (Tue, 15 Sep 2009)
New Revision: 3668

Added:
   ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/DecoratorImpl.java
   ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/DisposalMethod.java
   ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/ManagedBean.java
   ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/NewManagedBean.java
   ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/NewSessionBean.java
   ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/ProducerField.java
   ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethod.java
   ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/SessionBean.java
   ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/ee/
   ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/ee/EEResourceProducerField.java
   ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/ee/PersistenceContextProducerField.java
   ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/ws/
   ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/ws/WSApiAbstraction.java
Removed:
   ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/DecoratorBean.java
   ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/DisposalMethodBean.java
   ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java
   ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/NewEnterpriseBean.java
   ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/NewSimpleBean.java
   ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/ProducerFieldBean.java
   ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java
   ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
   ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/ee/EEResourceProducerField.java
   ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/ee/PersistenceContextProducerField.java
   ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/ws/WSApiAbstraction.java
Modified:
   ri/branches/kabir-builder/
   ri/branches/kabir-builder/api/src/main/java/javax/enterprise/inject/spi/BeanManager.java
   ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java
   ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/Validator.java
   ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java
   ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/BeanBuilderImpl.java
   ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/proxy/DecoratorProxyMethodHandler.java
   ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanInstance.java
   ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanProxyMethodHandler.java
   ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bootstrap/AbstractBeanDeployer.java
   ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployerEnvironment.java
   ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java
   ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/resolution/TypeSafeDecoratorResolver.java
   ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/resolution/TypeSafeDisposerResolver.java
   ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/util/Beans.java
   ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/multipleEnterprise/BootstrapTest.java
   ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/multipleEnterpriseAndSimple/BootstrapTest.java
   ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/multipleSimple/BootstrapTest.java
   ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/singleProducerMethod/BootstrapTest.java
   ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/deployment/structure/AccessibleManagerResolutionTest.java
   ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/ServletEnvironmentTest.java
   ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/NewEnterpriseBeanTest.java
   ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/newsimple/NewSimpleBeanTest.java
   ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/manager/EjbDescriptorLookupTest.java
Log:
Merged revisions 3659,3661,3663 via svnmerge from 
https://svn.jboss.org/repos/webbeans/ri/trunk

.......
  r3659 | pete.muir at jboss.org | 2009-09-14 12:39:54 +0100 (Mon, 14 Sep 2009) | 1 line
  
  Rename classes to reflect new spec names
.......
  r3661 | pete.muir at jboss.org | 2009-09-14 16:46:43 +0100 (Mon, 14 Sep 2009) | 1 line
  
  WBRI-377
.......
  r3663 | pete.muir at jboss.org | 2009-09-14 18:57:21 +0100 (Mon, 14 Sep 2009) | 1 line
  
  Add wrapExpressionFactory
.......



Property changes on: ri/branches/kabir-builder
___________________________________________________________________
Name: svnmerge-integrated
   - /ri/trunk:1-3656
   + /ri/trunk:1-3665

Modified: ri/branches/kabir-builder/api/src/main/java/javax/enterprise/inject/spi/BeanManager.java
===================================================================
--- ri/branches/kabir-builder/api/src/main/java/javax/enterprise/inject/spi/BeanManager.java	2009-09-15 13:02:01 UTC (rev 3667)
+++ ri/branches/kabir-builder/api/src/main/java/javax/enterprise/inject/spi/BeanManager.java	2009-09-15 13:31:15 UTC (rev 3668)
@@ -23,6 +23,7 @@
 import java.util.Set;
 
 import javax.el.ELResolver;
+import javax.el.ExpressionFactory;
 import javax.enterprise.context.ContextNotActiveException;
 import javax.enterprise.context.spi.Context;
 import javax.enterprise.context.spi.Contextual;
@@ -261,6 +262,14 @@
    public ELResolver getELResolver();
    
    /**
+    * Returns an ExpressionFactory 
+    * 
+    * @param expressionFactory
+    * @return
+    */
+   public ExpressionFactory wrapExpressionFactory(ExpressionFactory expressionFactory);
+   
+   /**
     * Get an {@link AnnotatedType} for the given class
     * @param <T> the type
     * @param type the type

Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java	2009-09-15 13:02:01 UTC (rev 3667)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java	2009-09-15 13:31:15 UTC (rev 3668)
@@ -38,6 +38,7 @@
 import java.util.concurrent.atomic.AtomicInteger;
 
 import javax.el.ELResolver;
+import javax.el.ExpressionFactory;
 import javax.enterprise.context.ContextNotActiveException;
 import javax.enterprise.context.spi.Context;
 import javax.enterprise.context.spi.Contextual;
@@ -56,9 +57,9 @@
 import javax.enterprise.inject.spi.ObserverMethod;
 import javax.inject.Qualifier;
 
-import org.jboss.webbeans.bean.DecoratorBean;
-import org.jboss.webbeans.bean.EnterpriseBean;
+import org.jboss.webbeans.bean.DecoratorImpl;
 import org.jboss.webbeans.bean.RIBean;
+import org.jboss.webbeans.bean.SessionBean;
 import org.jboss.webbeans.bean.proxy.ClientProxyProvider;
 import org.jboss.webbeans.bootstrap.api.ServiceRegistry;
 import org.jboss.webbeans.context.CreationalContextImpl;
@@ -67,6 +68,7 @@
 import org.jboss.webbeans.ejb.spi.EjbDescriptor;
 import org.jboss.webbeans.el.Namespace;
 import org.jboss.webbeans.el.WebBeansELResolver;
+import org.jboss.webbeans.el.WebBeansExpressionFactory;
 import org.jboss.webbeans.introspector.WBAnnotated;
 import org.jboss.webbeans.literal.AnyLiteral;
 import org.jboss.webbeans.literal.DefaultLiteral;
@@ -185,7 +187,7 @@
    private transient final Map<String, RIBean<?>> riBeans;
    
    // TODO review this structure
-   private transient final Map<EjbDescriptor<?>, EnterpriseBean<?>> enterpriseBeans;
+   private transient final Map<EjbDescriptor<?>, SessionBean<?>> enterpriseBeans;
    
    // TODO This isn't right, specialization should follow accessibility rules, but I think we can enforce these in resolve()
    private transient final Map<Contextual<?>, Contextual<?>> specializedBeans;
@@ -215,7 +217,7 @@
     * archives
     */
    private transient final TypeSafeBeanResolver<Bean<?>> beanResolver;
-   private transient final TypeSafeResolver<DecoratorBean<?>> decoratorResolver;
+   private transient final TypeSafeResolver<DecoratorImpl<?>> decoratorResolver;
    private transient final TypeSafeResolver<ObserverMethod<?,?>> observerResolver;
    private transient final NameBasedResolver nameBasedResolver;
    private transient final ELResolver webbeansELResolver;
@@ -231,7 +233,7 @@
     * observers deployed in this bean deployment archive activity
     */
    private transient final List<Bean<?>> beans;
-   private transient final List<DecoratorBean<?>> decorators;
+   private transient final List<DecoratorImpl<?>> decorators;
    private transient final List<String> namespaces;
    private transient final List<ObserverMethod<?,?>> observers;
    
@@ -276,10 +278,10 @@
       return new BeanManagerImpl(
             serviceRegistry, 
             new CopyOnWriteArrayList<Bean<?>>(),
-            new CopyOnWriteArrayList<DecoratorBean<?>>(),
+            new CopyOnWriteArrayList<DecoratorImpl<?>>(),
             new CopyOnWriteArrayList<ObserverMethod<?,?>>(),
             new CopyOnWriteArrayList<String>(),
-            new ConcurrentHashMap<EjbDescriptor<?>, EnterpriseBean<?>>(),
+            new ConcurrentHashMap<EjbDescriptor<?>, SessionBean<?>>(),
             new ConcurrentHashMap<String, RIBean<?>>(),
             new ClientProxyProvider(),
             contexts, 
@@ -302,7 +304,7 @@
       return new BeanManagerImpl(
             services, 
             new CopyOnWriteArrayList<Bean<?>>(),
-            new CopyOnWriteArrayList<DecoratorBean<?>>(),
+            new CopyOnWriteArrayList<DecoratorImpl<?>>(),
             new CopyOnWriteArrayList<ObserverMethod<?,?>>(),
             new CopyOnWriteArrayList<String>(),
             rootManager.getEnterpriseBeans(),
@@ -360,10 +362,10 @@
    private BeanManagerImpl(
          ServiceRegistry serviceRegistry, 
          List<Bean<?>> beans, 
-         List<DecoratorBean<?>> decorators, 
+         List<DecoratorImpl<?>> decorators, 
          List<ObserverMethod<?,?>> observers, 
          List<String> namespaces,
-         Map<EjbDescriptor<?>, EnterpriseBean<?>> enterpriseBeans, 
+         Map<EjbDescriptor<?>, SessionBean<?>> enterpriseBeans, 
          Map<String, RIBean<?>> riBeans, 
          ClientProxyProvider clientProxyProvider, 
          ListMultimap<Class<? extends Annotation>, Context> contexts, 
@@ -473,10 +475,10 @@
          
       };
       
-      public static Transform<DecoratorBean<?>> DECORATOR_BEAN = new Transform<DecoratorBean<?>>()
+      public static Transform<DecoratorImpl<?>> DECORATOR_BEAN = new Transform<DecoratorImpl<?>>()
       {
 
-         public Iterable<DecoratorBean<?>> transform(BeanManagerImpl beanManager)
+         public Iterable<DecoratorImpl<?>> transform(BeanManagerImpl beanManager)
          {
             return beanManager.getDecorators();
          }
@@ -524,9 +526,9 @@
       {
          return;
       }
-      if (bean.getClass().equals(EnterpriseBean.class))
+      if (bean.getClass().equals(SessionBean.class))
       {
-         EnterpriseBean<?> enterpriseBean = (EnterpriseBean<?>) bean;
+         SessionBean<?> enterpriseBean = (SessionBean<?>) bean;
          enterpriseBeans.put(enterpriseBean.getEjbDescriptor(), enterpriseBean);
       }
       if (bean instanceof RIBean<?>)
@@ -543,7 +545,7 @@
       beanResolver.clear();
    }
    
-   public void addDecorator(DecoratorBean<?> bean)
+   public void addDecorator(DecoratorImpl<?> bean)
    {
       decorators.add(bean);
       riBeans.put(bean.getId(), bean);
@@ -748,7 +750,7 @@
     * 
     * @return The bean map
     */
-   public Map<EjbDescriptor<?>, EnterpriseBean<?>> getEnterpriseBeans()
+   public Map<EjbDescriptor<?>, SessionBean<?>> getEnterpriseBeans()
    {
       return enterpriseBeans;
    }
@@ -764,7 +766,7 @@
       return Collections.unmodifiableList(beans);
    }
    
-   public List<DecoratorBean<?>> getDecorators()
+   public List<DecoratorImpl<?>> getDecorators()
    {
       return Collections.unmodifiableList(decorators);
    }
@@ -1324,6 +1326,11 @@
       return webbeansELResolver;
    }
    
+   public ExpressionFactory wrapExpressionFactory(ExpressionFactory expressionFactory)
+   {
+      return new WebBeansExpressionFactory(expressionFactory);
+   }
+   
    public <T> WBCreationalContext<T> createCreationalContext(Contextual<T> contextual)
    {
       return new CreationalContextImpl<T>(contextual);
@@ -1356,9 +1363,9 @@
       return getServices().get(EjbDescriptors.class).get(beanName);
    }
    
-   public <T> EnterpriseBean<T> getBean(EjbDescriptor<T> descriptor)
+   public <T> SessionBean<T> getBean(EjbDescriptor<T> descriptor)
    {
-      return (EnterpriseBean<T>) getEnterpriseBeans().get(descriptor);
+      return (SessionBean<T>) getEnterpriseBeans().get(descriptor);
    }
    
    public void cleanup()

Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/Validator.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/Validator.java	2009-09-15 13:02:01 UTC (rev 3667)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/Validator.java	2009-09-15 13:31:15 UTC (rev 3668)
@@ -41,10 +41,10 @@
 
 import org.jboss.webbeans.bean.AbstractClassBean;
 import org.jboss.webbeans.bean.AbstractProducerBean;
-import org.jboss.webbeans.bean.DecoratorBean;
-import org.jboss.webbeans.bean.DisposalMethodBean;
-import org.jboss.webbeans.bean.NewEnterpriseBean;
-import org.jboss.webbeans.bean.NewSimpleBean;
+import org.jboss.webbeans.bean.DecoratorImpl;
+import org.jboss.webbeans.bean.DisposalMethod;
+import org.jboss.webbeans.bean.NewSessionBean;
+import org.jboss.webbeans.bean.NewManagedBean;
 import org.jboss.webbeans.bean.RIBean;
 import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
 import org.jboss.webbeans.bootstrap.api.Service;
@@ -94,7 +94,7 @@
    private void validateRIBean(RIBean<?> bean, BeanManagerImpl beanManager, Collection<RIBean<?>> specializedBeans)
    {
       validateBean(bean, beanManager);
-      if (!(bean instanceof NewSimpleBean<?>) && !(bean instanceof NewEnterpriseBean<?>))
+      if (!(bean instanceof NewManagedBean<?>) && !(bean instanceof NewSessionBean<?>))
       {
          RIBean<?> abstractBean = bean;
          if (abstractBean.isSpecializing())
@@ -276,7 +276,7 @@
    {
       // TODO Move building this list to the boot or sth
       Set<Class<?>> decoratorBeanClasses = new HashSet<Class<?>>();
-      for (DecoratorBean<?> bean : beanManager.getDecorators())
+      for (DecoratorImpl<?> bean : beanManager.getDecorators())
       {
          decoratorBeanClasses.add(bean.getType());
       }
@@ -324,7 +324,7 @@
    
    private void validateDisposalMethods(BeanDeployerEnvironment environment)
    {
-      Set<DisposalMethodBean<?>> beans = environment.getUnresolvedDisposalBeans();
+      Set<DisposalMethod<?>> beans = environment.getUnresolvedDisposalBeans();
       if (!beans.isEmpty())
       {
          throw new DefinitionException("The following Disposal methods where not declared but not resolved to a producer method" + beans);

Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java	2009-09-15 13:02:01 UTC (rev 3667)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java	2009-09-15 13:31:15 UTC (rev 3668)
@@ -150,7 +150,7 @@
    
    protected T applyDecorators(T instance, CreationalContext<T> creationalContext, InjectionPoint originalInjectionPoint)
    {
-      List<SerializableBeanInstance<DecoratorBean<Object>, Object>> decoratorInstances = new ArrayList<SerializableBeanInstance<DecoratorBean<Object>,Object>>();
+      List<SerializableBeanInstance<DecoratorImpl<Object>, Object>> decoratorInstances = new ArrayList<SerializableBeanInstance<DecoratorImpl<Object>,Object>>();
       InjectionPoint ip = originalInjectionPoint;
       boolean outside = decoratorStackPosition.get().intValue() == 0;
       try
@@ -159,15 +159,15 @@
          while (i < decorators.size())
          {
             Decorator<?> decorator = decorators.get(i);
-            if (decorator instanceof DecoratorBean<?>)
+            if (decorator instanceof DecoratorImpl<?>)
             {
                decoratorStackPosition.set(++i);
                
                @SuppressWarnings("unchecked")
-               DecoratorBean<Object> decoratorBean = (DecoratorBean<Object>) decorator;
+               DecoratorImpl<Object> decoratorBean = (DecoratorImpl<Object>) decorator;
                
                Object decoratorInstance = getManager().getReference(ip, decorator, creationalContext);
-               decoratorInstances.add(new SerializableBeanInstance<DecoratorBean<Object>, Object>(decoratorBean, decoratorInstance));
+               decoratorInstances.add(new SerializableBeanInstance<DecoratorImpl<Object>, Object>(decoratorBean, decoratorInstance));
                ip = decoratorBean.getDelegateInjectionPoint();
             }
             else

Deleted: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/DecoratorBean.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/DecoratorBean.java	2009-09-15 13:02:01 UTC (rev 3667)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/DecoratorBean.java	2009-09-15 13:31:15 UTC (rev 3668)
@@ -1,228 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,  
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.webbeans.bean;
-
-import java.io.Serializable;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.enterprise.inject.spi.Decorator;
-import javax.inject.Inject;
-
-import org.jboss.webbeans.BeanManagerImpl;
-import org.jboss.webbeans.DefinitionException;
-import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
-import org.jboss.webbeans.injection.MethodInjectionPoint;
-import org.jboss.webbeans.injection.WBInjectionPoint;
-import org.jboss.webbeans.introspector.WBClass;
-
-public class DecoratorBean<T> extends SimpleBean<T> implements Decorator<T>
-{
-
-   public static <T> Decorator<T> wrapForResolver(final Decorator<T> decorator)
-   {
-      return new ForwardingDecorator<T>()
-      {
-
-         @Override
-         public Set<Annotation> getQualifiers()
-         {
-            return delegate().getDelegateQualifiers();
-         }
-
-         @Override
-         public Set<Type> getTypes()
-         {
-            return delegate().getTypes();
-         }
-
-         @Override
-         protected Decorator<T> delegate()
-         {
-            return decorator;
-         }
-
-      };
-   }
-
-   /**
-    * Creates a decorator bean
-    * 
-    * @param <T> The type
-    * @param clazz The class
-    * @param manager the current manager
-    * @return a Bean
-    */
-   public static <T> DecoratorBean<T> of(WBClass<T> clazz, BeanManagerImpl manager)
-   {
-      return new DecoratorBean<T>(clazz, manager);
-   }
-
-   private WBInjectionPoint<?, ?> delegateInjectionPoint;
-   private Set<Annotation> delegateBindings;
-   private Type delegateType;
-   private Set<Type> delegateTypes;
-   private Set<Type> decoratedTypes;
-
-   protected DecoratorBean(WBClass<T> type, BeanManagerImpl manager)
-   {
-      super(type, manager);
-   }
-
-   @Override
-   public void initialize(BeanDeployerEnvironment environment)
-   {
-      if (!isInitialized())
-      {
-         super.initialize(environment);
-         initDelegateInjectionPoint();
-         initDecoratedTypes();
-         initDelegateBindings();
-         initDelegateType();
-         checkDelegateType();
-      }
-   }
-
-   protected void initDecoratedTypes()
-   {
-      this.decoratedTypes = new HashSet<Type>();
-      this.decoratedTypes.addAll(getAnnotatedItem().getInterfaceOnlyFlattenedTypeHierarchy());
-      this.decoratedTypes.remove(Serializable.class);
-   }
-
-   protected void initDelegateInjectionPoint()
-   {
-      this.delegateInjectionPoint = getDelegateInjectionPoints().iterator().next();
-   }
-
-   @Override
-   protected void checkDelegateInjectionPoints()
-   {
-      for (WBInjectionPoint<?, ?> injectionPoint : getDelegateInjectionPoints())
-      {
-         if (injectionPoint instanceof MethodInjectionPoint<?, ?> && !injectionPoint.isAnnotationPresent(Inject.class))
-         {
-            throw new DefinitionException("Method with @Decorates parameter must be an initializer method " + injectionPoint);
-         }
-      }
-      if (getDelegateInjectionPoints().size() == 0)
-      {
-         throw new DefinitionException("No delegate injection points defined " + this);
-      }
-      else if (getDelegateInjectionPoints().size() > 1)
-      {
-         throw new DefinitionException("Too many delegate injection point defined " + this);
-      }
-   }
-
-   protected void initDelegateBindings()
-   {
-      this.delegateBindings = new HashSet<Annotation>(); 
-      this.delegateBindings.addAll(this.delegateInjectionPoint.getQualifiers());
-   }
-
-   protected void initDelegateType()
-   {
-      this.delegateType = this.delegateInjectionPoint.getBaseType();
-      this.delegateTypes = new HashSet<Type>();
-      delegateTypes.add(delegateType);
-   }
-
-   protected void checkDelegateType()
-   {
-      for (Type decoratedType : getDecoratedTypes())
-      {
-         if (decoratedType instanceof Class)
-         {
-            if (!((Class<?>) decoratedType).isAssignableFrom(delegateInjectionPoint.getJavaClass()))
-            {
-               throw new DefinitionException("The delegate type must extend or implement every decorated type. Decorated type " + decoratedType + "." + this );
-            }
-         }
-         else if (decoratedType instanceof ParameterizedType)
-         {
-            ParameterizedType parameterizedType = (ParameterizedType) decoratedType;
-            if (!delegateInjectionPoint.isParameterizedType())
-            {
-               throw new DefinitionException("The decorated type is parameterized, but the delegate type isn't. Delegate type " + delegateType + "." + this);
-            }
-            if (!Arrays.equals(delegateInjectionPoint.getActualTypeArguments(), parameterizedType.getActualTypeArguments()));
-            Type rawType = ((ParameterizedType) decoratedType).getRawType();
-            if (rawType instanceof Class && !((Class<?>) rawType).isAssignableFrom(delegateInjectionPoint.getJavaClass()))
-            {
-               throw new DefinitionException("The delegate type must extend or implement every decorated type. Decorated type " + decoratedType + "." + this );
-            }
-            else
-            {
-               throw new IllegalStateException("Unable to process " + decoratedType);
-            }
-
-         }
-      }
-   }
-
-   public Set<Annotation> getDelegateQualifiers()
-   {
-      return delegateBindings;
-   }
-
-   public Type getDelegateType()
-   {
-      return delegateType;
-   }
-
-   public Set<Type> getDecoratedTypes()
-   {
-      return decoratedTypes;
-   }
-   
-   public WBInjectionPoint<?, ?> getDelegateInjectionPoint()
-   {
-      return delegateInjectionPoint;
-   }
-
-   /**
-    * The type closure of the delegate type
-    * 
-    * @return the delegateTypes
-    */
-   public Set<Type> getDelegateTypes()
-   {
-      return delegateTypes;
-   }
-   
-   @Override
-   protected void initDecorators()
-   {
-      // No-op, decorators can't have decorators
-   }
-   
-   /* (non-Javadoc)
-    * @see org.jboss.webbeans.bean.SimpleBean#toString()
-    */
-   @Override
-   public String toString()
-   {
-      // TODO Auto-generated method stub
-      return super.toString("decorator");
-   }
-
-}

Copied: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/DecoratorImpl.java (from rev 3663, ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/DecoratorImpl.java)
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/DecoratorImpl.java	                        (rev 0)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/DecoratorImpl.java	2009-09-15 13:31:15 UTC (rev 3668)
@@ -0,0 +1,228 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,  
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.bean;
+
+import java.io.Serializable;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.enterprise.inject.spi.Decorator;
+import javax.inject.Inject;
+
+import org.jboss.webbeans.BeanManagerImpl;
+import org.jboss.webbeans.DefinitionException;
+import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
+import org.jboss.webbeans.injection.MethodInjectionPoint;
+import org.jboss.webbeans.injection.WBInjectionPoint;
+import org.jboss.webbeans.introspector.WBClass;
+
+public class DecoratorImpl<T> extends ManagedBean<T> implements Decorator<T>
+{
+
+   public static <T> Decorator<T> wrapForResolver(final Decorator<T> decorator)
+   {
+      return new ForwardingDecorator<T>()
+      {
+
+         @Override
+         public Set<Annotation> getQualifiers()
+         {
+            return delegate().getDelegateQualifiers();
+         }
+
+         @Override
+         public Set<Type> getTypes()
+         {
+            return delegate().getTypes();
+         }
+
+         @Override
+         protected Decorator<T> delegate()
+         {
+            return decorator;
+         }
+
+      };
+   }
+
+   /**
+    * Creates a decorator bean
+    * 
+    * @param <T> The type
+    * @param clazz The class
+    * @param manager the current manager
+    * @return a Bean
+    */
+   public static <T> DecoratorImpl<T> of(WBClass<T> clazz, BeanManagerImpl manager)
+   {
+      return new DecoratorImpl<T>(clazz, manager);
+   }
+
+   private WBInjectionPoint<?, ?> delegateInjectionPoint;
+   private Set<Annotation> delegateBindings;
+   private Type delegateType;
+   private Set<Type> delegateTypes;
+   private Set<Type> decoratedTypes;
+
+   protected DecoratorImpl(WBClass<T> type, BeanManagerImpl manager)
+   {
+      super(type, manager);
+   }
+
+   @Override
+   public void initialize(BeanDeployerEnvironment environment)
+   {
+      if (!isInitialized())
+      {
+         super.initialize(environment);
+         initDelegateInjectionPoint();
+         initDecoratedTypes();
+         initDelegateBindings();
+         initDelegateType();
+         checkDelegateType();
+      }
+   }
+
+   protected void initDecoratedTypes()
+   {
+      this.decoratedTypes = new HashSet<Type>();
+      this.decoratedTypes.addAll(getAnnotatedItem().getInterfaceOnlyFlattenedTypeHierarchy());
+      this.decoratedTypes.remove(Serializable.class);
+   }
+
+   protected void initDelegateInjectionPoint()
+   {
+      this.delegateInjectionPoint = getDelegateInjectionPoints().iterator().next();
+   }
+
+   @Override
+   protected void checkDelegateInjectionPoints()
+   {
+      for (WBInjectionPoint<?, ?> injectionPoint : getDelegateInjectionPoints())
+      {
+         if (injectionPoint instanceof MethodInjectionPoint<?, ?> && !injectionPoint.isAnnotationPresent(Inject.class))
+         {
+            throw new DefinitionException("Method with @Decorates parameter must be an initializer method " + injectionPoint);
+         }
+      }
+      if (getDelegateInjectionPoints().size() == 0)
+      {
+         throw new DefinitionException("No delegate injection points defined " + this);
+      }
+      else if (getDelegateInjectionPoints().size() > 1)
+      {
+         throw new DefinitionException("Too many delegate injection point defined " + this);
+      }
+   }
+
+   protected void initDelegateBindings()
+   {
+      this.delegateBindings = new HashSet<Annotation>(); 
+      this.delegateBindings.addAll(this.delegateInjectionPoint.getQualifiers());
+   }
+
+   protected void initDelegateType()
+   {
+      this.delegateType = this.delegateInjectionPoint.getBaseType();
+      this.delegateTypes = new HashSet<Type>();
+      delegateTypes.add(delegateType);
+   }
+
+   protected void checkDelegateType()
+   {
+      for (Type decoratedType : getDecoratedTypes())
+      {
+         if (decoratedType instanceof Class)
+         {
+            if (!((Class<?>) decoratedType).isAssignableFrom(delegateInjectionPoint.getJavaClass()))
+            {
+               throw new DefinitionException("The delegate type must extend or implement every decorated type. Decorated type " + decoratedType + "." + this );
+            }
+         }
+         else if (decoratedType instanceof ParameterizedType)
+         {
+            ParameterizedType parameterizedType = (ParameterizedType) decoratedType;
+            if (!delegateInjectionPoint.isParameterizedType())
+            {
+               throw new DefinitionException("The decorated type is parameterized, but the delegate type isn't. Delegate type " + delegateType + "." + this);
+            }
+            if (!Arrays.equals(delegateInjectionPoint.getActualTypeArguments(), parameterizedType.getActualTypeArguments()));
+            Type rawType = ((ParameterizedType) decoratedType).getRawType();
+            if (rawType instanceof Class && !((Class<?>) rawType).isAssignableFrom(delegateInjectionPoint.getJavaClass()))
+            {
+               throw new DefinitionException("The delegate type must extend or implement every decorated type. Decorated type " + decoratedType + "." + this );
+            }
+            else
+            {
+               throw new IllegalStateException("Unable to process " + decoratedType);
+            }
+
+         }
+      }
+   }
+
+   public Set<Annotation> getDelegateQualifiers()
+   {
+      return delegateBindings;
+   }
+
+   public Type getDelegateType()
+   {
+      return delegateType;
+   }
+
+   public Set<Type> getDecoratedTypes()
+   {
+      return decoratedTypes;
+   }
+   
+   public WBInjectionPoint<?, ?> getDelegateInjectionPoint()
+   {
+      return delegateInjectionPoint;
+   }
+
+   /**
+    * The type closure of the delegate type
+    * 
+    * @return the delegateTypes
+    */
+   public Set<Type> getDelegateTypes()
+   {
+      return delegateTypes;
+   }
+   
+   @Override
+   protected void initDecorators()
+   {
+      // No-op, decorators can't have decorators
+   }
+   
+   /* (non-Javadoc)
+    * @see org.jboss.webbeans.bean.SimpleBean#toString()
+    */
+   @Override
+   public String toString()
+   {
+      // TODO Auto-generated method stub
+      return super.toString("decorator");
+   }
+
+}

Copied: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/DisposalMethod.java (from rev 3663, ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/DisposalMethod.java)
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/DisposalMethod.java	                        (rev 0)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/DisposalMethod.java	2009-09-15 13:31:15 UTC (rev 3668)
@@ -0,0 +1,258 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,  
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.bean;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.Disposes;
+import javax.enterprise.inject.Produces;
+import javax.inject.Inject;
+
+import org.jboss.webbeans.BeanManagerImpl;
+import org.jboss.webbeans.DefinitionException;
+import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
+import org.jboss.webbeans.injection.MethodInjectionPoint;
+import org.jboss.webbeans.introspector.WBMethod;
+
+public class DisposalMethod<T> extends AbstractReceiverBean<T, Method>
+{
+
+   protected MethodInjectionPoint<T, ?> disposalMethodInjectionPoint;
+   private final String id;
+
+   protected DisposalMethod(BeanManagerImpl manager, WBMethod<T, ?> disposalMethod, AbstractClassBean<?> declaringBean)
+   {
+      super(declaringBean, manager);
+      this.disposalMethodInjectionPoint = MethodInjectionPoint.of(this, disposalMethod);
+      this.id = createId("DisposalMethod-" + declaringBean.getName() + "-" + disposalMethod.getSignature().toString());
+      initBindings();
+      initType();
+      initTypes();
+      initStereotypes();
+      initPolicy();
+   }
+   
+   @Override
+   public void initialize(BeanDeployerEnvironment environment)
+   {
+      addInjectionPoint(disposalMethodInjectionPoint);
+      super.initialize(environment);
+      checkDisposalMethod();
+   }
+
+   @SuppressWarnings("unchecked")
+   protected void initType()
+   {
+      this.type = (Class<T>) disposalMethodInjectionPoint.getAnnotatedParameters(Disposes.class).get(0).getJavaClass();
+   }
+
+   @Override
+   public WBMethod<T, ?> getAnnotatedItem()
+   {
+      return disposalMethodInjectionPoint;
+   }
+
+   public static <T> DisposalMethod<T> of(BeanManagerImpl manager, WBMethod<T, ?> disposalMethod, AbstractClassBean<?> declaringBean)
+   {
+      return new DisposalMethod<T>(manager, disposalMethod, declaringBean);
+   }
+
+   @Override
+   protected void initBindings()
+   {
+      // At least 1 parameter exists, already checked in constructor
+      this.bindings = new HashSet<Annotation>();
+      this.bindings.addAll(disposalMethodInjectionPoint.getWBParameters().get(0).getQualifiers());
+      initDefaultBindings();
+   }
+
+   /**
+    * Initializes the API types
+    */
+   @Override
+   protected void initTypes()
+   {
+      Set<Type> types = new HashSet<Type>();
+      types = new HashSet<Type>();
+      types.addAll(disposalMethodInjectionPoint.getAnnotatedParameters(Disposes.class).get(0).getTypeClosure());
+      types.add(Object.class);
+      super.types = types;
+   }
+
+   @Override
+   public String getName()
+   {
+      return null;
+   }
+
+   @Override
+   public Class<? extends Annotation> getScope()
+   {
+      return null;
+   }
+
+   @Override
+   public Set<Type> getTypes()
+   {
+      return types;
+   }
+
+   @Override
+   public String toString()
+   {
+      return disposalMethodInjectionPoint.toString();
+   }
+
+   @Override
+   public boolean isNullable()
+   {
+      // Not relevant
+      return false;
+   }
+
+   @Override
+   public boolean isSerializable()
+   {
+      // Not relevant
+      return false;
+   }
+
+   @Override
+   public boolean isProxyable()
+   {
+      return true;
+   }
+
+   public T create(CreationalContext<T> creationalContext)
+   {
+      // Not Relevant
+      return null;
+   }
+
+   public void invokeDisposeMethod(Object instance)
+   {
+      CreationalContext<T> creationalContext = manager.createCreationalContext(this);
+      Object receiverInstance = getReceiver(creationalContext);
+      if (receiverInstance == null)
+      {
+         disposalMethodInjectionPoint.invokeWithSpecialValue(null, Disposes.class, instance, manager, creationalContext, IllegalArgumentException.class);
+      }
+      else
+      {
+         disposalMethodInjectionPoint.invokeOnInstanceWithSpecialValue(receiverInstance, Disposes.class, instance, manager, creationalContext, IllegalArgumentException.class);
+      }
+      creationalContext.release();
+   }
+
+   private void checkDisposalMethod()
+   {
+      if (!disposalMethodInjectionPoint.getWBParameters().get(0).isAnnotationPresent(Disposes.class))
+      {
+         throw new DefinitionException(disposalMethodInjectionPoint.toString() + " doesn't have @Dispose as first parameter");
+      }
+      if (disposalMethodInjectionPoint.getAnnotatedParameters(Disposes.class).size() > 1)
+      {
+         throw new DefinitionException(disposalMethodInjectionPoint.toString() + " has more than one @Dispose parameters");
+      }
+      if (disposalMethodInjectionPoint.getAnnotatedParameters(Observes.class).size() > 0)
+      {
+         throw new DefinitionException("@Observes is not allowed on disposal method, see " + disposalMethodInjectionPoint.toString());
+      }
+      if (disposalMethodInjectionPoint.getAnnotation(Inject.class) != null)
+      {
+         throw new DefinitionException("@Intitializer is not allowed on a disposal method, see " + disposalMethodInjectionPoint.toString());
+      }
+      if (disposalMethodInjectionPoint.getAnnotation(Produces.class) != null)
+      {
+         throw new DefinitionException("@Produces is not allowed on a disposal method, see " + disposalMethodInjectionPoint.toString());
+      }
+      if (getDeclaringBean() instanceof SessionBean<?>)
+      {
+         boolean methodDeclaredOnTypes = false;
+         // TODO use annotated item?
+         for (Type type : getDeclaringBean().getTypes())
+         {
+            if (type instanceof Class<?>)
+            {
+               Class<?> clazz = (Class<?>) type;
+               try
+               {
+                  clazz.getDeclaredMethod(disposalMethodInjectionPoint.getName(), disposalMethodInjectionPoint.getParameterTypesAsArray());
+                  methodDeclaredOnTypes = true;
+               }
+               catch (NoSuchMethodException nsme)
+               {
+                  // No - op
+               }
+            }
+         }
+         if (!methodDeclaredOnTypes)
+         {
+            throw new DefinitionException("Producer method " + toString() + " must be declared on a business interface of " + getDeclaringBean());
+         }
+      }
+   }
+
+   @Override
+   public Class<T> getType()
+   {
+      return type;
+   }
+
+   @Override
+   protected String getDefaultName()
+   {
+      return disposalMethodInjectionPoint.getPropertyName();
+   }
+
+   public void destroy(T instance, CreationalContext<T> creationalContext)
+   {
+      // No-op. Producer method dependent objects are destroyed in producer method bean  
+   }
+
+   @Override
+   public String getId()
+   {
+      return id;
+   }
+
+   @Override
+   public AbstractBean<?, ?> getSpecializedBean()
+   {
+      // Doesn't support specialization
+      return null;
+   }
+   
+   @Override
+   protected void initScopeType()
+   {
+      // Disposal methods aren't scoped
+   }
+
+   public Set<Class<? extends Annotation>> getStereotypes()
+   {
+      return Collections.emptySet();
+   }
+
+}

Deleted: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/DisposalMethodBean.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/DisposalMethodBean.java	2009-09-15 13:02:01 UTC (rev 3667)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/DisposalMethodBean.java	2009-09-15 13:31:15 UTC (rev 3668)
@@ -1,258 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,  
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.webbeans.bean;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Method;
-import java.lang.reflect.Type;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.enterprise.context.spi.CreationalContext;
-import javax.enterprise.event.Observes;
-import javax.enterprise.inject.Disposes;
-import javax.enterprise.inject.Produces;
-import javax.inject.Inject;
-
-import org.jboss.webbeans.BeanManagerImpl;
-import org.jboss.webbeans.DefinitionException;
-import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
-import org.jboss.webbeans.injection.MethodInjectionPoint;
-import org.jboss.webbeans.introspector.WBMethod;
-
-public class DisposalMethodBean<T> extends AbstractReceiverBean<T, Method>
-{
-
-   protected MethodInjectionPoint<T, ?> disposalMethodInjectionPoint;
-   private final String id;
-
-   protected DisposalMethodBean(BeanManagerImpl manager, WBMethod<T, ?> disposalMethod, AbstractClassBean<?> declaringBean)
-   {
-      super(declaringBean, manager);
-      this.disposalMethodInjectionPoint = MethodInjectionPoint.of(this, disposalMethod);
-      this.id = createId("DisposalMethod-" + declaringBean.getName() + "-" + disposalMethod.getSignature().toString());
-      initBindings();
-      initType();
-      initTypes();
-      initStereotypes();
-      initPolicy();
-   }
-   
-   @Override
-   public void initialize(BeanDeployerEnvironment environment)
-   {
-      addInjectionPoint(disposalMethodInjectionPoint);
-      super.initialize(environment);
-      checkDisposalMethod();
-   }
-
-   @SuppressWarnings("unchecked")
-   protected void initType()
-   {
-      this.type = (Class<T>) disposalMethodInjectionPoint.getAnnotatedParameters(Disposes.class).get(0).getJavaClass();
-   }
-
-   @Override
-   public WBMethod<T, ?> getAnnotatedItem()
-   {
-      return disposalMethodInjectionPoint;
-   }
-
-   public static <T> DisposalMethodBean<T> of(BeanManagerImpl manager, WBMethod<T, ?> disposalMethod, AbstractClassBean<?> declaringBean)
-   {
-      return new DisposalMethodBean<T>(manager, disposalMethod, declaringBean);
-   }
-
-   @Override
-   protected void initBindings()
-   {
-      // At least 1 parameter exists, already checked in constructor
-      this.bindings = new HashSet<Annotation>();
-      this.bindings.addAll(disposalMethodInjectionPoint.getWBParameters().get(0).getQualifiers());
-      initDefaultBindings();
-   }
-
-   /**
-    * Initializes the API types
-    */
-   @Override
-   protected void initTypes()
-   {
-      Set<Type> types = new HashSet<Type>();
-      types = new HashSet<Type>();
-      types.addAll(disposalMethodInjectionPoint.getAnnotatedParameters(Disposes.class).get(0).getTypeClosure());
-      types.add(Object.class);
-      super.types = types;
-   }
-
-   @Override
-   public String getName()
-   {
-      return null;
-   }
-
-   @Override
-   public Class<? extends Annotation> getScope()
-   {
-      return null;
-   }
-
-   @Override
-   public Set<Type> getTypes()
-   {
-      return types;
-   }
-
-   @Override
-   public String toString()
-   {
-      return disposalMethodInjectionPoint.toString();
-   }
-
-   @Override
-   public boolean isNullable()
-   {
-      // Not relevant
-      return false;
-   }
-
-   @Override
-   public boolean isSerializable()
-   {
-      // Not relevant
-      return false;
-   }
-
-   @Override
-   public boolean isProxyable()
-   {
-      return true;
-   }
-
-   public T create(CreationalContext<T> creationalContext)
-   {
-      // Not Relevant
-      return null;
-   }
-
-   public void invokeDisposeMethod(Object instance)
-   {
-      CreationalContext<T> creationalContext = manager.createCreationalContext(this);
-      Object receiverInstance = getReceiver(creationalContext);
-      if (receiverInstance == null)
-      {
-         disposalMethodInjectionPoint.invokeWithSpecialValue(null, Disposes.class, instance, manager, creationalContext, IllegalArgumentException.class);
-      }
-      else
-      {
-         disposalMethodInjectionPoint.invokeOnInstanceWithSpecialValue(receiverInstance, Disposes.class, instance, manager, creationalContext, IllegalArgumentException.class);
-      }
-      creationalContext.release();
-   }
-
-   private void checkDisposalMethod()
-   {
-      if (!disposalMethodInjectionPoint.getWBParameters().get(0).isAnnotationPresent(Disposes.class))
-      {
-         throw new DefinitionException(disposalMethodInjectionPoint.toString() + " doesn't have @Dispose as first parameter");
-      }
-      if (disposalMethodInjectionPoint.getAnnotatedParameters(Disposes.class).size() > 1)
-      {
-         throw new DefinitionException(disposalMethodInjectionPoint.toString() + " has more than one @Dispose parameters");
-      }
-      if (disposalMethodInjectionPoint.getAnnotatedParameters(Observes.class).size() > 0)
-      {
-         throw new DefinitionException("@Observes is not allowed on disposal method, see " + disposalMethodInjectionPoint.toString());
-      }
-      if (disposalMethodInjectionPoint.getAnnotation(Inject.class) != null)
-      {
-         throw new DefinitionException("@Intitializer is not allowed on a disposal method, see " + disposalMethodInjectionPoint.toString());
-      }
-      if (disposalMethodInjectionPoint.getAnnotation(Produces.class) != null)
-      {
-         throw new DefinitionException("@Produces is not allowed on a disposal method, see " + disposalMethodInjectionPoint.toString());
-      }
-      if (getDeclaringBean() instanceof EnterpriseBean<?>)
-      {
-         boolean methodDeclaredOnTypes = false;
-         // TODO use annotated item?
-         for (Type type : getDeclaringBean().getTypes())
-         {
-            if (type instanceof Class<?>)
-            {
-               Class<?> clazz = (Class<?>) type;
-               try
-               {
-                  clazz.getDeclaredMethod(disposalMethodInjectionPoint.getName(), disposalMethodInjectionPoint.getParameterTypesAsArray());
-                  methodDeclaredOnTypes = true;
-               }
-               catch (NoSuchMethodException nsme)
-               {
-                  // No - op
-               }
-            }
-         }
-         if (!methodDeclaredOnTypes)
-         {
-            throw new DefinitionException("Producer method " + toString() + " must be declared on a business interface of " + getDeclaringBean());
-         }
-      }
-   }
-
-   @Override
-   public Class<T> getType()
-   {
-      return type;
-   }
-
-   @Override
-   protected String getDefaultName()
-   {
-      return disposalMethodInjectionPoint.getPropertyName();
-   }
-
-   public void destroy(T instance, CreationalContext<T> creationalContext)
-   {
-      // No-op. Producer method dependent objects are destroyed in producer method bean  
-   }
-
-   @Override
-   public String getId()
-   {
-      return id;
-   }
-
-   @Override
-   public AbstractBean<?, ?> getSpecializedBean()
-   {
-      // Doesn't support specialization
-      return null;
-   }
-   
-   @Override
-   protected void initScopeType()
-   {
-      // Disposal methods aren't scoped
-   }
-
-   public Set<Class<? extends Annotation>> getStereotypes()
-   {
-      return Collections.emptySet();
-   }
-
-}

Deleted: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java	2009-09-15 13:02:01 UTC (rev 3667)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java	2009-09-15 13:31:15 UTC (rev 3668)
@@ -1,402 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,  
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.webbeans.bean;
-
-import java.io.Serializable;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Method;
-import java.lang.reflect.Type;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.LinkedHashSet;
-import java.util.Set;
-
-import javassist.util.proxy.ProxyFactory;
-import javassist.util.proxy.ProxyObject;
-
-import javax.decorator.Decorator;
-import javax.enterprise.context.ApplicationScoped;
-import javax.enterprise.context.spi.CreationalContext;
-import javax.enterprise.event.Observes;
-import javax.enterprise.inject.CreationException;
-import javax.interceptor.Interceptor;
-
-import org.jboss.webbeans.BeanManagerImpl;
-import org.jboss.webbeans.DefinitionException;
-import org.jboss.webbeans.bean.proxy.EnterpriseBeanInstance;
-import org.jboss.webbeans.bean.proxy.EnterpriseBeanProxyMethodHandler;
-import org.jboss.webbeans.bean.proxy.Marker;
-import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
-import org.jboss.webbeans.ejb.InternalEjbDescriptor;
-import org.jboss.webbeans.ejb.api.SessionObjectReference;
-import org.jboss.webbeans.ejb.spi.BusinessInterfaceDescriptor;
-import org.jboss.webbeans.ejb.spi.EjbServices;
-import org.jboss.webbeans.injection.InjectionContextImpl;
-import org.jboss.webbeans.introspector.WBClass;
-import org.jboss.webbeans.introspector.WBMethod;
-import org.jboss.webbeans.log.Log;
-import org.jboss.webbeans.log.Logging;
-import org.jboss.webbeans.resources.ClassTransformer;
-import org.jboss.webbeans.util.Beans;
-import org.jboss.webbeans.util.Proxies;
-
-/**
- * An enterprise bean representation
- * 
- * @author Pete Muir
- * 
- * @param <T> The type (class) of the bean
- */
-public class EnterpriseBean<T> extends AbstractClassBean<T>
-{
-   private final Log log = Logging.getLog(EnterpriseBean.class);
-
-   // The EJB descriptor
-   private InternalEjbDescriptor<T> ejbDescriptor;
-
-   private Class<T> proxyClass;
-
-   private EnterpriseBean<?> specializedBean;
-
-   /**
-    * Creates a simple, annotation defined Enterprise Web Bean
-    * 
-    * @param <T> The type
-    * @param clazz The class
-    * @param manager the current manager
-    * @return An Enterprise Web Bean
-    */
-   public static <T> EnterpriseBean<T> of(InternalEjbDescriptor<T> ejbDescriptor, BeanManagerImpl manager)
-   {
-      WBClass<T> type = manager.getServices().get(ClassTransformer.class).loadClass(ejbDescriptor.getBeanClass());
-      return new EnterpriseBean<T>(type, ejbDescriptor, manager);
-   }
-
-   /**
-    * Constructor
-    * 
-    * @param type The type of the bean
-    * @param manager The Web Beans manager
-    */
-   protected EnterpriseBean(WBClass<T> type, InternalEjbDescriptor<T> ejbDescriptor, BeanManagerImpl manager)
-   {
-      super(type, manager);
-      initType();
-      this.ejbDescriptor = ejbDescriptor;
-      initTypes();
-      initBindings();
-   }
-
-   /**
-    * Initializes the bean and its metadata
-    */
-   @Override
-   public void initialize(BeanDeployerEnvironment environment)
-   {
-      if (!isInitialized())
-      {
-         super.initialize(environment);
-         initProxyClass();
-         checkEJBTypeAllowed();
-         checkConflictingRoles();
-         checkObserverMethods();
-         checkScopeAllowed();
-      }
-   }
-
-   @Override
-   protected void initTypes()
-   {
-      Set<Type> types = new HashSet<Type>();
-      types = new LinkedHashSet<Type>();
-      types.add(Object.class);
-      for (BusinessInterfaceDescriptor<?> businessInterfaceDescriptor : ejbDescriptor.getLocalBusinessInterfaces())
-      {
-         types.add(businessInterfaceDescriptor.getInterface());
-      }
-      super.types = types;
-   }
-
-   protected void initProxyClass()
-   {
-      Set<Type> types = new LinkedHashSet<Type>(getTypes());
-      types.add(EnterpriseBeanInstance.class);
-      types.add(Serializable.class);
-      ProxyFactory proxyFactory = Proxies.getProxyFactory(types);
-
-      @SuppressWarnings("unchecked")
-      Class<T> proxyClass = proxyFactory.createClass();
-
-      this.proxyClass = proxyClass;
-   }
-
-   /**
-    * Validates for non-conflicting roles
-    */
-   protected void checkConflictingRoles()
-   {
-      if (getType().isAnnotationPresent(Interceptor.class))
-      {
-         throw new DefinitionException("Enterprise beans cannot be interceptors");
-      }
-      if (getType().isAnnotationPresent(Decorator.class))
-      {
-         throw new DefinitionException("Enterprise beans cannot be decorators");
-      }
-   }
-
-   /**
-    * Check that the scope type is allowed by the stereotypes on the bean and
-    * the bean type
-    */
-   protected void checkScopeAllowed()
-   {
-      if (ejbDescriptor.isStateless() && !isDependent())
-      {
-         throw new DefinitionException("Scope " + getScope() + " is not allowed on stateless enterpise beans for " + getType() + ". Only @Dependent is allowed on stateless enterprise beans");
-      }
-      if (ejbDescriptor.isSingleton() && !(isDependent() || getScope().equals(ApplicationScoped.class)))
-      {
-         throw new DefinitionException("Scope " + getScope() + " is not allowed on singleton enterpise beans for " + getType() + ". Only @Dependent or @ApplicationScoped is allowed on singleton enterprise beans");
-      }
-   }
-
-   /**
-    * Validates specialization
-    */
-   @Override
-   protected void preSpecialize(BeanDeployerEnvironment environment)
-   {
-      super.preSpecialize(environment);
-      // We appear to check this twice?
-      if (!environment.getEjbDescriptors().contains(getAnnotatedItem().getWBSuperclass().getJavaClass()))
-      {
-         throw new DefinitionException("Annotation defined specializing EJB must have EJB superclass");
-      }
-   }
-
-   @Override
-   protected void specialize(BeanDeployerEnvironment environment)
-   {
-      if (environment.getClassBean(getAnnotatedItem().getWBSuperclass()) == null)
-      {
-         throw new IllegalStateException(toString() + " does not specialize a bean");
-      }
-      AbstractClassBean<?> specializedBean = environment.getClassBean(getAnnotatedItem().getWBSuperclass());
-      if (!(specializedBean instanceof EnterpriseBean<?>))
-      {
-         throw new IllegalStateException(toString() + " doesn't have a session bean as a superclass " + specializedBean);
-      }
-      else
-      {
-         this.specializedBean = (EnterpriseBean<?>) specializedBean; 
-      }
-   }
-
-   /**
-    * Creates an instance of the bean
-    * 
-    * @return The instance
-    */
-   public T create(final CreationalContext<T> creationalContext)
-   {
-      T instance = produce(creationalContext);
-      if (hasDecorators())
-      {
-         instance = applyDecorators(instance, creationalContext, null);
-      }
-      return instance;
-   }
-   
-   public void inject(final T instance, final CreationalContext<T> ctx)
-   {
-      new InjectionContextImpl<T>(getManager(), this, instance)
-      {
-         
-         public void proceed()
-         {
-            Beans.injectBoundFields(instance, ctx, getManager(), getInjectableFields());
-            Beans.callInitializers(instance, ctx, getManager(), getInitializerMethods());
-         }
-         
-      }.run();
-      
-   }
-
-   public T produce(CreationalContext<T> ctx)
-   {
-      try
-      {
-         T instance = proxyClass.newInstance();
-         ctx.push(instance);
-         ((ProxyObject) instance).setHandler(new EnterpriseBeanProxyMethodHandler<T>(this, ctx));
-         log.trace("Enterprise bean instance created for bean {0}", this);
-         return instance;
-      }
-      catch (InstantiationException e)
-      {
-         throw new RuntimeException("Could not instantiate enterprise proxy for " + toString(), e);
-      }
-      catch (IllegalAccessException e)
-      {
-         throw new RuntimeException("Could not access bean correctly when creating enterprise proxy for " + toString(), e);
-      }
-      catch (Exception e)
-      {
-         throw new CreationException("could not find the EJB in JNDI " + proxyClass, e);
-      }
-   }
-
-   public void destroy(T instance, CreationalContext<T> creationalContext)
-   {
-      if (instance == null)
-      {
-         throw new IllegalArgumentException("instance to destroy cannot be null");
-      }
-      if (!(instance instanceof EnterpriseBeanInstance))
-      {
-         throw new IllegalArgumentException("Cannot destroy session bean instance not created by the container");
-      }
-      EnterpriseBeanInstance enterpiseBeanInstance = (EnterpriseBeanInstance) instance;
-      enterpiseBeanInstance.destroy(Marker.INSTANCE, this, creationalContext);
-      creationalContext.release();
-   }
-
-   /**
-    * Validates the bean type
-    */
-   private void checkEJBTypeAllowed()
-   {
-      if (ejbDescriptor.isMessageDriven())
-      {
-         throw new DefinitionException("Message Driven Beans can't be Web Beans");
-      }
-   }
-
-   /**
-    * Gets a string representation
-    * 
-    * @return The string representation
-    */
-   @Override
-   public String toString()
-   {
-      StringBuilder buffer = new StringBuilder();
-      // buffer.append("Annotated " + Names.scopeTypeToString(getScopeType()) +
-      // Names.ejbTypeFromMetaData(getEjbMetaData()));
-      if (getName() == null)
-      {
-         buffer.append(" unnamed enterprise bean");
-      }
-      else
-      {
-         buffer.append(" enterprise bean '" + getName() + "'");
-      }
-      buffer.append(" [" + getType().getName() + "] ");
-      buffer.append("API types " + getTypes() + ", binding types " + getQualifiers());
-      return buffer.toString();
-   }
-
-   public void postConstruct(T instance, CreationalContext<T> creationalContext)
-   {
-      Beans.injectBoundFields(instance, creationalContext, getManager(), getInjectableFields());
-      Beans.callInitializers(instance, creationalContext, getManager(), getInitializerMethods());
-   }
-
-   public void preDestroy(CreationalContext<T> creationalContext)
-   {
-      creationalContext.release();
-   }
-   
-   @Override
-   protected void initSerializable()
-   {
-      // No-op
-   }
-   
-   @Override
-   public boolean isSerializable()
-   {
-      return true;
-   }
-
-   public InternalEjbDescriptor<T> getEjbDescriptor()
-   {
-      return ejbDescriptor;
-   }
-
-   public boolean isClientCanCallRemoveMethods()
-   {
-      return getEjbDescriptor().isStateful() && isDependent();
-   }
-
-   @Override
-   public AbstractBean<?, ?> getSpecializedBean()
-   {
-      return specializedBean;
-   }
-
-   /**
-    * If there are any observer methods, they must be static or business
-    * methods.
-    */
-   protected void checkObserverMethods()
-   {
-      for (WBMethod<?, ?> method : this.annotatedItem.getWBDeclaredMethodsWithAnnotatedParameters(Observes.class))
-      {
-         if (!method.isStatic())
-         {
-            if (!isMethodExistsOnTypes(method))
-            {
-               throw new DefinitionException("Observer method must be static or business method: " + method + " on " + getAnnotatedItem());
-            }
-         }
-      }
-   }
-   
-   // TODO must be a nicer way to do this!
-   public boolean isMethodExistsOnTypes(WBMethod<?, ?> method)
-   {
-      for (Type type : getTypes())
-      {
-         if (type instanceof Class)
-         {
-            for (Method m : ((Class<?>) type).getMethods())
-            {
-               if (method.getName().equals(m.getName()) && Arrays.equals(method.getParameterTypesAsArray(), m.getParameterTypes()))
-               {
-                  return true;
-               }
-            }
-         }
-      }
-      return false;
-   }
-   
-   public SessionObjectReference createReference()
-   {
-      return manager.getServices().get(EjbServices.class).resolveEjb(getEjbDescriptor().delegate());
-   }
-
-   public Set<Class<? extends Annotation>> getStereotypes()
-   {
-      return Collections.emptySet();
-   }
-   
-}
-

Copied: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/ManagedBean.java (from rev 3663, ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ManagedBean.java)
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/ManagedBean.java	                        (rev 0)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/ManagedBean.java	2009-09-15 13:31:15 UTC (rev 3668)
@@ -0,0 +1,359 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,  
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.bean;
+
+import java.util.Set;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.Disposes;
+import javax.enterprise.inject.spi.Decorator;
+import javax.enterprise.inject.spi.InjectionPoint;
+
+import org.jboss.webbeans.BeanManagerImpl;
+import org.jboss.webbeans.DefinitionException;
+import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
+import org.jboss.webbeans.injection.ConstructorInjectionPoint;
+import org.jboss.webbeans.injection.InjectionContextImpl;
+import org.jboss.webbeans.injection.WBInjectionPoint;
+import org.jboss.webbeans.introspector.WBClass;
+import org.jboss.webbeans.introspector.WBConstructor;
+import org.jboss.webbeans.introspector.WBField;
+import org.jboss.webbeans.introspector.WBMethod;
+import org.jboss.webbeans.log.LogProvider;
+import org.jboss.webbeans.log.Logging;
+import org.jboss.webbeans.metadata.cache.MetaAnnotationStore;
+import org.jboss.webbeans.util.Beans;
+import org.jboss.webbeans.util.Names;
+import org.jboss.webbeans.util.Reflections;
+
+/**
+ * Represents a simple bean
+ * 
+ * @author Pete Muir
+ * 
+ * @param <T> The type (class) of the bean
+ */
+public class ManagedBean<T> extends AbstractClassBean<T>
+{
+   // Logger
+   private static LogProvider log = Logging.getLogProvider(ManagedBean.class);
+
+   // The constructor
+   private ConstructorInjectionPoint<T> constructor;
+   private Set<WBInjectionPoint<?, ?>> ejbInjectionPoints;
+   private Set<WBInjectionPoint<?, ?>> persistenceContextInjectionPoints;
+   private Set<WBInjectionPoint<?, ?>> persistenceUnitInjectionPoints;
+   private Set<WBInjectionPoint<?, ?>> resourceInjectionPoints;
+
+   private ManagedBean<?> specializedBean;
+
+   
+
+   /**
+    * Creates a simple, annotation defined Web Bean
+    * 
+    * @param <T> The type
+    * @param clazz The class
+    * @param manager the current manager
+    * @return A Web Bean
+    */
+   public static <T> ManagedBean<T> of(WBClass<T> clazz, BeanManagerImpl manager)
+   {
+      return new ManagedBean<T>(clazz, manager);
+   }
+
+   /**
+    * Constructor
+    * 
+    * @param type The type of the bean
+    * @param manager The Web Beans manager
+    */
+   protected ManagedBean(WBClass<T> type, BeanManagerImpl manager)
+   {
+      super(type, manager);
+      initType();
+      initTypes();
+      initBindings();
+   }
+
+   /**
+    * Creates an instance of the bean
+    * 
+    * @return The instance
+    */
+   public T create(CreationalContext<T> creationalContext)
+   {
+      InjectionPoint originalInjectionPoint = null;
+      if (hasDecorators())
+      {
+         originalInjectionPoint = attachCorrectInjectionPoint();
+      }
+      T instance = produce(creationalContext);
+      inject(instance, creationalContext);
+      postConstruct(instance);
+      if (hasDecorators())
+      {
+         instance = applyDecorators(instance, creationalContext, originalInjectionPoint);
+      }
+      return instance;
+   }
+   
+   public T produce(CreationalContext<T> ctx)
+   {
+      T instance = constructor.newInstance(manager, ctx);
+      if (!hasDecorators())
+      {
+         // This should be safe, but needs verification PLM
+         // Without this, the chaining of decorators will fail as the incomplete instance will be resolved
+         ctx.push(instance);
+      }
+      return instance;
+   }
+   
+   public void inject(final T instance, final CreationalContext<T> ctx)
+   {
+      new InjectionContextImpl<T>(getManager(), this, instance)
+      {
+         
+         public void proceed()
+         {
+            Beans.injectEEFields(instance, getManager(), ejbInjectionPoints, persistenceContextInjectionPoints, persistenceUnitInjectionPoints, resourceInjectionPoints);
+            Beans.injectBoundFields(instance, ctx, getManager(), getInjectableFields());
+            Beans.callInitializers(instance, ctx, getManager(), getInitializerMethods());
+         }
+         
+      }.run();
+      
+   }
+
+   protected InjectionPoint attachCorrectInjectionPoint()
+   {
+      Decorator<?> decorator = getDecorators().get(getDecorators().size() - 1);
+      if (decorator instanceof DecoratorImpl<?>)
+      {
+         DecoratorImpl<?> decoratorBean = (DecoratorImpl<?>) decorator;
+         InjectionPoint outerDelegateInjectionPoint = decoratorBean.getDelegateInjectionPoint();
+         return getManager().replaceOrPushCurrentInjectionPoint(outerDelegateInjectionPoint);
+      }
+      else
+      {
+         throw new IllegalStateException("Cannot operate on user defined decorator");
+      }
+   }
+
+   /**
+    * Destroys an instance of the bean
+    * 
+    * @param instance The instance
+    */
+   public void destroy(T instance, CreationalContext<T> creationalContext)
+   {
+      try
+      {
+         preDestroy(instance);
+         creationalContext.release();
+      }
+      catch (Exception e)
+      {
+         log.error("Error destroying " + toString(), e);
+      }
+   }
+
+   /**
+    * Initializes the bean and its metadata
+    */
+   @Override
+   public void initialize(BeanDeployerEnvironment environment)
+   {
+      if (!isInitialized())
+      {
+         initConstructor();
+         checkConstructor();
+         super.initialize(environment);
+         initPostConstruct();
+         initPreDestroy();
+         initEEInjectionPoints();
+      }
+   }
+
+   private void initEEInjectionPoints()
+   {
+      this.ejbInjectionPoints = Beans.getEjbInjectionPoints(this, getAnnotatedItem(), getManager());
+      this.persistenceContextInjectionPoints = Beans.getPersistenceContextInjectionPoints(this, getAnnotatedItem(), getManager());
+      this.persistenceUnitInjectionPoints = Beans.getPersistenceUnitInjectionPoints(this, getAnnotatedItem(), getManager());
+      this.resourceInjectionPoints = Beans.getResourceInjectionPoints(this, getAnnotatedItem(), manager);
+   }
+
+   /**
+    * Validates the type
+    */
+   protected void checkType()
+   {
+      if (getAnnotatedItem().isNonStaticMemberClass())
+      {
+         throw new DefinitionException("Simple bean " + type + " cannot be a non-static inner class");
+      }
+      if (!isDependent() && getAnnotatedItem().isParameterizedType())
+      {
+         throw new DefinitionException("Managed bean " + type + " must be @Dependent");
+      }
+      boolean passivating = manager.getServices().get(MetaAnnotationStore.class).getScopeModel(scopeType).isPassivating();
+      if (passivating && !Reflections.isSerializable(getBeanClass()))
+      {
+         throw new DefinitionException("Simple bean declaring a passivating scope must have a serializable implementation class " + toString());
+      }
+      if (hasDecorators())
+      {
+         if (getAnnotatedItem().isFinal())
+         {
+            throw new DefinitionException("Bean class which has decorators cannot be declared final " + this);
+         }
+         for (Decorator<?> decorator : getDecorators())
+         {
+            if (decorator instanceof DecoratorImpl<?>)
+            {
+               DecoratorImpl<?> decoratorBean = (DecoratorImpl<?>) decorator;
+               for (WBMethod<?, ?> decoratorMethod : decoratorBean.getAnnotatedItem().getWBMethods())
+               {
+                  WBMethod<?, ?> method = getAnnotatedItem().getWBMethod(decoratorMethod.getSignature());  
+                  if (method != null && !method.isStatic() && !method.isPrivate() && method.isFinal())
+                  {
+                     throw new DefinitionException("Decorated bean method " + method + " (decorated by "+ decoratorMethod + ") cannot be declarted final");
+                  }
+               }
+            }
+            else
+            {
+               throw new IllegalStateException("Can only operate on container provided decorators " + decorator);
+            }
+         }
+      }
+   }
+
+   @Override
+   protected void checkBeanImplementation()
+   {
+      super.checkBeanImplementation();
+      if (!isDependent())
+      {
+         for (WBField<?, ?> field : getAnnotatedItem().getWBFields())
+         {
+            if (field.isPublic() && !field.isStatic())
+            {
+               throw new DefinitionException("Normal scoped Web Bean implementation class has a public field " + getAnnotatedItem());
+            }
+         }
+      }
+   }
+   
+   protected void checkConstructor()
+   {
+      if (!constructor.getAnnotatedWBParameters(Disposes.class).isEmpty())
+      {
+         throw new DefinitionException("Managed bean constructor must not have a parameter annotated @Disposes " + constructor);
+      }
+      if (!constructor.getAnnotatedWBParameters(Observes.class).isEmpty())
+      {
+         throw new DefinitionException("Managed bean constructor must not have a parameter annotated @Observes " + constructor);
+      }
+   }
+
+   @Override
+   protected void preSpecialize(BeanDeployerEnvironment environment)
+   {
+      super.preSpecialize(environment);
+      if (environment.getEjbDescriptors().contains(getAnnotatedItem().getWBSuperclass().getJavaClass()))
+      {
+         throw new DefinitionException("Simple bean must specialize a simple bean");
+      }
+   }
+
+   @Override
+   protected void specialize(BeanDeployerEnvironment environment)
+   {
+      if (environment.getClassBean(getAnnotatedItem().getWBSuperclass()) == null)
+      {
+         throw new DefinitionException(toString() + " does not specialize a bean");
+      }
+      AbstractClassBean<?> specializedBean = environment.getClassBean(getAnnotatedItem().getWBSuperclass());
+      if (!(specializedBean instanceof ManagedBean))
+      {
+         throw new DefinitionException(toString() + " doesn't have a simple bean as a superclass " + specializedBean);
+      }
+      else
+      {
+         this.specializedBean = (ManagedBean<?>) specializedBean;
+      }
+   }
+
+
+   /**
+    * Initializes the constructor
+    */
+   protected void initConstructor()
+   {
+      this.constructor = Beans.getBeanConstructor(this, getAnnotatedItem());
+      // TODO We loop unecessarily many times here, I want to probably introduce some callback mechanism. PLM.
+      addInjectionPoints(Beans.getParameterInjectionPoints(this, constructor));
+   }
+
+   /**
+    * Returns the constructor
+    * 
+    * @return The constructor
+    */
+   public WBConstructor<T> getConstructor()
+   {
+      return constructor;
+   }
+
+   /**
+    * Gets a string representation
+    * 
+    * @return The string representation
+    */
+   @Override
+   public String toString()
+   {
+      return toString("simple bean");
+   }
+   
+   protected String toString(String beanType)
+   {
+      StringBuilder buffer = new StringBuilder();
+      buffer.append(Names.scopeTypeToString(getScope()));
+      if (getName() == null)
+      {
+         buffer.append("unnamed ").append(beanType);
+      }
+      else
+      {
+         buffer.append(beanType).append(" '" + getName() + "'");
+      }
+      buffer.append(" ").append(getType().getName()).append(", ");
+      buffer.append(" API types = ").append(Names.typesToString(getTypes())).append(", binding types = " + Names.annotationsToString(getQualifiers()));
+      return buffer.toString();
+   }
+
+   @Override
+   public ManagedBean<?> getSpecializedBean()
+   {
+      return specializedBean;
+   }
+
+}

Deleted: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/NewEnterpriseBean.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/NewEnterpriseBean.java	2009-09-15 13:02:01 UTC (rev 3667)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/NewEnterpriseBean.java	2009-09-15 13:31:15 UTC (rev 3668)
@@ -1,126 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,  
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.webbeans.bean;
-
-import java.lang.annotation.Annotation;
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.enterprise.context.Dependent;
-
-import org.jboss.webbeans.BeanManagerImpl;
-import org.jboss.webbeans.ejb.InternalEjbDescriptor;
-import org.jboss.webbeans.introspector.WBClass;
-import org.jboss.webbeans.literal.NewLiteral;
-import org.jboss.webbeans.resources.ClassTransformer;
-
-/**
- * Represents a @New enterprise bean
- * 
- * @author Nicklas Karlsson
- */
-public class NewEnterpriseBean<T> extends EnterpriseBean<T> implements NewBean
-{
-
-   /**
-    * Creates an instance of a NewEnterpriseBean from an annotated class
-    * 
-    * @param clazz The annotated class
-    * @param manager The Web Beans manager
-    * @return a new NewEnterpriseBean instance
-    */
-   public static <T> NewEnterpriseBean<T> of(InternalEjbDescriptor<T> ejbDescriptor, BeanManagerImpl manager)
-   {
-      WBClass<T> type = manager.getServices().get(ClassTransformer.class).loadClass(ejbDescriptor.getBeanClass());
-      return new NewEnterpriseBean<T>(type, ejbDescriptor, manager);
-   }
-   
-   private Set<Annotation> bindings;
-
-   /**
-    * Protected constructor
-    * 
-    * @param type An annotated class
-    * @param manager The Web Beans manager
-    */
-   protected NewEnterpriseBean(final WBClass<T> type, InternalEjbDescriptor<T> ejbDescriptor, BeanManagerImpl manager)
-   {
-      super(type, ejbDescriptor, manager);
-      this.bindings = new HashSet<Annotation>();
-      this.bindings.add(new NewLiteral()
-      {
-         
-         public Class<?> value()
-         {
-            return type.getJavaClass();
-         }
-         
-      });
-   }
-
-   /**
-    * Gets the scope type
-    * 
-    * @return @Dependent
-    */
-   @Override
-   public Class<? extends Annotation> getScope()
-   {
-      return Dependent.class;
-   }
-
-   @Override
-   public boolean isAlternative()
-   {
-      return false;
-   }
-
-   /**
-    * Gets the name of the bean
-    * 
-    * @return null
-    */
-   @Override
-   public String getName()
-   {
-      return null;
-   }
-
-   /**
-    * Gets the bindings
-    * 
-    * @returns @New
-    */
-   @Override
-   public Set<Annotation> getQualifiers()
-   {
-      return bindings;
-   }
-   
-   @Override
-   public boolean isSpecializing()
-   {
-      return false;
-   }
-   
-   @Override
-   protected void checkScopeAllowed()
-   {
-      // No-op
-   }
-
-}

Copied: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/NewManagedBean.java (from rev 3663, ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/NewManagedBean.java)
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/NewManagedBean.java	                        (rev 0)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/NewManagedBean.java	2009-09-15 13:31:15 UTC (rev 3668)
@@ -0,0 +1,117 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,  
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.bean;
+
+import java.lang.annotation.Annotation;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.enterprise.context.Dependent;
+
+import org.jboss.webbeans.BeanManagerImpl;
+import org.jboss.webbeans.introspector.WBClass;
+import org.jboss.webbeans.literal.NewLiteral;
+
+/**
+ * Represents a @New simple bean
+ * 
+ * @author Nicklas Karlsson 
+ */
+public class NewManagedBean<T> extends ManagedBean<T> implements NewBean
+{
+
+   /**
+    * Creates an instance of a NewSimpleBean from an annotated class
+    * 
+    * @param clazz The annotated class
+    * @param manager The Web Beans manager
+    * @return a new NewSimpleBean instance
+    */
+   public static <T> NewManagedBean<T> of(WBClass<T> clazz, BeanManagerImpl manager)
+   {
+      return new NewManagedBean<T>(clazz, manager);
+   }
+   
+   private Set<Annotation> bindings;
+
+   /**
+    * Protected constructor
+    * 
+    * @param type An annotated class
+    * @param manager The Web Beans manager
+    */
+   protected NewManagedBean(final WBClass<T> type, BeanManagerImpl manager)
+   {
+      super(type, manager);
+      this.bindings = new HashSet<Annotation>();
+      this.bindings.add(new NewLiteral()
+      {
+         
+         public Class<?> value()
+         {
+            return type.getJavaClass();
+         }
+         
+      });
+   }
+
+   /**
+    * Gets the scope type
+    * 
+    * @return @Dependent
+    */
+   @Override
+   public Class<? extends Annotation> getScope()
+   {
+      return Dependent.class;
+   }
+
+   @Override
+   public boolean isAlternative()
+   {
+      return false;
+   }
+
+   /**
+    * Gets the name of the bean
+    * 
+    * @return null
+    */
+   @Override
+   public String getName()
+   {
+      return null;
+   }
+
+   /**
+    * Gets the bindings
+    * 
+    * @returns @New
+    */
+   @Override
+   public Set<Annotation> getQualifiers()
+   {
+      return bindings;
+   }
+
+   @Override
+   public boolean isSpecializing()
+   {
+      return false;
+   }
+   
+}

Copied: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/NewSessionBean.java (from rev 3663, ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/NewSessionBean.java)
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/NewSessionBean.java	                        (rev 0)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/NewSessionBean.java	2009-09-15 13:31:15 UTC (rev 3668)
@@ -0,0 +1,126 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,  
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.bean;
+
+import java.lang.annotation.Annotation;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.enterprise.context.Dependent;
+
+import org.jboss.webbeans.BeanManagerImpl;
+import org.jboss.webbeans.ejb.InternalEjbDescriptor;
+import org.jboss.webbeans.introspector.WBClass;
+import org.jboss.webbeans.literal.NewLiteral;
+import org.jboss.webbeans.resources.ClassTransformer;
+
+/**
+ * Represents a @New enterprise bean
+ * 
+ * @author Nicklas Karlsson
+ */
+public class NewSessionBean<T> extends SessionBean<T> implements NewBean
+{
+
+   /**
+    * Creates an instance of a NewEnterpriseBean from an annotated class
+    * 
+    * @param clazz The annotated class
+    * @param manager The Web Beans manager
+    * @return a new NewEnterpriseBean instance
+    */
+   public static <T> NewSessionBean<T> of(InternalEjbDescriptor<T> ejbDescriptor, BeanManagerImpl manager)
+   {
+      WBClass<T> type = manager.getServices().get(ClassTransformer.class).loadClass(ejbDescriptor.getBeanClass());
+      return new NewSessionBean<T>(type, ejbDescriptor, manager);
+   }
+   
+   private Set<Annotation> bindings;
+
+   /**
+    * Protected constructor
+    * 
+    * @param type An annotated class
+    * @param manager The Web Beans manager
+    */
+   protected NewSessionBean(final WBClass<T> type, InternalEjbDescriptor<T> ejbDescriptor, BeanManagerImpl manager)
+   {
+      super(type, ejbDescriptor, manager);
+      this.bindings = new HashSet<Annotation>();
+      this.bindings.add(new NewLiteral()
+      {
+         
+         public Class<?> value()
+         {
+            return type.getJavaClass();
+         }
+         
+      });
+   }
+
+   /**
+    * Gets the scope type
+    * 
+    * @return @Dependent
+    */
+   @Override
+   public Class<? extends Annotation> getScope()
+   {
+      return Dependent.class;
+   }
+
+   @Override
+   public boolean isAlternative()
+   {
+      return false;
+   }
+
+   /**
+    * Gets the name of the bean
+    * 
+    * @return null
+    */
+   @Override
+   public String getName()
+   {
+      return null;
+   }
+
+   /**
+    * Gets the bindings
+    * 
+    * @returns @New
+    */
+   @Override
+   public Set<Annotation> getQualifiers()
+   {
+      return bindings;
+   }
+   
+   @Override
+   public boolean isSpecializing()
+   {
+      return false;
+   }
+   
+   @Override
+   protected void checkScopeAllowed()
+   {
+      // No-op
+   }
+
+}

Deleted: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/NewSimpleBean.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/NewSimpleBean.java	2009-09-15 13:02:01 UTC (rev 3667)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/NewSimpleBean.java	2009-09-15 13:31:15 UTC (rev 3668)
@@ -1,117 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,  
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.webbeans.bean;
-
-import java.lang.annotation.Annotation;
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.enterprise.context.Dependent;
-
-import org.jboss.webbeans.BeanManagerImpl;
-import org.jboss.webbeans.introspector.WBClass;
-import org.jboss.webbeans.literal.NewLiteral;
-
-/**
- * Represents a @New simple bean
- * 
- * @author Nicklas Karlsson 
- */
-public class NewSimpleBean<T> extends SimpleBean<T> implements NewBean
-{
-
-   /**
-    * Creates an instance of a NewSimpleBean from an annotated class
-    * 
-    * @param clazz The annotated class
-    * @param manager The Web Beans manager
-    * @return a new NewSimpleBean instance
-    */
-   public static <T> NewSimpleBean<T> of(WBClass<T> clazz, BeanManagerImpl manager)
-   {
-      return new NewSimpleBean<T>(clazz, manager);
-   }
-   
-   private Set<Annotation> bindings;
-
-   /**
-    * Protected constructor
-    * 
-    * @param type An annotated class
-    * @param manager The Web Beans manager
-    */
-   protected NewSimpleBean(final WBClass<T> type, BeanManagerImpl manager)
-   {
-      super(type, manager);
-      this.bindings = new HashSet<Annotation>();
-      this.bindings.add(new NewLiteral()
-      {
-         
-         public Class<?> value()
-         {
-            return type.getJavaClass();
-         }
-         
-      });
-   }
-
-   /**
-    * Gets the scope type
-    * 
-    * @return @Dependent
-    */
-   @Override
-   public Class<? extends Annotation> getScope()
-   {
-      return Dependent.class;
-   }
-
-   @Override
-   public boolean isAlternative()
-   {
-      return false;
-   }
-
-   /**
-    * Gets the name of the bean
-    * 
-    * @return null
-    */
-   @Override
-   public String getName()
-   {
-      return null;
-   }
-
-   /**
-    * Gets the bindings
-    * 
-    * @returns @New
-    */
-   @Override
-   public Set<Annotation> getQualifiers()
-   {
-      return bindings;
-   }
-
-   @Override
-   public boolean isSpecializing()
-   {
-      return false;
-   }
-   
-}

Copied: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/ProducerField.java (from rev 3663, ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerField.java)
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/ProducerField.java	                        (rev 0)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/ProducerField.java	2009-09-15 13:31:15 UTC (rev 3668)
@@ -0,0 +1,168 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,  
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.bean;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.util.Collections;
+import java.util.Set;
+
+import javax.enterprise.context.spi.CreationalContext;
+
+import org.jboss.webbeans.BeanManagerImpl;
+import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
+import org.jboss.webbeans.introspector.WBField;
+import org.jboss.webbeans.util.Names;
+
+/**
+ * Represents a producer field
+ * 
+ * @author Pete Muir
+ * 
+ * @param <T>
+ */
+public class ProducerField<T> extends AbstractProducerBean<T, Field>
+{
+   // The underlying field
+   private WBField<T, ?> field;
+   private final String id;
+   
+   /**
+    * Creates a producer field
+    * 
+    * @param field The underlying method abstraction
+    * @param declaringBean The declaring bean abstraction
+    * @param manager the current manager
+    * @return A producer field
+    */
+   public static <T> ProducerField<T> of(WBField<T, ?> field, AbstractClassBean<?> declaringBean, BeanManagerImpl manager)
+   {
+      return new ProducerField<T>(field, declaringBean, manager);
+   }
+
+   /**
+    * Constructor
+    * 
+    * @param method The producer field abstraction
+    * @param declaringBean The declaring bean
+    * @param manager The Web Beans manager
+    */
+   protected ProducerField(WBField<T, ?> field, AbstractClassBean<?> declaringBean, BeanManagerImpl manager)
+   {
+      super(declaringBean, manager);
+      this.field = field;
+      initType();
+      initTypes();
+      initBindings();
+      this.id = createId("ProducerField-" + declaringBean.getType().getName() + "-"+ field.getName());
+      initStereotypes();
+      initPolicy();
+   }
+   
+   @Override
+   public void initialize(BeanDeployerEnvironment environment)
+   {
+      if (!isInitialized())
+      {
+         super.initialize(environment);
+      }
+   }
+
+   public void destroy(T instance, CreationalContext<T> creationalContext)
+   {
+      dispose(instance);
+   }
+
+   public void dispose(T instance)
+   {
+      // No clean up required
+   }
+
+   public T produce(CreationalContext<T> ctx)
+   {
+      return field.get(getReceiver(ctx));
+   }
+
+
+   /**
+    * Gets the annotated item representing the field
+    * 
+    * @return The annotated item
+    */
+   @Override
+   protected WBField<T, ?> getAnnotatedItem()
+   {
+      return field;
+   }
+
+   /**
+    * Returns the default name
+    * 
+    * @return The default name
+    */
+   @Override
+   protected String getDefaultName()
+   {
+      return field.getPropertyName();
+   }
+
+   /**
+    * Gets a string representation
+    * 
+    * @return The string representation
+    */
+   @Override
+   public String toString()
+   {
+      StringBuilder buffer = new StringBuilder();
+      buffer.append("Annotated " + Names.scopeTypeToString(getScope()));
+      if (getName() == null)
+      {
+         buffer.append("unnamed producer field bean");
+      }
+      else
+      {
+         buffer.append("simple producer field bean '" + getName() + "'");
+      }
+      buffer.append(" [" + getBeanClass().getName() + "] for class type [" + getType().getName() + "] API types " + getTypes() + ", binding types " + getQualifiers());
+      return buffer.toString();
+   }
+   
+   @Override
+   public AbstractBean<?, ?> getSpecializedBean()
+   {
+      return null;
+   }
+   
+   @Override
+   public boolean isSpecializing()
+   {
+      return false;
+   }
+   
+   @Override
+   public String getId()
+   {
+      return id;
+   }
+
+   public Set<Class<? extends Annotation>> getStereotypes()
+   {
+      return Collections.emptySet();
+   }
+
+}

Deleted: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/ProducerFieldBean.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/ProducerFieldBean.java	2009-09-15 13:02:01 UTC (rev 3667)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/ProducerFieldBean.java	2009-09-15 13:31:15 UTC (rev 3668)
@@ -1,168 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,  
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.webbeans.bean;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Field;
-import java.util.Collections;
-import java.util.Set;
-
-import javax.enterprise.context.spi.CreationalContext;
-
-import org.jboss.webbeans.BeanManagerImpl;
-import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
-import org.jboss.webbeans.introspector.WBField;
-import org.jboss.webbeans.util.Names;
-
-/**
- * Represents a producer field bean
- * 
- * @author Pete Muir
- * 
- * @param <T>
- */
-public class ProducerFieldBean<T> extends AbstractProducerBean<T, Field>
-{
-   // The underlying field
-   private WBField<T, ?> field;
-   private final String id;
-   
-   /**
-    * Creates a producer field Web Bean
-    * 
-    * @param field The underlying method abstraction
-    * @param declaringBean The declaring bean abstraction
-    * @param manager the current manager
-    * @return A producer Web Bean
-    */
-   public static <T> ProducerFieldBean<T> of(WBField<T, ?> field, AbstractClassBean<?> declaringBean, BeanManagerImpl manager)
-   {
-      return new ProducerFieldBean<T>(field, declaringBean, manager);
-   }
-
-   /**
-    * Constructor
-    * 
-    * @param method The producer field abstraction
-    * @param declaringBean The declaring bean
-    * @param manager The Web Beans manager
-    */
-   protected ProducerFieldBean(WBField<T, ?> field, AbstractClassBean<?> declaringBean, BeanManagerImpl manager)
-   {
-      super(declaringBean, manager);
-      this.field = field;
-      initType();
-      initTypes();
-      initBindings();
-      this.id = createId("ProducerField-" + declaringBean.getType().getName() + "-"+ field.getName());
-      initStereotypes();
-      initPolicy();
-   }
-   
-   @Override
-   public void initialize(BeanDeployerEnvironment environment)
-   {
-      if (!isInitialized())
-      {
-         super.initialize(environment);
-      }
-   }
-
-   public void destroy(T instance, CreationalContext<T> creationalContext)
-   {
-      dispose(instance);
-   }
-
-   public void dispose(T instance)
-   {
-      // No clean up required
-   }
-
-   public T produce(CreationalContext<T> ctx)
-   {
-      return field.get(getReceiver(ctx));
-   }
-
-
-   /**
-    * Gets the annotated item representing the field
-    * 
-    * @return The annotated item
-    */
-   @Override
-   protected WBField<T, ?> getAnnotatedItem()
-   {
-      return field;
-   }
-
-   /**
-    * Returns the default name
-    * 
-    * @return The default name
-    */
-   @Override
-   protected String getDefaultName()
-   {
-      return field.getPropertyName();
-   }
-
-   /**
-    * Gets a string representation
-    * 
-    * @return The string representation
-    */
-   @Override
-   public String toString()
-   {
-      StringBuilder buffer = new StringBuilder();
-      buffer.append("Annotated " + Names.scopeTypeToString(getScope()));
-      if (getName() == null)
-      {
-         buffer.append("unnamed producer field bean");
-      }
-      else
-      {
-         buffer.append("simple producer field bean '" + getName() + "'");
-      }
-      buffer.append(" [" + getBeanClass().getName() + "] for class type [" + getType().getName() + "] API types " + getTypes() + ", binding types " + getQualifiers());
-      return buffer.toString();
-   }
-   
-   @Override
-   public AbstractBean<?, ?> getSpecializedBean()
-   {
-      return null;
-   }
-   
-   @Override
-   public boolean isSpecializing()
-   {
-      return false;
-   }
-   
-   @Override
-   public String getId()
-   {
-      return id;
-   }
-
-   public Set<Class<? extends Annotation>> getStereotypes()
-   {
-      return Collections.emptySet();
-   }
-
-}

Copied: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethod.java (from rev 3663, ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethod.java)
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethod.java	                        (rev 0)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethod.java	2009-09-15 13:31:15 UTC (rev 3668)
@@ -0,0 +1,293 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,  
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.bean;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+import java.util.Collections;
+import java.util.Set;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.CreationException;
+import javax.enterprise.inject.Disposes;
+
+import org.jboss.webbeans.BeanManagerImpl;
+import org.jboss.webbeans.DefinitionException;
+import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
+import org.jboss.webbeans.injection.MethodInjectionPoint;
+import org.jboss.webbeans.injection.ParameterInjectionPoint;
+import org.jboss.webbeans.introspector.WBMethod;
+import org.jboss.webbeans.introspector.WBParameter;
+import org.jboss.webbeans.util.Names;
+
+/**
+ * Represents a producer method bean
+ * 
+ * @author Pete Muir
+ * 
+ * @param <T>
+ */
+public class ProducerMethod<T> extends AbstractProducerBean<T, Method>
+{
+   // The underlying method
+   private MethodInjectionPoint<T, ?> method;
+
+   private DisposalMethod<?> disposalMethodBean;
+
+   private ProducerMethod<?> specializedBean;
+
+   private final String id;
+
+   /**
+    * Creates a producer method Web Bean
+    * 
+    * @param method The underlying method abstraction
+    * @param declaringBean The declaring bean abstraction
+    * @param manager the current manager
+    * @return A producer Web Bean
+    */
+   public static <T> ProducerMethod<T> of(WBMethod<T, ?> method, AbstractClassBean<?> declaringBean, BeanManagerImpl manager)
+   {
+      return new ProducerMethod<T>(method, declaringBean, manager);
+   }
+
+   protected ProducerMethod(WBMethod<T, ?> method, AbstractClassBean<?> declaringBean, BeanManagerImpl manager)
+   {
+      super(declaringBean, manager);
+      this.method = MethodInjectionPoint.of(this, method);
+      initType();
+      initTypes();
+      initBindings();
+      this.id = createId("ProducerMethod-" + declaringBean.getType().getName() + "-" + method.getSignature().toString());
+      initStereotypes();
+      initPolicy();
+   }
+
+   public T produce(CreationalContext<T> creationalContext)
+   {
+      Object receiver = getReceiver(creationalContext);
+      if (receiver != null)
+      {
+         return method.invokeOnInstance(receiver, manager, creationalContext, CreationException.class);
+      }
+      else
+      {
+         return method.invoke(receiver, manager, creationalContext, CreationException.class);
+      }
+   }
+
+   /**
+    * Initializes the bean and its metadata
+    */
+   @Override
+   public void initialize(BeanDeployerEnvironment environment)
+   {
+      if (!isInitialized())
+      {
+         initProducerMethodInjectableParameters();
+         super.initialize(environment);
+         checkProducerMethod();
+         initDisposalMethod(environment);
+      }
+   }
+
+   /**
+    * Initializes the injection points
+    */
+   protected void initProducerMethodInjectableParameters()
+   {
+      for (WBParameter<?, ?> parameter : method.getWBParameters())
+      {
+         addInjectionPoint(ParameterInjectionPoint.of(this, parameter));
+      }
+   }
+
+   /**
+    * Validates the producer method
+    */
+   protected void checkProducerMethod()
+   {
+      if (getAnnotatedItem().getAnnotatedWBParameters(Observes.class).size() > 0)
+      {
+         throw new DefinitionException("Producer method cannot have parameter annotated @Observes");
+      }
+      else if (getAnnotatedItem().getAnnotatedWBParameters(Disposes.class).size() > 0)
+      {
+         throw new DefinitionException("Producer method cannot have parameter annotated @Disposes");
+      }
+      else if (getDeclaringBean() instanceof SessionBean<?>)
+      {
+         boolean methodDeclaredOnTypes = false;
+         // TODO use annotated item?
+         for (Type type : getDeclaringBean().getTypes())
+         {
+            if (type instanceof Class)
+            {
+               Class<?> clazz = (Class<?>) type;
+               try
+               {
+                  clazz.getDeclaredMethod(getAnnotatedItem().getName(), getAnnotatedItem().getParameterTypesAsArray());
+                  methodDeclaredOnTypes = true;
+               }
+               catch (NoSuchMethodException nsme)
+               {
+                  // No - op
+               }
+            }
+         }
+         if (!methodDeclaredOnTypes)
+         {
+            throw new DefinitionException("Producer method " + toString() + " must be declared on a business interface of " + getDeclaringBean());
+         }
+      }
+   }
+
+   /**
+    * Initializes the remove method
+    */
+   protected void initDisposalMethod(BeanDeployerEnvironment environment)
+   {
+      Set<DisposalMethod<?>> disposalBeans = environment.resolveDisposalBeans(getTypes(), getQualifiers(), getDeclaringBean());
+
+      if (disposalBeans.size() == 1)
+      {
+         this.disposalMethodBean = disposalBeans.iterator().next();
+      }
+      else if (disposalBeans.size() > 1)
+      {
+         // TODO List out found disposal methods
+         throw new DefinitionException("Cannot declare multiple disposal methods for this producer method. Producer method: " + this + ". Disposal methods: " + disposalBeans);
+      }
+   }
+
+   public void destroy(T instance, CreationalContext<T> creationalContext)
+   {
+      try
+      {
+         dispose(instance);
+      }
+      finally
+      {
+         if (getDeclaringBean().isDependent())
+         {
+            creationalContext.release();
+         }
+      }
+   }
+   
+   public void dispose(T instance) 
+   {
+      if (disposalMethodBean != null)
+      {
+         disposalMethodBean.invokeDisposeMethod(instance);
+      }
+   }
+
+   /**
+    * Gets the annotated item representing the method
+    * 
+    * @return The annotated item
+    */
+   @Override
+   public WBMethod<T, ?> getAnnotatedItem()
+   {
+      return method;
+   }
+
+   /**
+    * Returns the default name
+    * 
+    * @return The default name
+    */
+   @Override
+   protected String getDefaultName()
+   {
+      return method.getPropertyName();
+   }
+
+   /**
+    * Returns the disposal method
+    * 
+    * @return The method representation
+    */
+   public DisposalMethod<?> getDisposalMethod()
+   {
+      return disposalMethodBean;
+   }
+
+   /**
+    * Gets a string representation
+    * 
+    * @return The string representation
+    */
+   @Override
+   public String toString()
+   {
+      StringBuilder buffer = new StringBuilder();
+      buffer.append(Names.scopeTypeToString(getScope()));
+      if (getName() == null)
+      {
+         buffer.append("unnamed producer method bean");
+      }
+      else
+      {
+         buffer.append("simple producer method bean '" + getName() + "'");
+      }
+      buffer.append(" [" + getBeanClass().getName() + "] for class type [" + getType().getName() + "] API types " + getTypes() + ", binding types " + getQualifiers());
+      return buffer.toString();
+   }
+
+   @Override
+   public AbstractBean<?, ?> getSpecializedBean()
+   {
+      return specializedBean;
+   }
+
+   @Override
+   protected void preSpecialize(BeanDeployerEnvironment environment)
+   {
+      if (getDeclaringBean().getAnnotatedItem().getWBSuperclass().getDeclaredWBMethod(getAnnotatedItem().getAnnotatedMethod()) == null)
+      {
+         throw new DefinitionException("Specialized producer method does not override a method on the direct superclass");
+      }
+   }
+
+   @Override
+   protected void specialize(BeanDeployerEnvironment environment)
+   {
+      WBMethod<?, ?> superClassMethod = getDeclaringBean().getAnnotatedItem().getWBSuperclass().getWBMethod(getAnnotatedItem().getAnnotatedMethod());
+      if (environment.getProducerMethod(superClassMethod) == null)
+      {
+         throw new IllegalStateException(toString() + " does not specialize a bean");
+      }
+      this.specializedBean = environment.getProducerMethod(superClassMethod);
+   }
+
+   @Override
+   public String getId()
+   {
+      return id;
+   }
+
+   public Set<Class<? extends Annotation>> getStereotypes()
+   {
+      return Collections.emptySet();
+   }
+
+}

Deleted: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java	2009-09-15 13:02:01 UTC (rev 3667)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java	2009-09-15 13:31:15 UTC (rev 3668)
@@ -1,293 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,  
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.webbeans.bean;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Method;
-import java.lang.reflect.Type;
-import java.util.Collections;
-import java.util.Set;
-
-import javax.enterprise.context.spi.CreationalContext;
-import javax.enterprise.event.Observes;
-import javax.enterprise.inject.CreationException;
-import javax.enterprise.inject.Disposes;
-
-import org.jboss.webbeans.BeanManagerImpl;
-import org.jboss.webbeans.DefinitionException;
-import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
-import org.jboss.webbeans.injection.MethodInjectionPoint;
-import org.jboss.webbeans.injection.ParameterInjectionPoint;
-import org.jboss.webbeans.introspector.WBMethod;
-import org.jboss.webbeans.introspector.WBParameter;
-import org.jboss.webbeans.util.Names;
-
-/**
- * Represents a producer method bean
- * 
- * @author Pete Muir
- * 
- * @param <T>
- */
-public class ProducerMethodBean<T> extends AbstractProducerBean<T, Method>
-{
-   // The underlying method
-   private MethodInjectionPoint<T, ?> method;
-
-   private DisposalMethodBean<?> disposalMethodBean;
-
-   private ProducerMethodBean<?> specializedBean;
-
-   private final String id;
-
-   /**
-    * Creates a producer method Web Bean
-    * 
-    * @param method The underlying method abstraction
-    * @param declaringBean The declaring bean abstraction
-    * @param manager the current manager
-    * @return A producer Web Bean
-    */
-   public static <T> ProducerMethodBean<T> of(WBMethod<T, ?> method, AbstractClassBean<?> declaringBean, BeanManagerImpl manager)
-   {
-      return new ProducerMethodBean<T>(method, declaringBean, manager);
-   }
-
-   protected ProducerMethodBean(WBMethod<T, ?> method, AbstractClassBean<?> declaringBean, BeanManagerImpl manager)
-   {
-      super(declaringBean, manager);
-      this.method = MethodInjectionPoint.of(this, method);
-      initType();
-      initTypes();
-      initBindings();
-      this.id = createId("ProducerMethod-" + declaringBean.getType().getName() + "-" + method.getSignature().toString());
-      initStereotypes();
-      initPolicy();
-   }
-
-   public T produce(CreationalContext<T> creationalContext)
-   {
-      Object receiver = getReceiver(creationalContext);
-      if (receiver != null)
-      {
-         return method.invokeOnInstance(receiver, manager, creationalContext, CreationException.class);
-      }
-      else
-      {
-         return method.invoke(receiver, manager, creationalContext, CreationException.class);
-      }
-   }
-
-   /**
-    * Initializes the bean and its metadata
-    */
-   @Override
-   public void initialize(BeanDeployerEnvironment environment)
-   {
-      if (!isInitialized())
-      {
-         initProducerMethodInjectableParameters();
-         super.initialize(environment);
-         checkProducerMethod();
-         initDisposalMethod(environment);
-      }
-   }
-
-   /**
-    * Initializes the injection points
-    */
-   protected void initProducerMethodInjectableParameters()
-   {
-      for (WBParameter<?, ?> parameter : method.getWBParameters())
-      {
-         addInjectionPoint(ParameterInjectionPoint.of(this, parameter));
-      }
-   }
-
-   /**
-    * Validates the producer method
-    */
-   protected void checkProducerMethod()
-   {
-      if (getAnnotatedItem().getAnnotatedWBParameters(Observes.class).size() > 0)
-      {
-         throw new DefinitionException("Producer method cannot have parameter annotated @Observes");
-      }
-      else if (getAnnotatedItem().getAnnotatedWBParameters(Disposes.class).size() > 0)
-      {
-         throw new DefinitionException("Producer method cannot have parameter annotated @Disposes");
-      }
-      else if (getDeclaringBean() instanceof EnterpriseBean<?>)
-      {
-         boolean methodDeclaredOnTypes = false;
-         // TODO use annotated item?
-         for (Type type : getDeclaringBean().getTypes())
-         {
-            if (type instanceof Class)
-            {
-               Class<?> clazz = (Class<?>) type;
-               try
-               {
-                  clazz.getDeclaredMethod(getAnnotatedItem().getName(), getAnnotatedItem().getParameterTypesAsArray());
-                  methodDeclaredOnTypes = true;
-               }
-               catch (NoSuchMethodException nsme)
-               {
-                  // No - op
-               }
-            }
-         }
-         if (!methodDeclaredOnTypes)
-         {
-            throw new DefinitionException("Producer method " + toString() + " must be declared on a business interface of " + getDeclaringBean());
-         }
-      }
-   }
-
-   /**
-    * Initializes the remove method
-    */
-   protected void initDisposalMethod(BeanDeployerEnvironment environment)
-   {
-      Set<DisposalMethodBean<?>> disposalBeans = environment.resolveDisposalBeans(getTypes(), getQualifiers(), getDeclaringBean());
-
-      if (disposalBeans.size() == 1)
-      {
-         this.disposalMethodBean = disposalBeans.iterator().next();
-      }
-      else if (disposalBeans.size() > 1)
-      {
-         // TODO List out found disposal methods
-         throw new DefinitionException("Cannot declare multiple disposal methods for this producer method. Producer method: " + this + ". Disposal methods: " + disposalBeans);
-      }
-   }
-
-   public void destroy(T instance, CreationalContext<T> creationalContext)
-   {
-      try
-      {
-         dispose(instance);
-      }
-      finally
-      {
-         if (getDeclaringBean().isDependent())
-         {
-            creationalContext.release();
-         }
-      }
-   }
-   
-   public void dispose(T instance) 
-   {
-      if (disposalMethodBean != null)
-      {
-         disposalMethodBean.invokeDisposeMethod(instance);
-      }
-   }
-
-   /**
-    * Gets the annotated item representing the method
-    * 
-    * @return The annotated item
-    */
-   @Override
-   public WBMethod<T, ?> getAnnotatedItem()
-   {
-      return method;
-   }
-
-   /**
-    * Returns the default name
-    * 
-    * @return The default name
-    */
-   @Override
-   protected String getDefaultName()
-   {
-      return method.getPropertyName();
-   }
-
-   /**
-    * Returns the disposal method
-    * 
-    * @return The method representation
-    */
-   public DisposalMethodBean<?> getDisposalMethod()
-   {
-      return disposalMethodBean;
-   }
-
-   /**
-    * Gets a string representation
-    * 
-    * @return The string representation
-    */
-   @Override
-   public String toString()
-   {
-      StringBuilder buffer = new StringBuilder();
-      buffer.append(Names.scopeTypeToString(getScope()));
-      if (getName() == null)
-      {
-         buffer.append("unnamed producer method bean");
-      }
-      else
-      {
-         buffer.append("simple producer method bean '" + getName() + "'");
-      }
-      buffer.append(" [" + getBeanClass().getName() + "] for class type [" + getType().getName() + "] API types " + getTypes() + ", binding types " + getQualifiers());
-      return buffer.toString();
-   }
-
-   @Override
-   public AbstractBean<?, ?> getSpecializedBean()
-   {
-      return specializedBean;
-   }
-
-   @Override
-   protected void preSpecialize(BeanDeployerEnvironment environment)
-   {
-      if (getDeclaringBean().getAnnotatedItem().getWBSuperclass().getDeclaredWBMethod(getAnnotatedItem().getAnnotatedMethod()) == null)
-      {
-         throw new DefinitionException("Specialized producer method does not override a method on the direct superclass");
-      }
-   }
-
-   @Override
-   protected void specialize(BeanDeployerEnvironment environment)
-   {
-      WBMethod<?, ?> superClassMethod = getDeclaringBean().getAnnotatedItem().getWBSuperclass().getWBMethod(getAnnotatedItem().getAnnotatedMethod());
-      if (environment.getProducerMethod(superClassMethod) == null)
-      {
-         throw new IllegalStateException(toString() + " does not specialize a bean");
-      }
-      this.specializedBean = environment.getProducerMethod(superClassMethod);
-   }
-
-   @Override
-   public String getId()
-   {
-      return id;
-   }
-
-   public Set<Class<? extends Annotation>> getStereotypes()
-   {
-      return Collections.emptySet();
-   }
-
-}

Copied: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/SessionBean.java (from rev 3663, ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SessionBean.java)
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/SessionBean.java	                        (rev 0)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/SessionBean.java	2009-09-15 13:31:15 UTC (rev 3668)
@@ -0,0 +1,402 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,  
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.bean;
+
+import java.io.Serializable;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+import javassist.util.proxy.ProxyFactory;
+import javassist.util.proxy.ProxyObject;
+
+import javax.decorator.Decorator;
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.CreationException;
+import javax.interceptor.Interceptor;
+
+import org.jboss.webbeans.BeanManagerImpl;
+import org.jboss.webbeans.DefinitionException;
+import org.jboss.webbeans.bean.proxy.EnterpriseBeanInstance;
+import org.jboss.webbeans.bean.proxy.EnterpriseBeanProxyMethodHandler;
+import org.jboss.webbeans.bean.proxy.Marker;
+import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
+import org.jboss.webbeans.ejb.InternalEjbDescriptor;
+import org.jboss.webbeans.ejb.api.SessionObjectReference;
+import org.jboss.webbeans.ejb.spi.BusinessInterfaceDescriptor;
+import org.jboss.webbeans.ejb.spi.EjbServices;
+import org.jboss.webbeans.injection.InjectionContextImpl;
+import org.jboss.webbeans.introspector.WBClass;
+import org.jboss.webbeans.introspector.WBMethod;
+import org.jboss.webbeans.log.Log;
+import org.jboss.webbeans.log.Logging;
+import org.jboss.webbeans.resources.ClassTransformer;
+import org.jboss.webbeans.util.Beans;
+import org.jboss.webbeans.util.Proxies;
+
+/**
+ * An enterprise bean representation
+ * 
+ * @author Pete Muir
+ * 
+ * @param <T> The type (class) of the bean
+ */
+public class SessionBean<T> extends AbstractClassBean<T>
+{
+   private final Log log = Logging.getLog(SessionBean.class);
+
+   // The EJB descriptor
+   private InternalEjbDescriptor<T> ejbDescriptor;
+
+   private Class<T> proxyClass;
+
+   private SessionBean<?> specializedBean;
+
+   /**
+    * Creates a simple, annotation defined Enterprise Web Bean
+    * 
+    * @param <T> The type
+    * @param clazz The class
+    * @param manager the current manager
+    * @return An Enterprise Web Bean
+    */
+   public static <T> SessionBean<T> of(InternalEjbDescriptor<T> ejbDescriptor, BeanManagerImpl manager)
+   {
+      WBClass<T> type = manager.getServices().get(ClassTransformer.class).loadClass(ejbDescriptor.getBeanClass());
+      return new SessionBean<T>(type, ejbDescriptor, manager);
+   }
+
+   /**
+    * Constructor
+    * 
+    * @param type The type of the bean
+    * @param manager The Web Beans manager
+    */
+   protected SessionBean(WBClass<T> type, InternalEjbDescriptor<T> ejbDescriptor, BeanManagerImpl manager)
+   {
+      super(type, manager);
+      initType();
+      this.ejbDescriptor = ejbDescriptor;
+      initTypes();
+      initBindings();
+   }
+
+   /**
+    * Initializes the bean and its metadata
+    */
+   @Override
+   public void initialize(BeanDeployerEnvironment environment)
+   {
+      if (!isInitialized())
+      {
+         super.initialize(environment);
+         initProxyClass();
+         checkEJBTypeAllowed();
+         checkConflictingRoles();
+         checkObserverMethods();
+         checkScopeAllowed();
+      }
+   }
+
+   @Override
+   protected void initTypes()
+   {
+      Set<Type> types = new HashSet<Type>();
+      types = new LinkedHashSet<Type>();
+      types.add(Object.class);
+      for (BusinessInterfaceDescriptor<?> businessInterfaceDescriptor : ejbDescriptor.getLocalBusinessInterfaces())
+      {
+         types.add(businessInterfaceDescriptor.getInterface());
+      }
+      super.types = types;
+   }
+
+   protected void initProxyClass()
+   {
+      Set<Type> types = new LinkedHashSet<Type>(getTypes());
+      types.add(EnterpriseBeanInstance.class);
+      types.add(Serializable.class);
+      ProxyFactory proxyFactory = Proxies.getProxyFactory(types);
+
+      @SuppressWarnings("unchecked")
+      Class<T> proxyClass = proxyFactory.createClass();
+
+      this.proxyClass = proxyClass;
+   }
+
+   /**
+    * Validates for non-conflicting roles
+    */
+   protected void checkConflictingRoles()
+   {
+      if (getType().isAnnotationPresent(Interceptor.class))
+      {
+         throw new DefinitionException("Enterprise beans cannot be interceptors");
+      }
+      if (getType().isAnnotationPresent(Decorator.class))
+      {
+         throw new DefinitionException("Enterprise beans cannot be decorators");
+      }
+   }
+
+   /**
+    * Check that the scope type is allowed by the stereotypes on the bean and
+    * the bean type
+    */
+   protected void checkScopeAllowed()
+   {
+      if (ejbDescriptor.isStateless() && !isDependent())
+      {
+         throw new DefinitionException("Scope " + getScope() + " is not allowed on stateless enterpise beans for " + getType() + ". Only @Dependent is allowed on stateless enterprise beans");
+      }
+      if (ejbDescriptor.isSingleton() && !(isDependent() || getScope().equals(ApplicationScoped.class)))
+      {
+         throw new DefinitionException("Scope " + getScope() + " is not allowed on singleton enterpise beans for " + getType() + ". Only @Dependent or @ApplicationScoped is allowed on singleton enterprise beans");
+      }
+   }
+
+   /**
+    * Validates specialization
+    */
+   @Override
+   protected void preSpecialize(BeanDeployerEnvironment environment)
+   {
+      super.preSpecialize(environment);
+      // We appear to check this twice?
+      if (!environment.getEjbDescriptors().contains(getAnnotatedItem().getWBSuperclass().getJavaClass()))
+      {
+         throw new DefinitionException("Annotation defined specializing EJB must have EJB superclass");
+      }
+   }
+
+   @Override
+   protected void specialize(BeanDeployerEnvironment environment)
+   {
+      if (environment.getClassBean(getAnnotatedItem().getWBSuperclass()) == null)
+      {
+         throw new IllegalStateException(toString() + " does not specialize a bean");
+      }
+      AbstractClassBean<?> specializedBean = environment.getClassBean(getAnnotatedItem().getWBSuperclass());
+      if (!(specializedBean instanceof SessionBean<?>))
+      {
+         throw new IllegalStateException(toString() + " doesn't have a session bean as a superclass " + specializedBean);
+      }
+      else
+      {
+         this.specializedBean = (SessionBean<?>) specializedBean; 
+      }
+   }
+
+   /**
+    * Creates an instance of the bean
+    * 
+    * @return The instance
+    */
+   public T create(final CreationalContext<T> creationalContext)
+   {
+      T instance = produce(creationalContext);
+      if (hasDecorators())
+      {
+         instance = applyDecorators(instance, creationalContext, null);
+      }
+      return instance;
+   }
+   
+   public void inject(final T instance, final CreationalContext<T> ctx)
+   {
+      new InjectionContextImpl<T>(getManager(), this, instance)
+      {
+         
+         public void proceed()
+         {
+            Beans.injectBoundFields(instance, ctx, getManager(), getInjectableFields());
+            Beans.callInitializers(instance, ctx, getManager(), getInitializerMethods());
+         }
+         
+      }.run();
+      
+   }
+
+   public T produce(CreationalContext<T> ctx)
+   {
+      try
+      {
+         T instance = proxyClass.newInstance();
+         ctx.push(instance);
+         ((ProxyObject) instance).setHandler(new EnterpriseBeanProxyMethodHandler<T>(this, ctx));
+         log.trace("Enterprise bean instance created for bean {0}", this);
+         return instance;
+      }
+      catch (InstantiationException e)
+      {
+         throw new RuntimeException("Could not instantiate enterprise proxy for " + toString(), e);
+      }
+      catch (IllegalAccessException e)
+      {
+         throw new RuntimeException("Could not access bean correctly when creating enterprise proxy for " + toString(), e);
+      }
+      catch (Exception e)
+      {
+         throw new CreationException("could not find the EJB in JNDI " + proxyClass, e);
+      }
+   }
+
+   public void destroy(T instance, CreationalContext<T> creationalContext)
+   {
+      if (instance == null)
+      {
+         throw new IllegalArgumentException("instance to destroy cannot be null");
+      }
+      if (!(instance instanceof EnterpriseBeanInstance))
+      {
+         throw new IllegalArgumentException("Cannot destroy session bean instance not created by the container");
+      }
+      EnterpriseBeanInstance enterpiseBeanInstance = (EnterpriseBeanInstance) instance;
+      enterpiseBeanInstance.destroy(Marker.INSTANCE, this, creationalContext);
+      creationalContext.release();
+   }
+
+   /**
+    * Validates the bean type
+    */
+   private void checkEJBTypeAllowed()
+   {
+      if (ejbDescriptor.isMessageDriven())
+      {
+         throw new DefinitionException("Message Driven Beans can't be Web Beans");
+      }
+   }
+
+   /**
+    * Gets a string representation
+    * 
+    * @return The string representation
+    */
+   @Override
+   public String toString()
+   {
+      StringBuilder buffer = new StringBuilder();
+      // buffer.append("Annotated " + Names.scopeTypeToString(getScopeType()) +
+      // Names.ejbTypeFromMetaData(getEjbMetaData()));
+      if (getName() == null)
+      {
+         buffer.append(" unnamed enterprise bean");
+      }
+      else
+      {
+         buffer.append(" enterprise bean '" + getName() + "'");
+      }
+      buffer.append(" [" + getType().getName() + "] ");
+      buffer.append("API types " + getTypes() + ", binding types " + getQualifiers());
+      return buffer.toString();
+   }
+
+   public void postConstruct(T instance, CreationalContext<T> creationalContext)
+   {
+      Beans.injectBoundFields(instance, creationalContext, getManager(), getInjectableFields());
+      Beans.callInitializers(instance, creationalContext, getManager(), getInitializerMethods());
+   }
+
+   public void preDestroy(CreationalContext<T> creationalContext)
+   {
+      creationalContext.release();
+   }
+   
+   @Override
+   protected void initSerializable()
+   {
+      // No-op
+   }
+   
+   @Override
+   public boolean isSerializable()
+   {
+      return true;
+   }
+
+   public InternalEjbDescriptor<T> getEjbDescriptor()
+   {
+      return ejbDescriptor;
+   }
+
+   public boolean isClientCanCallRemoveMethods()
+   {
+      return getEjbDescriptor().isStateful() && isDependent();
+   }
+
+   @Override
+   public AbstractBean<?, ?> getSpecializedBean()
+   {
+      return specializedBean;
+   }
+
+   /**
+    * If there are any observer methods, they must be static or business
+    * methods.
+    */
+   protected void checkObserverMethods()
+   {
+      for (WBMethod<?, ?> method : this.annotatedItem.getWBDeclaredMethodsWithAnnotatedParameters(Observes.class))
+      {
+         if (!method.isStatic())
+         {
+            if (!isMethodExistsOnTypes(method))
+            {
+               throw new DefinitionException("Observer method must be static or business method: " + method + " on " + getAnnotatedItem());
+            }
+         }
+      }
+   }
+   
+   // TODO must be a nicer way to do this!
+   public boolean isMethodExistsOnTypes(WBMethod<?, ?> method)
+   {
+      for (Type type : getTypes())
+      {
+         if (type instanceof Class)
+         {
+            for (Method m : ((Class<?>) type).getMethods())
+            {
+               if (method.getName().equals(m.getName()) && Arrays.equals(method.getParameterTypesAsArray(), m.getParameterTypes()))
+               {
+                  return true;
+               }
+            }
+         }
+      }
+      return false;
+   }
+   
+   public SessionObjectReference createReference()
+   {
+      return manager.getServices().get(EjbServices.class).resolveEjb(getEjbDescriptor().delegate());
+   }
+
+   public Set<Class<? extends Annotation>> getStereotypes()
+   {
+      return Collections.emptySet();
+   }
+   
+}
+

Deleted: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java	2009-09-15 13:02:01 UTC (rev 3667)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java	2009-09-15 13:31:15 UTC (rev 3668)
@@ -1,359 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,  
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.webbeans.bean;
-
-import java.util.Set;
-
-import javax.enterprise.context.spi.CreationalContext;
-import javax.enterprise.event.Observes;
-import javax.enterprise.inject.Disposes;
-import javax.enterprise.inject.spi.Decorator;
-import javax.enterprise.inject.spi.InjectionPoint;
-
-import org.jboss.webbeans.BeanManagerImpl;
-import org.jboss.webbeans.DefinitionException;
-import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
-import org.jboss.webbeans.injection.ConstructorInjectionPoint;
-import org.jboss.webbeans.injection.InjectionContextImpl;
-import org.jboss.webbeans.injection.WBInjectionPoint;
-import org.jboss.webbeans.introspector.WBClass;
-import org.jboss.webbeans.introspector.WBConstructor;
-import org.jboss.webbeans.introspector.WBField;
-import org.jboss.webbeans.introspector.WBMethod;
-import org.jboss.webbeans.log.LogProvider;
-import org.jboss.webbeans.log.Logging;
-import org.jboss.webbeans.metadata.cache.MetaAnnotationStore;
-import org.jboss.webbeans.util.Beans;
-import org.jboss.webbeans.util.Names;
-import org.jboss.webbeans.util.Reflections;
-
-/**
- * Represents a simple bean
- * 
- * @author Pete Muir
- * 
- * @param <T> The type (class) of the bean
- */
-public class SimpleBean<T> extends AbstractClassBean<T>
-{
-   // Logger
-   private static LogProvider log = Logging.getLogProvider(SimpleBean.class);
-
-   // The constructor
-   private ConstructorInjectionPoint<T> constructor;
-   private Set<WBInjectionPoint<?, ?>> ejbInjectionPoints;
-   private Set<WBInjectionPoint<?, ?>> persistenceContextInjectionPoints;
-   private Set<WBInjectionPoint<?, ?>> persistenceUnitInjectionPoints;
-   private Set<WBInjectionPoint<?, ?>> resourceInjectionPoints;
-
-   private SimpleBean<?> specializedBean;
-
-   
-
-   /**
-    * Creates a simple, annotation defined Web Bean
-    * 
-    * @param <T> The type
-    * @param clazz The class
-    * @param manager the current manager
-    * @return A Web Bean
-    */
-   public static <T> SimpleBean<T> of(WBClass<T> clazz, BeanManagerImpl manager)
-   {
-      return new SimpleBean<T>(clazz, manager);
-   }
-
-   /**
-    * Constructor
-    * 
-    * @param type The type of the bean
-    * @param manager The Web Beans manager
-    */
-   protected SimpleBean(WBClass<T> type, BeanManagerImpl manager)
-   {
-      super(type, manager);
-      initType();
-      initTypes();
-      initBindings();
-   }
-
-   /**
-    * Creates an instance of the bean
-    * 
-    * @return The instance
-    */
-   public T create(CreationalContext<T> creationalContext)
-   {
-      InjectionPoint originalInjectionPoint = null;
-      if (hasDecorators())
-      {
-         originalInjectionPoint = attachCorrectInjectionPoint();
-      }
-      T instance = produce(creationalContext);
-      inject(instance, creationalContext);
-      postConstruct(instance);
-      if (hasDecorators())
-      {
-         instance = applyDecorators(instance, creationalContext, originalInjectionPoint);
-      }
-      return instance;
-   }
-   
-   public T produce(CreationalContext<T> ctx)
-   {
-      T instance = constructor.newInstance(manager, ctx);
-      if (!hasDecorators())
-      {
-         // This should be safe, but needs verification PLM
-         // Without this, the chaining of decorators will fail as the incomplete instance will be resolved
-         ctx.push(instance);
-      }
-      return instance;
-   }
-   
-   public void inject(final T instance, final CreationalContext<T> ctx)
-   {
-      new InjectionContextImpl<T>(getManager(), this, instance)
-      {
-         
-         public void proceed()
-         {
-            Beans.injectEEFields(instance, getManager(), ejbInjectionPoints, persistenceContextInjectionPoints, persistenceUnitInjectionPoints, resourceInjectionPoints);
-            Beans.injectBoundFields(instance, ctx, getManager(), getInjectableFields());
-            Beans.callInitializers(instance, ctx, getManager(), getInitializerMethods());
-         }
-         
-      }.run();
-      
-   }
-
-   protected InjectionPoint attachCorrectInjectionPoint()
-   {
-      Decorator<?> decorator = getDecorators().get(getDecorators().size() - 1);
-      if (decorator instanceof DecoratorBean<?>)
-      {
-         DecoratorBean<?> decoratorBean = (DecoratorBean<?>) decorator;
-         InjectionPoint outerDelegateInjectionPoint = decoratorBean.getDelegateInjectionPoint();
-         return getManager().replaceOrPushCurrentInjectionPoint(outerDelegateInjectionPoint);
-      }
-      else
-      {
-         throw new IllegalStateException("Cannot operate on user defined decorator");
-      }
-   }
-
-   /**
-    * Destroys an instance of the bean
-    * 
-    * @param instance The instance
-    */
-   public void destroy(T instance, CreationalContext<T> creationalContext)
-   {
-      try
-      {
-         preDestroy(instance);
-         creationalContext.release();
-      }
-      catch (Exception e)
-      {
-         log.error("Error destroying " + toString(), e);
-      }
-   }
-
-   /**
-    * Initializes the bean and its metadata
-    */
-   @Override
-   public void initialize(BeanDeployerEnvironment environment)
-   {
-      if (!isInitialized())
-      {
-         initConstructor();
-         checkConstructor();
-         super.initialize(environment);
-         initPostConstruct();
-         initPreDestroy();
-         initEEInjectionPoints();
-      }
-   }
-
-   private void initEEInjectionPoints()
-   {
-      this.ejbInjectionPoints = Beans.getEjbInjectionPoints(this, getAnnotatedItem(), getManager());
-      this.persistenceContextInjectionPoints = Beans.getPersistenceContextInjectionPoints(this, getAnnotatedItem(), getManager());
-      this.persistenceUnitInjectionPoints = Beans.getPersistenceUnitInjectionPoints(this, getAnnotatedItem(), getManager());
-      this.resourceInjectionPoints = Beans.getResourceInjectionPoints(this, getAnnotatedItem(), manager);
-   }
-
-   /**
-    * Validates the type
-    */
-   protected void checkType()
-   {
-      if (getAnnotatedItem().isNonStaticMemberClass())
-      {
-         throw new DefinitionException("Simple bean " + type + " cannot be a non-static inner class");
-      }
-      if (!isDependent() && getAnnotatedItem().isParameterizedType())
-      {
-         throw new DefinitionException("Managed bean " + type + " must be @Dependent");
-      }
-      boolean passivating = manager.getServices().get(MetaAnnotationStore.class).getScopeModel(scopeType).isPassivating();
-      if (passivating && !Reflections.isSerializable(getBeanClass()))
-      {
-         throw new DefinitionException("Simple bean declaring a passivating scope must have a serializable implementation class " + toString());
-      }
-      if (hasDecorators())
-      {
-         if (getAnnotatedItem().isFinal())
-         {
-            throw new DefinitionException("Bean class which has decorators cannot be declared final " + this);
-         }
-         for (Decorator<?> decorator : getDecorators())
-         {
-            if (decorator instanceof DecoratorBean<?>)
-            {
-               DecoratorBean<?> decoratorBean = (DecoratorBean<?>) decorator;
-               for (WBMethod<?, ?> decoratorMethod : decoratorBean.getAnnotatedItem().getWBMethods())
-               {
-                  WBMethod<?, ?> method = getAnnotatedItem().getWBMethod(decoratorMethod.getSignature());  
-                  if (method != null && !method.isStatic() && !method.isPrivate() && method.isFinal())
-                  {
-                     throw new DefinitionException("Decorated bean method " + method + " (decorated by "+ decoratorMethod + ") cannot be declarted final");
-                  }
-               }
-            }
-            else
-            {
-               throw new IllegalStateException("Can only operate on container provided decorators " + decorator);
-            }
-         }
-      }
-   }
-
-   @Override
-   protected void checkBeanImplementation()
-   {
-      super.checkBeanImplementation();
-      if (!isDependent())
-      {
-         for (WBField<?, ?> field : getAnnotatedItem().getWBFields())
-         {
-            if (field.isPublic() && !field.isStatic())
-            {
-               throw new DefinitionException("Normal scoped Web Bean implementation class has a public field " + getAnnotatedItem());
-            }
-         }
-      }
-   }
-   
-   protected void checkConstructor()
-   {
-      if (!constructor.getAnnotatedWBParameters(Disposes.class).isEmpty())
-      {
-         throw new DefinitionException("Managed bean constructor must not have a parameter annotated @Disposes " + constructor);
-      }
-      if (!constructor.getAnnotatedWBParameters(Observes.class).isEmpty())
-      {
-         throw new DefinitionException("Managed bean constructor must not have a parameter annotated @Observes " + constructor);
-      }
-   }
-
-   @Override
-   protected void preSpecialize(BeanDeployerEnvironment environment)
-   {
-      super.preSpecialize(environment);
-      if (environment.getEjbDescriptors().contains(getAnnotatedItem().getWBSuperclass().getJavaClass()))
-      {
-         throw new DefinitionException("Simple bean must specialize a simple bean");
-      }
-   }
-
-   @Override
-   protected void specialize(BeanDeployerEnvironment environment)
-   {
-      if (environment.getClassBean(getAnnotatedItem().getWBSuperclass()) == null)
-      {
-         throw new DefinitionException(toString() + " does not specialize a bean");
-      }
-      AbstractClassBean<?> specializedBean = environment.getClassBean(getAnnotatedItem().getWBSuperclass());
-      if (!(specializedBean instanceof SimpleBean))
-      {
-         throw new DefinitionException(toString() + " doesn't have a simple bean as a superclass " + specializedBean);
-      }
-      else
-      {
-         this.specializedBean = (SimpleBean<?>) specializedBean;
-      }
-   }
-
-
-   /**
-    * Initializes the constructor
-    */
-   protected void initConstructor()
-   {
-      this.constructor = Beans.getBeanConstructor(this, getAnnotatedItem());
-      // TODO We loop unecessarily many times here, I want to probably introduce some callback mechanism. PLM.
-      addInjectionPoints(Beans.getParameterInjectionPoints(this, constructor));
-   }
-
-   /**
-    * Returns the constructor
-    * 
-    * @return The constructor
-    */
-   public WBConstructor<T> getConstructor()
-   {
-      return constructor;
-   }
-
-   /**
-    * Gets a string representation
-    * 
-    * @return The string representation
-    */
-   @Override
-   public String toString()
-   {
-      return toString("simple bean");
-   }
-   
-   protected String toString(String beanType)
-   {
-      StringBuilder buffer = new StringBuilder();
-      buffer.append(Names.scopeTypeToString(getScope()));
-      if (getName() == null)
-      {
-         buffer.append("unnamed ").append(beanType);
-      }
-      else
-      {
-         buffer.append(beanType).append(" '" + getName() + "'");
-      }
-      buffer.append(" ").append(getType().getName()).append(", ");
-      buffer.append(" API types = ").append(Names.typesToString(getTypes())).append(", binding types = " + Names.annotationsToString(getQualifiers()));
-      return buffer.toString();
-   }
-
-   @Override
-   public SimpleBean<?> getSpecializedBean()
-   {
-      return specializedBean;
-   }
-
-}

Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/BeanBuilderImpl.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/BeanBuilderImpl.java	2009-09-15 13:02:01 UTC (rev 3667)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/BeanBuilderImpl.java	2009-09-15 13:31:15 UTC (rev 3668)
@@ -38,15 +38,15 @@
 
 import org.jboss.webbeans.BeanManagerImpl;
 import org.jboss.webbeans.bean.AbstractClassBean;
-import org.jboss.webbeans.bean.DecoratorBean;
-import org.jboss.webbeans.bean.DisposalMethodBean;
-import org.jboss.webbeans.bean.EnterpriseBean;
-import org.jboss.webbeans.bean.NewEnterpriseBean;
-import org.jboss.webbeans.bean.NewSimpleBean;
-import org.jboss.webbeans.bean.ProducerFieldBean;
-import org.jboss.webbeans.bean.ProducerMethodBean;
+import org.jboss.webbeans.bean.DecoratorImpl;
+import org.jboss.webbeans.bean.DisposalMethod;
+import org.jboss.webbeans.bean.ManagedBean;
+import org.jboss.webbeans.bean.NewManagedBean;
+import org.jboss.webbeans.bean.NewSessionBean;
+import org.jboss.webbeans.bean.ProducerField;
+import org.jboss.webbeans.bean.ProducerMethod;
 import org.jboss.webbeans.bean.RIBean;
-import org.jboss.webbeans.bean.SimpleBean;
+import org.jboss.webbeans.bean.SessionBean;
 import org.jboss.webbeans.bean.builder.spi.DecoratorBeanBuilder;
 import org.jboss.webbeans.bean.builder.spi.EnterpriseBeanBuilder;
 import org.jboss.webbeans.bean.builder.spi.SimpleBeanBuilder;
@@ -104,7 +104,7 @@
    private <T> Set<Bean<?>> createSimpleBeans(WBClass<T> clazz)
    {
       Set<Bean<?>> beans = new HashSet<Bean<?>>();
-      SimpleBean<T> bean = SimpleBean.of(clazz, beanManager);
+      ManagedBean<T> bean = ManagedBean.of(clazz, beanManager);
       
       beanDeployerEnvironment.addBean(bean);
       beans.add(bean);
@@ -114,7 +114,7 @@
       
       createSubBeans(beans, bean);
       
-      NewSimpleBean<T> newBean = NewSimpleBean.of(clazz, beanManager);
+      NewManagedBean<T> newBean = NewManagedBean.of(clazz, beanManager);
       beanDeployerEnvironment.addBean(newBean);
       beans.add(newBean);
       if (!delayInitialization)
@@ -126,7 +126,7 @@
    private <T> Set<Bean<?>> createEnterpriseBeans(InternalEjbDescriptor<T> ejbDescriptor)
    {
       Set<Bean<?>> beans = new HashSet<Bean<?>>();
-      EnterpriseBean<T> bean = EnterpriseBean.of(ejbDescriptor, beanManager);
+      SessionBean<T> bean = SessionBean.of(ejbDescriptor, beanManager);
       beanDeployerEnvironment.addBean(bean);
       beans.add(bean);
       if (!delayInitialization)
@@ -134,7 +134,7 @@
       
       createSubBeans(beans, bean);
       
-      NewEnterpriseBean<T> newBean = NewEnterpriseBean.of(ejbDescriptor, beanManager);
+      NewSessionBean<T> newBean = NewSessionBean.of(ejbDescriptor, beanManager);
       beanDeployerEnvironment.addBean(newBean);
       beans.add(newBean);
       if (!delayInitialization)
@@ -145,7 +145,7 @@
    
    private <T> Set<Bean<?>> createDecorator(WBClass<T> annotatedClass)
    {
-      DecoratorBean<?> bean = DecoratorBean.of(annotatedClass, beanManager);
+      DecoratorImpl<?> bean = DecoratorImpl.of(annotatedClass, beanManager);
       beanDeployerEnvironment.addBean(bean);
       if (!delayInitialization)
          bean.initialize(beanDeployerEnvironment);
@@ -185,7 +185,7 @@
    {
       for (WBMethod<?, ?> method : annotatedClass.getWBDeclaredMethodsWithAnnotatedParameters(Disposes.class))
       {
-         DisposalMethodBean<?> disposalBean = DisposalMethodBean.of(beanManager, method, declaringBean);
+         DisposalMethod<?> disposalBean = DisposalMethod.of(beanManager, method, declaringBean);
          beanDeployerEnvironment.addBean(disposalBean);
          //Do not delay initialization of decorator beans, they get initialized right away in the original impl
          disposalBean.initialize(beanDeployerEnvironment);
@@ -195,7 +195,7 @@
    
    protected <T> void createProducerMethod(Set<Bean<?>> beans, AbstractClassBean<?> declaringBean, WBMethod<T, ?> annotatedMethod)
    {
-      ProducerMethodBean<T> bean = ProducerMethodBean.of(annotatedMethod, declaringBean, beanManager);
+      ProducerMethod<T> bean = ProducerMethod.of(annotatedMethod, declaringBean, beanManager);
       beanDeployerEnvironment.addBean(bean);
       beans.add(bean);
       if (!delayInitialization)
@@ -212,7 +212,7 @@
 
    protected <T> void createProducerField(Set<Bean<?>> beans, AbstractClassBean<?> declaringBean, WBField<T, ?> field)
    {
-      ProducerFieldBean<T> bean = ProducerFieldBean.of(field, declaringBean, beanManager);
+      ProducerField<T> bean = ProducerField.of(field, declaringBean, beanManager);
       beanDeployerEnvironment.addBean(bean);
       beans.add(bean);
       if (!delayInitialization)

Copied: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/ee (from rev 3663, ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee)

Deleted: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/ee/EEResourceProducerField.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/EEResourceProducerField.java	2009-09-14 17:57:21 UTC (rev 3663)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/ee/EEResourceProducerField.java	2009-09-15 13:31:15 UTC (rev 3668)
@@ -1,74 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,  
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.webbeans.bean.ee;
-
-import org.jboss.webbeans.BeanManagerImpl;
-import org.jboss.webbeans.bean.AbstractClassBean;
-import org.jboss.webbeans.bean.ProducerField;
-import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
-import org.jboss.webbeans.ejb.EJBApiAbstraction;
-import org.jboss.webbeans.introspector.WBField;
-import org.jboss.webbeans.persistence.PersistenceApiAbstraction;
-import org.jboss.webbeans.ws.WSApiAbstraction;
-
-/**
- * @author pmuir
- *
- */
-public class EEResourceProducerField<T> extends ProducerField<T>
-{
-   
-   /**
-    * Creates an EE resource producer field
-    * 
-    * @param field The underlying method abstraction
-    * @param declaringBean The declaring bean abstraction
-    * @param manager the current manager
-    * @return A producer field
-    */
-   public static <T> EEResourceProducerField<T> of(WBField<T, ?> field, AbstractClassBean<?> declaringBean, BeanManagerImpl manager)
-   {
-      return new EEResourceProducerField<T>(field, declaringBean, manager);
-   }
-
-   protected EEResourceProducerField(WBField<T, ?> field, AbstractClassBean<?> declaringBean, BeanManagerImpl manager)
-   {
-      super(field, declaringBean, manager);
-   }
-   
-   @Override
-   public void initialize(BeanDeployerEnvironment environment)
-   {
-      if (!isInitialized())
-      {
-         super.initialize(environment);
-         checkEEResource();
-      }
-   }
-   
-   protected void checkEEResource()
-   {
-      EJBApiAbstraction ejbApiAbstraction = manager.getServices().get(EJBApiAbstraction.class);
-      PersistenceApiAbstraction persistenceApiAbstraction = manager.getServices().get(PersistenceApiAbstraction.class);
-      WSApiAbstraction wsApiAbstraction = manager.getServices().get(WSApiAbstraction.class);
-      if (!(getAnnotatedItem().isAnnotationPresent(ejbApiAbstraction.RESOURCE_ANNOTATION_CLASS) || getAnnotatedItem().isAnnotationPresent(persistenceApiAbstraction.PERSISTENCE_CONTEXT_ANNOTATION_CLASS) || getAnnotatedItem().isAnnotationPresent(persistenceApiAbstraction.PERSISTENCE_UNIT_ANNOTATION_CLASS) || getAnnotatedItem().isAnnotationPresent(ejbApiAbstraction.EJB_ANNOTATION_CLASS)) || getAnnotatedItem().isAnnotationPresent(wsApiAbstraction.WEB_SERVICE_REF_ANNOTATION_CLASS))
-      {
-         throw new IllegalStateException("Tried to create an EEResourceProducerField, but no @Resource, @PersistenceContext, @PersistenceUnit, @WebServiceRef or @EJB is present " + getAnnotatedItem());
-      }
-   }
-
-}

Copied: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/ee/EEResourceProducerField.java (from rev 3663, ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/EEResourceProducerField.java)
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/ee/EEResourceProducerField.java	                        (rev 0)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/ee/EEResourceProducerField.java	2009-09-15 13:31:15 UTC (rev 3668)
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,  
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.bean.ee;
+
+import org.jboss.webbeans.BeanManagerImpl;
+import org.jboss.webbeans.bean.AbstractClassBean;
+import org.jboss.webbeans.bean.ProducerField;
+import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
+import org.jboss.webbeans.ejb.EJBApiAbstraction;
+import org.jboss.webbeans.introspector.WBField;
+import org.jboss.webbeans.persistence.PersistenceApiAbstraction;
+import org.jboss.webbeans.ws.WSApiAbstraction;
+
+/**
+ * @author pmuir
+ *
+ */
+public class EEResourceProducerField<T> extends ProducerField<T>
+{
+   
+   /**
+    * Creates an EE resource producer field
+    * 
+    * @param field The underlying method abstraction
+    * @param declaringBean The declaring bean abstraction
+    * @param manager the current manager
+    * @return A producer field
+    */
+   public static <T> EEResourceProducerField<T> of(WBField<T, ?> field, AbstractClassBean<?> declaringBean, BeanManagerImpl manager)
+   {
+      return new EEResourceProducerField<T>(field, declaringBean, manager);
+   }
+
+   protected EEResourceProducerField(WBField<T, ?> field, AbstractClassBean<?> declaringBean, BeanManagerImpl manager)
+   {
+      super(field, declaringBean, manager);
+   }
+   
+   @Override
+   public void initialize(BeanDeployerEnvironment environment)
+   {
+      if (!isInitialized())
+      {
+         super.initialize(environment);
+         checkEEResource();
+      }
+   }
+   
+   protected void checkEEResource()
+   {
+      EJBApiAbstraction ejbApiAbstraction = manager.getServices().get(EJBApiAbstraction.class);
+      PersistenceApiAbstraction persistenceApiAbstraction = manager.getServices().get(PersistenceApiAbstraction.class);
+      WSApiAbstraction wsApiAbstraction = manager.getServices().get(WSApiAbstraction.class);
+      if (!(getAnnotatedItem().isAnnotationPresent(ejbApiAbstraction.RESOURCE_ANNOTATION_CLASS) || getAnnotatedItem().isAnnotationPresent(persistenceApiAbstraction.PERSISTENCE_CONTEXT_ANNOTATION_CLASS) || getAnnotatedItem().isAnnotationPresent(persistenceApiAbstraction.PERSISTENCE_UNIT_ANNOTATION_CLASS) || getAnnotatedItem().isAnnotationPresent(ejbApiAbstraction.EJB_ANNOTATION_CLASS)) || getAnnotatedItem().isAnnotationPresent(wsApiAbstraction.WEB_SERVICE_REF_ANNOTATION_CLASS))
+      {
+         throw new IllegalStateException("Tried to create an EEResourceProducerField, but no @Resource, @PersistenceContext, @PersistenceUnit, @WebServiceRef or @EJB is present " + getAnnotatedItem());
+      }
+   }
+
+}

Deleted: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/ee/PersistenceContextProducerField.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/PersistenceContextProducerField.java	2009-09-14 17:57:21 UTC (rev 3663)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/ee/PersistenceContextProducerField.java	2009-09-15 13:31:15 UTC (rev 3668)
@@ -1,60 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,  
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.webbeans.bean.ee;
-
-import javax.persistence.EntityManager;
-
-import org.jboss.webbeans.BeanManagerImpl;
-import org.jboss.webbeans.bean.AbstractClassBean;
-import org.jboss.webbeans.introspector.WBField;
-
-/**
- * @author pmuir
- *
- */
-public class PersistenceContextProducerField<T extends EntityManager> extends EEResourceProducerField<T>
-{
-   
-   /**
-    * Creates an EE resource producer field
-    * 
-    * @param field The underlying method abstraction
-    * @param declaringBean The declaring bean abstraction
-    * @param manager the current manager
-    * @return A producer field
-    */
-   public static <T extends EntityManager> EEResourceProducerField<T> of(WBField<T, ?> field, AbstractClassBean<?> declaringBean, BeanManagerImpl manager)
-   {
-      return new PersistenceContextProducerField<T>(field, declaringBean, manager);
-   }
-
-   /**
-    * @param field
-    * @param declaringBean
-    * @param manager
-    */
-   protected PersistenceContextProducerField(WBField<T, ?> field, AbstractClassBean<?> declaringBean, BeanManagerImpl manager)
-   {
-      super(field, declaringBean, manager);
-   }
-   
-   public void dispose(T instance) 
-   {
-      instance.close();
-   }
-
-}

Copied: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/ee/PersistenceContextProducerField.java (from rev 3663, ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/PersistenceContextProducerField.java)
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/ee/PersistenceContextProducerField.java	                        (rev 0)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/ee/PersistenceContextProducerField.java	2009-09-15 13:31:15 UTC (rev 3668)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,  
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.bean.ee;
+
+import javax.persistence.EntityManager;
+
+import org.jboss.webbeans.BeanManagerImpl;
+import org.jboss.webbeans.bean.AbstractClassBean;
+import org.jboss.webbeans.introspector.WBField;
+
+/**
+ * @author pmuir
+ *
+ */
+public class PersistenceContextProducerField<T extends EntityManager> extends EEResourceProducerField<T>
+{
+   
+   /**
+    * Creates an EE resource producer field
+    * 
+    * @param field The underlying method abstraction
+    * @param declaringBean The declaring bean abstraction
+    * @param manager the current manager
+    * @return A producer field
+    */
+   public static <T extends EntityManager> EEResourceProducerField<T> of(WBField<T, ?> field, AbstractClassBean<?> declaringBean, BeanManagerImpl manager)
+   {
+      return new PersistenceContextProducerField<T>(field, declaringBean, manager);
+   }
+
+   /**
+    * @param field
+    * @param declaringBean
+    * @param manager
+    */
+   protected PersistenceContextProducerField(WBField<T, ?> field, AbstractClassBean<?> declaringBean, BeanManagerImpl manager)
+   {
+      super(field, declaringBean, manager);
+   }
+   
+   public void dispose(T instance) 
+   {
+      instance.close();
+   }
+
+}

Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/proxy/DecoratorProxyMethodHandler.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/proxy/DecoratorProxyMethodHandler.java	2009-09-15 13:02:01 UTC (rev 3667)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/proxy/DecoratorProxyMethodHandler.java	2009-09-15 13:31:15 UTC (rev 3668)
@@ -24,7 +24,7 @@
 
 import javassist.util.proxy.MethodHandler;
 
-import org.jboss.webbeans.bean.DecoratorBean;
+import org.jboss.webbeans.bean.DecoratorImpl;
 import org.jboss.webbeans.bean.SerializableBeanInstance;
 import org.jboss.webbeans.introspector.MethodSignature;
 import org.jboss.webbeans.introspector.WBMethod;
@@ -40,7 +40,7 @@
 {
    private static final long serialVersionUID = 4577632640130385060L;
 
-   private final List<SerializableBeanInstance<DecoratorBean<Object>, Object>> decoratorInstances;
+   private final List<SerializableBeanInstance<DecoratorImpl<Object>, Object>> decoratorInstances;
    
    private final Object instance;
 
@@ -51,7 +51,7 @@
     * 
     * @param proxy The generic proxy
     */
-   public DecoratorProxyMethodHandler(List<SerializableBeanInstance<DecoratorBean<Object>, Object>> decoratorInstances, Object instance)
+   public DecoratorProxyMethodHandler(List<SerializableBeanInstance<DecoratorImpl<Object>, Object>> decoratorInstances, Object instance)
    {
       this.decoratorInstances = decoratorInstances;
       this.instance = instance;
@@ -77,7 +77,7 @@
    public Object invoke(Object self, Method method, Method proceed, Object[] args) throws Throwable
    {
       MethodSignature methodSignature = new MethodSignatureImpl(method);
-      for (SerializableBeanInstance<DecoratorBean<Object>, Object> beanInstance : decoratorInstances)
+      for (SerializableBeanInstance<DecoratorImpl<Object>, Object> beanInstance : decoratorInstances)
       {
          WBMethod<?, ?> decoratorMethod = beanInstance.getBean().getAnnotatedItem().getWBMethod(methodSignature);
          if (decoratorMethod != null)

Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanInstance.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanInstance.java	2009-09-15 13:02:01 UTC (rev 3667)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanInstance.java	2009-09-15 13:31:15 UTC (rev 3668)
@@ -18,7 +18,7 @@
 
 import javax.enterprise.context.spi.CreationalContext;
 
-import org.jboss.webbeans.bean.EnterpriseBean;
+import org.jboss.webbeans.bean.SessionBean;
 
 /**
  * Interface implemented by all enterprise bean proxies to query/control the proxy
@@ -29,6 +29,6 @@
 public interface EnterpriseBeanInstance
 {
    
-   public void destroy(Marker marker, EnterpriseBean<?> enterpriseBean, CreationalContext<?> creationalContext);
+   public void destroy(Marker marker, SessionBean<?> enterpriseBean, CreationalContext<?> creationalContext);
    
 }

Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanProxyMethodHandler.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanProxyMethodHandler.java	2009-09-15 13:02:01 UTC (rev 3667)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanProxyMethodHandler.java	2009-09-15 13:31:15 UTC (rev 3668)
@@ -24,7 +24,7 @@
 
 import javax.enterprise.context.spi.CreationalContext;
 
-import org.jboss.webbeans.bean.EnterpriseBean;
+import org.jboss.webbeans.bean.SessionBean;
 import org.jboss.webbeans.ejb.api.SessionObjectReference;
 import org.jboss.webbeans.introspector.MethodSignature;
 import org.jboss.webbeans.introspector.jlr.MethodSignatureImpl;
@@ -59,7 +59,7 @@
     * 
     * @param proxy The generic proxy
     */
-   public EnterpriseBeanProxyMethodHandler(EnterpriseBean<T> bean, CreationalContext<T> creationalContext)
+   public EnterpriseBeanProxyMethodHandler(SessionBean<T> bean, CreationalContext<T> creationalContext)
    {
       this.objectInterface = bean.getEjbDescriptor().getObjectInterface();
       this.removeMethodSignatures = bean.getEjbDescriptor().getRemoveMethodSignatures();

Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bootstrap/AbstractBeanDeployer.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bootstrap/AbstractBeanDeployer.java	2009-09-15 13:02:01 UTC (rev 3667)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bootstrap/AbstractBeanDeployer.java	2009-09-15 13:31:15 UTC (rev 3668)
@@ -16,14 +16,12 @@
  */
 package org.jboss.webbeans.bootstrap;
 
-import java.util.ArrayList;
-import java.util.List;
 import java.util.Set;
 
 import javax.inject.Inject;
 
 import org.jboss.webbeans.BeanManagerImpl;
-import org.jboss.webbeans.bean.DecoratorBean;
+import org.jboss.webbeans.bean.DecoratorImpl;
 import org.jboss.webbeans.bean.RIBean;
 import org.jboss.webbeans.bean.builder.InternalBeanBuilderFactory;
 import org.jboss.webbeans.bean.builder.spi.DecoratorBeanBuilder;
@@ -33,11 +31,14 @@
 import org.jboss.webbeans.ejb.InternalEjbDescriptor;
 import org.jboss.webbeans.event.ObserverMethodImpl;
 import org.jboss.webbeans.introspector.WBClass;
+import org.jboss.webbeans.introspector.WBField;
 import org.jboss.webbeans.jsf.JsfApiAbstraction;
 import org.jboss.webbeans.log.LogProvider;
 import org.jboss.webbeans.log.Logging;
+import org.jboss.webbeans.persistence.PersistenceApiAbstraction;
 import org.jboss.webbeans.servlet.ServletApiAbstraction;
 import org.jboss.webbeans.util.Reflections;
+import org.jboss.webbeans.ws.WSApiAbstraction;
 
 public class AbstractBeanDeployer
 {
@@ -72,7 +73,7 @@
       Set<RIBean<?>> beans = getEnvironment().getBeans();
       // ensure that all decorators are initialized before initializing 
       // the rest of the beans
-      for (DecoratorBean<?> bean : getEnvironment().getDecorators())
+      for (DecoratorImpl<?> bean : getEnvironment().getDecorators())
       {
          bean.initialize(getEnvironment());
          manager.addDecorator(bean);
@@ -141,6 +142,20 @@
              hasSimpleWebBeanConstructor(clazz);
    }
    
+   protected boolean isEEResourceProducerField(WBField<?, ?> field)
+   {
+      EJBApiAbstraction ejbApiAbstraction = manager.getServices().get(EJBApiAbstraction.class);
+      PersistenceApiAbstraction persistenceApiAbstraction = manager.getServices().get(PersistenceApiAbstraction.class);
+      WSApiAbstraction wsApiAbstraction = manager.getServices().get(WSApiAbstraction.class);
+      return field.isAnnotationPresent(ejbApiAbstraction.EJB_ANNOTATION_CLASS) || field.isAnnotationPresent(ejbApiAbstraction.RESOURCE_ANNOTATION_CLASS) || field.isAnnotationPresent(persistenceApiAbstraction.PERSISTENCE_UNIT_ANNOTATION_CLASS) || field.isAnnotationPresent(wsApiAbstraction.WEB_SERVICE_REF_ANNOTATION_CLASS); 
+   }
+   
+   protected boolean isPersistenceContextProducerField(WBField<?, ?> field)
+   {
+      PersistenceApiAbstraction persistenceApiAbstraction = manager.getServices().get(PersistenceApiAbstraction.class);
+      return field.isAnnotationPresent(persistenceApiAbstraction.PERSISTENCE_CONTEXT_ANNOTATION_CLASS); 
+   }
+   
    private static boolean hasSimpleWebBeanConstructor(WBClass<?> type)
    {
       return type.getNoArgsWBConstructor() != null || type.getAnnotatedWBConstructors(Inject.class).size() > 0;

Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployerEnvironment.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployerEnvironment.java	2009-09-15 13:02:01 UTC (rev 3667)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployerEnvironment.java	2009-09-15 13:31:15 UTC (rev 3668)
@@ -28,11 +28,11 @@
 
 import org.jboss.webbeans.BeanManagerImpl;
 import org.jboss.webbeans.bean.AbstractClassBean;
-import org.jboss.webbeans.bean.DecoratorBean;
-import org.jboss.webbeans.bean.DisposalMethodBean;
+import org.jboss.webbeans.bean.DecoratorImpl;
+import org.jboss.webbeans.bean.DisposalMethod;
 import org.jboss.webbeans.bean.NewBean;
-import org.jboss.webbeans.bean.ProducerFieldBean;
-import org.jboss.webbeans.bean.ProducerMethodBean;
+import org.jboss.webbeans.bean.ProducerField;
+import org.jboss.webbeans.bean.ProducerMethod;
 import org.jboss.webbeans.bean.RIBean;
 import org.jboss.webbeans.bean.builtin.AbstractBuiltInBean;
 import org.jboss.webbeans.bean.builtin.ExtensionBean;
@@ -47,29 +47,29 @@
 {
 
    private final Map<WBClass<?>, AbstractClassBean<?>> classBeanMap;
-   private final Map<WBMethod<?, ?>, ProducerMethodBean<?>> producerMethodBeanMap;
+   private final Map<WBMethod<?, ?>, ProducerMethod<?>> producerMethodBeanMap;
    private final Set<RIBean<?>> beans;
    private final Set<ObserverMethodImpl<?, ?>> observers;
-   private final List<DisposalMethodBean<?>> allDisposalBeans;
-   private final Set<DisposalMethodBean<?>> resolvedDisposalBeans;
-   private final Set<DecoratorBean<?>> decorators;
+   private final List<DisposalMethod<?>> allDisposalBeans;
+   private final Set<DisposalMethod<?>> resolvedDisposalBeans;
+   private final Set<DecoratorImpl<?>> decorators;
    private final EjbDescriptors ejbDescriptors;
    private final TypeSafeDisposerResolver disposalMethodResolver;
 
    public BeanDeployerEnvironment(EjbDescriptors ejbDescriptors, BeanManagerImpl manager)
    {
       this.classBeanMap = new HashMap<WBClass<?>, AbstractClassBean<?>>();
-      this.producerMethodBeanMap = new HashMap<WBMethod<?, ?>, ProducerMethodBean<?>>();
-      this.allDisposalBeans = new ArrayList<DisposalMethodBean<?>>();
-      this.resolvedDisposalBeans = new HashSet<DisposalMethodBean<?>>();
+      this.producerMethodBeanMap = new HashMap<WBMethod<?, ?>, ProducerMethod<?>>();
+      this.allDisposalBeans = new ArrayList<DisposalMethod<?>>();
+      this.resolvedDisposalBeans = new HashSet<DisposalMethod<?>>();
       this.beans = new HashSet<RIBean<?>>();
-      this.decorators = new HashSet<DecoratorBean<?>>();
+      this.decorators = new HashSet<DecoratorImpl<?>>();
       this.observers = new HashSet<ObserverMethodImpl<?, ?>>();
       this.ejbDescriptors = ejbDescriptors;
       this.disposalMethodResolver = new TypeSafeDisposerResolver(manager, allDisposalBeans);
    }
 
-   public ProducerMethodBean<?> getProducerMethod(WBMethod<?, ?> method)
+   public ProducerMethod<?> getProducerMethod(WBMethod<?, ?> method)
    {
       if (!producerMethodBeanMap.containsKey(method))
       {
@@ -77,7 +77,7 @@
       }
       else
       {
-         ProducerMethodBean<?> bean = producerMethodBeanMap.get(method);
+         ProducerMethod<?> bean = producerMethodBeanMap.get(method);
          bean.initialize(this);
          return bean;
       }
@@ -97,13 +97,13 @@
       }
    }
 
-   public void addBean(ProducerMethodBean<?> bean)
+   public void addBean(ProducerMethod<?> bean)
    {
       producerMethodBeanMap.put(bean.getAnnotatedItem(), bean);
       beans.add(bean);
    }
    
-   public void addBean(ProducerFieldBean<?> bean)
+   public void addBean(ProducerField<?> bean)
    {
       beans.add(bean);
    }
@@ -127,12 +127,12 @@
       beans.add(bean);
    }
 
-   public void addBean(DecoratorBean<?> bean)
+   public void addBean(DecoratorImpl<?> bean)
    {
       decorators.add(bean);
    }
    
-   public void addBean(DisposalMethodBean<?> bean)
+   public void addBean(DisposalMethod<?> bean)
    {
       allDisposalBeans.add(bean);
    }
@@ -147,7 +147,7 @@
       return Collections.unmodifiableSet(beans);
    }
    
-   public Set<DecoratorBean<?>> getDecorators()
+   public Set<DecoratorImpl<?>> getDecorators()
    {
       return Collections.unmodifiableSet(decorators);
    }
@@ -158,9 +158,9 @@
    }
 
 
-   public Set<DisposalMethodBean<?>> getUnresolvedDisposalBeans()
+   public Set<DisposalMethod<?>> getUnresolvedDisposalBeans()
    {
-      Set<DisposalMethodBean<?>> beans = new HashSet<DisposalMethodBean<?>>(allDisposalBeans);
+      Set<DisposalMethod<?>> beans = new HashSet<DisposalMethod<?>>(allDisposalBeans);
       beans.removeAll(resolvedDisposalBeans);
       return Collections.unmodifiableSet(beans);
    }
@@ -179,9 +179,9 @@
     * @param bindings The binding types to match
     * @return The set of matching disposal methods
     */
-   public Set<DisposalMethodBean<?>> resolveDisposalBeans(Set<Type> types, Set<Annotation> bindings, AbstractClassBean<?> declaringBean)
+   public Set<DisposalMethod<?>> resolveDisposalBeans(Set<Type> types, Set<Annotation> bindings, AbstractClassBean<?> declaringBean)
    {
-      Set<DisposalMethodBean<?>> beans = disposalMethodResolver.resolve(ResolvableFactory.of(types, bindings, declaringBean));
+      Set<DisposalMethod<?>> beans = disposalMethodResolver.resolve(ResolvableFactory.of(types, bindings, declaringBean));
       resolvedDisposalBeans.addAll(beans);
       return Collections.unmodifiableSet(beans);
    }

Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java	2009-09-15 13:02:01 UTC (rev 3667)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java	2009-09-15 13:31:15 UTC (rev 3668)
@@ -62,6 +62,7 @@
 import org.jboss.webbeans.servlet.ServletApiAbstraction;
 import org.jboss.webbeans.transaction.spi.TransactionServices;
 import org.jboss.webbeans.util.serviceProvider.ServiceLoader;
+import org.jboss.webbeans.ws.WSApiAbstraction;
 
 /**
  * Common bootstrapping functionality that is run at application startup and
@@ -212,6 +213,7 @@
       services.add(EJBApiAbstraction.class, new EJBApiAbstraction(resourceLoader));
       services.add(JsfApiAbstraction.class, new JsfApiAbstraction(resourceLoader));
       services.add(PersistenceApiAbstraction.class, new PersistenceApiAbstraction(resourceLoader));
+      services.add(WSApiAbstraction.class, new WSApiAbstraction(resourceLoader));
       services.add(ServletApiAbstraction.class, new ServletApiAbstraction(resourceLoader));
       // Temporary workaround to provide context for building annotated class
       // TODO expose AnnotatedClass on SPI and allow container to provide impl of this via ResourceLoader

Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/resolution/TypeSafeDecoratorResolver.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/resolution/TypeSafeDecoratorResolver.java	2009-09-15 13:02:01 UTC (rev 3667)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/resolution/TypeSafeDecoratorResolver.java	2009-09-15 13:31:15 UTC (rev 3668)
@@ -22,7 +22,7 @@
 import java.util.TreeSet;
 
 import org.jboss.webbeans.BeanManagerImpl;
-import org.jboss.webbeans.bean.DecoratorBean;
+import org.jboss.webbeans.bean.DecoratorImpl;
 import org.jboss.webbeans.util.Beans;
 import org.jboss.webbeans.util.Reflections;
 
@@ -30,31 +30,31 @@
  * @author pmuir
  *
  */
-public class TypeSafeDecoratorResolver extends TypeSafeBeanResolver<DecoratorBean<?>>
+public class TypeSafeDecoratorResolver extends TypeSafeBeanResolver<DecoratorImpl<?>>
 {
 
-   public TypeSafeDecoratorResolver(BeanManagerImpl manager, Iterable<DecoratorBean<?>> decorators)
+   public TypeSafeDecoratorResolver(BeanManagerImpl manager, Iterable<DecoratorImpl<?>> decorators)
    {
       super(manager, decorators);
    }
 
    @Override
-   protected boolean matches(Resolvable resolvable, DecoratorBean<?> bean)
+   protected boolean matches(Resolvable resolvable, DecoratorImpl<?> bean)
    {
       return Reflections.isAssignableFrom(bean.getDelegateTypes(), resolvable.getTypeClosure()) && Beans.containsAllBindings(bean.getDelegateQualifiers(), resolvable.getQualifiers(), getManager()) && getManager().getEnabledDecoratorClasses().contains(bean.getType());
    }
    
    @Override
-   protected Set<DecoratorBean<?>> sortResult(Set<DecoratorBean<?>> matchedDecorators)
+   protected Set<DecoratorImpl<?>> sortResult(Set<DecoratorImpl<?>> matchedDecorators)
    {
-      Set<DecoratorBean<?>> sortedBeans = new TreeSet<DecoratorBean<?>>(new Comparator<DecoratorBean<?>>()
+      Set<DecoratorImpl<?>> sortedBeans = new TreeSet<DecoratorImpl<?>>(new Comparator<DecoratorImpl<?>>()
       {
          
-         public int compare(DecoratorBean<?> o1, DecoratorBean<?> o2)
+         public int compare(DecoratorImpl<?> o1, DecoratorImpl<?> o2)
          {
             List<Class<?>> enabledDecorators = getManager().getEnabledDecoratorClasses();
-            int p1 = enabledDecorators.indexOf(((DecoratorBean<?>) o1).getType());
-            int p2 = enabledDecorators.indexOf(((DecoratorBean<?>) o2).getType());
+            int p1 = enabledDecorators.indexOf(((DecoratorImpl<?>) o1).getType());
+            int p2 = enabledDecorators.indexOf(((DecoratorImpl<?>) o2).getType());
             return p1 - p2;
          }
    

Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/resolution/TypeSafeDisposerResolver.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/resolution/TypeSafeDisposerResolver.java	2009-09-15 13:02:01 UTC (rev 3667)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/resolution/TypeSafeDisposerResolver.java	2009-09-15 13:31:15 UTC (rev 3668)
@@ -20,7 +20,7 @@
 import java.util.Set;
 
 import org.jboss.webbeans.BeanManagerImpl;
-import org.jboss.webbeans.bean.DisposalMethodBean;
+import org.jboss.webbeans.bean.DisposalMethod;
 import org.jboss.webbeans.util.Beans;
 import org.jboss.webbeans.util.Reflections;
 
@@ -28,19 +28,19 @@
  * @author pmuir
  *
  */
-public class TypeSafeDisposerResolver extends TypeSafeResolver<DisposalMethodBean<?>>
+public class TypeSafeDisposerResolver extends TypeSafeResolver<DisposalMethod<?>>
 {
 
    private final BeanManagerImpl manager;
 
-   public TypeSafeDisposerResolver(BeanManagerImpl manager, Iterable<DisposalMethodBean<?>> disposers)
+   public TypeSafeDisposerResolver(BeanManagerImpl manager, Iterable<DisposalMethod<?>> disposers)
    {
       super(disposers);
       this.manager = manager;
    }
 
    @Override
-   protected boolean matches(Resolvable resolvable, DisposalMethodBean<?> disposer)
+   protected boolean matches(Resolvable resolvable, DisposalMethod<?> disposer)
    {
          return resolvable.getDeclaringBean().equals(disposer.getDeclaringBean()) && Reflections.isAssignableFrom(disposer.getType(), resolvable.getTypeClosure()) && Beans.containsAllBindings(disposer.getQualifiers(), resolvable.getQualifiers(), manager);
    }
@@ -54,7 +54,7 @@
    }
 
    @Override
-   protected Set<DisposalMethodBean<?>> filterResult(Set<DisposalMethodBean<?>> matched)
+   protected Set<DisposalMethod<?>> filterResult(Set<DisposalMethod<?>> matched)
    {
       return matched;
    }
@@ -66,7 +66,7 @@
    }
 
    @Override
-   protected Set<DisposalMethodBean<?>> sortResult(Set<DisposalMethodBean<?>> matched)
+   protected Set<DisposalMethod<?>> sortResult(Set<DisposalMethod<?>> matched)
    {
       return matched;
    }

Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/util/Beans.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/util/Beans.java	2009-09-15 13:02:01 UTC (rev 3667)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/util/Beans.java	2009-09-15 13:31:15 UTC (rev 3668)
@@ -38,7 +38,7 @@
 import org.jboss.webbeans.BeanManagerImpl;
 import org.jboss.webbeans.DefinitionException;
 import org.jboss.webbeans.bean.AbstractProducerBean;
-import org.jboss.webbeans.bean.EnterpriseBean;
+import org.jboss.webbeans.bean.SessionBean;
 import org.jboss.webbeans.bean.RIBean;
 import org.jboss.webbeans.ejb.EJBApiAbstraction;
 import org.jboss.webbeans.injection.ConstructorInjectionPoint;
@@ -80,9 +80,9 @@
     */
    public static boolean isPassivatingScope(Bean<?> bean, BeanManagerImpl manager)
    {
-      if (bean instanceof EnterpriseBean<?>)
+      if (bean instanceof SessionBean<?>)
       {
-         return ((EnterpriseBean<?>) bean).getEjbDescriptor().isStateful();
+         return ((SessionBean<?>) bean).getEjbDescriptor().isStateful();
       }
       else
       {
@@ -99,9 +99,9 @@
     */
    public static boolean isPassivationCapableBean(Bean<?> bean)
    {
-      if (bean instanceof EnterpriseBean<?>)
+      if (bean instanceof SessionBean<?>)
       {
-         return ((EnterpriseBean<?>) bean).getEjbDescriptor().isStateful();
+         return ((SessionBean<?>) bean).getEjbDescriptor().isStateful();
       }
       else if (bean instanceof AbstractProducerBean<?, ?>)
       {

Copied: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/ws (from rev 3663, ri/trunk/impl/src/main/java/org/jboss/webbeans/ws)

Deleted: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/ws/WSApiAbstraction.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/ws/WSApiAbstraction.java	2009-09-14 17:57:21 UTC (rev 3663)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/ws/WSApiAbstraction.java	2009-09-15 13:31:15 UTC (rev 3668)
@@ -1,41 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,  
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.webbeans.ws;
-
-import java.lang.annotation.Annotation;
-
-import org.jboss.webbeans.bootstrap.api.Service;
-import org.jboss.webbeans.resources.spi.ResourceLoader;
-import org.jboss.webbeans.util.ApiAbstraction;
-
-public class WSApiAbstraction extends ApiAbstraction implements Service
-{
-
-   public final Class<? extends Annotation> WEB_SERVICE_REF_ANNOTATION_CLASS;
-
-   /**
-    * @param resourceLoader
-    */
-   public WSApiAbstraction(ResourceLoader resourceLoader)
-   {
-      super(resourceLoader);
-      WEB_SERVICE_REF_ANNOTATION_CLASS = annotationTypeForName("javax.xml.ws.WebServiceRef");
-   }
-   
-   public void cleanup() {}
-   
-}
\ No newline at end of file

Copied: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/ws/WSApiAbstraction.java (from rev 3663, ri/trunk/impl/src/main/java/org/jboss/webbeans/ws/WSApiAbstraction.java)
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/ws/WSApiAbstraction.java	                        (rev 0)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/ws/WSApiAbstraction.java	2009-09-15 13:31:15 UTC (rev 3668)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,  
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.ws;
+
+import java.lang.annotation.Annotation;
+
+import org.jboss.webbeans.bootstrap.api.Service;
+import org.jboss.webbeans.resources.spi.ResourceLoader;
+import org.jboss.webbeans.util.ApiAbstraction;
+
+public class WSApiAbstraction extends ApiAbstraction implements Service
+{
+
+   public final Class<? extends Annotation> WEB_SERVICE_REF_ANNOTATION_CLASS;
+
+   /**
+    * @param resourceLoader
+    */
+   public WSApiAbstraction(ResourceLoader resourceLoader)
+   {
+      super(resourceLoader);
+      WEB_SERVICE_REF_ANNOTATION_CLASS = annotationTypeForName("javax.xml.ws.WebServiceRef");
+   }
+   
+   public void cleanup() {}
+   
+}
\ No newline at end of file

Modified: ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/multipleEnterprise/BootstrapTest.java
===================================================================
--- ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/multipleEnterprise/BootstrapTest.java	2009-09-15 13:02:01 UTC (rev 3667)
+++ ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/multipleEnterprise/BootstrapTest.java	2009-09-15 13:31:15 UTC (rev 3668)
@@ -9,7 +9,7 @@
 import org.jboss.testharness.impl.packaging.Artifact;
 import org.jboss.testharness.impl.packaging.Packaging;
 import org.jboss.testharness.impl.packaging.PackagingType;
-import org.jboss.webbeans.bean.EnterpriseBean;
+import org.jboss.webbeans.bean.SessionBean;
 import org.jboss.webbeans.bean.RIBean;
 import org.jboss.webbeans.test.AbstractWebBeansTest;
 import org.testng.annotations.Test;
@@ -36,10 +36,10 @@
       assert classes.containsKey(Panther.class);
       assert classes.containsKey(Tiger.class);
       
-      assert classes.get(Hound.class) instanceof EnterpriseBean;
-      assert classes.get(Elephant.class) instanceof EnterpriseBean;
-      assert classes.get(Panther.class) instanceof EnterpriseBean;
-      assert classes.get(Tiger.class) instanceof EnterpriseBean;
+      assert classes.get(Hound.class) instanceof SessionBean;
+      assert classes.get(Elephant.class) instanceof SessionBean;
+      assert classes.get(Panther.class) instanceof SessionBean;
+      assert classes.get(Tiger.class) instanceof SessionBean;
    }
    
 }

Modified: ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/multipleEnterpriseAndSimple/BootstrapTest.java
===================================================================
--- ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/multipleEnterpriseAndSimple/BootstrapTest.java	2009-09-15 13:02:01 UTC (rev 3667)
+++ ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/multipleEnterpriseAndSimple/BootstrapTest.java	2009-09-15 13:31:15 UTC (rev 3668)
@@ -9,9 +9,9 @@
 import org.jboss.testharness.impl.packaging.Artifact;
 import org.jboss.testharness.impl.packaging.Packaging;
 import org.jboss.testharness.impl.packaging.PackagingType;
-import org.jboss.webbeans.bean.EnterpriseBean;
+import org.jboss.webbeans.bean.SessionBean;
 import org.jboss.webbeans.bean.RIBean;
-import org.jboss.webbeans.bean.SimpleBean;
+import org.jboss.webbeans.bean.ManagedBean;
 import org.jboss.webbeans.test.AbstractWebBeansTest;
 import org.testng.annotations.Test;
 
@@ -41,14 +41,14 @@
       assert classes.containsKey(SeaBass.class);
       assert classes.containsKey(Sole.class);
       
-      assert classes.get(Hound.class) instanceof EnterpriseBean;
-      assert classes.get(Elephant.class) instanceof EnterpriseBean;
-      assert classes.get(Panther.class) instanceof EnterpriseBean;
-      assert classes.get(Tiger.class) instanceof EnterpriseBean;
-      assert classes.get(Tuna.class) instanceof SimpleBean;
-      assert classes.get(Salmon.class) instanceof SimpleBean;
-      assert classes.get(SeaBass.class) instanceof SimpleBean;
-      assert classes.get(Sole.class) instanceof SimpleBean;
+      assert classes.get(Hound.class) instanceof SessionBean;
+      assert classes.get(Elephant.class) instanceof SessionBean;
+      assert classes.get(Panther.class) instanceof SessionBean;
+      assert classes.get(Tiger.class) instanceof SessionBean;
+      assert classes.get(Tuna.class) instanceof ManagedBean;
+      assert classes.get(Salmon.class) instanceof ManagedBean;
+      assert classes.get(SeaBass.class) instanceof ManagedBean;
+      assert classes.get(Sole.class) instanceof ManagedBean;
    }
    
 }

Modified: ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/multipleSimple/BootstrapTest.java
===================================================================
--- ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/multipleSimple/BootstrapTest.java	2009-09-15 13:02:01 UTC (rev 3667)
+++ ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/multipleSimple/BootstrapTest.java	2009-09-15 13:31:15 UTC (rev 3668)
@@ -8,7 +8,7 @@
 
 import org.jboss.testharness.impl.packaging.Artifact;
 import org.jboss.webbeans.bean.RIBean;
-import org.jboss.webbeans.bean.SimpleBean;
+import org.jboss.webbeans.bean.ManagedBean;
 import org.jboss.webbeans.test.AbstractWebBeansTest;
 import org.testng.annotations.Test;
 
@@ -33,10 +33,10 @@
       assert classes.containsKey(SeaBass.class);
       assert classes.containsKey(Sole.class);
       
-      assert classes.get(Tuna.class) instanceof SimpleBean;
-      assert classes.get(Salmon.class) instanceof SimpleBean;
-      assert classes.get(SeaBass.class) instanceof SimpleBean;
-      assert classes.get(Sole.class) instanceof SimpleBean;
+      assert classes.get(Tuna.class) instanceof ManagedBean;
+      assert classes.get(Salmon.class) instanceof ManagedBean;
+      assert classes.get(SeaBass.class) instanceof ManagedBean;
+      assert classes.get(Sole.class) instanceof ManagedBean;
    }
    
 }

Modified: ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/singleProducerMethod/BootstrapTest.java
===================================================================
--- ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/singleProducerMethod/BootstrapTest.java	2009-09-15 13:02:01 UTC (rev 3667)
+++ ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/singleProducerMethod/BootstrapTest.java	2009-09-15 13:31:15 UTC (rev 3668)
@@ -9,9 +9,9 @@
 import org.jboss.testharness.impl.packaging.Artifact;
 import org.jboss.testharness.impl.packaging.Packaging;
 import org.jboss.testharness.impl.packaging.PackagingType;
-import org.jboss.webbeans.bean.ProducerMethodBean;
+import org.jboss.webbeans.bean.ProducerMethod;
 import org.jboss.webbeans.bean.RIBean;
-import org.jboss.webbeans.bean.SimpleBean;
+import org.jboss.webbeans.bean.ManagedBean;
 import org.jboss.webbeans.test.AbstractWebBeansTest;
 import org.testng.annotations.Test;
 
@@ -36,8 +36,8 @@
       assert classes.containsKey(TarantulaProducer.class);
       assert classes.containsKey(Tarantula.class);
       
-      assert classes.get(TarantulaProducer.class) instanceof SimpleBean;
-      assert classes.get(Tarantula.class) instanceof ProducerMethodBean;
+      assert classes.get(TarantulaProducer.class) instanceof ManagedBean;
+      assert classes.get(Tarantula.class) instanceof ProducerMethod;
    }
    
 }

Modified: ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/deployment/structure/AccessibleManagerResolutionTest.java
===================================================================
--- ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/deployment/structure/AccessibleManagerResolutionTest.java	2009-09-15 13:02:01 UTC (rev 3667)
+++ ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/deployment/structure/AccessibleManagerResolutionTest.java	2009-09-15 13:31:15 UTC (rev 3668)
@@ -7,7 +7,7 @@
 import org.jboss.webbeans.BeanManagerImpl;
 import org.jboss.webbeans.ContextualIdStore;
 import org.jboss.webbeans.bean.RIBean;
-import org.jboss.webbeans.bean.SimpleBean;
+import org.jboss.webbeans.bean.ManagedBean;
 import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
 import org.jboss.webbeans.bootstrap.api.ServiceRegistry;
 import org.jboss.webbeans.bootstrap.api.helpers.SimpleServiceRegistry;
@@ -38,7 +38,7 @@
    private void addBean(BeanManagerImpl manager, Class<?> c)
    {
       WBClass<?> clazz = WBClassImpl.of(c, classTransformer);
-      RIBean<?> bean = SimpleBean.of(clazz, manager);
+      RIBean<?> bean = ManagedBean.of(clazz, manager);
       manager.addBean(bean);
       BeanDeployerEnvironment environment = new BeanDeployerEnvironment(new EjbDescriptors(), manager);
       bean.initialize(environment);

Modified: ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/ServletEnvironmentTest.java
===================================================================
--- ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/ServletEnvironmentTest.java	2009-09-15 13:02:01 UTC (rev 3667)
+++ ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/ServletEnvironmentTest.java	2009-09-15 13:31:15 UTC (rev 3668)
@@ -11,7 +11,7 @@
 import org.jboss.webbeans.BeanManagerImpl;
 import org.jboss.webbeans.Container;
 import org.jboss.webbeans.bean.RIBean;
-import org.jboss.webbeans.bean.SimpleBean;
+import org.jboss.webbeans.bean.ManagedBean;
 import org.jboss.webbeans.mock.MockBeanDeploymentArchive;
 import org.jboss.webbeans.mock.MockServletLifecycle;
 import org.testng.annotations.AfterClass;
@@ -60,10 +60,10 @@
       assert beans.containsKey(SeaBass.class);
       assert beans.containsKey(Sole.class);
       
-      assert beans.get(Tuna.class) instanceof SimpleBean;
-      assert beans.get(Salmon.class) instanceof SimpleBean;
-      assert beans.get(SeaBass.class) instanceof SimpleBean;
-      assert beans.get(Sole.class) instanceof SimpleBean;
+      assert beans.get(Tuna.class) instanceof ManagedBean;
+      assert beans.get(Salmon.class) instanceof ManagedBean;
+      assert beans.get(SeaBass.class) instanceof ManagedBean;
+      assert beans.get(Sole.class) instanceof ManagedBean;
       manager.getInstanceByType(Sole.class, new AnnotationLiteral<Whitefish>() {}).ping();
    }
    
@@ -82,7 +82,7 @@
       
       Bean<?> bean = beans.get(TarantulaProducer.class);
       
-      assert beans.get(TarantulaProducer.class) instanceof SimpleBean;
+      assert beans.get(TarantulaProducer.class) instanceof ManagedBean;
       manager.getInstanceByType(Tarantula.class, new AnnotationLiteral<Tame>() {}).ping();
    }
    
@@ -98,7 +98,7 @@
          }
       }
       assert classes.containsKey(Hound.class);
-      assert classes.get(Hound.class) instanceof SimpleBean;
+      assert classes.get(Hound.class) instanceof ManagedBean;
       manager.getInstanceByType(HoundLocal.class, new AnnotationLiteral<Tame>() {}).ping();
    }
    

Modified: ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/NewEnterpriseBeanTest.java
===================================================================
--- ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/NewEnterpriseBeanTest.java	2009-09-15 13:02:01 UTC (rev 3667)
+++ ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/NewEnterpriseBeanTest.java	2009-09-15 13:31:15 UTC (rev 3668)
@@ -8,8 +8,8 @@
 import org.jboss.testharness.impl.packaging.Artifact;
 import org.jboss.testharness.impl.packaging.Packaging;
 import org.jboss.testharness.impl.packaging.PackagingType;
-import org.jboss.webbeans.bean.EnterpriseBean;
-import org.jboss.webbeans.bean.NewEnterpriseBean;
+import org.jboss.webbeans.bean.SessionBean;
+import org.jboss.webbeans.bean.NewSessionBean;
 import org.jboss.webbeans.introspector.WBAnnotated;
 import org.jboss.webbeans.literal.NewLiteral;
 import org.jboss.webbeans.test.AbstractWebBeansTest;
@@ -30,19 +30,19 @@
       
    };
    
-   private EnterpriseBean<WrappedEnterpriseBeanLocal> wrappedEnterpriseBean;
-   private NewEnterpriseBean<WrappedEnterpriseBeanLocal> newEnterpriseBean;
+   private SessionBean<WrappedEnterpriseBeanLocal> wrappedEnterpriseBean;
+   private NewSessionBean<WrappedEnterpriseBeanLocal> newEnterpriseBean;
    
    public void initNewBean() 
    {
       Set<Bean<?>> beans = getCurrentManager().getBeans(WrappedEnterpriseBeanLocal.class);
       assert getCurrentManager().getBeans(WrappedEnterpriseBeanLocal.class).size() == 1;
-      assert getCurrentManager().getBeans(WrappedEnterpriseBeanLocal.class).iterator().next() instanceof EnterpriseBean;
-      wrappedEnterpriseBean = (EnterpriseBean<WrappedEnterpriseBeanLocal>) getCurrentManager().getBeans(WrappedEnterpriseBeanLocal.class).iterator().next();
+      assert getCurrentManager().getBeans(WrappedEnterpriseBeanLocal.class).iterator().next() instanceof SessionBean;
+      wrappedEnterpriseBean = (SessionBean<WrappedEnterpriseBeanLocal>) getCurrentManager().getBeans(WrappedEnterpriseBeanLocal.class).iterator().next();
       
       assert getCurrentManager().getBeans(WrappedEnterpriseBeanLocal.class, NEW_LITERAL).size() == 1;
-      assert getCurrentManager().getBeans(WrappedEnterpriseBeanLocal.class, NEW_LITERAL).iterator().next() instanceof NewEnterpriseBean;
-      newEnterpriseBean = (NewEnterpriseBean<WrappedEnterpriseBeanLocal>) getCurrentManager().getBeans(WrappedEnterpriseBeanLocal.class, NEW_LITERAL).iterator().next();
+      assert getCurrentManager().getBeans(WrappedEnterpriseBeanLocal.class, NEW_LITERAL).iterator().next() instanceof NewSessionBean;
+      newEnterpriseBean = (NewSessionBean<WrappedEnterpriseBeanLocal>) getCurrentManager().getBeans(WrappedEnterpriseBeanLocal.class, NEW_LITERAL).iterator().next();
       
    }
    

Modified: ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/newsimple/NewSimpleBeanTest.java
===================================================================
--- ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/newsimple/NewSimpleBeanTest.java	2009-09-15 13:02:01 UTC (rev 3667)
+++ ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/newsimple/NewSimpleBeanTest.java	2009-09-15 13:31:15 UTC (rev 3668)
@@ -5,8 +5,8 @@
 import javax.enterprise.inject.New;
 
 import org.jboss.testharness.impl.packaging.Artifact;
-import org.jboss.webbeans.bean.NewSimpleBean;
-import org.jboss.webbeans.bean.SimpleBean;
+import org.jboss.webbeans.bean.NewManagedBean;
+import org.jboss.webbeans.bean.ManagedBean;
 import org.jboss.webbeans.introspector.WBAnnotated;
 import org.jboss.webbeans.literal.NewLiteral;
 import org.jboss.webbeans.test.AbstractWebBeansTest;
@@ -15,20 +15,20 @@
 @Artifact
 public class NewSimpleBeanTest extends AbstractWebBeansTest
 {
-   private SimpleBean<WrappedSimpleBean> wrappedSimpleBean;
-   private NewSimpleBean<WrappedSimpleBean> newSimpleBean;
+   private ManagedBean<WrappedSimpleBean> wrappedSimpleBean;
+   private NewManagedBean<WrappedSimpleBean> newSimpleBean;
    
    private static final New NEW_LITERAL = new NewLiteral();
    
    public void initNewBean() {
       
       assert getCurrentManager().getBeans(WrappedSimpleBean.class).size() == 1;
-      assert getCurrentManager().getBeans(WrappedSimpleBean.class).iterator().next() instanceof SimpleBean;
-      wrappedSimpleBean = (SimpleBean<WrappedSimpleBean>) getCurrentManager().getBeans(WrappedSimpleBean.class).iterator().next();
+      assert getCurrentManager().getBeans(WrappedSimpleBean.class).iterator().next() instanceof ManagedBean;
+      wrappedSimpleBean = (ManagedBean<WrappedSimpleBean>) getCurrentManager().getBeans(WrappedSimpleBean.class).iterator().next();
       
       assert getCurrentManager().getBeans(WrappedSimpleBean.class, NEW_LITERAL).size() == 1;
-      assert getCurrentManager().getBeans(WrappedSimpleBean.class, NEW_LITERAL).iterator().next() instanceof NewSimpleBean;
-      newSimpleBean = (NewSimpleBean<WrappedSimpleBean>) getCurrentManager().getBeans(WrappedSimpleBean.class, NEW_LITERAL).iterator().next();
+      assert getCurrentManager().getBeans(WrappedSimpleBean.class, NEW_LITERAL).iterator().next() instanceof NewManagedBean;
+      newSimpleBean = (NewManagedBean<WrappedSimpleBean>) getCurrentManager().getBeans(WrappedSimpleBean.class, NEW_LITERAL).iterator().next();
    }
 
    @Test(groups = { "new" })

Modified: ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/manager/EjbDescriptorLookupTest.java
===================================================================
--- ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/manager/EjbDescriptorLookupTest.java	2009-09-15 13:02:01 UTC (rev 3667)
+++ ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/manager/EjbDescriptorLookupTest.java	2009-09-15 13:31:15 UTC (rev 3668)
@@ -22,7 +22,7 @@
 import org.jboss.testharness.impl.packaging.Artifact;
 import org.jboss.testharness.impl.packaging.Packaging;
 import org.jboss.testharness.impl.packaging.PackagingType;
-import org.jboss.webbeans.bean.EnterpriseBean;
+import org.jboss.webbeans.bean.SessionBean;
 import org.jboss.webbeans.ejb.InternalEjbDescriptor;
 import org.jboss.webbeans.ejb.spi.EjbDescriptor;
 import org.jboss.webbeans.test.AbstractWebBeansTest;
@@ -44,11 +44,11 @@
       assert descriptor.getClass().equals(InternalEjbDescriptor.class);
       Bean<CatLocal> bean = getCurrentManager().getBean(descriptor);
       assert bean != null;
-      assert bean instanceof EnterpriseBean;
+      assert bean instanceof SessionBean;
       assert bean.getBeanClass().equals(Cat.class);
       InjectionTarget<CatLocal> it = getCurrentManager().createInjectionTarget(descriptor);
       assert it != null;
-      assert it instanceof EnterpriseBean;
+      assert it instanceof SessionBean;
       assert it == bean;
    }
 




More information about the weld-commits mailing list