openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gerdo...@apache.org
Subject svn commit: r729783 - in /incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans: component/ config/ container/ decorator/ inject/ inject/xml/ intercept/ proxy/ util/
Date Sun, 28 Dec 2008 21:58:45 GMT
Author: gerdogdu
Date: Sun Dec 28 13:58:44 2008
New Revision: 729783

URL: http://svn.apache.org/viewvc?rev=729783&view=rev
Log:
Arranging and testing for M1 Release.

Modified:
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractComponent.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContainerDeployer.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ManagerImpl.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecorator.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecoratorConfig.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/InjectableConstructor.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/xml/XMLInjectableConstructor.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorDataImpl.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorHandler.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/JavassistProxyFactory.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractComponent.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractComponent.java?rev=729783&r1=729782&r2=729783&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractComponent.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractComponent.java
Sun Dec 28 13:58:44 2008
@@ -18,7 +18,6 @@
 
 import java.lang.annotation.Annotation;
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
@@ -34,8 +33,6 @@
 import org.apache.webbeans.context.DependentContext;
 import org.apache.webbeans.deployment.DeploymentTypeManager;
 import org.apache.webbeans.intercept.InterceptorData;
-import org.apache.webbeans.intercept.InterceptorDataComparator;
-import org.apache.webbeans.intercept.InterceptorDataImpl;
 
 /**
  * 
@@ -436,18 +433,18 @@
 	 * @see org.apache.webbeans.component.Component#setNullable()
 	 */
 	@Override
-	public void setNullable(boolean serializable)
+	public void setNullable(boolean nullable)
 	{
-		this.serializable = serializable;
+		this.nullable = nullable;
 	}
 
 	/* (non-Javadoc)
 	 * @see org.apache.webbeans.component.Component#setSerializable()
 	 */
 	@Override
-	public void setSerializable(boolean nullable)
+	public void setSerializable(boolean serializable)
 	{
-		this.nullable = nullable;
+		this.serializable = serializable;
 		
 	}
 

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContainerDeployer.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContainerDeployer.java?rev=729783&r1=729782&r2=729783&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContainerDeployer.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContainerDeployer.java
Sun Dec 28 13:58:44 2008
@@ -29,7 +29,6 @@
 import javax.webbeans.Interceptor;
 import javax.webbeans.ScopeType;
 import javax.webbeans.Specializes;
-import javax.webbeans.Stereotype;
 import javax.webbeans.manager.Bean;
 
 import org.apache.webbeans.WebBeansConstants;

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ManagerImpl.java?rev=729783&r1=729782&r2=729783&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ManagerImpl.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ManagerImpl.java
Sun Dec 28 13:58:44 2008
@@ -21,6 +21,7 @@
 import java.lang.reflect.Type;
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.IdentityHashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -56,6 +57,7 @@
 import org.apache.webbeans.intercept.InterceptorComparator;
 import org.apache.webbeans.intercept.WebBeansInterceptorConfig;
 import org.apache.webbeans.intercept.webbeans.WebBeansInterceptor;
+import org.apache.webbeans.proxy.JavassistProxyFactory;
 import org.apache.webbeans.util.Asserts;
 import org.apache.webbeans.util.ClassUtil;
 import org.apache.webbeans.util.WebBeansUtil;
@@ -85,6 +87,7 @@
 	
 	private InjectionResolver injectionResolver = null;
 	
+	private Map<Bean<?>, Object> proxyMap = Collections.synchronizedMap(new IdentityHashMap<Bean<?>,
Object>());
 	
 	public ManagerImpl()
 	{		
@@ -258,9 +261,26 @@
 				isSetOnThis = true;
 			}
 			
-			context = getContext(bean.getScopeType());
-			instance = context.get(bean, true);
+			if(!bean.getScopeType().equals(Dependent.class))
+			{
+				if(this.proxyMap.containsKey(bean))
+				{
+					instance = (T)this.proxyMap.get(bean);
+				}
+				else
+				{
+					instance =(T) JavassistProxyFactory.createNewProxyInstance(bean);
+					
+					this.proxyMap.put(bean, instance);
+				}
+			}
 			
