openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gerdo...@apache.org
Subject svn commit: r719890 [4/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/decorator/DecoratorUtil.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/DecoratorUtil.java?rev=719890&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/DecoratorUtil.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/DecoratorUtil.java Sat Nov 22 10:09:38 2008
@@ -0,0 +1,142 @@
+/*
+ *  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.decorator;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import javax.webbeans.Decorates;
+import javax.webbeans.manager.Decorator;
+
+import org.apache.webbeans.component.ComponentImpl;
+import org.apache.webbeans.container.ManagerImpl;
+import org.apache.webbeans.exception.WebBeansConfigurationException;
+import org.apache.webbeans.exception.WebBeansException;
+import org.apache.webbeans.logger.WebBeansLogger;
+import org.apache.webbeans.util.AnnotationUtil;
+import org.apache.webbeans.util.Asserts;
+import org.apache.webbeans.util.ClassUtil;
+
+public  final class DecoratorUtil
+{
+	private static WebBeansLogger logger = WebBeansLogger.getLogger(DecoratorUtil.class);
+	
+	private DecoratorUtil()
+	{
+		
+	}
+	
+	public static void checkDecoratorConditions(Class<?> decoratorClazz)
+	{
+		Field[] fields = decoratorClazz.getDeclaredFields();
+		Set<Class<?>> decoratorSet = new HashSet<Class<?>>();
+		ClassUtil.setInterfaceTypeHierarchy(decoratorSet, decoratorClazz);
+		boolean found = false;
+		for(Field field : fields)
+		{
+			if(AnnotationUtil.isAnnotationExist(field.getAnnotations(), Decorates.class))
+			{
+				if(found)
+				{
+					throw new WebBeansConfigurationException("Decorator class : " + decoratorClazz.getName() + " can only contain one delegate attribute but find more than one!.");
+				}
+				else
+				{
+					Class<?> fieldType = field.getType();
+					if(!ClassUtil.isInterface(fieldType.getModifiers()))
+					{
+						throw new WebBeansConfigurationException("Decorator class : " + decoratorClazz.getName() + " delegate attribute type must be interface"); 
+					}
+					
+					for(Class<?> decType : decoratorSet)
+					{
+						if(!fieldType.isAssignableFrom(decType))
+						{
+							throw new WebBeansConfigurationException("Decorator class : " + decoratorClazz.getName() + " delegate attribute must implement all of the decorator decorated types.");
+						}
+					}					
+					
+					found = true;
+				}				
+			}
+			
+		}
+	}
+	
+	
+	public static void checkSimpleWebBeanDecoratorConditions(ComponentImpl<?> component)
+	{
+		Asserts.assertNotNull("component", "component parameter can not be null");
+		
+		Set<Annotation> annSet = component.getBindingTypes();
+		Annotation[] anns = new Annotation[annSet.size()];
+		anns = annSet.toArray(anns);
+		
+		List<Decorator> decoratorList = ManagerImpl.getManager().resolveDecorators(component.getTypes(), anns);
+		if(!decoratorList.isEmpty())
+		{
+			Class<?> clazz = component.getReturnType();
+			if(ClassUtil.isFinal(clazz.getModifiers()))
+			{
+				throw new WebBeansConfigurationException("Simple web bean component : " + component.getReturnType().getName() + 
+						" can not be declared final, because it has one o more decorators");
+			}
+			
+			Method[] methods = clazz.getDeclaredMethods();
+			for(Method method : methods)
+			{
+				int modifiers = method.getModifiers();
+				if(!ClassUtil.isStatic(modifiers) && !ClassUtil.isPrivate(modifiers) && ClassUtil.isFinal(modifiers))
+				{
+					//Check decorator implements this
+					Iterator<Decorator> itDecorator = decoratorList.iterator();
+					while(itDecorator.hasNext())
+					{
+						WebBeansDecorator decorator = (WebBeansDecorator)itDecorator.next();
+						Class<?> decClazz = decorator.getClazz();
+						
+						try
+						{
+							if(decClazz.getMethod(method.getName(),method.getParameterTypes()) != null)
+							{
+								throw new WebBeansConfigurationException("Simple web bean component : " + component.getReturnType().getName() + 
+								" can not define non-private, non-static, final method : "+ method.getName() + ", because one of its decorators implements this method");
+								
+							}
+							
+						} catch (SecurityException e)
+						{
+							logger.error("Security exception, can not access decorator class : " + decClazz.getName() + " method : " + method.getName(), e);
+							throw new WebBeansException(e);
+							
+						} catch (NoSuchMethodException e)
+						{
+							continue;
+						}
+						
+					}
+				}
+			}
+		}
+	}
+	
+}

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

Added: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/DecoratorsManager.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/DecoratorsManager.java?rev=719890&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/DecoratorsManager.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/DecoratorsManager.java Sat Nov 22 10:09:38 2008
@@ -0,0 +1,78 @@
+/*
+ *  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.decorator;
+
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import org.apache.webbeans.util.Asserts;
+
+public class DecoratorsManager
+{
+	private static DecoratorsManager instance = new DecoratorsManager();
+
+	private List<Class<?>> enabledDecorators = new CopyOnWriteArrayList<Class<?>>();
+
+	private DecoratorsManager()
+	{
+
+	}
+
+	public static DecoratorsManager getInstance()
+	{
+		return instance;
+	}
+
+	public void addNewDecorator(Class<?> decoratorClazz)
+	{
+		Asserts.assertNotNull(decoratorClazz, "decoratorClazz parameter can not be emtpy");
+		if (!enabledDecorators.contains(decoratorClazz))
+		{
+			enabledDecorators.add(decoratorClazz);
+		}
+	}
+
+	public int compare(Class<?> src, Class<?> target)
+	{
+		Asserts.assertNotNull(src, "src parameter can not be  null");
+		Asserts.assertNotNull(target, "target parameter can not be null");
+
+		int srcIndex = enabledDecorators.indexOf(src);
+		int targetIndex = enabledDecorators.indexOf(target);
+
+		if (srcIndex == -1 || targetIndex == -1)
+		{
+			throw new IllegalArgumentException("One of the compare class of the list : [" + src.getName() + "," + target.getName() + "]" + " is not contained in the enabled decorators list!");
+		}
+
+		if (srcIndex == targetIndex)
+			return 0;
+		else if (srcIndex < targetIndex)
+			return -1;
+		else
+			return 1;
+	}
+	
+	public boolean isDecoratorEnabled(Class<?> decoratorClazz)
+	{
+		Asserts.nullCheckForClass(decoratorClazz, "decoratorClazz can not be null");
+
+		return enabledDecorators.contains(decoratorClazz);
+	}
+	
+
+}
\ No newline at end of file

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

Added: 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=719890&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecorator.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecorator.java Sat Nov 22 10:09:38 2008
@@ -0,0 +1,278 @@
+/*
+ *  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.decorator;
+
+import java.io.Serializable;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.webbeans.BindingType;
+import javax.webbeans.Decorates;
+import javax.webbeans.manager.Decorator;
+
+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;
+import org.apache.webbeans.util.ClassUtil;
+
+public class WebBeansDecorator extends Decorator
+{
+	private static WebBeansLogger logger = WebBeansLogger.getLogger(WebBeansDecorator.class);
+	
+	/**Decorator class*/
+	private Class<?> clazz; 
+	
+	private Set<Class<?>> decoratedTypes = new HashSet<Class<?>>();
+	
+	private Class<?> delegateType;
+	
+	private Set<Annotation> delegateBindingTypes = new HashSet<Annotation>();
+	
+	/**Simple Web Beans component*/
+	private AbstractComponent<Object> delegateComponent;
+	
+	
+	public WebBeansDecorator(AbstractComponent<Object> delegateComponent)
+	{
+		super(ManagerImpl.getManager());
+		this.delegateComponent = delegateComponent;
+		this.clazz = delegateComponent.getReturnType();
+		
+		init();
+	}
+	
+	
+	private void init()
+	{
+		ClassUtil.setInterfaceTypeHierarchy(this.decoratedTypes, this.clazz);
+		
+		if(this.decoratedTypes.contains(Serializable.class))
+		{
+			this.decoratedTypes.remove(Serializable.class);
+		}
+		
+		initDelegate();
+	}
+	
+	
+	private void initDelegate()
+	{
+		Field field = ClassUtil.getFieldWithAnnotation(this.clazz, Decorates.class);
+		this.delegateType = field.getType();
+		
+		Annotation[] anns = field.getAnnotations();
+		
+		for(Annotation ann : anns)
+		{
+			if(ann.annotationType().isAnnotationPresent(BindingType.class))
+			{
+				this.delegateBindingTypes.add(ann);
+			}
+		}
+
+	}
+	
+	public boolean isDecoratorMatch(Set<Class<?>> apiType, Set<Annotation> annotation)
+	{
+		boolean foundApi = false;
+		for(Class<?> clazz : apiType)
+		{
+			if(this.delegateType.equals(clazz))
+			{
+				foundApi = true;
+				break;
+			}
+		}
+		
+		boolean allBindingsOk = false;
+		if(foundApi)
+		{
+			for(Annotation annot : annotation)
+			{
+				boolean bindingOk = false;
+				for(Annotation bindingType : delegateBindingTypes)
+				{
+					if(AnnotationUtil.isAnnotationMemberExist(bindingType.annotationType(), annot, bindingType))
+					{
+						bindingOk = true;
+						break;
+					}
+				}
+				
+				if(bindingOk)
+				{
+					allBindingsOk = true;
+				}
+				else
+				{
+					allBindingsOk = false;
+					break;
+				}
+			}
+		}
+		
+		if(!allBindingsOk)
+		{
+			return false;
+		}
+		
+		return true;
+	}
+	
+	@Override
+	public Set<Annotation> getDelegateBindingTypes()
+	{
+		return delegateBindingTypes;
+	}
+
+	@Override
+	public Class<?> getDelegateType()
+	{
+		return delegateType;
+	}
+
+	@Override
+	public void setDelegate(Object instance, Object delegate)
+	{
+		Field field = ClassUtil.getFieldWithAnnotation(getClazz(), Decorates.class);	
+		if(!field.isAccessible())
+		{
+			field.setAccessible(true);
+		}
+		
+		try
+		{
+			field.set(instance, delegate);
+			
+		} catch (IllegalArgumentException e)
+		{
+			logger.error("Delegate field is not found on the given decorator class : " + instance.getClass().getName(), e);
+			throw new WebBeansException(e);
+			
+		}catch(IllegalAccessException e)
+		{
+			logger.error("Illegal access exception for field "+ field.getName() + " in decorator class : " + instance.getClass().getName(),e);
+		}
+		
+
+	}
+	@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();
+	}
+
+	
+
+	/**
+	 * @return the clazz
+	 */
+	public Class<?> getClazz()
+	{
+		return clazz;
+	}
+
+
+	/* (non-Javadoc)
+	 * @see java.lang.Object#hashCode()
+	 */
+	@Override
+	public int hashCode()
+	{
+		final int prime = 31;
+		int result = 1;
+		result = prime * result + ((clazz == null) ? 0 : clazz.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 WebBeansDecorator other = (WebBeansDecorator) obj;
+		if (clazz == null)
+		{
+			if (other.clazz != null)
+				return false;
+		} else if (!clazz.equals(other.clazz))
+			return false;
+		return true;
+	}
+
+	
+}

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

