openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gerdo...@apache.org
Subject svn commit: r719890 [6/14] - in /incubator/openwebbeans/trunk/webbeans-impl: ./ src/ src/main/ src/main/java/ src/main/java/META-INF/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/webbeans/ src/main/java/org/apache/webbeans/anno...
Date Sat, 22 Nov 2008 18:09:48 GMT
Added: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/ejb/EJBInterceptorConfig.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/ejb/EJBInterceptorConfig.java?rev=719890&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/ejb/EJBInterceptorConfig.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/ejb/EJBInterceptorConfig.java Sat Nov 22 10:09:38 2008
@@ -0,0 +1,152 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You 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.apache.webbeans.intercept.ejb;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.Interceptors;
+
+import org.apache.webbeans.intercept.InterceptorData;
+import org.apache.webbeans.util.AnnotationUtil;
+import org.apache.webbeans.util.Asserts;
+import org.apache.webbeans.util.ClassUtil;
+import org.apache.webbeans.util.WebBeansUtil;
+
+/**
+ * Configures the EJB related interceptors.
+ * 
+ * @author <a href="mailto:gurkanerdogdu@yahoo.com">Gurkan Erdogdu</a>
+ * @since 1.0
+ */
+public final class EJBInterceptorConfig
+{
+	/*
+	 * Private constructor
+	 */
+	private EJBInterceptorConfig()
+	{
+		
+	}
+	
+	/**
+	 * Configures the given class for applicable interceptors.
+	 * 
+	 * @param clazz configuration interceptors for this
+	 */
+	public static void configure(Class<?> clazz, List<InterceptorData> stack)
+	{
+		Asserts.assertNotNull(clazz, "Clazz argument can not be null");
+		
+		
+		if(AnnotationUtil.isAnnotationExistOnClass(clazz, Interceptors.class))
+		{
+			Interceptors incs = clazz.getAnnotation(Interceptors.class);
+			Class<?>[] intClasses = incs.value();
+			
+			for(Class<?> intClass : intClasses)
+			{
+				configureInterceptorAnnots(intClass, stack, false,null);	
+			}
+			
+		}
+		
+		
+		configureBeanAnnots(clazz, stack);
+	}
+	
+	/*
+	 * Configure interceptor class 
+	 */
+	private static void configureInterceptorAnnots(Class<?> clazz,List<InterceptorData> stack, boolean isMethod, Method m)
+	{
+		//1- Look interceptor class super class
+		//2- Look interceptor class
+		Class<?> superClass = clazz.getSuperclass();
+		if(superClass != null && !superClass.equals(Object.class))
+		{
+			configureInterceptorAnnots(superClass, stack, false,null);			
+		}
+
+		WebBeansUtil.configureInterceptorMethods(clazz, AroundInvoke.class,true,isMethod,stack,m,false);
+		WebBeansUtil.configureInterceptorMethods(clazz, PostConstruct.class,true,isMethod,stack,m,false);
+		WebBeansUtil.configureInterceptorMethods(clazz, PreDestroy.class,true,isMethod,stack,m,false);
+		
+	}
+		
+	/*
+	 * Configure bean class
+	 */
+	private static void configureBeanAnnots(Class<?> clazz,List<InterceptorData> stack)
+	{
+		//1- Look method intercepor class annotations
+		//2- Look super class around invoke
+		//3- Look bean around invoke
+		
+		//1-
+		Method[] methods = clazz.getDeclaredMethods();
+		
+		for(Method method : methods)
+		{
+			Interceptors incs = method.getAnnotation(Interceptors.class);
+			if(incs != null)
+			{
+				Class<?>[] intClasses = incs.value();
+				
+				for(Class<?> intClass : intClasses)
+				{
+					configureInterceptorAnnots(intClass, stack, true,method);
+				}		
+				
+			}
+		} 
+		
+		//2- Super clazz
+		List<Class<?>> listSuperClazz = ClassUtil.getSuperClasses(clazz, new ArrayList<Class<?>>());
+		configureBeanSuperClassAnnots(listSuperClazz,stack);
+		
+		//3- Bean itself
+		WebBeansUtil.configureInterceptorMethods(clazz, AroundInvoke.class,false,false,stack,null,false);
+		WebBeansUtil.configureInterceptorMethods(clazz, PostConstruct.class,false,false,stack,null,false);
+		WebBeansUtil.configureInterceptorMethods(clazz, PreDestroy.class,false,false,stack,null,false);
+		
+	}
+	
+	/*
+	 * Super class annots.
+	 */
+	private static void configureBeanSuperClassAnnots(List<Class<?>> list, List<InterceptorData> stack)
+	{
+		int i = list.size();
+		
+		for(int j = i-1; j>=0;j--)
+		{
+			Class<?> clazz = list.get(j);
+			if(!clazz.equals(Object.class))
+			{
+				WebBeansUtil.configureInterceptorMethods(clazz, AroundInvoke.class,false,false,stack,null,false);
+				WebBeansUtil.configureInterceptorMethods(clazz, PostConstruct.class,false,false,stack,null,false);
+				WebBeansUtil.configureInterceptorMethods(clazz, PreDestroy.class,false,false,stack,null,false);				
+			}
+		}
+	}
+		
+}
\ No newline at end of file

Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/ejb/EJBInterceptorConfig.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java?rev=719890&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java Sat Nov 22 10:09:38 2008
@@ -0,0 +1,353 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You 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.apache.webbeans.intercept.webbeans;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.webbeans.InterceptorBindingType;
+import javax.webbeans.NonBinding;
+import javax.webbeans.manager.InterceptionType;
+import javax.webbeans.manager.Interceptor;
+
+import org.apache.webbeans.component.AbstractComponent;
+import org.apache.webbeans.container.ManagerImpl;
+import org.apache.webbeans.exception.WebBeansConfigurationException;
+import org.apache.webbeans.intercept.InterceptorUtil;
+import org.apache.webbeans.intercept.WebBeansInterceptorConfig;
+import org.apache.webbeans.util.AnnotationUtil;
+import org.apache.webbeans.util.WebBeansUtil;
+
+/**
+ * Defines the webbeans specific interceptors.
+ * 
+ * <p>
+ * WebBeans interceotor classes has at least one {@link InterceptorBindingType} annotation.
+ * It can be defined on the class or method level at the component. WebBeans interceptors are
+ * called after the EJB related interceptors are called in the chain. Semantics of the interceptors
+ * are specified by the EJB specificatin.
+ * </p>
+ * 
+ * @author <a href="mailto:gurkanerdogdu@yahoo.com">Gurkan Erdogdu</a>
+ * @since 1.0
+ */
+public class WebBeansInterceptor extends Interceptor
+{
+	/**InterceptorBindingTypes exist on the interceptor class*/
+	private Map<Class<? extends Annotation>, Annotation> interceptorBindingSet = new HashMap<Class<? extends Annotation>,Annotation>();
+	
+	/**Interceptor class*/
+	private Class<?> clazz; 
+	
+	/**Simple Web Beans component*/
+	private AbstractComponent<Object> delegateComponent;
+	
+	public WebBeansInterceptor(AbstractComponent<Object> delegateComponent)
+	{
+		super(ManagerImpl.getManager());
+		this.delegateComponent = delegateComponent;
+		this.clazz = getDelegate().getReturnType(); 
+		
+	}
+	
+	
+	public AbstractComponent<Object> getDelegate()
+	{
+		return this.delegateComponent;
+	}
+	
+	/**
+	 * Add new binding type to the interceptor.
+	 * 
+	 * @param bindingType interceptor binding type annot. class
+	 * @param annot binding type annotation
+	 */
+	public void addInterceptorBindingType(Class<? extends Annotation> bindingType, Annotation annot)
+	{
+		Method[] methods = bindingType.getDeclaredMethods();
+		
+		for(Method method : methods)
+		{
+			Class<?> clazz = method.getReturnType();
+			if(clazz.isArray() || clazz.isAnnotation())
+			{
+				if(!AnnotationUtil.isAnnotationExist(method.getAnnotations(), NonBinding.class))
+				{
+					throw new WebBeansConfigurationException("Interceptor definition class : " + getClazz().getName() + 
+							" @InterceptorBindingType : " + bindingType.getName() + " must have @NonBinding valued members for its array-valued and annotation valued members");
+				}
+			}
+		}
+		
+		interceptorBindingSet.put(bindingType,annot);
+	}
+		
+	
+	/**
+	 * Checks whether this interceptor has given binding types with {@link NonBinding} member
+	 * values.
+	 * 
+	 * @param bindingTypes binding types
+	 * @param annots binding types annots.
+	 * @return true if binding types exist ow false
+	 */
+	public boolean isBindingTypesExist(List<Class<? extends Annotation>> bindingTypes, List<Annotation> annots)
+	{
+		boolean result = false;
+		
+		
+		if(bindingTypes != null && annots != null && (bindingTypes.size() == annots.size()))
+		{
+			int i = 0;
+			for(Class<? extends Annotation> bindingType : bindingTypes)
+			{
+				if(this.interceptorBindingSet.containsKey(bindingType))
+				{
+					Annotation target = this.interceptorBindingSet.get(bindingType);
+					if(AnnotationUtil.isAnnotationMemberExist(bindingType, annots.get(i), target))
+					{
+						result = true;
+					}
+					else
+					{
+						return false;
+					}
+				}
+				else
+				{
+					return false;
+				}
+				
+				i++;
+			}
+		}
+		
+		return result;
+	}
+
+
+	/**
+	 * Gets the interceptor class.
+	 * 
+	 * @return interceptor class
+	 */
+	public Class<?> getClazz()
+	{
+		return clazz;
+	}
+
+	public Set<Interceptor> getMetaInceptors()
+	{
+		Set<Interceptor> set = new HashSet<Interceptor>();
+		
+		Set<Class<? extends Annotation>> keys = interceptorBindingSet.keySet();
+		Iterator<Class<? extends Annotation>> it = keys.iterator();
+		
+		while(it.hasNext())
+		{
+			Class<? extends Annotation> clazzAnnot = it.next();
+			if(AnnotationUtil.isMetaAnnotationExist(clazzAnnot.getAnnotations(), InterceptorBindingType.class))
+			{
+ 				Annotation[] anns =	AnnotationUtil.getMetaAnnotations(clazzAnnot.getAnnotations(), InterceptorBindingType.class);
+ 				
+ 				/*
+ 				 * For example:
+ 				 * 
+ 				 * @InterceptorBindingType
+ 				 * @Transactional
+ 				 * @Action
+ 				 * public @interface ActionTransactional
+ 				 * 
+ 				 * @ActionTransactional @Production
+ 				 * {
+ 				 * 
+ 				 * }
+ 				 * 
+ 				 */
+ 				
+ 				//For example : @Transactional @Action Interceptor
+ 				Set<Interceptor> metas = WebBeansInterceptorConfig.findDeployedWebBeansInterceptor(anns);
+ 				set.addAll(metas);
+ 				
+ 				//For each @Transactional and @Action Interceptor
+ 				for(Annotation ann : anns)
+ 				{
+ 					Annotation[] simple = new Annotation[1];
+ 					simple[0] = ann;
+ 					metas = WebBeansInterceptorConfig.findDeployedWebBeansInterceptor(simple);
+ 					set.addAll(metas);
+ 				}
+ 				
+			}
+		}
+		
+		return set;
+	}
+	
+	/**
+	 * Sets interceptor class.
+	 * 
+	 * @param clazz class instance
+	 */
+	public void setClazz(Class<?> clazz)
+	{
+		this.clazz = clazz;
+	}
+
+
+	/*
+	 * (non-Javadoc)
+	 * @see java.lang.Object#equals(java.lang.Object)
+	 */
+	@Override
+	public boolean equals(Object obj)
+	{
+		if(this == obj)
+			return true;
+		
+		WebBeansInterceptor o = null;
+		
+		if(obj instanceof WebBeansInterceptor)
+		{
+			o = (WebBeansInterceptor) obj;
+			
+			if(o.clazz != null && this.clazz != null)
+			{
+				return o.clazz.equals(this.clazz);
+			}
+			
+		}
+		
+		return false;
+	}
+
+
+	/*
+	 * (non-Javadoc)
+	 * @see java.lang.Object#hashCode()
+	 */
+	@Override
+	public int hashCode()
+	{
+		return this.clazz != null ? clazz.hashCode() : 0;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see java.lang.Object#toString()
+	 */
+	@Override
+	public String toString()
+	{
+		return "WebBeans Interceptor with class : " + "[" + this.clazz.getName() + "]";
+	}
+
+
+	@Override
+	public Set<Annotation> getInterceptorBindingTypes()
+	{
+		Set<Annotation> set = new HashSet<Annotation>();
+		Set<Class<? extends Annotation>> keySet = this.interceptorBindingSet.keySet();
+		Iterator<Class<? extends Annotation>> itSet = keySet.iterator();
+		
+		while(itSet.hasNext())
+		{
+			set.add(this.interceptorBindingSet.get(itSet.next()));
+		}
+		
+		return set;
+	}
+
+
+	@Override
+	public Method getMethod(InterceptionType type)
+	{
+		Class<? extends Annotation> interceptorTypeAnnotationClazz = InterceptorUtil.getInterceptorAnnotationClazz(type);
+		Method method = WebBeansUtil.checkCommonAnnotationCriterias(getClazz(), interceptorTypeAnnotationClazz, true);
+		
+		return method;
+	}
+
+
+	@Override
+	public Object create()
+	{
+		return delegateComponent.create();
+	}
+
+
+	@Override
+	public void destroy(Object instance)
+	{
+		delegateComponent.destroy(instance);
+	}
+
+
+	@Override
+	public Set<Annotation> getBindingTypes()
+	{
+		return delegateComponent.getBindingTypes();
+	}
+
+
+	@Override
+	public Class<? extends Annotation> getDeploymentType()
+	{
+		return delegateComponent.getDeploymentType();
+	}
+
+
+	@Override
+	public String getName()
+	{
+		return delegateComponent.getName();
+	}
+
+
+	@Override
+	public Class<? extends Annotation> getScopeType()
+	{
+		return delegateComponent.getScopeType();
+	}
+
+
+	@Override
+	public Set<Class<?>> getTypes()
+	{
+		return delegateComponent.getTypes();
+	}
+
+
+	@Override
+	public boolean isNullable()
+	{
+		return delegateComponent.isNullable();
+	}
+
+
+	@Override
+	public boolean isSerializable()
+	{
+		return delegateComponent.isSerializable();
+	}
+}
\ No newline at end of file

Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/jsf/ConversationImpl.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/jsf/ConversationImpl.java?rev=719890&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/jsf/ConversationImpl.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/jsf/ConversationImpl.java Sat Nov 22 10:09:38 2008
@@ -0,0 +1,168 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You 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.apache.webbeans.jsf;
+
+
+import javax.webbeans.Conversation;
+import javax.webbeans.ConversationScoped;
+
+import org.apache.webbeans.container.ManagerImpl;
+import org.apache.webbeans.context.ConversationContext;
+import org.apache.webbeans.util.Asserts;
+import org.apache.webbeans.util.StringUtil;
+
+public class ConversationImpl implements Conversation
+{
+	private String id;
+	
+	private String viewId;
+	
+	private boolean longRunning = false;
+	
+	private long timeout;
+	
+	private String sessionId;
+	
+	private long activeTime = 0L;
+	
+	public ConversationImpl(String sessionId)
+	{
+		Asserts.assertNotNull(sessionId);
+		this.sessionId = sessionId;
+		
+	}
+
+	public void begin()
+	{
+		this.longRunning = true;
+		this.id = StringUtil.generateUUIDStringWithoutDash();
+		
+		ConversationManager.getInstance().addConversationContext(this,(ConversationContext) ManagerImpl.getManager().getContext(ConversationScoped.class));
+	}
+
+	public void begin(String id)
+	{
+		this.longRunning = true;
+		this.id = id;
+		
+		ConversationManager.getInstance().addConversationContext(this,(ConversationContext) ManagerImpl.getManager().getContext(ConversationScoped.class));		
+	}
+
+	public void end()
+	{
+		this.longRunning = false;
+	}
+
+	public String getId()
+	{
+		return this.id;
+	}
+
+	public long getTimeout()
+	{
+		return this.timeout;
+	}
+
+	public boolean isLongRunning()
+	{
+		return this.longRunning;
+	}
+
+	public void setTimeout(long milliseconds)
+	{
+		this.timeout = milliseconds;
+	}
+	
+	public String getSessionId()
+	{
+		return this.sessionId;
+	}
+	
+
+	/**
+	 * @return the creationTime
+	 */
+	public long getActiveTime()
+	{
+		return activeTime;
+	}
+
+	/**
+	 * @return the viewId
+	 */
+	public String getViewId()
+	{
+		return viewId;
+	}
+
+	public void updateTimeOut()
+	{
+		this.activeTime = System.currentTimeMillis();
+	}
+	
+	/**
+	 * @param viewId the viewId to set
+	 */
+	public void setViewId(String viewId)
+	{
+		this.viewId = viewId;
+	}
+
+	/* (non-Javadoc)
+	 * @see java.lang.Object#hashCode()
+	 */
+	@Override
+	public int hashCode()
+	{
+		final int prime = 31;
+		int result = 1;
+		result = prime * result + ((id == null) ? 0 : id.hashCode());
+		result = prime * result + ((sessionId == null) ? 0 : sessionId.hashCode());
+		return result;
+	}
+
+	/* (non-Javadoc)
+	 * @see java.lang.Object#equals(java.lang.Object)
+	 */
+	@Override
+	public boolean equals(Object obj)
+	{
+		if (this == obj)
+			return true;
+		if (obj == null)
+			return false;
+		if (getClass() != obj.getClass())
+			return false;
+		final ConversationImpl other = (ConversationImpl) obj;
+		if (id == null)
+		{
+			if (other.id != null)
+				return false;
+		} else if (!id.equals(other.id))
+			return false;
+		if (sessionId == null)
+		{
+			if (other.sessionId != null)
+				return false;
+		} else if (!sessionId.equals(other.sessionId))
+			return false;
+		return true;
+	}
+	
+	
+	
+}	
\ No newline at end of file

Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/jsf/ConversationImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/jsf/ConversationManager.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/jsf/ConversationManager.java?rev=719890&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/jsf/ConversationManager.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/jsf/ConversationManager.java Sat Nov 22 10:09:38 2008
@@ -0,0 +1,167 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You 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.apache.webbeans.jsf;
+
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javax.webbeans.Conversation;
+import javax.webbeans.manager.Bean;
+
+import org.apache.webbeans.annotation.CurrentLiteral;
+import org.apache.webbeans.container.ManagerImpl;
+import org.apache.webbeans.context.ConversationContext;
+import org.apache.webbeans.util.Asserts;
+
+public class ConversationManager
+{
+	private static ConversationManager manager = null;
+	
+	private Map<Conversation, ConversationContext> conversations = null;
+	
+	private ConversationManager()
+	{
+		
+	}
+
+	public static ConversationManager getInstance()
+	{
+		if(manager == null)
+		{
+			manager = new ConversationManager();
+			manager.conversations = new ConcurrentHashMap<Conversation, ConversationContext>();
+		}
+		
+		return manager;
+	}
+	
+	public void addConversationContext(Conversation conversation, ConversationContext context)
+	{
+		conversations.put(conversation, context);
+	}
+	
+	public ConversationContext removeConversation(Conversation conversation)
+	{
+		Asserts.assertNotNull(conversation,"conversation can not be null");
+		
+		return conversations.remove(conversation);
+	}
+
+	public ConversationContext getConversationContext(Conversation conversation)
+	{
+		Asserts.assertNotNull(conversation,"conversation can not be null");
+		
+		return conversations.get(conversation);
+	}
+	
+	
+	public Conversation getConversation(String conversationId)
+	{
+		Asserts.assertNotNull(conversationId,"conversationId parameter can not be null");
+		
+		ConversationImpl conv = null;
+		Set<Conversation> set = conversations.keySet();
+		Iterator<Conversation> it = set.iterator();
+		
+		while(it.hasNext())
+		{
+			conv = (ConversationImpl)it.next();
+			if(conv.getId().equals(conversationId))
+			{
+				return conv;
+			}
+		}
+		
+		return null;
+		
+	}
+	
+	public void destroyConversationContextWithSessionId(String sessionId)
+	{
+		Asserts.assertNotNull(sessionId,"sessionId parameter can not be null");
+		
+		ConversationImpl conv = null;
+		Set<Conversation> set = conversations.keySet();
+		Iterator<Conversation> it = set.iterator();
+		
+		while(it.hasNext())
+		{
+			conv = (ConversationImpl)it.next();
+			if(conv.getSessionId().equals(sessionId))
+			{
+				it.remove();
+			}
+		}
+	}
+	
+	public Conversation createNewConversation(String viewId)
+	{
+		Asserts.assertNotNull(viewId,"viewId parameter can not be null");
+		
+		Conversation conversation = getCurrentConversation();
+		((ConversationImpl)conversation).setViewId(viewId);
+		
+		//Create conversation context
+		//ContextFactory.initConversationContext();
+		
+		//addConversationContext(conversation,(ConversationContext) ManagerImpl.getManager().getContext(ConversationScoped.class));
+			
+		return conversation;
+		
+	}
+	
+	public Conversation getCurrentConversation()
+	{
+		
+		Bean<Conversation> bean =  ManagerImpl.getManager().resolveByType(Conversation.class, new CurrentLiteral()).iterator().next();
+		Conversation conversation = ManagerImpl.getManager().getInstance(bean);
+		
+		return conversation;
+	}
+	
+	public void destroyWithRespectToTimout()
+	{
+		ConversationImpl conv = null;
+		Set<Conversation> set = conversations.keySet();
+		Iterator<Conversation> it = set.iterator();
+		
+		while(it.hasNext())
+		{
+			conv = (ConversationImpl)it.next();
+			long timeout = conv.getTimeout();
+			
+			if(timeout != 0L)
+			{
+				if((System.currentTimeMillis() - conv.getActiveTime()) > timeout)
+				{
+					it.remove();
+				}				
+			}
+		}
+	}
+	
+	public void destroyAllConversations()
+	{
+		if(conversations != null)
+		{
+			conversations.clear();
+			conversations = null;			
+		}
+	}
+}

Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/jsf/ConversationManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/jsf/WebBeansJSFFilter.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/jsf/WebBeansJSFFilter.java?rev=719890&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/jsf/WebBeansJSFFilter.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/jsf/WebBeansJSFFilter.java Sat Nov 22 10:09:38 2008
@@ -0,0 +1,87 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You 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.apache.webbeans.jsf;
+
+import java.io.IOException;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpServletResponseWrapper;
+import javax.webbeans.Conversation;
+import javax.webbeans.manager.Bean;
+
+import org.apache.webbeans.annotation.CurrentLiteral;
+import org.apache.webbeans.container.ManagerImpl;
+import org.apache.webbeans.util.JSFUtil;
+
+public class WebBeansJSFFilter implements Filter
+{
+
+	public void destroy()
+	{
+		
+	}
+
+	public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
+	{
+		HttpServletResponse servletResponse = (HttpServletResponse) response;
+		HttpServletResponseWrapper responseWrapper = new HttpServletResponseWrapper(servletResponse){
+
+			/* (non-Javadoc)
+			 * @see javax.servlet.http.HttpServletResponseWrapper#sendRedirect(java.lang.String)
+			 */
+			@Override
+			public void sendRedirect(String location) throws IOException
+			{
+				Bean<Conversation> bean =  ManagerImpl.getManager().resolveByType(Conversation.class, new CurrentLiteral()).iterator().next();
+				Conversation conversation = ManagerImpl.getManager().getInstance(bean);
+								
+				String path = location;
+				
+				if(conversation != null)
+				{
+					
+					if(conversation.isLongRunning())
+					{
+						//Find JSFish view od of the redirection
+						path = JSFUtil.getRedirectViewId(location);
+						path = JSFUtil.getViewHandler().getActionURL(JSFUtil.getCurrentFacesContext(), path);
+						path = JSFUtil.getExternalContext().encodeActionURL(path+"?cid="+conversation.getId());
+					}					
+				}
+				
+				super.sendRedirect(path);
+				
+			}
+			
+			
+		};
+		
+		chain.doFilter(request, responseWrapper);
+	}
+
+	public void init(FilterConfig config) throws ServletException
+	{
+		
+	}
+
+}

Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/jsf/WebBeansJSFFilter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/jsf/WebBeansPhaseListener.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/jsf/WebBeansPhaseListener.java?rev=719890&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/jsf/WebBeansPhaseListener.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/jsf/WebBeansPhaseListener.java Sat Nov 22 10:09:38 2008
@@ -0,0 +1,180 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You 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.apache.webbeans.jsf;
+
+import javax.faces.component.UIViewRoot;
+import javax.faces.component.html.HtmlInputHidden;
+import javax.faces.event.PhaseEvent;
+import javax.faces.event.PhaseId;
+import javax.faces.event.PhaseListener;
+import javax.webbeans.ConversationScoped;
+
+import org.apache.webbeans.container.ManagerImpl;
+import org.apache.webbeans.context.ContextFactory;
+import org.apache.webbeans.context.ConversationContext;
+import org.apache.webbeans.logger.WebBeansLogger;
+import org.apache.webbeans.util.JSFUtil;
+
+public class WebBeansPhaseListener implements PhaseListener
+{
+	private static final long serialVersionUID = -8131516076829979596L;
+
+	private static WebBeansLogger logger = WebBeansLogger.getLogger(WebBeansPhaseListener.class);
+
+	private static ConversationManager conversationManager = ConversationManager.getInstance();
+
+	private static ManagerImpl manager = ManagerImpl.getManager();
+	
+	private ConversationImpl conversation = null;
+
+	public void afterPhase(PhaseEvent phaseEvent)
+	{
+		if (phaseEvent.getPhaseId().equals(PhaseId.RESTORE_VIEW))
+		{
+			if (!JSFUtil.isPostBack())
+			{
+				String cid = JSFUtil.getExternalContext().getRequestParameterMap().get("cid");
+
+				//non-faces get request
+				if (cid == null)
+				{
+					logger.info("Create new transitional conversation for non-faces request with view id : " + JSFUtil.getViewId());
+					conversation = (ConversationImpl) conversationManager.createNewConversation(JSFUtil.getViewId());
+					
+					ContextFactory.initConversationContext(null);
+					
+				} else
+				{
+					logger.info("Propogation of the conversation with id : " + cid + " for view : " + JSFUtil.getViewId());
+					conversation = (ConversationImpl) conversationManager.getConversation(cid);
+					
+					//can not restore conversation, create new transitional
+					if (conversation == null)
+					{
+						logger.info("Propogated conversation can not be restored for view id : "+ JSFUtil.getViewId()+". Creates new transitional conversation");
+						conversation = (ConversationImpl) conversationManager.createNewConversation(JSFUtil.getViewId());
+						
+						ContextFactory.initConversationContext(null);
+					}
+					else
+					{
+						ContextFactory.initConversationContext(conversationManager.getConversationContext(conversation));
+					}
+				}
+			}
+			else
+			{
+				logger.info("Postback JSF Request for view id : " + JSFUtil.getViewId());
+				
+				UIViewRoot viewRoot = JSFUtil.getViewRoot();
+				HtmlInputHidden conversationId = (HtmlInputHidden) viewRoot.findComponent("javax_webbeans_ConversationId");
+				
+				if(conversationId != null)
+				{
+					//look long running conversation if exist
+					conversation = (ConversationImpl) conversationManager.getConversation(conversationId.getValue().toString());
+					ContextFactory.initConversationContext(conversationManager.getConversationContext(conversation));
+					
+				}
+				
+				//no long running conversation, create one transitional
+				else
+				{
+					logger.info("Create new transient conversation for JSF postback view id : " + JSFUtil.getViewId());
+					conversation = (ConversationImpl) conversationManager.createNewConversation(JSFUtil.getViewId());
+					
+					ContextFactory.initConversationContext(null);
+				}
+			}
+		}
+
+		else if (phaseEvent.getPhaseId().equals(PhaseId.RENDER_RESPONSE))
+		{
+			ConversationContext context = (ConversationContext)ManagerImpl.getManager().getContext(ConversationScoped.class);
+			
+			//if long running, saves it
+			if (conversation.isLongRunning())
+			{
+				logger.info("Conversation with id : "+ conversation.getId() + " is marked as long running conversation");				
+				context.setActive(false);
+			}
+
+			//else destroy cınversation context
+			else
+			{
+				logger.info("Destroying the conversation context for view id : " + JSFUtil.getViewId());
+				context.destroy();
+			}
+
+		}
+
+	}
+
+	public void beforePhase(PhaseEvent phaseEvent)
+	{		
+		if (phaseEvent.getPhaseId().equals(PhaseId.APPLY_REQUEST_VALUES))
+		{
+			ConversationContext context = (ConversationContext) manager.getContext(ConversationScoped.class);
+
+			if (JSFUtil.isPostBack())
+			{
+				logger.info("Activating the conversation context for view id : " + JSFUtil.getViewId());
+				context.setActive(true);
+				
+				conversation.updateTimeOut();
+			}
+		}
+
+		else if (phaseEvent.getPhaseId().equals(PhaseId.RENDER_RESPONSE))
+		{
+			ConversationContext context = (ConversationContext) manager.getContext(ConversationScoped.class);
+
+			if (!JSFUtil.isPostBack())
+			{
+				logger.info("Activating the conversation context for view id : " + JSFUtil.getViewId());
+				context.setActive(true);
+				
+				conversation.updateTimeOut();
+			}
+
+			if(conversation.isLongRunning())
+			{
+				UIViewRoot viewRoot = JSFUtil.getViewRoot();
+				
+				HtmlInputHidden hidden = (HtmlInputHidden) viewRoot.findComponent("javax_webbeans_ConversationId");
+				
+				if(hidden != null)
+				{
+					viewRoot.getChildren().remove(hidden);	
+				}
+				
+				hidden = (HtmlInputHidden)JSFUtil.getApplication().createComponent(HtmlInputHidden.COMPONENT_TYPE);
+				hidden.setValue(conversation.getId());
+				hidden.setId("javax_webbeans_ConversationId");
+				
+				viewRoot.getChildren().add(hidden);	
+			}			
+		}
+
+	}
+
+	public PhaseId getPhaseId()
+	{
+		return PhaseId.ANY_PHASE;
+	}
+
+}

Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/jsf/WebBeansPhaseListener.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/WebBeansLifeCycle.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/WebBeansLifeCycle.java?rev=719890&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/WebBeansLifeCycle.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/WebBeansLifeCycle.java Sat Nov 22 10:09:38 2008
@@ -0,0 +1,146 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You 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.apache.webbeans.lifecycle;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletRequestEvent;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSessionEvent;
+import javax.servlet.jsp.JspApplicationContext;
+import javax.servlet.jsp.JspFactory;
+
+import org.apache.webbeans.WebBeansConstants;
+import org.apache.webbeans.config.WebBeansContainerDeployer;
+import org.apache.webbeans.config.WebBeansScanner;
+import org.apache.webbeans.context.ContextFactory;
+import org.apache.webbeans.el.WebBeansELResolver;
+import org.apache.webbeans.exception.WebBeansException;
+import org.apache.webbeans.jsf.ConversationManager;
+import org.apache.webbeans.logger.WebBeansLogger;
+import org.apache.webbeans.util.JNDIUtil;
+
+public final class WebBeansLifeCycle
+{
+	private static WebBeansLogger logger = WebBeansLogger.getLogger(WebBeansLifeCycle.class);
+	
+	private static ScheduledExecutorService service = null;
+
+	private WebBeansLifeCycle()
+	{
+		
+	}
+	
+
+	public static void requestStarted(ServletRequestEvent event)
+	{
+		logger.info("Initializing of the Request Context with Remote Address : " + event.getServletRequest().getRemoteAddr());
+		ContextFactory.initRequestContext((HttpServletRequest)event.getServletRequest());		
+	}
+	
+	public static void requestEnded(ServletRequestEvent event)
+	{
+		logger.info("Destroying of the Request Context with Remote Address : " + event.getServletRequest().getRemoteAddr());
+		ContextFactory.destroyRequestContext((HttpServletRequest)event.getServletRequest());		
+	}
+	
+	public static void sessionStarted(HttpSessionEvent event)
+	{
+		logger.info("Initializing of the Session Context with session id : " + event.getSession().getId());
+		ContextFactory.initSessionContext(event.getSession());		
+	}
+	
+	public static void sessionEnded(HttpSessionEvent event)
+	{
+		logger.info("Destroying of the Session Context with session id : " + event.getSession().getId());
+		ContextFactory.destroySessionContext(event.getSession());	
+		
+		ConversationManager conversationManager = ConversationManager.getInstance();
+		conversationManager.destroyConversationContextWithSessionId(event.getSession().getId());		
+	}
+	
+	public static void applicationStarted(ServletContextEvent event)
+	{
+		//I do not know this is the correct way, spec is not so explicit.
+		service = Executors.newScheduledThreadPool(1);
+		service.scheduleWithFixedDelay(new Runnable(){
+
+			public void run()
+			{
+				ConversationManager.getInstance().destroyWithRespectToTimout();
+				
+			}
+			
+		}, 15000, 15000, TimeUnit.MILLISECONDS);
+		
+		
+		logger.info("Starting the WebBeans Container Configuration");
+		long begin = System.currentTimeMillis();
+		
+		logger.info("Scanning classpaths for WebBeans artifacts is started");
+		WebBeansScanner scanner = WebBeansScanner.getScannerInstance();
+		scanner.scan(event.getServletContext());
+		logger.info("Scanning is ended.");
+		
+		logger.info("Deploying the scanned WebBeans artifacts."); 
+		WebBeansContainerDeployer.deploy();
+		logger.info("Deploying is ended.");
+		
+		long end = System.currentTimeMillis();
+		logger.info("WebBeans Container Configuration is ended, takes " + Long.toString(end - begin) + " ms.");
+		
+		//Initalize Application Context
+		logger.info("Initializing of the Application Context with Context Path : " + event.getServletContext().getContextPath());
+		ContextFactory.initApplicationContext(event.getServletContext());
+		
+		ServletContext context = event.getServletContext();
+		
+		try
+		{
+			//check this application is JSF application
+			URL url = context.getResource("/WEB-INF/faces-config.xml");
+			if(url == null)
+			{
+				JspApplicationContext applicationCtx = JspFactory.getDefaultFactory().getJspApplicationContext(context);
+				applicationCtx.addELResolver(new WebBeansELResolver());
+			}
+			
+		}catch(MalformedURLException e)
+		{
+			logger.error(e);
+			throw new WebBeansException(e);
+		}
+
+		
+	}
+	
+	public static void applicationEnded(ServletContextEvent event)
+	{
+		service.shutdownNow();
+		
+		logger.info("Destroying of the Application Context with Context Path : " + event.getServletContext().getContextPath());
+		ContextFactory.destroyApplicationContext(event.getServletContext());
+		JNDIUtil.unbind(WebBeansConstants.WEB_BEANS_MANAGER_JNDI_NAME);		
+	}
+	
+}

Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/WebBeansLifeCycle.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/logger/WebBeansLogger.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/logger/WebBeansLogger.java?rev=719890&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/logger/WebBeansLogger.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/logger/WebBeansLogger.java Sat Nov 22 10:09:38 2008
@@ -0,0 +1,162 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You 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.apache.webbeans.logger;
+
+import org.apache.log4j.Logger;
+
+/**
+ * Wrapper class around the log4j logger class to include some checks
+ * before the logs are actually written.
+ * 
+ * <p>
+ * Actually, it is a thin layer on the log4j {@link Logger} implementation.
+ * </p>
+ * 
+ * @author <a href="mailto:gurkanerdogdu@yahoo.com">Gurkan Erdogdu</a>
+ * @since 1.0
+ */
+public final class WebBeansLogger
+{
+	/**Inner logger object to log actual log messages*/
+	private Logger logger = null;
+
+	/**Private constructor*/
+	private WebBeansLogger()
+	{
+
+	}
+	
+
+	/**
+	 * Gets the new web beans logger instance.
+	 * @param clazz own the return logger
+	 * @return new logger
+	 */
+	public static WebBeansLogger getLogger(Class<?> clazz)
+	{
+		WebBeansLogger wbLogger = new WebBeansLogger();
+		Logger inLogger = Logger.getLogger(clazz);
+		
+		wbLogger.setLogger(inLogger);
+		
+		return wbLogger;
+	}
+
+	public void fatal(String message)
+	{
+		checkNullLogger();
+		logger.fatal(message);
+	}
+	
+	public void fatal(String message,Throwable e)
+	{
+		checkNullLogger();
+		logger.fatal(message,e);
+		
+	}
+	
+	public void error(Throwable e)
+	{
+		checkNullLogger();
+		logger.error(e);
+	}
+	
+
+	public void error(String message)
+	{
+		checkNullLogger();
+		logger.error(message);
+	}
+	
+	public void error(String message,Throwable e)
+	{
+		checkNullLogger();
+		logger.error(message,e);
+		
+	}
+	
+	public void warn(String message)
+	{
+		checkNullLogger();
+		logger.warn(message);
+	}
+	
+	public void warn(String message,Throwable e)
+	{
+		checkNullLogger();
+		logger.warn(message,e);
+	}
+	
+	public void info(String message)
+	{
+		checkNullLogger();
+		if(logger.isInfoEnabled())
+			logger.info(message);
+	}
+	
+	public void info(String message,Throwable e)
+	{
+		checkNullLogger();
+		if(logger.isInfoEnabled())
+			logger.info(message,e);
+	}
+	
+	public void debug(String message)
+	{
+		checkNullLogger();
+		if(logger.isDebugEnabled())
+			logger.debug(message);
+	}
+	
+	public void debug(String message,Throwable e)
+	{
+		checkNullLogger();
+		if(logger.isDebugEnabled())
+			logger.debug(message,e);
+	}
+	
+	public void trace(String message)
+	{
+		checkNullLogger();
+		if(logger.isTraceEnabled())
+			logger.trace(message);
+	}
+	
+	public void trace(String message,Throwable e)
+	{
+		checkNullLogger();
+		if(logger.isTraceEnabled())
+			logger.trace(message,e);
+	}
+	
+	/**
+	 * Sets the logger
+	 * @param logger new logger instance
+	 */
+	public void setLogger(Logger logger)
+	{
+		this.logger = logger;
+	}
+	
+	private void checkNullLogger()
+	{
+		if(this.logger == null)
+		{
+			throw new NullPointerException("Logger can not be null");
+		}
+	}
+}

Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/logger/WebBeansLogger.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 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=719890&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/JavassistProxyFactory.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/JavassistProxyFactory.java Sat Nov 22 10:09:38 2008
@@ -0,0 +1,67 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You 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.apache.webbeans.proxy;
+
+import java.io.Serializable;
+import java.lang.reflect.Method;
+
+import org.apache.webbeans.component.AbstractComponent;
+import org.apache.webbeans.exception.WebBeansException;
+import org.apache.webbeans.intercept.InterceptorHandler;
+import org.apache.webbeans.util.ClassUtil;
+
+import javassist.util.proxy.MethodFilter;
+import javassist.util.proxy.ProxyFactory;
+
+public final class JavassistProxyFactory
+{
+	private JavassistProxyFactory()
+	{
+		
+	}
+	
+	
+	public static Object createNewProxyInstance(Class<?> superClazz, Class<?>[] paramTypes, Object[] args, AbstractComponent<?> component)
+	{
+		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)
+				{
+					if(ClassUtil.isObjectMethod(arg0.getName()))
+						return false;
+					return true;
+				}
+				
+			});
+			
+			result = fact.create(paramTypes, args); 
+		}catch(Throwable e)
+		{
+			throw new WebBeansException(e);
+		}
+		
+		return result;
+	}
+
+}

Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/JavassistProxyFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/servlet/WebBeansConfigurationListener.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/servlet/WebBeansConfigurationListener.java?rev=719890&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/servlet/WebBeansConfigurationListener.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/servlet/WebBeansConfigurationListener.java Sat Nov 22 10:09:38 2008
@@ -0,0 +1,86 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You 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.apache.webbeans.servlet;
+
+
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+import javax.servlet.ServletRequestEvent;
+import javax.servlet.ServletRequestListener;
+import javax.servlet.http.HttpSessionEvent;
+import javax.servlet.http.HttpSessionListener;
+
+import org.apache.webbeans.lifecycle.WebBeansLifeCycle;
+
+/**
+ * Configures the all web beans components that are defined in the EAR or WAR
+ * file.
+ * @author <a href="mailto:gurkanerdogdu@yahoo.com">Gurkan Erdogdu</a>
+ * @since 1.0
+ */
+public class WebBeansConfigurationListener implements ServletContextListener,ServletRequestListener,HttpSessionListener
+{
+
+	/**
+	 * Performed when the servlet context destroyed.
+	 */
+	public void contextDestroyed(ServletContextEvent event)
+	{
+		WebBeansLifeCycle.applicationEnded(event);
+	}
+
+	/**
+	 * Performed when the servlet context started.
+	 */
+	public void contextInitialized(ServletContextEvent event)
+	{
+		WebBeansLifeCycle.applicationStarted(event);
+	}
+
+	/**
+	 * Destroy request context
+	 */
+	public void requestDestroyed(ServletRequestEvent event)
+	{
+		WebBeansLifeCycle.requestEnded(event);
+	}
+
+	/**
+	 * Initializes the request context
+	 */
+	public void requestInitialized(ServletRequestEvent event)
+	{
+		WebBeansLifeCycle.requestStarted(event);
+	}
+
+	/**
+	 * Initializes session context
+	 */
+	public void sessionCreated(HttpSessionEvent event)
+	{
+		WebBeansLifeCycle.sessionStarted(event);
+	}
+
+	/**
+	 * Destroy session context
+	 */
+	public void sessionDestroyed(HttpSessionEvent event)
+	{
+		WebBeansLifeCycle.sessionEnded(event);
+	}
+	
+}

Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/servlet/WebBeansConfigurationListener.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/AnnotationUtil.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/AnnotationUtil.java?rev=719890&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/AnnotationUtil.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/AnnotationUtil.java Sat Nov 22 10:09:38 2008
@@ -0,0 +1,665 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You 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.apache.webbeans.util;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+import javax.webbeans.BindingType;
+import javax.webbeans.DuplicateBindingTypeException;
+import javax.webbeans.NonBinding;
+
+
+
+/**
+ * Utility class related with {@link Annotation} operations.
+ * 
+ * @author <a href="mailto:gurkanerdogdu@yahoo.com">Gurkan Erdogdu</a>
+ * @since 1.0
+ */
+public final class AnnotationUtil
+{
+	//No instantiate
+	private AnnotationUtil()
+	{
+		throw new UnsupportedOperationException();
+	}
+	
+	/**
+	 * Check given annotation exist on the method.
+	 * 
+	 * @param method method
+	 * @param clazz annotation class
+	 * @return true or false
+	 */
+	public static boolean isMethodHasAnnotation(Method method, Class<? extends Annotation> clazz)
+	{
+		Asserts.assertNotNull(method, "Method argument can not be null");
+		Asserts.assertNotNull(clazz, "Clazz argument can not be null");
+		
+		Annotation[] anns = method.getDeclaredAnnotations();
+		for(Annotation annotation : anns)
+		{
+			if(annotation.annotationType().equals(clazz))
+			{
+				return true;
+			}
+		}
+		
+		return false;
+		
+	}
+	
+	
+	/**
+	 * Check given annotation exist in the any parameter of the given method.
+	 * Return true if exist false otherwise.
+	 * @param method method 
+	 * @param annotation checking annotation
+	 * @return true or false
+	 */
+	public static boolean isMethodParameterAnnotationExist(Method method, Class<? extends Annotation> clazz)
+	{
+		Asserts.assertNotNull(method, "Method argument can not be null");
+		Asserts.assertNotNull(clazz, "Clazz argument can not be null");
+		
+		Annotation[][] parameterAnns = method.getParameterAnnotations();		
+		
+		for(Annotation[] parameters : parameterAnns)
+		{
+			for(Annotation param : parameters)
+			{
+				Class<? extends Annotation> btype = param.annotationType();
+				if(btype.equals(clazz))
+				{
+					return true;
+				}
+			}
+			
+		}
+		return false;
+	}
+	
+	public static Type[] getMethodParameterGenericTypesWithGivenAnnotation(Method method, Class<? extends Annotation> clazz)
+	{
+		Asserts.assertNotNull(method, "Method argument can not be null");
+		Asserts.assertNotNull(clazz, "Clazz argument can not be null");
+		
+		List<Type> list = new ArrayList<Type>();
+		Type[] result = null;
+		
+		Annotation[][] parameterAnns = method.getParameterAnnotations();		
+		Type[] genericTypes = method.getGenericParameterTypes();
+		
+		int i = 0;
+		for(Annotation[] parameters : parameterAnns)
+		{
+			for(Annotation param : parameters)
+			{
+				Class<? extends Annotation> btype = param.annotationType();
+				if(btype.equals(clazz))
+				{
+					list.add(genericTypes[i]);
+					break;
+				}
+			}
+			
+			i++;
+			
+		}
+		
+		result = new Type[list.size()];
+		result = list.toArray(result);
+		
+		return result;
+	}
+	
+	public static Type[] getConstructorParameterGenericTypesWithGivenAnnotation(Constructor<?> constructor, Class<? extends Annotation> clazz)
+	{
+		Asserts.assertNotNull(constructor, "constructor argument can not be null");
+		Asserts.assertNotNull(clazz, "Clazz argument can not be null");
+		
+		List<Type> list = new ArrayList<Type>();
+		Type[] result = null;
+		
+		Annotation[][] parameterAnns = constructor.getParameterAnnotations();		
+		Type[] genericTypes = constructor.getGenericParameterTypes();
+		
+		int i = 0;
+		for(Annotation[] parameters : parameterAnns)
+		{
+			for(Annotation param : parameters)
+			{
+				Class<? extends Annotation> btype = param.annotationType();
+				if(btype.equals(clazz))
+				{
+					list.add(genericTypes[i]);
+					break;
+				}
+			}
+			
+			i++;
+			
+		}
+		
+		result = new Type[list.size()];
+		result = list.toArray(result);
+		
+		return result;
+	}
+	
+	
+	/**
+	 * Check given annotation exist in the multiple parameter of the given method.
+	 * Return true if exist false otherwise.
+	 * 
+	 * @param method method 
+	 * @param annotation checking annotation
+	 * @return true or false
+	 */
+	public static boolean isMethodMultipleParameterAnnotationExist(Method method, Class<? extends Annotation> clazz)
+	{
+		Asserts.assertNotNull(method, "Method argument can not be null");
+		Asserts.assertNotNull(clazz, "Clazz argument can not be null");
+		
+		Annotation[][] parameterAnns = method.getParameterAnnotations();		
+		
+		boolean found = false;
+		
+		for(Annotation[] parameters : parameterAnns)
+		{
+			for(Annotation param : parameters)
+			{
+				
+				if(param.annotationType().equals(clazz))
+				{
+					if(!found)
+					{
+						found = true;
+					}
+					else
+					{
+						return true;
+					}
+				}
+			}
+			
+		}
+		return false;
+	}
+	
+	/**
+	 * Gets the method first found parameter type that is annotated 
+	 * with the given annotation.
+	 *
+	 * @param method method 
+	 * @param annotation checking annotation
+	 * @return type
+	 */
+	public static Type getMethodFirstParameterWithAnnotation(Method method, Class<? extends Annotation> clazz)
+	{
+		Asserts.assertNotNull(method, "Method argument can not be null");
+		Asserts.assertNotNull(clazz, "Clazz argument can not be null");
+		
+		Annotation[][] parameterAnns = method.getParameterAnnotations();
+		Type[] params = method.getGenericParameterTypes();
+		
+		int index = 0;
+		for(Annotation[] parameters : parameterAnns)
+		{
+			for(Annotation param : parameters)
+			{
+				Class<? extends Annotation> btype = param.annotationType();
+				if(btype.equals(clazz))
+				{
+					return params[index];
+				}
+			}
+			
+			index++;
+			
+		}
+		return null;
+	}
+	
+	public static Class<?> getMethodFirstParameterTypeClazzWithAnnotation(Method method, Class<? extends Annotation> clazz)
+	{
+		Type type = getMethodFirstParameterWithAnnotation(method, clazz);
+		
+		if(type instanceof ParameterizedType)
+		{
+			return (Class<?>)((ParameterizedType)type).getRawType();
+		}
+		else
+		{
+			return (Class<?>)type;
+		}
+	}
+	
+	/**
+	 * Gets the method first found parameter binding types.
+	 *
+	 * @param method method 
+	 * @param annotation checking annotation
+	 * @return annotation array
+	 */
+	public static Annotation[] getMethodFirstParameterBindingTypesWithGivenAnnotation(Method method, Class<? extends Annotation> clazz)
+	{
+		Asserts.assertNotNull(method, "Method argument can not be null");
+		Asserts.assertNotNull(clazz, "Clazz argument can not be null");
+		
+		Annotation[][] parameterAnns = method.getParameterAnnotations();
+		List<Annotation> list = new ArrayList<Annotation>();
+		Annotation[] result = null;
+		
+		int index = 0;
+		for(Annotation[] parameters : parameterAnns)
+		{
+			boolean found = false;
+			for(Annotation param : parameters)
+			{
+				Class<? extends Annotation> btype = param.annotationType();
+				if(btype.equals(clazz))
+				{
+					found = true;
+					continue;
+				}
+				
+				if(btype.isAnnotationPresent(BindingType.class))
+				{
+					list.add(param);
+				}
+				
+			}
+			
+			if(found)
+			{
+				result = new Annotation[list.size()];
+				result = list.toArray(result);
+				return result;
+			}
+			
+			index++;
+			
+		}
+		result = new Annotation[0];
+		return result;
+	}
+	
+	
+	
+	
+	/**
+	 * Check given annotation cross ref exist in the any parameter of the given method.
+	 * Return true if exist false otherwise.
+	 * @param method method 
+	 * @param annotation checking annotation
+	 * @return true or false
+	 */
+	public static boolean isMethodParameterAnnotationCrossRefExist(Method method, Class<? extends Annotation> clazz)
+	{
+		Asserts.assertNotNull(method, "Method argument can not be null");
+		Asserts.assertNotNull(clazz, "Clazz argument can not be null");
+		
+		Annotation[][] parameterAnns = method.getParameterAnnotations();		
+		
+		for(Annotation[] parameters : parameterAnns)
+		{
+			for(Annotation param : parameters)
+			{
+				Annotation[] btype = param.annotationType().getAnnotations();
+				
+				for(Annotation b : btype)
+				{
+					if(b.annotationType().equals(clazz))
+					{
+						return true;
+					}
+				}
+			}
+			
+		}
+		return false;
+	}
+	
+	/**
+	 * Returns true if the injection point binding type and {@link NonBinding} member values are
+	 * equal to the given member annotation.
+	 * 
+	 * @param clazz annotation class
+	 * @param src component binding type annotation
+	 * @param member annotation for querying the binding type
+	 * @return true or false
+	 */
+	public static boolean isAnnotationMemberExist(Class<? extends Annotation> clazz,Annotation src, Annotation member)
+	{
+		Asserts.assertNotNull(clazz, "Clazz argument can not be null");
+		Asserts.assertNotNull(src, "Src argument can not be null");
+		Asserts.assertNotNull(member, "Member argument can not be null");
+		
+		if(!src.annotationType().equals(member.annotationType()))
+		{
+			return false;
+		}
+		
+		Method[] methods =  clazz.getDeclaredMethods();
+		
+		List<String> list = new ArrayList<String>();
+		
+		for(Method method : methods)
+		{
+			Annotation[] annots = method.getDeclaredAnnotations();
+			
+			if(annots.length > 0)
+			{
+				for(Annotation annot : annots)
+				{
+					if(!annot.annotationType().equals(NonBinding.class))
+					{
+						list.add(method.getName());
+					}
+				}
+				
+			}
+			else
+			{
+				list.add(method.getName());
+			}
+		}
+		
+		return checkEquality(src.toString(), member.toString(), list);
+	
+	}
+	
+	/**
+	 * Check that given two annotation values are equal or not.
+	 * 
+	 * @param src annotation toString method
+	 * @param member annotation toString method
+	 * @param arguments annotation member values with {@link NonBinding} annoations.
+	 * @return true or false
+	 */
+	private static boolean checkEquality(String src, String member,List<String> arguments)
+	{
+		if((checkEquBuffer(src, arguments).toString().equals(checkEquBuffer(member, arguments).toString())))
+				return true;
+		return false;
+	}
+	
+	/*
+	 * Private check method
+	 */
+	private static StringBuffer checkEquBuffer(String src, List<String> arguments)
+	{
+		int index = src.indexOf('(');
+		
+		String sbstr = src.substring(index+1,src.length()-1);
+		
+		StringBuffer srcBuf = new StringBuffer();
+
+		StringTokenizer tok = new StringTokenizer(sbstr,",");
+		while(tok.hasMoreTokens())
+		{
+			String token = tok.nextToken();
+			
+			StringTokenizer tok2 = new StringTokenizer(token,"=");
+			while(tok2.hasMoreElements())
+			{
+				String tt = tok2.nextToken();
+				if(arguments.contains(tt.trim()))
+				{
+					srcBuf.append(tt);
+					srcBuf.append("=");
+					
+					if(tok2.hasMoreElements())
+						srcBuf.append(tok2.nextToken());
+				}
+			}
+			
+		}
+	
+		return srcBuf;
+	}
+	
+	/**
+	 * Gets the array of binding annotations on the given array.
+	 * 
+	 * @param annotations annotation array
+	 * @return array containing binding type anns
+	 */
+	public static Annotation[] getBindingAnnotations(Annotation...annotations)
+	{
+		Asserts.assertNotNull(annotations, "Annotations argument can not be null");
+		
+		Set<Annotation> set = new HashSet<Annotation>();
+		
+		for(Annotation annot : annotations)
+		{
+			if(annot.annotationType().isAnnotationPresent(BindingType.class))
+			{
+				set.add(annot);
+			}
+		}
+		
+		Annotation[] a = new Annotation[set.size()];
+		a = set.toArray(a);
+		
+		return a;
+	}
+	
+	/**
+	 * Gets array of methods that has parameter with given annotation type.
+	 * 
+	 * @param clazz class for check
+	 * @param annotation for check
+	 * @return array of methods
+	 */
+	public static Method[] getMethodsWithParameterAnnotation(Class<?> clazz, Class<? extends Annotation> annotation)
+	{
+		Asserts.assertNotNull(clazz, "Clazz argument can not be null");
+		Asserts.assertNotNull(annotation, "Annotation argument can not be null");
+		
+		Method[] methods =  clazz.getDeclaredMethods();
+		List<Method> list = new ArrayList<Method>();
+		Method[] rMethod = null;
+		
+		for(Method m : methods)
+		{
+			if(isMethodParameterAnnotationExist(m, annotation))
+			{
+				list.add(m);
+			}
+		}
+		
+		rMethod = new Method[list.size()];
+		rMethod = list.toArray(rMethod);
+		
+		return rMethod;
+	}
+	
+	/**
+	 * Gets array of methods that has given annotation type.
+	 * 
+	 * @param clazz class for check
+	 * @param annotation for check
+	 * @return array of methods
+	 */
+	public static Method[] getMethodsWithAnnotation(Class<?> clazz, Class<? extends Annotation> annotation)
+	{
+		Asserts.assertNotNull(clazz, "Clazz argument can not be null");
+		Asserts.assertNotNull(annotation, "Annotation argument can not be null");
+		
+		Method[] methods =  clazz.getDeclaredMethods();
+		List<Method> list = new ArrayList<Method>();
+		Method[] rMethod = null;
+		
+		for(Method m : methods)
+		{
+			if(isMethodHasAnnotation(m, annotation))
+			{
+				list.add(m);
+			}
+		}
+		
+		rMethod = new Method[list.size()];
+		rMethod = list.toArray(rMethod);
+		
+		return rMethod;
+	}
+	
+	
+	/**
+	 * Check whether or not class contains the given annotation.
+	 * 
+	 * @param clazz class instance
+	 * @param annotation annotation class
+	 * @return return true or false
+	 */
+	public static boolean isAnnotationExistOnClass(Class<?> clazz, Class<? extends Annotation> annotation)
+	{
+		Asserts.assertNotNull(clazz, "Clazz argument can not be null");
+		Asserts.assertNotNull(annotation, "Annotation argument can not be null");
+		
+		Annotation a = clazz.getAnnotation(annotation);
+		
+		if(a != null)
+		{
+			return true;
+		}
+		
+		return false;
+	}
+	
+
+	public static boolean isMetaAnnotationExist(Annotation[] anns, Class<? extends Annotation> metaAnnotation)
+	{
+		Asserts.assertNotNull(anns, "Anns argument can not be null");
+		Asserts.assertNotNull(metaAnnotation, "MetaAnnotation argument can not be null");
+		
+		for(Annotation annot : anns)
+		{
+			if(annot.annotationType().isAnnotationPresent(metaAnnotation))
+			{
+				return true;
+			}
+		}
+		
+		return false;
+		
+	}
+	
+	public static boolean isAnnotationExist(Annotation[] anns, Class<? extends Annotation> annotation)
+	{
+		Asserts.assertNotNull(anns, "anns argument can not be null");
+		Asserts.assertNotNull(annotation, "annotation argument can not be null");
+		
+		for(Annotation annot : anns)
+		{
+			if(annot.annotationType().equals(annotation))
+			{
+				return true;
+			}
+		}
+		
+		return false;
+		
+	}
+	
+	
+
+	public static Annotation[] getMetaAnnotations(Annotation[] anns, Class<? extends Annotation> metaAnnotation)
+	{
+		List<Annotation> annots = new ArrayList<Annotation>();
+		Annotation[] result = null;
+		Asserts.assertNotNull(anns, "Anns argument can not be null");
+		Asserts.assertNotNull(metaAnnotation, "MetaAnnotation argument can not be null");
+
+		for(Annotation annot : anns)
+		{
+			if(annot.annotationType().isAnnotationPresent(metaAnnotation))
+			{
+				annots.add(annot);
+			}
+		}
+		
+		result = new Annotation[annots.size()];
+		result = annots.toArray(result);
+		
+		return result;
+	}
+	
+	public static Field[] getClazzFieldsWithGivenAnnotation(Class<?> clazz, Class<? extends Annotation> annotation)
+	{
+		Field[] fields = clazz.getDeclaredFields();
+		List<Field> list = new ArrayList<Field>();
+		
+		if(fields.length != 0)
+		{
+			for(Field field : fields)
+			{
+				if(field.isAnnotationPresent(annotation))
+				{
+					list.add(field);
+				}
+			}
+		}
+		
+		fields = new Field[list.size()];
+		fields = list.toArray(fields);
+		
+		return fields;
+	}
+	
+	public static void checkBindingTypeConditions(Annotation...bindignTypeAnnots)
+	{
+		Annotation before = null;
+		
+		for(Annotation ann : bindignTypeAnnots)
+		{
+			if(!ann.annotationType().isAnnotationPresent(BindingType.class))
+			{
+				throw new IllegalArgumentException("Binding annotations must be annotated with @BindingType");
+			}
+			
+			if(before == null)
+			{
+				before = ann;
+			}
+			else
+			{
+				if(before.equals(ann))
+				{
+					throw new DuplicateBindingTypeException("Binding annotations can not contain duplicate binding : @" + before.annotationType().getName());
+				}
+				else
+				{
+					before = ann;
+				}
+			}
+		}
+	}
+	
+}

Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/AnnotationUtil.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/Asserts.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/Asserts.java?rev=719890&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/Asserts.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/Asserts.java Sat Nov 22 10:09:38 2008
@@ -0,0 +1,118 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You 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.apache.webbeans.util;
+
+import java.lang.reflect.Method;
+
+import org.dom4j.Element;
+
+/**
+ * Simple utility classes with some assertions methods.
+ * 
+ * @author <a href="mailto:gurkanerdogdu@yahoo.com">Gurkan Erdogdu</a>
+ * @since 1.0
+ */
+public final class Asserts
+{
+
+	/*
+	 * Private constructor
+	 */
+	private Asserts()
+	{
+		throw new UnsupportedOperationException();
+	}
+	
+	/**
+	 * Check the object is null or not
+	 * 
+	 * @param obj null check object
+	 * @param message exception message
+	 */
+	public static void assertNotNull(Object obj, String message)
+	{
+		if(obj == null)
+		{
+			throw new NullPointerException(message);
+		}
+	}
+	
+	/**
+	 * Check the object is null or not
+	 * 
+	 * @param obj null check object
+	 */
+	public static void assertNotNull(Object obj)
+	{
+		if(obj == null)
+		{
+			throw new NullPointerException();
+		}
+	}
+	
+	/**
+	 * Null check for type modifiers.
+	 * 
+	 * @param modifier modifier parameter check
+	 */
+	public static void nullCheckForModifier(Integer modifier)
+	{
+		Asserts.assertNotNull(modifier, "modifier argument can not be null");
+	}
+	
+	/**
+	 * Null check for class parameter.
+	 * 
+	 * @param clazz parameter
+	 */
+	public static void nullCheckForClass(Class<?> clazz)
+	{
+		Asserts.assertNotNull(clazz, "clazz argument can not be null");
+	}
+	
+	/**
+	 * Null check for class parameter.
+	 * 
+	 * @param clazz parameter
+	 */
+	public static void nullCheckForClass(Class<?> clazz,String message)
+	{
+		Asserts.assertNotNull(clazz, message);
+	}
+	
+	
+	/**
+	 * Null check for method parameter.
+	 * 
+	 * @param method parameter
+	 */
+	public static void nullCheckForMethod(Method method)
+	{
+		Asserts.assertNotNull(method, "method argument can not be null");
+	}
+	
+	/**
+	 * Null check for element parameter.
+	 * 
+	 * @param element parameter
+	 */
+	public static void nullCheckForDomElement(Element element)
+	{
+		Asserts.assertNotNull(element, "element argument can not be null");
+	}
+	
+}

Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/Asserts.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message