+			else
+			{
+				context = getContext(bean.getScopeType());
+				instance = context.get(bean, true);					
+			}
+						
 		}finally
 		{
 			if(isSetOnThis)

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecorator.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecorator.java?rev=729783&r1=729782&r2=729783&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecorator.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecorator.java
Sun Dec 28 13:58:44 2008
@@ -233,6 +233,15 @@
 	
 
 	/**
+	 * @return the delegateComponent
+	 */
+	public AbstractComponent<Object> getDelegateComponent()
+	{
+		return delegateComponent;
+	}
+
+
+	/**
 	 * @return the clazz
 	 */
 	public Class<?> getClazz()

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecoratorConfig.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecoratorConfig.java?rev=729783&r1=729782&r2=729783&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecoratorConfig.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecoratorConfig.java
Sun Dec 28 13:58:44 2008
@@ -76,15 +76,13 @@
 		
 		while(itList.hasNext())
 		{
-			Decorator decorator = itList.next();
+			WebBeansDecorator decorator = (WebBeansDecorator)itList.next();
+			
 			Object decoratorInstance = ManagerImpl.getManager().getInstance(decorator);
-
 			decorator.setDelegate(decoratorInstance, instance);
 		
 			component.getDecoratorStack().add(decoratorInstance);			
 		}
-		
-		
 	}
 	
 	private static Set<Decorator> getWebBeansDecorators()

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/InjectableConstructor.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/InjectableConstructor.java?rev=729783&r1=729782&r2=729783&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/InjectableConstructor.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/InjectableConstructor.java
Sun Dec 28 13:58:44 2008
@@ -23,14 +23,11 @@
 import java.util.ArrayList;
 import java.util.List;
 
-import javax.webbeans.Dependent;
-
 import org.apache.webbeans.annotation.CurrentLiteral;
 import org.apache.webbeans.component.AbstractComponent;
 import org.apache.webbeans.component.ComponentImpl;
 import org.apache.webbeans.ejb.EJBUtil;
 import org.apache.webbeans.exception.WebBeansException;