Added: 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=719890&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecoratorConfig.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecoratorConfig.java Sat Nov 22 10:09:38 2008
@@ -0,0 +1,117 @@
+/*
+ *  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.decorator;
+
+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;
+import java.util.Set;
+
+import javax.webbeans.manager.Decorator;
+
+import org.apache.webbeans.annotation.CurrentLiteral;
+import org.apache.webbeans.component.AbstractComponent;
+import org.apache.webbeans.container.ManagerImpl;
+import org.apache.webbeans.logger.WebBeansLogger;
+
+public final class WebBeansDecoratorConfig
+{
+	private static WebBeansLogger logger = WebBeansLogger.getLogger(WebBeansDecoratorConfig.class);
+
+
+	private WebBeansDecoratorConfig()
+	{
+		
+	}
+	
+	public static void configureDecoratorClass(AbstractComponent<Object> delegate)
+	{
+		logger.info("Configuring the Web Beans Interceptor Class : " + delegate.getReturnType().getName() + " started");
+
+		WebBeansDecorator decorator = new WebBeansDecorator(delegate);
+
+		logger.info("Configuring the Web Beans Interceptor Class : " + delegate.getReturnType() + " ended");
+
+		ManagerImpl.getManager().addDecorator(decorator);
+	}
+	
+	public static void configureDecarotors(AbstractComponent<?> component, Object instance)
+	{
+		Set<Annotation> bindingTypes = component.getBindingTypes();
+		Annotation[] anns = new Annotation[bindingTypes.size()];
+		anns = bindingTypes.toArray(anns);
+		
+		List<Decorator> decoratorList = ManagerImpl.getManager().resolveDecorators(component.getTypes(), anns);
+		Iterator<Decorator> itList = decoratorList.iterator();
+		
+		while(itList.hasNext())
+		{
+			Decorator decorator = itList.next();
+			Object decoratorInstance = ManagerImpl.getManager().getInstance(decorator);
+
+			decorator.setDelegate(decoratorInstance, instance);
+		
+			component.getDecoratorStack().add(decoratorInstance);			
+		}
+		
+		
+	}
+	
+	private static Set<Decorator> getWebBeansDecorators()
+	{
+		return Collections.unmodifiableSet(ManagerImpl.getManager().getDecorators());
+	}
+
+	
+	public static Set<Decorator> findDeployedWebBeansDecorator(Set<Class<?>> apiType, Annotation...anns)
+	{
+		Set<Decorator> set = new HashSet<Decorator>();
+
+		Iterator<Decorator> it = getWebBeansDecorators().iterator();
+		WebBeansDecorator decorator = null;
+
+		List<Class<? extends Annotation>> bindingTypes = new ArrayList<Class<? extends Annotation>>();
+		Set<Annotation> listAnnot = new HashSet<Annotation>();
+		for (Annotation ann : anns)
+		{
+			bindingTypes.add(ann.annotationType());
+			listAnnot.add(ann);
+		}
+		
+		if(listAnnot.isEmpty())
+		{
+			listAnnot.add(new CurrentLiteral());
+		}
+
+		while (it.hasNext())
+		{
+			decorator = (WebBeansDecorator) it.next();
+			
+			if(decorator.isDecoratorMatch(apiType, listAnnot))
+			{
+				set.add(decorator);
+			}
+		}
+
+		return set;
+		
+	}
+	
+}

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

Added: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/deployment/DeploymentTypeManager.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/deployment/DeploymentTypeManager.java?rev=719890&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/deployment/DeploymentTypeManager.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/deployment/DeploymentTypeManager.java Sat Nov 22 10:09:38 2008
@@ -0,0 +1,101 @@
+/*
+ *  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.deployment;
+
+import java.lang.annotation.Annotation;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javax.webbeans.Standard;
+
+import org.apache.webbeans.util.Asserts;
+
+public class DeploymentTypeManager
+{
+	private static DeploymentTypeManager instance = null;
+	
+	private Map<Class<? extends Annotation>, Integer> deploymentTypeMap = new ConcurrentHashMap<Class<? extends Annotation>, Integer>();
+
+	private DeploymentTypeManager()
+	{
+		
+	}
+	
+	public static DeploymentTypeManager getInstance()
+	{
+		if(instance == null)
+		{
+			instance = new DeploymentTypeManager();
+			instance.deploymentTypeMap.put(Standard.class, Integer.valueOf(0));
+		}
+		
+		return instance;
+	}
+	
+	
+	public void addNewDeploymentType(Class<? extends Annotation> deploymentType,Integer precedence)
+	{
+		Asserts.assertNotNull(deploymentType, "deploymentType parameter can not be null");
+		Asserts.assertNotNull(precedence,"predence parameter can not be null");
+		
+		if(!deploymentType.equals(Standard.class))
+		{
+			if(!instance.deploymentTypeMap.containsKey(deploymentType))
+			{
+				instance.deploymentTypeMap.put(deploymentType, precedence);
+			}
+		}
+	}
+	
+	public int getPrecedence(Class<? extends Annotation> deploymentType)
+	{
+		Asserts.assertNotNull(deploymentType, "deploymentType parameter can not be null");
+		
+		if(!instance.deploymentTypeMap.containsKey(deploymentType))
+		{
+			throw new IllegalArgumentException("Deployment type with annotation class : " + deploymentType.getName() + " is not applicable");
+		}
+		else
+		{
+			return instance.deploymentTypeMap.get(deploymentType);
+		}
+	}
+	
+	public int comparePrecedences(Class<? extends Annotation> typeFirst, Class<? extends Annotation> typeSecond)
+	{
+		Asserts.assertNotNull(typeFirst, "typeFirst parameter can not be null");
+		Asserts.assertNotNull(typeSecond, "typeSecond parameter can not be null");
+		
+		int precOne = getPrecedence(typeFirst);
+		int precSecond = getPrecedence(typeSecond);
+		
+		if(precOne == precSecond) 
+			return 0;
+		else if(precOne < precSecond) 
+			return -1;
+		else
+			return 1;
+		
+	}
+	
+	
+	public boolean isDeploymentTypeEnabled(Class<? extends Annotation> deploymentType)
+	{
+		Asserts.assertNotNull(deploymentType, "deploymentType parameter can not be null");
+		return instance.deploymentTypeMap.containsKey(deploymentType);
+	}
+}
\ No newline at end of file

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

Added: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/deployment/StereoTypeManager.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/deployment/StereoTypeManager.java?rev=719890&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/deployment/StereoTypeManager.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/deployment/StereoTypeManager.java Sat Nov 22 10:09:38 2008
@@ -0,0 +1,58 @@
+/*
+ *  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.deployment;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.webbeans.util.Asserts;
+
+public class StereoTypeManager
+{
+	private static StereoTypeManager instance = new StereoTypeManager();
+
+	private Map<String, StereoTypeModel> stereoTypeMap = new ConcurrentHashMap<String, StereoTypeModel>();
+	
+	private StereoTypeManager()
+	{
+		
+	}
+	
+	public static StereoTypeManager getInstance()
+	{
+		return instance;
+	}
+	
+	public void addStereoTypeModel(StereoTypeModel model)
+	{
+		Asserts.assertNotNull(model, "model parameter can not be null");
+		
+		getInstance().stereoTypeMap.put(model.getName(), model);
+	}
+	
+	public StereoTypeModel getStereoTypeModel(String modelName)
+	{
+		Asserts.assertNotNull(modelName, "modelName parameter can not be null");
+		
+		if(getInstance().stereoTypeMap.containsKey(modelName))
+		{
+			return getInstance().stereoTypeMap.get(modelName);
+		}
+		
+		return null;
+	}
+}

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

Added: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/deployment/StereoTypeModel.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/deployment/StereoTypeModel.java?rev=719890&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/deployment/StereoTypeModel.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/deployment/StereoTypeModel.java Sat Nov 22 10:09:38 2008
@@ -0,0 +1,157 @@
+/*
+ *  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.deployment;
+
+import java.lang.annotation.Annotation;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.webbeans.DeploymentType;
+import javax.webbeans.ScopeType;
+import javax.webbeans.Stereotype;
+
+import org.apache.webbeans.util.AnnotationUtil;
+import org.apache.webbeans.util.Asserts;
+
+public class StereoTypeModel
+{
+	private String name;
+	
+	private Annotation defaultDeploymentType;
+	
+	private Annotation defaultScopeType;
+	
+	private Set<Class<? extends Annotation>> supportedScopes = null;
+	
+	private Set<Class<?>>  restrictedTypes = null;
+	
+	
+	public StereoTypeModel(Class<?> clazz)
+	{
+		this.name = clazz.getName();
+		
+		if(AnnotationUtil.isMetaAnnotationExist(clazz.getAnnotations(), DeploymentType.class))
+		{
+			this.defaultDeploymentType = AnnotationUtil.getMetaAnnotations(clazz.getAnnotations(), DeploymentType.class)[0];
+		}
+		
+		if(AnnotationUtil.isMetaAnnotationExist(clazz.getAnnotations(), ScopeType.class))
+		{
+			this.defaultScopeType = AnnotationUtil.getMetaAnnotations(clazz.getAnnotations(), ScopeType.class)[0];
+		}
+		
+		configureScopes(clazz);
+		configureTypes(clazz);
+	}
+	
+	private void configureScopes(Class<?> clazz)
+	{
+		Asserts.nullCheckForClass(clazz);
+		Stereotype type = clazz.getAnnotation(Stereotype.class);
+		
+		Class<? extends Annotation>[] supportedScopes = type.supportedScopes();
+		this.supportedScopes = new HashSet<Class<? extends Annotation>>(Arrays.asList(supportedScopes));
+		
+		
+	}
+	
+	private void configureTypes(Class<?> clazz)
+	{
+		Asserts.nullCheckForClass(clazz);
+		Stereotype type = clazz.getAnnotation(Stereotype.class);
+		this.restrictedTypes = new HashSet<Class<?>>(Arrays.asList(type.requiredTypes()));
+	}
+
+	/**
+	 * @return the name
+	 */
+	public String getName()
+	{
+		return name;
+	}
+
+	/**
+	 * @param name the name to set
+	 */
+	public void setName(String name)
+	{
+		this.name = name;
+	}
+
+	/**
+	 * @return the defaultDeploymentType
+	 */
+	public Annotation getDefaultDeploymentType()
+	{
+		return defaultDeploymentType;
+	}
+
+	/**
+	 * @return the defaultScopeType
+	 */
+	public Annotation getDefaultScopeType()
+	{
+		return defaultScopeType;
+	}
+
+
+	/**
+	 * @return the supportedScopes
+	 */
+	public Set<Class<? extends Annotation>> getSupportedScopes()
+	{
+		return Collections.unmodifiableSet(this.supportedScopes);
+	}
+
+	/**
+	 * @return the restrictedTypes
+	 */
+	public Set<Class<?>> getRestrictedTypes()
+	{
+		return Collections.unmodifiableSet(this.restrictedTypes);
+	}
+
+	/* (non-Javadoc)
+	 * @see java.lang.Object#equals(java.lang.Object)
+	 */
+	@Override
+	public boolean equals(Object obj)
+	{
+		if(obj == this)
+		{
+			return true;
+		}
+		
+		if(!(obj instanceof StereoTypeModel))
+			return false;
+		
+		StereoTypeModel model = (StereoTypeModel)obj;
+		
+		return model.name.equals(this.name);
+	}
+
+	/* (non-Javadoc)
+	 * @see java.lang.Object#hashCode()
+	 */
+	@Override
+	public int hashCode()
+	{
+		return this.name.hashCode();
+	}
+}
\ No newline at end of file

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

