openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1435116 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans: component/ context/creational/ intercept/
Date Fri, 18 Jan 2013 12:46:31 GMT
Author: struberg
Date: Fri Jan 18 12:46:30 2013
New Revision: 1435116

URL: http://svn.apache.org/viewvc?rev=1435116&view=rev
Log:
OWB-233 cleanup CeationalContext. Remove all Decorators and Interceptors

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerMethodBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/CreationalContextImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/DependentCreationalContext.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorDataImpl.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerMethodBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerMethodBean.java?rev=1435116&r1=1435115&r2=1435116&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerMethodBean.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerMethodBean.java
Fri Jan 18 12:46:30 2013
@@ -23,26 +23,19 @@ import java.lang.annotation.Annotation;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 import java.lang.reflect.Type;
-import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
 import javax.enterprise.context.Dependent;
-import javax.enterprise.context.spi.Contextual;
 import javax.enterprise.context.spi.CreationalContext;
 import javax.enterprise.inject.spi.Bean;
-import javax.enterprise.inject.spi.InjectionPoint;
 import javax.enterprise.inject.spi.InjectionTarget;
-import javax.enterprise.inject.spi.Producer;
 
 import org.apache.webbeans.context.creational.CreationalContextImpl;
 import org.apache.webbeans.context.creational.DependentCreationalContext;
-import org.apache.webbeans.context.creational.DependentCreationalContext.DependentType;
 import org.apache.webbeans.exception.WebBeansConfigurationException;
-import org.apache.webbeans.inject.AbstractInjectable;
 import org.apache.webbeans.inject.InjectableMethod;
-import org.apache.webbeans.portable.ProducerMethodProducer;
 import org.apache.webbeans.util.ClassUtil;
 import org.apache.webbeans.util.WebBeansUtil;
 

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/CreationalContextImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/CreationalContextImpl.java?rev=1435116&r1=1435115&r2=1435116&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/CreationalContextImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/CreationalContextImpl.java
Fri Jan 18 12:46:30 2013
@@ -25,20 +25,14 @@ import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
 
 import javax.enterprise.context.spi.Contextual;
 import javax.enterprise.context.spi.CreationalContext;
 import javax.enterprise.inject.spi.Bean;
-import javax.enterprise.inject.spi.Decorator;
-import javax.enterprise.inject.spi.Interceptor;
 
 import org.apache.webbeans.config.WebBeansContext;
-import org.apache.webbeans.context.creational.DependentCreationalContext.DependentType;
 import org.apache.webbeans.exception.WebBeansException;
 import org.apache.webbeans.util.Asserts;
 import org.apache.webbeans.util.WebBeansUtil;
@@ -64,10 +58,6 @@ public class CreationalContextImpl<T> im
 
     /**Contextual bean*/
     private Contextual<T> contextual = null;
-        
-    /**Ejb interceptors*/
-    //contextual instance --> interceptors
-    private ConcurrentMap<Object, List<EjbInterceptorContext>> ejbInterceptors
= null;
 
     private WebBeansContext webBeansContext;
     
@@ -91,69 +81,6 @@ public class CreationalContextImpl<T> im
         return webBeansContext;
     }
 
-    /**
-     * Add interceptor instance.
-     * @param ownerInstance
-     * @param instance interceptor instance
-     */
-    public void addEjbInterceptor(Object ownerInstance, EjbInterceptorContext instance)
-    {
-        Asserts.assertNotNull(ownerInstance,"Owner instance parameter can not be null");
-        Asserts.assertNotNull(instance,"Instance parameter can not be null");
-        
-        List<EjbInterceptorContext> list = null;
-        if (ejbInterceptors == null)
-        {
-            ejbInterceptors =  new ConcurrentHashMap<Object, List<EjbInterceptorContext>>();
-        }
-        else
-        {
-            list = ejbInterceptors.get(ownerInstance);
-        }
-
-        if(list == null)
-        {
-            list = new ArrayList<EjbInterceptorContext>();
-            List<EjbInterceptorContext> oldList = ejbInterceptors.putIfAbsent(ownerInstance,
list);
-            if(oldList != null)
-            {
-                list = oldList;
-            }
-        }
-        
-        
-        list.add(instance);
-    }
-    
-    /**
-     * Gets interceptor instance.
-     * @param clazz interceptor class
-     * @return interceptor instance
-     */
-    public EjbInterceptorContext getEjbInterceptor(Object ownerInstance,Class<?> clazz)
-    {
-        Asserts.assertNotNull(ownerInstance,"Owner instance can not be null");
-
-        if (ejbInterceptors == null)
-        {
-            return null;
-        }
-        
-        List<EjbInterceptorContext> ejbInts = ejbInterceptors.get(ownerInstance);
-        if(ejbInts != null)
-        {
-            for(EjbInterceptorContext ejbInterceptor : ejbInts)
-            {
-                if(ejbInterceptor.getInterceptorClass() == clazz)
-                {
-                    return ejbInterceptor;
-                }
-            }            
-        }
-        
-        return null;
-    }
-    
     public T getDelegate()
     {
         return this.delegate;
@@ -193,19 +120,6 @@ public class CreationalContextImpl<T> im
         if(instance != null)
         {
             DependentCreationalContext<K> dependentCreational = new DependentCreationalContext<K>(dependent);
-            if(dependent instanceof Interceptor)
-            {
-                dependentCreational.setDependentType(DependentType.INTERCEPTOR);
-            }
-            else if(dependent instanceof Decorator)
-            {
-                dependentCreational.setDependentType(DependentType.DECORATOR);
-            }
-            else
-            {
-                dependentCreational.setDependentType(DependentType.BEAN);
-            }
-
             dependentCreational.setInstance(instance);
 
             synchronized(this)
@@ -227,43 +141,6 @@ public class CreationalContextImpl<T> im
         }
     }
 