-import org.apache.webbeans.proxy.JavassistProxyFactory;
 import org.apache.webbeans.util.AnnotationUtil;
 
 /**
@@ -111,14 +108,7 @@
 		{
 			if (!EJBUtil.isEJBSessionClass(con.getDeclaringClass()))
 			{
-				if(getInjectionOwnerComponent().getScopeType().equals(Dependent.class))
-				{
-					instance = con.newInstance(list.toArray());
-				}
-				else
-				{
-					instance = (T) JavassistProxyFactory.createNewProxyInstance(con.getDeclaringClass(),
con.getParameterTypes(), list.toArray(), getInjectionOwnerComponent());					
-				}				
+				instance = con.newInstance(list.toArray());
 			}
 
 		} catch (Exception e)

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/xml/XMLInjectableConstructor.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/xml/XMLInjectableConstructor.java?rev=729783&r1=729782&r2=729783&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/xml/XMLInjectableConstructor.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/xml/XMLInjectableConstructor.java
Sun Dec 28 13:58:44 2008
@@ -22,13 +22,10 @@
 import java.util.Iterator;
 import java.util.List;
 
-import javax.webbeans.Dependent;
-
 import org.apache.webbeans.component.AbstractComponent;
 import org.apache.webbeans.ejb.EJBUtil;
 import org.apache.webbeans.exception.WebBeansException;
 import org.apache.webbeans.inject.InjectableConstructor;
-import org.apache.webbeans.proxy.JavassistProxyFactory;
 import org.apache.webbeans.util.Asserts;
 
 public class XMLInjectableConstructor<T> extends InjectableConstructor<T>
@@ -68,14 +65,16 @@
 		{
 			if (!EJBUtil.isEJBSessionClass(con.getDeclaringClass()))
 			{
-				if(getInjectionOwnerComponent().getScopeType().equals(Dependent.class))
-				{
-					instance = con.newInstance(list.toArray());
-				}
-				else
-				{
-					instance = (T) JavassistProxyFactory.createNewProxyInstance(con.getDeclaringClass(),
con.getParameterTypes(), list.toArray(), getInjectionOwnerComponent());					
-				}				
+				instance = con.newInstance(list.toArray());
+				
+//				if(getInjectionOwnerComponent().getScopeType().equals(Dependent.class))
+//				{
+//					
+//				}
+//				else
+//				{
+//					instance = (T) JavassistProxyFactory.createNewProxyInstance(con.getDeclaringClass(),
con.getParameterTypes(), list.toArray(), getInjectionOwnerComponent());					
+//				}				
 			}
 
 		} catch (Throwable e)

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorDataImpl.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorDataImpl.java?rev=729783&r1=729782&r2=729783&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorDataImpl.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorDataImpl.java
Sun Dec 28 13:58:44 2008
@@ -18,15 +18,12 @@
 
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Method;
-import java.util.Comparator;
 
 import javax.annotation.PostConstruct;
 import javax.annotation.PreDestroy;
 import javax.interceptor.AroundInvoke;
 import javax.webbeans.manager.Interceptor;
 
-import org.apache.webbeans.intercept.webbeans.WebBeansInterceptor;
-
 /**
  * Abstract implementation of the {@link InterceptorData} api
  * contract.

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorHandler.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorHandler.java?rev=729783&r1=729782&r2=729783&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorHandler.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorHandler.java
Sun Dec 28 13:58:44 2008
@@ -24,8 +24,10 @@
 
 import javax.interceptor.ExcludeClassInterceptors;
 import javax.interceptor.Interceptors;
+import javax.webbeans.manager.Context;
 
 import org.apache.webbeans.component.AbstractComponent;
+import org.apache.webbeans.container.ManagerImpl;
 import org.apache.webbeans.exception.WebBeansException;
 import org.apache.webbeans.logger.WebBeansLogger;
 import org.apache.webbeans.util.AnnotationUtil;
@@ -51,6 +53,9 @@
 	
 	public Object invoke(Object instance, Method method, Method proceed, Object[] arguments)
throws Throwable
 	{
+		Context webbeansContext = ManagerImpl.getManager().getContext(component.getScopeType());
+		Object webbeansInstance = webbeansContext.get(this.component, true);
+		
 		if(!ClassUtil.isObjectMethod(method.getName()) && InterceptorUtil.isWebBeansBusinessMethod(method))
 		{
 			if(this.calledMethod == null)
@@ -67,7 +72,6 @@
 				this.isSameDecMethod = false;
 			}
 			
-			
 			//Run around invoke chain
 			List<InterceptorData> stack = component.getInterceptorStack();
 			
@@ -86,7 +90,7 @@
 			
 		}
 		
-		return proceed.invoke(instance, arguments);
+		return method.invoke(webbeansInstance, arguments);
 	}
 	
 	private void callDecorators(List<Object> decorators, Method method, Object[] arguments)

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/JavassistProxyFactory.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/JavassistProxyFactory.java?rev=729783&r1=729782&r2=729783&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/JavassistProxyFactory.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/JavassistProxyFactory.java
Sun Dec 28 13:58:44 2008
@@ -18,15 +18,19 @@
 
 import java.io.Serializable;
 import java.lang.annotation.Annotation;
-import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import javax.webbeans.manager.Bean;
 
 import org.apache.webbeans.annotation.WebBeansAnnotation;
 import org.apache.webbeans.component.AbstractComponent;
+import org.apache.webbeans.decorator.WebBeansDecorator;
 import org.apache.webbeans.exception.WebBeansException;
 import org.apache.webbeans.intercept.InterceptorHandler;
-import org.apache.webbeans.util.ClassUtil;
+import org.apache.webbeans.intercept.webbeans.WebBeansInterceptor;
 
-import javassist.util.proxy.MethodFilter;
 import javassist.util.proxy.ProxyFactory;
 
 public final class JavassistProxyFactory
@@ -37,27 +41,44 @@
 	}
 	
 	
-	public static Object createNewProxyInstance(Class<?> superClazz, Class<?>[]
paramTypes, Object[] args, AbstractComponent<?> component)
+	public static <T> Object createNewProxyInstance(Bean<T> bean)
 	{
 		Object result = null;
 		try
 		{
-			ProxyFactory fact = new ProxyFactory();
-			fact.setInterfaces(new Class[]{Serializable.class});
-			fact.setSuperclass(superClazz);
-			fact.setHandler(new InterceptorHandler(component));
-			fact.setFilter(new MethodFilter(){
-
-				public boolean isHandled(Method arg0)
+			Set<Class<?>> types = bean.getTypes();
+			List<Class<?>> interfaceList = new ArrayList<Class<?>>();
+			Class<?> superClass = null;
+			for(Class<?> type : types)
+			{
+				if(type.isInterface())
 				{
-					if(ClassUtil.isObjectMethod(arg0.getName()))
-						return false;
-					return true;
+					interfaceList.add(type);
 				}
+		        else if ((superClass == null) 
+		        		|| (superClass.isAssignableFrom(type) && type != Object.class ))
+		         {
+		        	superClass = type;
+		         }
 				
-			});
+			}
+			
+			interfaceList.add(Serializable.class);
+			
+			Class<?>[] interfaceArray = new Class<?>[interfaceList.size()];
+			interfaceArray = interfaceList.toArray(interfaceArray);
+			
+			ProxyFactory fact = new ProxyFactory();
+			fact.setInterfaces(interfaceArray);
+			fact.setSuperclass(superClass);
+			
+			if(!(bean instanceof WebBeansDecorator) && !(bean instanceof WebBeansInterceptor))
+			{
+				fact.setHandler(new InterceptorHandler((AbstractComponent<?>)bean));
+			}
+			
+			result = fact.createClass().newInstance();
 			
-			result = fact.create(paramTypes, args); 
 		}catch(Throwable e)
 		{
 			throw new WebBeansException(e);

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java?rev=729783&r1=729782&r2=729783&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java
Sun Dec 28 13:58:44 2008
@@ -533,7 +533,10 @@
 		Method[] methods = clazz.getMethods();
 		for (Method method : methods)
 		{
-			list.add(method.getName());
+			if(!method.getName().equals("toString"))
+			{
+				list.add(method.getName());	
+			}
 		}
 
 		return list;



Mime
View raw message