Added: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/ejb/EJBConfig.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/ejb/EJBConfig.java?rev=719890&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/ejb/EJBConfig.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/ejb/EJBConfig.java Sat Nov 22 10:09:38 2008
@@ -0,0 +1,29 @@
+/*
+ *  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.ejb;
+
+/**
+ * Operations related with the configuration of the EJB based
+ * web beans components.
+ * 
+ * @author <a href="mailto:gurkanerdogdu@yahoo.com">Gurkan Erdogdu</a>
+ * @since 1.0
+ */
+public class EJBConfig
+{
+
+}

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

Added: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/ejb/EJBLookUp.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/ejb/EJBLookUp.java?rev=719890&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/ejb/EJBLookUp.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/ejb/EJBLookUp.java Sat Nov 22 10:09:38 2008
@@ -0,0 +1,38 @@
+/*
+ *  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.ejb;
+
+import javax.webbeans.manager.EnterpriseBeanLookup;
+
+/**
+ * This class is used for looking the EJBs in the container.
+ * 
+ * @author <a href="mailto:gurkanerdogdu@yahoo.com">Gurkan Erdogdu</a>
+ * @since 1.0
+ */
+public class EJBLookUp implements EnterpriseBeanLookup
+{
+
+	/**
+	 * 
+	 */
+	public Object lookup(String ejbName)
+	{
+		return null;
+	}
+
+}

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

