[webbeans-commits] Webbeans SVN: r2754 - in ri/trunk: impl/src/main/java/org/jboss/webbeans/bean/proxy and 3 other directories.

webbeans-commits at lists.jboss.org webbeans-commits at lists.jboss.org
Wed Jun 3 18:46:00 EDT 2009


Author: pete.muir at jboss.org
Date: 2009-06-03 18:46:00 -0400 (Wed, 03 Jun 2009)
New Revision: 2754

Modified:
   ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanInstance.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanProxyMethodHandler.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/context/AbstractContext.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/context/AbstractMapContext.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/context/DependentContext.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/ejb/InternalEjbDescriptor.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/ejb/SessionBeanInterceptor.java
   ri/trunk/porting-package/src/main/java/org/jboss/webbeans/tck/BeansImpl.java
Log:
updates for ejb remove method support

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java	2009-06-03 15:29:52 UTC (rev 2753)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java	2009-06-03 22:46:00 UTC (rev 2754)
@@ -268,7 +268,7 @@
       }
       else
       {
-         // TODO getManager().getEjbResolver().removeEjb(enterpiseBeanInstance.getUnproxiedInstances());
+         enterpiseBeanInstance.destroy();
       }
    }
 
@@ -402,7 +402,7 @@
    
    public SessionObjectReference createReference()
    {
-      return manager.getServices().get(EjbServices.class).resolveEjb(getEjbDescriptor());
+      return manager.getServices().get(EjbServices.class).resolveEjb(getEjbDescriptor().delegate());
    }
    
 }

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanInstance.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanInstance.java	2009-06-03 15:29:52 UTC (rev 2753)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanInstance.java	2009-06-03 22:46:00 UTC (rev 2754)
@@ -25,6 +25,7 @@
 public interface EnterpriseBeanInstance
 {
    
+   // TODO These methods may conflict :-(
    /**
     * Indicated if a remove method has been invoked by the application
     * 
@@ -34,4 +35,6 @@
    
    public void setDestroyed(boolean destroyed);
    
+   public void destroy();
+   
 }

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanProxyMethodHandler.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanProxyMethodHandler.java	2009-06-03 15:29:52 UTC (rev 2753)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanProxyMethodHandler.java	2009-06-03 22:46:00 UTC (rev 2754)
@@ -113,7 +113,7 @@
          {
             throw new IllegalArgumentException("enterpriseBeanInstance.setDestroyed() called with >1 argument");
          }
-         if (!args[0].getClass().equals(boolean.class))
+         if (!(args[0].getClass().equals(boolean.class) || args[0].getClass().equals(Boolean.class)))
          {
             throw new IllegalArgumentException("enterpriseBeanInstance.setDestroyed() called with non-boolean argument");
          }
@@ -125,6 +125,12 @@
          return null;
       }
       
+      if ("destroy".equals(method.getName()))
+      {
+         reference.remove();
+         return null;
+      }
+      
       Class<?> businessInterface = method.getDeclaringClass();
       if (businessInterface.equals(Object.class))
       {

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/context/AbstractContext.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/context/AbstractContext.java	2009-06-03 15:29:52 UTC (rev 2753)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/context/AbstractContext.java	2009-06-03 22:46:00 UTC (rev 2754)
@@ -95,6 +95,6 @@
       return active.get();
    }
    
-   public abstract <T> void destroy(Contextual<T> contextual, T instance);
+   public abstract <T> void destroyAndRemove(Contextual<T> contextual, T instance);
 
 }

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/context/AbstractMapContext.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/context/AbstractMapContext.java	2009-06-03 15:29:52 UTC (rev 2753)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/context/AbstractMapContext.java	2009-06-03 22:46:00 UTC (rev 2754)
@@ -122,13 +122,19 @@
    }
 
    /**
-    * Destroys a bean
+    * Destroys and removes bean
     * 
     * @param <T> The type of the bean
     * @param contextual The contextual type to destroy
     */
-   public <T> void destroy(Contextual<T> contextual, T instance)
+   public <T> void destroyAndRemove(Contextual<T> contextual, T instance)
    {
+      destroy(contextual);
+      getBeanStore().remove(contextual);
+   }
+   
+   private <T> void destroy(Contextual<T> contextual)
+   {
       log.trace("Destroying " + contextual);
       if (getBeanStore() == null)
       {
@@ -138,12 +144,6 @@
       contextual.destroy(beanInstance.getInstance(), beanInstance.getCreationalContext());
    }
    
-   private <T> void destroy(Contextual<T> contextual)
-   {
-      BeanInstance<T> beanInstance = getBeanStore().get(contextual);
-      destroy(contextual, beanInstance.getInstance());
-   }
-   
 
    /**
     * Destroys the context

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/context/DependentContext.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/context/DependentContext.java	2009-06-03 15:29:52 UTC (rev 2753)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/context/DependentContext.java	2009-06-03 22:46:00 UTC (rev 2754)
@@ -160,7 +160,7 @@
       }
    }
    
-   public <T> void destroy(Contextual<T> contextual, T instance)
+   public <T> void destroyAndRemove(Contextual<T> contextual, T instance)
    {
       if (contextual instanceof Bean)
       {

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/ejb/InternalEjbDescriptor.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/ejb/InternalEjbDescriptor.java	2009-06-03 15:29:52 UTC (rev 2753)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/ejb/InternalEjbDescriptor.java	2009-06-03 22:46:00 UTC (rev 2754)
@@ -33,7 +33,6 @@
 {
    
    private final Class<?> objectInterface;
-   private final boolean local; 
    private final EjbDescriptor<T> delegate;
    
    public InternalEjbDescriptor(EjbDescriptor<T> ejbDescriptor)
@@ -43,26 +42,19 @@
       if (it.hasNext())
       {
          this.objectInterface = it.next().getInterface();
-         this.local = true;
       }
       else
       {
          this.objectInterface = null;
-         this.local = false;
       }
    }
    
    @Override
-   protected EjbDescriptor<T> delegate()
+   public EjbDescriptor<T> delegate()
    {
       return delegate;
    }
    
-   public boolean isLocal()
-   {
-      return local;
-   }
-   
    public Class<?> getObjectInterface()
    {
       return objectInterface;

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/ejb/SessionBeanInterceptor.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/ejb/SessionBeanInterceptor.java	2009-06-03 15:29:52 UTC (rev 2753)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/ejb/SessionBeanInterceptor.java	2009-06-03 22:46:00 UTC (rev 2754)
@@ -78,7 +78,11 @@
       bean.preDestroy(target);
       if (contextual)
       {
-         getEnterpriseBeanInstance(bean).setDestroyed(true);
+         EnterpriseBeanInstance instance = getEnterpriseBeanInstance(bean);
+         if (instance != null)
+         {
+            instance.setDestroyed(true);
+         }
       }
       invocationContext.proceed();
    }
@@ -112,6 +116,10 @@
       {
          return (EnterpriseBeanInstance) instance;
       }
+      else if (instance == null)
+      {
+         return null;
+      }
       else
       {
          throw new IllegalStateException("Contextual instance not an session bean created by the container");

Modified: ri/trunk/porting-package/src/main/java/org/jboss/webbeans/tck/BeansImpl.java
===================================================================
--- ri/trunk/porting-package/src/main/java/org/jboss/webbeans/tck/BeansImpl.java	2009-06-03 15:29:52 UTC (rev 2753)
+++ ri/trunk/porting-package/src/main/java/org/jboss/webbeans/tck/BeansImpl.java	2009-06-03 22:46:00 UTC (rev 2754)
@@ -75,7 +75,7 @@
       // Get the EJB Descriptor and resolve it
       if (CurrentManager.rootManager().getNewEnterpriseBeanMap().containsKey(beanType))
       {  
-         EjbDescriptor<?> ejbDescriptor = CurrentManager.rootManager().getNewEnterpriseBeanMap().get(beanType).getEjbDescriptor();
+         EjbDescriptor<?> ejbDescriptor = CurrentManager.rootManager().getNewEnterpriseBeanMap().get(beanType).getEjbDescriptor().delegate();
          return CurrentManager.rootManager().getServices().get(EjbServices.class).resolveEjb(ejbDescriptor).getBusinessObject(localInterface);
       }   
       throw new NullPointerException("No EJB found for " + localInterface.getName() + " on bean " + beanType.getName());
@@ -86,12 +86,12 @@
       return CurrentManager.rootManager().getCurrent().getInstance(bean, true);
    }
 
-   public <T> void destroyBeanInstance(Bean<T> bean, T instance)
+   public <T> void destroyAndRemoveBeanInstance(Bean<T> bean, T instance)
    {
       Context context = CurrentManager.rootManager().getCurrent().getContext(bean.getScopeType());
       if (context instanceof AbstractContext)
       {
-         ((AbstractContext) context).destroy(bean, instance);
+         ((AbstractContext) context).destroyAndRemove(bean, instance);
       }
       else
       {




More information about the weld-commits mailing list