-    /**
-     * Gets bean interceptor instance.
-     * @param interceptor interceptor bean
-     * @return bean interceptor instance
-     */
-    public Object getDependentInterceptor(Object ownerInstance, Contextual<?> interceptor)
-    {
-        Asserts.assertNotNull(interceptor,"Interceptor parameter can not be null");
-        
-        if(ownerInstance == null || dependentObjects == null)
-        {
-            return null;
-        }
-
-        synchronized(this)
-        {
-            if (dependentObjects != null)
-            {
-                List<DependentCreationalContext<?>> values = dependentObjects.get(ownerInstance);
-                if (values != null && !values.isEmpty())
-                {
-                    Iterator<DependentCreationalContext<?>> it = values.iterator();
-                    while (it.hasNext())
-                    {
-                        DependentCreationalContext<?> dc = it.next();
-                        if (dc.getDependentType().equals(DependentType.INTERCEPTOR) &&
-                                dc.getContextual().equals(interceptor))
-                        {
-                            return dc.getInstance();
-                        }
-                    }
-                }
-            }
-        }
-        
-        return null;
-    }
 
 
     @SuppressWarnings("unchecked")
@@ -309,12 +186,6 @@ public class CreationalContextImpl<T> im
             }
         }
 
-        // the instances are managed as normal dependent instances already
-        if (ejbInterceptors != null)
-        {
-            ejbInterceptors.clear();
-            ejbInterceptors = null;
-        }
     }
     
     /**
@@ -352,7 +223,6 @@ public class CreationalContextImpl<T> im
         {
             s.writeObject(null);
         }
-        s.writeObject(ejbInterceptors);
     }
 
 
@@ -371,30 +241,25 @@ public class CreationalContextImpl<T> im
         {
             contextual = (Contextual<T>) webBeansContext.getBeanManagerImpl().getPassivationCapableBean(id);
         }
-                
-        ejbInterceptors = (ConcurrentMap<Object, List<EjbInterceptorContext>>)
s.readObject();
-    }
 
-//    private static volatile int ids = 0;
-//    private final int id = ids++;
+    }
 
     @Override
     public String toString()
     {
 
-        final String name;
+        final StringBuilder sb = new StringBuilder("CreationalContext{name=");
 
         if (contextual instanceof Bean)
         {
             Bean bean = (Bean) contextual;
-            name = bean.getBeanClass().getSimpleName();
+            sb.append(bean.getBeanClass().getSimpleName());
         }
         else
         {
-            name = "unknown";
+            sb.append("unknown");
         }
 
-        return String.format("CreationalContext{name=%s}", name);
-//        return String.format("CreationalContext{id=%s, name=%s}", id, name);
+        return sb.append("}").toString();
     }
 }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/DependentCreationalContext.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/DependentCreationalContext.java?rev=1435116&r1=1435115&r2=1435116&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/DependentCreationalContext.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/DependentCreationalContext.java
Fri Jan 18 12:46:30 2013
@@ -39,8 +39,6 @@ public class DependentCreationalContext<
 
     private Contextual<S> contextual;
     
-    private DependentType dependentType;
-    
     private Object instance;
     
     /**
@@ -60,37 +58,12 @@ public class DependentCreationalContext<
         this.instance = instance;
     }
 
-
-    public enum DependentType
-    {
-        DECORATOR,
-        INTERCEPTOR,
-        BEAN
-    }
     
     public DependentCreationalContext(Contextual<S> contextual)
     {
         this.contextual = contextual;
     }
     
-    
-    /**
-     * @return the dependentType
-     */
-    public DependentType getDependentType()
-    {
-        return dependentType;
-    }
-
-
-
-    /**
-     * @param dependentType the dependentType to set
-     */
-    public void setDependentType(DependentType dependentType)
-    {
-        this.dependentType = dependentType;
-    }
 
     /**
      * @return the contextual
@@ -103,7 +76,6 @@ public class DependentCreationalContext<
     private void writeObject(ObjectOutputStream s)
     throws IOException
     {
-        s.writeObject(dependentType);
         s.writeObject(instance);
 
         //Write for contextual
@@ -131,7 +103,6 @@ public class DependentCreationalContext<
     private void readObject(ObjectInputStream s)
     throws IOException, ClassNotFoundException
     {
-        dependentType = (DependentType) s.readObject();
         instance = s.readObject();
 
         //Read for contextual

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorDataImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorDataImpl.java?rev=1435116&r1=1435115&r2=1435116&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorDataImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorDataImpl.java
Fri Jan 18 12:46:30 2013
@@ -20,23 +20,16 @@ package org.apache.webbeans.intercept;
 
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Method;
-import java.util.logging.Level;
 import java.util.logging.Logger;
 
 import javax.annotation.PostConstruct;
 import javax.annotation.PreDestroy;
-import javax.enterprise.context.spi.CreationalContext;
 import javax.enterprise.inject.spi.Interceptor;
 import javax.interceptor.AroundInvoke;
 
-import org.apache.webbeans.config.OWBLogConst;
 import org.apache.webbeans.config.WebBeansContext;
-import org.apache.webbeans.container.BeanManagerImpl;
 import org.apache.webbeans.context.creational.CreationalContextImpl;
-import org.apache.webbeans.context.creational.EjbInterceptorContext;
 import org.apache.webbeans.decorator.WebBeansDecoratorInterceptor;
-import org.apache.webbeans.inject.OWBInjector;
-import org.apache.webbeans.intercept.webbeans.WebBeansInterceptorBeanPleaseRemove;
 import org.apache.webbeans.logger.WebBeansLoggerFacade;
 import org.apache.webbeans.plugins.OpenWebBeansEjbLCAPlugin;
 
@@ -411,62 +404,8 @@ public class InterceptorDataImpl impleme
     @SuppressWarnings("unchecked")
     public Object createNewInstance(Object ownerInstance, CreationalContextImpl<?>
ownerCreationalContext)
     {
-        // check for this InterceptorData is defined by interceptor class
-        if (isDefinedWithWebBeansInterceptor && definedInInterceptorClass)
-        {
-            Object interceptor;
-
-            // Means that it is the last interceptor added by InterceptorHandler
-            if (webBeansInterceptor == null)
-            {
-                return decoratorInterceptor;
-            }
-
-            interceptor = ownerCreationalContext.getDependentInterceptor(ownerInstance, webBeansInterceptor);
-            // There is no define interceptor, define and add it into dependent
-            if (interceptor == null)
-            {
-                BeanManagerImpl manager = webBeansContext.getBeanManagerImpl();
-
-                WebBeansInterceptorBeanPleaseRemove<Object> actualInterceptor = (WebBeansInterceptorBeanPleaseRemove<Object>)
webBeansInterceptor;
-                CreationalContext<?> creationalContext = manager.createCreationalContext(webBeansInterceptor);
-                interceptor = manager.getReference(webBeansInterceptor, actualInterceptor.getBeanClass(),
creationalContext);
-
-                ownerCreationalContext.addDependent(ownerInstance, (WebBeansInterceptorBeanPleaseRemove<Object>)
webBeansInterceptor, interceptor);
-            }
-            return interceptor;
-        }
-
-        EjbInterceptorContext ejbInterceptorContext ;
-        Object interceptor = null;
-        // control for this InterceptorData is defined by interceptor class
-        if (definedInInterceptorClass)
-        {
-            ejbInterceptorContext = ownerCreationalContext.getEjbInterceptor(ownerInstance,
interceptorClass);
-            if (ejbInterceptorContext == null)
-            {
-                interceptor = webBeansContext.getWebBeansUtil().newInstanceForced(interceptorClass);
-                try
-                {
-                    OWBInjector.inject(webBeansContext.getBeanManagerImpl(), interceptor,
ownerCreationalContext);
-
-                    ejbInterceptorContext = new EjbInterceptorContext();
-                    ejbInterceptorContext.setInterceptorInstance(interceptor);
-                    ejbInterceptorContext.setInterceptorClass(interceptorClass);
-                }
-                catch (Exception e)
-                {
-                    logger.log(Level.SEVERE, WebBeansLoggerFacade.constructMessage(OWBLogConst.ERROR_0022,
interceptorClass), e);
-                }
-
-                ownerCreationalContext.addEjbInterceptor(ownerInstance, ejbInterceptorContext);
-            }
-            else
-            {
-                interceptor = ejbInterceptorContext.getInterceptorInstance();
-            }
-        }
-        return interceptor;
+        // this got pruned completely...
+        return null;
     }
 
     @Override



Mime
View raw message