Added: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/ejb/EJBUtil.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/ejb/EJBUtil.java?rev=719890&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/ejb/EJBUtil.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/ejb/EJBUtil.java Sat Nov 22 10:09:38 2008
@@ -0,0 +1,101 @@
+/*
+ *  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.ejb;
+
+import javax.ejb.MessageDriven;
+import javax.ejb.Stateful;
+import javax.ejb.Stateless;
+
+import org.apache.webbeans.util.AnnotationUtil;
+import org.apache.webbeans.util.Asserts;
+
+/**
+ * Utility classes related with the EJB based web beans components.
+ * 
+ * @author <a href="mailto:gurkanerdogdu@yahoo.com">Gurkan Erdogdu</a>
+ * @since 1.0
+ */
+public final class EJBUtil
+{
+	/*
+	 * Private constructor
+	 */
+	private EJBUtil()
+	{
+		throw new UnsupportedOperationException();
+	}
+
+	/**
+	 * Check the given class is an EJB sesion class or not.
+	 * 
+	 * <p>
+	 * EJB class means, it is annotated with
+	 * {@link Stateless} or {@link Stateful} annotations.
+	 * </p>
+	 * 
+	 * @param clazz class instance
+	 * @return true or false
+	 */
+	//TODO Look EJB Specification for more concrete definition
+	public static boolean isEJBSessionClass(Class<?> clazz)
+	{
+		return (AnnotationUtil.isAnnotationExistOnClass(clazz, Stateless.class) || AnnotationUtil.isAnnotationExistOnClass(clazz, Stateful.class)) ;
+	}
+	
+	/**
+	 * Check the given class is an EJB is MDB class or not.
+	 * 
+	 * <p>
+	 * EJB class means, it is annotated with
+	 * {@link MessageDriven} annotations.
+	 * </p>
+	 * 
+	 * @param clazz class instance
+	 * @return true or false
+	 */
+	public static boolean isEJBMessageDrivenClass(Class<?> clazz)
+	{
+		return (AnnotationUtil.isAnnotationExistOnClass(clazz, MessageDriven.class)) ;
+	}
+	
+	
+	/**
+	 * True if class is an ejb.
+	 * 
+	 * @param clazz class check for ejb
+	 * @return true if ejb
+	 */
+	public static boolean isEJBClass(Class<?> clazz)
+	{
+		return (isEJBSessionClass(clazz) || isEJBMessageDrivenClass(clazz)) ? true : false;
+	}
+	
+	/**
+	 * Return true if it is defined in the ejb-jar.xml
+	 * false otherwise.
+	 * 
+	 * @param clazzName class name
+	 * @return true if it is defined in the ejb-jar.xml
+	 */
+	public static boolean isDefinedInXML(String clazzName)
+	{
+		Asserts.assertNotNull(clazzName,"clazzName parameter can not be null");
+		
+		return false;
+	}
+	
+}

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

Added: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/ejb/orm/ORMUtil.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/ejb/orm/ORMUtil.java?rev=719890&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/ejb/orm/ORMUtil.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/ejb/orm/ORMUtil.java Sat Nov 22 10:09:38 2008
@@ -0,0 +1,50 @@
+/*
+ *  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.ejb.orm;
+
+import org.apache.webbeans.util.Asserts;
+
+/**
+ * Some utility methods for parsing orm.xml file
+ * in folders META-INF/orm.xml.
+ * 
+ * @author <a href="mailto:gurkanerdogdu@yahoo.com">Gurkan Erdogdu</a>
+ * @since 1.0
+ */
+public final class ORMUtil
+{
+	private ORMUtil()
+	{
+		
+	}
+
+	/**
+	 * Return true if it is defined in the ejb-jar.xml
+	 * false otherwise.
+	 * 
+	 * @param clazzName class name
+	 * @return true if it is defined in the orm.xml
+	 */
+	public static boolean isDefinedInXML(String clazzName)
+	{
+		Asserts.assertNotNull(clazzName,"clazzName parameter can not be null");
+		
+		return false;
+	}
+
+	
+}

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

Added: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/el/WebBeansELResolver.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/el/WebBeansELResolver.java?rev=719890&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/el/WebBeansELResolver.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/el/WebBeansELResolver.java Sat Nov 22 10:09:38 2008
@@ -0,0 +1,133 @@
+/*
+ *  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.el;
+
+import java.beans.FeatureDescriptor;
+import java.util.Iterator;
+
+import javax.el.ELContext;
+import javax.el.ELException;
+import javax.el.ELResolver;
+import javax.el.PropertyNotFoundException;
+import javax.el.PropertyNotWritableException;
+import javax.webbeans.Dependent;
+import javax.webbeans.manager.Bean;
+import javax.webbeans.manager.Manager;
+
+import org.apache.webbeans.container.ManagerImpl;
+import org.apache.webbeans.context.DependentContext;
+
+public class WebBeansELResolver extends ELResolver
+{
+
+	@Override
+	public Class<?> getCommonPropertyType(ELContext arg0, Object arg1)
+	{
+		return null;
+	}
+
+	@Override
+	public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext arg0, Object arg1)
+	{
+		return null;
+	}
+
+	@Override
+	public Class<?> getType(ELContext arg0, Object arg1, Object arg2) throws NullPointerException, PropertyNotFoundException, ELException
+	{
+		return null;
+	}
+
+	@Override
+	public Object getValue(ELContext context, Object obj, Object property) throws NullPointerException, PropertyNotFoundException, ELException
+	{
+		Manager manager = ManagerImpl.getManager();
+
+		Object object = null;
+		DependentContext dependentContext = null;
+		Bean<?> bean =  null;
+		boolean isActiveSet = false;
+		boolean isResolution = false;
+		try
+		{
+			if(obj == null)
+			{
+				isResolution = true;
+				
+				dependentContext = (DependentContext)ManagerImpl.getManager().getContext(Dependent.class);
+				
+				if(!dependentContext.isActive())
+				{
+					dependentContext.setActive(true);
+					isActiveSet = true;
+				}
+				
+				String name = (String) property;
+				object = manager.getInstanceByName(name);
+				
+				context.setPropertyResolved(true);				
+				bean = manager.resolveByName(name).iterator().next();
+				
+			}
+						
+		}finally
+		{
+			if(isResolution)
+			{
+				if(bean != null)
+				{
+					destroyBean(bean, object);	
+				}
+				
+				if(isActiveSet)
+				{
+					dependentContext.setActive(false);	
+				}				
+			}
+		}
+		
+		return object;
+	}
+	
+	@SuppressWarnings("unchecked")
+	private <T> void destroyBean(Bean<?> bean, Object instance)
+	{
+		Bean<T> destroy = (Bean<T>)bean;
+		
+		if(destroy.getScopeType().equals(Dependent.class))
+		{
+			T inst = (T) instance;
+			
+			destroy.destroy(inst);
+			
+		}
+		
+	}
+
+	@Override
+	public boolean isReadOnly(ELContext arg0, Object arg1, Object arg2) throws NullPointerException, PropertyNotFoundException, ELException
+	{
+		return false;
+	}
+
+	@Override
+	public void setValue(ELContext arg0, Object arg1, Object arg2, Object arg3) throws NullPointerException, PropertyNotFoundException, PropertyNotWritableException, ELException
+	{
+		
+	}
+
+}

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

Added: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/BeanObserverImpl.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/BeanObserverImpl.java?rev=719890&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/BeanObserverImpl.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/BeanObserverImpl.java Sat Nov 22 10:09:38 2008
@@ -0,0 +1,225 @@
+/*
+ *  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.event;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.webbeans.Dependent;
+import javax.webbeans.Observer;
+import javax.webbeans.Observes;
+import javax.webbeans.manager.Context;
+
+import org.apache.webbeans.annotation.CurrentLiteral;
+import org.apache.webbeans.component.AbstractComponent;
+import org.apache.webbeans.component.ObservesMethodsOwner;
+import org.apache.webbeans.container.InjectionResolver;
+import org.apache.webbeans.container.ManagerImpl;
+import org.apache.webbeans.context.DependentContext;
+import org.apache.webbeans.util.AnnotationUtil;
+
+public class BeanObserverImpl<T> implements Observer<T>
+{
+	private ObservesMethodsOwner<?> bean;
+	
+	private Method observerMethod;
+	
+	private boolean ifExist;
+	
+	private TransactionalObserverType type;
+	
+	private ManagerImpl manager;
+		
+	public BeanObserverImpl(ObservesMethodsOwner<?> bean, Method observerMethod, boolean ifExist, TransactionalObserverType type)
+	{
+		this.bean = bean;
+		this.observerMethod = observerMethod;
+		this.ifExist = ifExist;
+		this.type = type;
+		this.manager = ManagerImpl.getManager();
+	}
+
+	public void notify(T event)
+	{
+		AbstractComponent<?> baseComponent = (AbstractComponent<?>) bean;
+		Object object = null;
+
+		boolean isActiveSet = false;
+		DependentContext dependentContext = (DependentContext)ManagerImpl.getManager().getContext(Dependent.class);
+		
+		try
+		{
+			if(baseComponent.getScopeType().equals(Dependent.class))
+			{
+				dependentContext = (DependentContext)ManagerImpl.getManager().getContext(Dependent.class);
+				
+				if(!dependentContext.isActive())
+				{
+					isActiveSet = true;
+					dependentContext.setActive(true);
+					
+				}
+				
+				object = ManagerImpl.getManager().getInstance(baseComponent);
+			}
+			
+			Context context = manager.getContext(baseComponent.getScopeType());		
+			if(ifExist)
+			{
+				object = context.get(baseComponent, false);
+			}
+			else
+			{
+				object = context.get(baseComponent, true);
+			}
+			
+			if(object != null)
+			{
+				Object[] args = null;
+				List<Object> argsObjects = getMethodArguments(event);
+				
+				args = new Object[argsObjects.size()];
+				args = argsObjects.toArray(args);
+				
+				try
+				{
+					observerMethod.invoke(object, args);
+					
+				} catch (IllegalArgumentException e)
+				{
+					throw e;
+					
+				} catch (IllegalAccessException e)
+				{
+					throw new RuntimeException(e);
+					
+				} catch (InvocationTargetException e)
+				{
+					throw new RuntimeException(e);
+				}finally
+				{
+					if(isActiveSet)
+					{
+						object = null;
+					}
+				}
+				
+			}
+			
+		}finally
+		{
+			if(isActiveSet)
+			{
+				dependentContext.setActive(false);
+			}
+		}
+		
+	}
+	
+	private List<Object> getMethodArguments(Object event)
+	{
+		Type[] types = this.observerMethod.getGenericParameterTypes();
+		Annotation[][] annots = this.observerMethod.getParameterAnnotations();
+		List<Object> list = new ArrayList<Object>();
+		
+		if (types.length > 0)
+		{
+			int i = 0;
+			for (Type type : types)
+			{
+				Annotation[] annot = annots[i];
+				
+				boolean observesAnnotation = false;
+				
+				if (annot.length == 0)
+				{
+					annot = new Annotation[1];
+					annot[0] = new CurrentLiteral();
+				}
+				else
+				{
+					for(Annotation observersAnnot : annot)
+					{
+						if(observersAnnot.annotationType().equals(Observes.class))
+						{
+							list.add(event);
+							observesAnnotation = true;
+							break;
+						}
+					}
+				}
+				
+				if(!observesAnnotation)
+				{
+					Type[] args = new Type[0];
+					Class<?> clazz = null;
+					if (type instanceof ParameterizedType)
+					{
+						ParameterizedType pt = (ParameterizedType) type;
+						args = new Type[1];
+						args = pt.getActualTypeArguments();
+
+						clazz = (Class<?>) pt.getRawType();
+					} else
+					{
+						clazz = (Class<?>) type;
+					}
+					
+					Annotation[] bindingTypes = AnnotationUtil.getBindingAnnotations(annot);
+					
+					if(bindingTypes.length > 0)
+					{
+						list.add(manager.getInstance(InjectionResolver.getInstance().implResolveByType(clazz, args, bindingTypes).iterator().next()));	
+					}
+					else
+					{
+						list.add(null);
+					}
+					
+				}				
+				
+				i++;
+			}
+		}
+		
+		return list;		
+	}
+
+	/**
+	 * @return the bean
+	 */
+	public ObservesMethodsOwner<?> getBean()
+	{
+		return bean;
+	}
+
+	/**
+	 * @return the type
+	 */
+	public TransactionalObserverType getType()
+	{
+		return type;
+	}
+	
+	
+	
+}

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

Added: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/EventImpl.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/EventImpl.java?rev=719890&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/EventImpl.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/EventImpl.java Sat Nov 22 10:09:38 2008
@@ -0,0 +1,81 @@
+/*
+ *  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.event;
+
+import java.lang.annotation.Annotation;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.webbeans.Event;
+import javax.webbeans.Observable;
+import javax.webbeans.Observer;
+
+import org.apache.webbeans.container.ManagerImpl;
+
+public class EventImpl<T> implements Event<T>
+{
+	private Annotation[] injectedBindings;
+	
+	private Class<T> eventType;
+	
+	private ManagerImpl manager = null;
+	
+	public EventImpl(Annotation[] injectedBindings, Class<T> eventType)
+	{
+		this.injectedBindings = injectedBindings;
+		this.eventType = eventType;
+		this.manager = ManagerImpl.getManager();
+	}
+
+	public void fire(T event, Annotation... bindings)
+	{
+		EventUtil.checkEventBindings(bindings);
+		this.manager.fireEvent(event, getEventBindings(bindings));
+		
+	}
+
+	public void observe(Observer<T> observer, Annotation... bindings)
+	{
+		EventUtil.checkEventBindings(bindings);
+		this.manager.addObserver(observer, eventType, bindings);
+	}
+
+	private Annotation[] getEventBindings(Annotation...annotations)
+	{
+		List<Annotation> eventBindings = new ArrayList<Annotation>();
+		Annotation[] anns = null;
+		
+		for(Annotation binding : injectedBindings)
+		{
+			if(!binding.annotationType().equals(Observable.class))
+			{
+				eventBindings.add(binding);
+			}
+		}
+		
+		for(Annotation binding : annotations)
+		{
+			eventBindings.add(binding);
+		}
+		
+		anns = new Annotation[eventBindings.size()];
+		anns = eventBindings.toArray(anns);
+		
+		return anns;
+		
+	}
+}

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

Added: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/EventUtil.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/EventUtil.java?rev=719890&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/EventUtil.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/EventUtil.java Sat Nov 22 10:09:38 2008
@@ -0,0 +1,176 @@
+/*
+ *  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.event;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+
+import javax.webbeans.AfterTransactionCompletion;
+import javax.webbeans.AfterTransactionFailure;
+import javax.webbeans.AfterTransactionSuccess;
+import javax.webbeans.BeforeTransactionCompletion;
+import javax.webbeans.Destructor;
+import javax.webbeans.Disposes;
+import javax.webbeans.Event;
+import javax.webbeans.Initializer;
+import javax.webbeans.Observes;
+import javax.webbeans.Produces;
+
+import org.apache.webbeans.exception.WebBeansConfigurationException;
+import org.apache.webbeans.util.AnnotationUtil;
+import org.apache.webbeans.util.Asserts;
+import org.apache.webbeans.util.ClassUtil;
+
+public final class EventUtil
+{
+	private EventUtil()
+	{
+		
+	}
+	
+	public static void checkEventType(Class<?> eventType)
+	{
+		Asserts.assertNotNull(eventType, "eventType parameter can not be null");
+		
+		if(ClassUtil.isParametrized(eventType))
+		{
+			throw new IllegalArgumentException("Event type : " + eventType.getName() + " can not be generic");
+		}
+	}
+	
+	public static void checkEventBindings(Annotation...annotations)
+	{
+		AnnotationUtil.checkBindingTypeConditions(annotations);
+	}
+	
+	public static TransactionalObserverType getObserverMethodTransactionType(Method observerMethod)
+	{
+		if(AnnotationUtil.isMethodParameterAnnotationExist(observerMethod, AfterTransactionCompletion.class))
+		{
+			return TransactionalObserverType.AFTER_TRANSACTION_COMPLETION;
+		}
+		else if(AnnotationUtil.isMethodParameterAnnotationExist(observerMethod, AfterTransactionSuccess.class))
+		{
+			return TransactionalObserverType.AFTER_TRANSACTION_SUCCESS;
+		}
+		else if(AnnotationUtil.isMethodParameterAnnotationExist(observerMethod, AfterTransactionFailure.class))
+		{
+			return TransactionalObserverType.AFTER_TRANSACTION_FAILURE;
+		}
+		else if(AnnotationUtil.isMethodParameterAnnotationExist(observerMethod, BeforeTransactionCompletion.class))
+		{
+			return TransactionalObserverType.BEFORE_TRANSACTION_COMPLETION;
+		}
+		else
+		{
+			return TransactionalObserverType.NONE;
+		}
+		
+	}
+	
+	public static void checkObserverMethodConditions(Method candidateObserverMethod, Class<?> clazz)
+	{
+		Asserts.assertNotNull(candidateObserverMethod, "candidateObserverMethod parameter can not be null");
+		Asserts.nullCheckForClass(clazz);
+		
+		if(AnnotationUtil.isMethodMultipleParameterAnnotationExist(candidateObserverMethod, Observes.class))
+		{
+			throw new WebBeansConfigurationException("Observer method : " + candidateObserverMethod.getName() + " in class : " + 
+					clazz.getName() + " can not define two parameters with annotated @Observes");
+		}
+		
+		if(AnnotationUtil.isMethodHasAnnotation(candidateObserverMethod, Produces.class) ||
+				AnnotationUtil.isMethodHasAnnotation(candidateObserverMethod, Initializer.class) ||
+				AnnotationUtil.isMethodHasAnnotation(candidateObserverMethod, Destructor.class))
+		{
+			throw new WebBeansConfigurationException("Observer method : " + candidateObserverMethod.getName() + " in class : " + 
+					clazz.getName() + " can not annotated with annotation in the list {@Produces, @Initializer, @Destructor}");
+			
+		}
+		
+		if(AnnotationUtil.isMethodParameterAnnotationExist(candidateObserverMethod, Disposes.class))
+		{
+			throw new WebBeansConfigurationException("Observer method : " + candidateObserverMethod.getName() + " in class : " + 
+					clazz.getName() + " can not annotated with annotation @Disposes");
+		}
+		
+		 Type type = AnnotationUtil.getMethodFirstParameterWithAnnotation(candidateObserverMethod, Observes.class);
+		 Class<?> eventType = null;
+		 if(type instanceof ParameterizedType)
+		 {
+			 ClassUtil.checkParametrizedType((ParameterizedType)type);
+			 eventType = (Class<?>)((ParameterizedType)type).getRawType();
+		 }
+		 else
+		 {
+			 eventType = (Class<?>) type;
+		 }
+		 
+		 if(ClassUtil.isParametrized(eventType))
+		 {
+				throw new WebBeansConfigurationException("Observer method : " + candidateObserverMethod.getName() + " in class : " + 
+						clazz.getName() + " can not defined as generic");
+		 }
+	}
+	
+	public static void checkObservableMethodParameterConditions(Type[] parametersType, String fieldName, String errorMessage)
+	{
+		Asserts.assertNotNull(parametersType, "parametersType parameter can not be null");
+		
+		for(Type observableType : parametersType)
+		{
+			EventUtil.checkObservableFieldConditions(observableType, fieldName, errorMessage);
+		}
+		
+	}
+	
+	public static void checkObservableFieldConditions(Type fieldType, String fieldName,  String errorMessage)
+	{
+		Asserts.assertNotNull(fieldType,"fieldType parameter can not be null");
+		Asserts.assertNotNull(fieldName, "fieldName parameter can not be null");
+		
+		if(errorMessage == null)
+		{
+			errorMessage = "Failed on check @Observable field/method-parameter with name : " + fieldName;
+		}
+		
+		
+		if(!ClassUtil.isParametrizedType(fieldType))
+		{
+			throw new WebBeansConfigurationException("@Observable field/method-parameter in " + errorMessage + " with field : " + fieldName + " must be ParametrizedType with actual type argument");
+		}
+		else
+		{
+			ParameterizedType pType = (ParameterizedType) fieldType;
+			Class<?> clazz = (Class<?>)pType.getRawType();
+			
+			if(!clazz.equals(Event.class))
+			{
+				throw new WebBeansConfigurationException("@Observable field/method-parameter in " + errorMessage + " with field : " + fieldName + " must be ParametrizedType with raw type argument javax.webbeans.Event");
+			}
+			
+			if(!ClassUtil.checkParametrizedType(pType))
+			{
+				throw new WebBeansConfigurationException("@Observable field/method-parameter in " + errorMessage + " with field : " + fieldName + " can not be ParametrizedType with type variable or wildcard type arguments");
+			}
+		}
+		
+	}
+
+}

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

Added: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java?rev=719890&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java Sat Nov 22 10:09:38 2008
@@ -0,0 +1,356 @@
+/*
+ *  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.event;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CopyOnWriteArraySet;
+
+import javax.transaction.Status;
+import javax.transaction.Synchronization;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+import javax.webbeans.IfExists;
+import javax.webbeans.Observer;
+import javax.webbeans.ObserverException;
+import javax.webbeans.Observes;
+import javax.webbeans.TypeLiteral;
+
+import org.apache.webbeans.component.ObservesMethodsOwner;
+import org.apache.webbeans.logger.WebBeansLogger;
+import org.apache.webbeans.util.AnnotationUtil;
+import org.apache.webbeans.util.Asserts;
+
+@SuppressWarnings("unchecked")
+public final class NotificationManager implements Synchronization
+{
+	private static final WebBeansLogger logger = WebBeansLogger.getLogger(NotificationManager.class);
+	
+	@SuppressWarnings("unchecked")
+	private static NotificationManager instance = new NotificationManager();
+	
+	private Map<Class<?>, Set<ObserverImpl<?>>> observers = new ConcurrentHashMap<Class<?>, Set<ObserverImpl<?>>>();
+		
+	private TransactionManager transactionManager;
+	
+	private Set<TransactionalNotifier> transactionSet = new CopyOnWriteArraySet<TransactionalNotifier>();
+	
+	private NotificationManager()
+	{
+		
+	}
+	
+	@SuppressWarnings("unchecked")
+	public static NotificationManager getInstance()
+	{
+		return instance;
+	}
+	
+	public <T> void  addObserver(Observer<T> observer, Class<T> eventType, Annotation...annotations)
+	{
+		addObserver(observer, false, TransactionalObserverType.NONE, eventType, annotations);
+	}
+	
+	public <T> void  addObserver(Observer<T> observer, boolean ifExist, TransactionalObserverType type, Class<T> eventType, Annotation...annotations)
+	{
+		EventUtil.checkEventType(eventType);
+		EventUtil.checkEventBindings(annotations);
+		
+		ObserverImpl<T> observerImpl = new ObserverImpl<T>(observer, ifExist, type, eventType, annotations);
+		
+		Set<ObserverImpl<?>> set = observers.get(eventType);
+		if(set == null)
+		{
+			set = new HashSet<ObserverImpl<?>>();
+			observers.put(eventType, set);
+		}
+			
+		set.add(observerImpl);
+	}
+	
+	
+	public <T>  void  addObserver(Observer<T> observer, TypeLiteral<T> eventType, Annotation...annotations)
+	{
+		EventUtil.checkEventType(eventType.getRawType());
+		EventUtil.checkEventBindings(annotations);
+		
+		ObserverImpl<T> observerImpl = new ObserverImpl<T>(observer, eventType.getRawType(), annotations);
+		
+		Set<ObserverImpl<?>> set = observers.get(eventType);
+		if(set == null)
+		{
+			set = new HashSet<ObserverImpl<?>>();
+			observers.put(eventType.getRawType(), set);
+		}
+			
+		
+		set.add(observerImpl);
+	}
+	
+
+	public <T> void removeObserver(Observer<T> observer, Class<T> eventType, Annotation...annotations)
+	{
+		EventUtil.checkEventType(eventType);
+		EventUtil.checkEventBindings(annotations);
+		
+		if(observers.containsKey(eventType))
+		{
+			Set<ObserverImpl<?>> set = observers.get(eventType);
+			Iterator<ObserverImpl<?>> it = set.iterator();
+			while(it.hasNext())
+			{
+				ObserverImpl<?> s = it.next();
+				Observer<T> ob = (Observer<T>)s.getObserver();
+				
+				if(ob.equals(observer))
+				{
+					set.remove(s);
+				}
+			}
+		}
+	}
+	
+	public <T> void removeObserver(Observer<T> observer, TypeLiteral<T> eventType, Annotation...annotations)
+	{
+		EventUtil.checkEventType(eventType.getRawType());
+		EventUtil.checkEventBindings(annotations);
+		
+		if(observers.containsKey(eventType))
+		{
+			Set<ObserverImpl<?>> set = observers.get(eventType.getRawType());
+			Iterator<ObserverImpl<?>> it = set.iterator();
+			while(it.hasNext())
+			{
+				ObserverImpl<?> s = it.next();
+				Observer<T> ob = (Observer<T>)s.getObserver();
+				
+				if(ob.equals(observer))
+				{
+					set.remove(s);
+				}
+			}
+		}
+	}
+	
+	public <T> Set<Observer<T>> resolveObservers(T event, Annotation... bindings)
+	{
+		
+		Set<ObserverImpl<?>> resolvedSet = new HashSet<ObserverImpl<?>>();
+		Set<Observer<T>> unres = new HashSet<Observer<T>>();
+		
+		@SuppressWarnings("unchecked")Class<T> eventType = (Class<T>)event.getClass();
+		
+		EventUtil.checkEventType(eventType);
+		EventUtil.checkEventBindings(bindings);
+		
+		Set<Class<?>> keySet = this.observers.keySet();
+		Iterator<Class<?>> itKeySet = keySet.iterator();
+		
+		while(itKeySet.hasNext())
+		{
+			Class<?> type = itKeySet.next();
+			if(type.isAssignableFrom(eventType))
+			{
+				resolvedSet.addAll(this.observers.get(type));
+			}
+		}
+		
+		
+		Iterator<ObserverImpl<?>> it = resolvedSet.iterator();
+		while(it.hasNext())
+		{
+			@SuppressWarnings("unchecked")
+			ObserverImpl<T> impl = (ObserverImpl<T>)it.next();
+			
+			if(impl.isObserverOfBindings(bindings))
+			{
+				unres.add(impl.getObserver());	
+			}
+		}
+		
+		return unres;		
+	}	
+	
+	public void fireEvent(Object event, Annotation... bindings)
+	{
+		Set<Observer<Object>> observers = resolveObservers(event, bindings);
+		Iterator<Observer<Object>> it = observers.iterator();
+		
+		TransactionalNotifier transNotifier = null;
+		while(it.hasNext())
+		{
+			Observer<Object> observer =  it.next();
+			try
+			{
+				if(observer instanceof BeanObserverImpl)
+				{
+					BeanObserverImpl<Object> beanObserver = (BeanObserverImpl<Object>)observer;
+					TransactionalObserverType type = beanObserver.getType();
+					if(!type.equals(TransactionalObserverType.NONE))
+					{
+						Transaction transaction = this.transactionManager.getTransaction();
+						if(transaction != null)
+						{
+							transaction.registerSynchronization(this);
+							if(transNotifier == null)
+							{
+								transNotifier = new TransactionalNotifier(event);
+								this.transactionSet.add(transNotifier);
+							}
+							
+							//Register for transaction
+							if(type.equals(TransactionalObserverType.AFTER_TRANSACTION_COMPLETION))
+							{
+								transNotifier.addAfterCompletionObserver(observer);
+							}
+							else if(type.equals(TransactionalObserverType.AFTER_TRANSACTION_SUCCESS))
+							{
+								transNotifier.addAfterCompletionSuccessObserver(observer);
+							}
+							else if(type.equals(TransactionalObserverType.AFTER_TRANSACTION_FAILURE))
+							{
+								transNotifier.addAfterCompletionFailureObserver(observer);
+							}
+							else if(type.equals(TransactionalObserverType.BEFORE_TRANSACTION_COMPLETION))
+							{
+								transNotifier.addBeforeCompletionObserver(observer);
+							}
+						}
+						else
+						{
+							observer.notify(event);
+						}
+					}else
+					{
+						observer.notify(event);
+					}
+				}
+				else
+				{
+					observer.notify(event);
+				}
+				
+			}catch(Throwable e)
+			{
+				if(Exception.class.isAssignableFrom(e.getClass()))
+				{
+					throw new ObserverException("Exception is thrown while handling event object with type : " + event.getClass().getName(),e);
+				}
+			}
+		}		
+	}
+	
+	public <T> void addObservableComponentMethods(ObservesMethodsOwner<?> component)
+	{
+		Asserts.assertNotNull(component, "component parameter can not be null");
+		Set<Method> observableMethods = component.getObservableMethods();
+		Iterator<Method> itMethods = observableMethods.iterator();
+		
+		while(itMethods.hasNext())
+		{
+			Method observableMethod = itMethods.next();
+			Annotation[] bindingTypes = AnnotationUtil.getMethodFirstParameterBindingTypesWithGivenAnnotation(observableMethod, Observes.class);
+			
+			boolean ifExist = false;
+			
+			if(AnnotationUtil.isMethodParameterAnnotationExist(observableMethod, IfExists.class))
+			{
+				ifExist = true;
+			}
+			
+			TransactionalObserverType type = EventUtil.getObserverMethodTransactionType(observableMethod);
+			
+			BeanObserverImpl<T> observer = new BeanObserverImpl(component, observableMethod, ifExist, type);
+
+			Class<T> clazz = (Class<T>)AnnotationUtil.getMethodFirstParameterTypeClazzWithAnnotation(observableMethod, Observes.class);
+						
+			addObserver(observer, ifExist, type , clazz, bindingTypes);			
+		}
+		
+	}
+	
+
+	public void afterCompletion(int status)
+	{
+		try
+		{
+			Iterator<TransactionalNotifier> it = this.transactionSet.iterator();
+			
+			if(status == Status.STATUS_COMMITTED)
+			{
+				//Call @AfterTransactionSuccess
+				while(it.hasNext())
+				{
+					TransactionalNotifier notifier = it.next();
+					notifier.notifyAfterCompletionSuccess();
+				}
+				
+			}
+			else if(status == Status.STATUS_ROLLEDBACK)
+			{
+				//Call @AfterTransactionFailure
+				while(it.hasNext())
+				{
+					TransactionalNotifier notifier = it.next();
+					notifier.notifyAfterCompletionFailure();
+				}
+				
+			}
+			else
+			{
+				//Call @AfterTransactionCompletion
+				while(it.hasNext())
+				{
+					TransactionalNotifier notifier = it.next();
+					notifier.notifyAfterCompletion();
+				}
+				
+			}
+			
+			
+		}catch(Throwable e)
+		{
+			logger.error("Exception is occured in the transational observer ",e);
+		}finally
+		{
+			this.transactionSet.clear();
+		}
+	}
+	
+	public void beforeCompletion()
+	{
+		//Call @BeforeTransactionCompletion		
+		try
+		{
+			Iterator<TransactionalNotifier> it = this.transactionSet.iterator();
+			while(it.hasNext())
+			{
+				TransactionalNotifier notifier = it.next();
+				notifier.notifyBeforeCompletion();
+			}
+			
+		}catch(Throwable e)
+		{
+			logger.error("Exception is occured in the transational observer ",e);
+		}
+	}	 
+}
\ No newline at end of file

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

Added: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverImpl.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverImpl.java?rev=719890&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverImpl.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverImpl.java Sat Nov 22 10:09:38 2008
@@ -0,0 +1,160 @@
+/*
+ *  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.event;
+
+import java.lang.annotation.Annotation;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.webbeans.Observer;
+
+import org.apache.webbeans.util.AnnotationUtil;
+
+/**
+ * Implementation of the {@link Observer} interface contract.
+ * 
+ * @author <a href="mailto:gurkanerdogdu@yahoo.com">Gurkan Erdogdu</a>
+ * @since 1.0
+ * 
+ * @param <T> generic event type
+ */
+public class ObserverImpl<T>
+{
+	/**Event binding types apeearing on the parameter*/
+	private Set<Annotation> eventBindingTypes = new HashSet<Annotation>();
+	
+	/**Event object type*/
+	private Class<T> eventType;
+	
+	private Observer<T> observer;
+	
+	private boolean ifExist;
+	
+	private TransactionalObserverType transObserverType;
+	
+	/**
+	 * Constructs new observer instance.
+	 * 
+	 * @param component web beans component defines the observer method
+	 * @param observerMethod observer method
+	 * @param eventType event type
+	 */
+	public ObserverImpl(Observer<T> observer, Class<T> eventType,Annotation...annotations)
+	{
+		this(observer, false, TransactionalObserverType.NONE, eventType, annotations);
+	}
+	
+	public ObserverImpl(Observer<T> observer,  boolean ifExist, TransactionalObserverType type, Class<T> eventType,Annotation...annotations)
+	{
+		for(Annotation annotation : annotations)
+		{
+			this.eventBindingTypes.add(annotation);
+		}
+		
+		this.observer = observer;
+		this.eventType = eventType;
+		this.ifExist = ifExist;
+		this.transObserverType = type;
+	}
+	
+	
+	public boolean isObserverOfBindings(Annotation...annotations)
+	{
+		boolean ok = true;
+		for(Annotation annot : annotations)
+		{
+			if(!this.eventBindingTypes.contains(annot))
+			{
+				ok = false;
+				break;
+			}
+			else
+			{
+				if(!AnnotationUtil.isAnnotationMemberExist(annot.annotationType(), annot, getAnnotation(annot.annotationType())))
+				{
+					ok = false;
+					break;
+				}
+			}
+			
+		}
+		
+		return ok;
+		
+	}
+	
+	private Annotation getAnnotation(Class<? extends Annotation> type)
+	{
+		Iterator<Annotation> it = this.eventBindingTypes.iterator();
+		while(it.hasNext())
+		{
+			Annotation annot = it.next();
+			
+			if(annot.annotationType().equals(type))
+			{
+				return annot;
+			}
+		}
+		
+		return null;
+	}
+	
+	/**
+	 * Gets event binding types.
+	 */
+	public Set<Annotation> getEventBindingTypes()
+	{
+		return this.eventBindingTypes;
+	}
+
+	/**
+	 * Gets event type.
+	 */
+	public Class<T> getEventType()
+	{
+		return this.eventType;
+	}
+	
+	
+
+	/**
+	 * @return the observer
+	 */
+	public Observer<T> getObserver()
+	{
+		return observer;
+	}
+
+	/**
+	 * @return the ifExist
+	 */
+	public boolean isIfExist()
+	{
+		return ifExist;
+	}
+
+	/**
+	 * @return the transObserverType
+	 */
+	public TransactionalObserverType getTransObserverType()
+	{
+		return transObserverType;
+	}
+	
+	
+}
\ No newline at end of file

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

Added: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/TransactionalNotifier.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/TransactionalNotifier.java?rev=719890&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/TransactionalNotifier.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/TransactionalNotifier.java Sat Nov 22 10:09:38 2008
@@ -0,0 +1,150 @@
+/*
+ *  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.event;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.webbeans.Observer;
+
+import org.apache.webbeans.util.Asserts;
+
+class TransactionalNotifier
+{
+	private Object event;
+	
+	private Set<Observer<Object>> afterCompletion = new HashSet<Observer<Object>>();
+	
+	private Set<Observer<Object>> afterCompletionSuccess = new HashSet<Observer<Object>>();
+	
+	private Set<Observer<Object>> afterCompletionFailure = new HashSet<Observer<Object>>();
+	
+	private Set<Observer<Object>> beforeCompletion = new HashSet<Observer<Object>>();
+	
+	
+	public TransactionalNotifier(Object event)
+	{
+		this.event = event;
+	}
+
+	public void addAfterCompletionObserver(Observer<Object> observer)
+	{
+		checkNull(observer);
+		
+		this.afterCompletion.add(observer);
+		
+	}
+	
+	public void addAfterCompletionSuccessObserver(Observer<Object> observer)
+	{
+		checkNull(observer);
+		
+		this.afterCompletionSuccess.add(observer);
+	}
+
+	public void addAfterCompletionFailureObserver(Observer<Object> observer)
+	{
+		checkNull(observer);
+		
+		this.afterCompletionFailure.add(observer);
+	}
+
+	public void addBeforeCompletionObserver(Observer<Object> observer)
+	{
+		checkNull(observer);
+		
+		this.beforeCompletion.add(observer);
+	}
+	
+	public void notifyAfterCompletion() throws Throwable
+	{
+		Iterator<Observer<Object>> it = this.afterCompletion.iterator();
+		handleEvent(it);
+	}
+	
+	public void notifyAfterCompletionSuccess() throws Throwable
+	{
+		Iterator<Observer<Object>> it = this.afterCompletionSuccess.iterator();
+		handleEvent(it);
+		
+	}
+	
+	public void notifyAfterCompletionFailure() throws Throwable
+	{
+		Iterator<Observer<Object>> it = this.afterCompletionFailure.iterator();
+		handleEvent(it);
+		
+	}
+	
+	public void notifyBeforeCompletion() throws Throwable
+	{
+		Iterator<Observer<Object>> it = this.beforeCompletion.iterator();
+		handleEvent(it);
+		
+	}
+	
+	
+	/* (non-Javadoc)
+	 * @see java.lang.Object#hashCode()
+	 */
+	@Override
+	public int hashCode()
+	{
+		final int prime = 31;
+		int result = 1;
+		result = prime * result + ((event.getClass() == null) ? 0 : event.getClass().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 TransactionalNotifier other = (TransactionalNotifier) obj;
+		if (event.getClass() == null)
+		{
+			if (other.event.getClass() != null)
+				return false;
+		} else if (!event.getClass().equals(other.event.getClass()))
+			return false;
+		return true;
+	}
+	
+	private void handleEvent(Iterator<Observer<Object>> it)
+	{
+		while(it.hasNext())
+		{
+			it.next().notify(this.event);
+		}		
+		
+	}
+
+	private void checkNull(Observer<Object> observer)
+	{
+		Asserts.assertNotNull(observer,"observer parameter can not be null");
+	}
+
+}

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

Added: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/TransactionalObserverType.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/TransactionalObserverType.java?rev=719890&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/TransactionalObserverType.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/TransactionalObserverType.java Sat Nov 22 10:09:38 2008
@@ -0,0 +1,26 @@
+/*
+ *  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.event;
+
+public enum TransactionalObserverType
+{
+	AFTER_TRANSACTION_COMPLETION,
+	AFTER_TRANSACTION_SUCCESS,
+	AFTER_TRANSACTION_FAILURE,
+	BEFORE_TRANSACTION_COMPLETION,
+	NONE
+}

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

Added: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/exception/ComponentNotFoundException.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/exception/ComponentNotFoundException.java?rev=719890&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/exception/ComponentNotFoundException.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/exception/ComponentNotFoundException.java Sat Nov 22 10:09:38 2008
@@ -0,0 +1,34 @@
+/*
+ *  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.exception;
+
+/**
+ * Throws when the component is not found in the web beans container.
+ * 
+ * @author <a href="mailto:gurkanerdogdu@yahoo.com">Gurkan Erdogdu</a>
+ * @since 1.0
+ */
+public class ComponentNotFoundException extends WebBeansException
+{
+	private static final long serialVersionUID = 532093075405474889L;
+
+	public ComponentNotFoundException(String message)
+	{
+		super(message);
+	}
+
+}

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



Mime
View raw message