You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwebbeans.apache.org by ge...@apache.org on 2008/11/22 19:09:48 UTC

svn commit: r719890 [7/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...

Added: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java?rev=719890&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java Sat Nov 22 10:09:38 2008
@@ -0,0 +1,1231 @@
+/*
+ *  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.Modifier;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.lang.reflect.TypeVariable;
+import java.lang.reflect.WildcardType;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.Date;
+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.AnnotationLiteral;
+
+import org.apache.webbeans.exception.WebBeansException;
+
+/**
+ * Utility classes with respect to the class operations.
+ * 
+ * @author <a href="mailto:gurkanerdogdu@yahoo.com">Gurkan Erdogdu</a>
+ * @since 1.0
+ */
+@SuppressWarnings("unchecked")
+public final class ClassUtil
+{
+	public static Map<Class<?>, Object> PRIMITIVE_CLASS_DEFAULT_VALUES = null;
+
+	public static Set<Class<?>> VALUE_TYPES = new HashSet<Class<?>>();
+
+	public static Set<Class<?>> PRIMITIVES = new HashSet<Class<?>>();
+
+	static
+	{
+		PRIMITIVE_CLASS_DEFAULT_VALUES = new HashMap<Class<?>, Object>();
+		PRIMITIVE_CLASS_DEFAULT_VALUES.put(Integer.class, Integer.MIN_VALUE);
+		PRIMITIVE_CLASS_DEFAULT_VALUES.put(Float.class, Float.MIN_VALUE);
+		PRIMITIVE_CLASS_DEFAULT_VALUES.put(Double.class, Double.MIN_VALUE);
+		PRIMITIVE_CLASS_DEFAULT_VALUES.put(Character.class, Character.MIN_VALUE);
+		PRIMITIVE_CLASS_DEFAULT_VALUES.put(String.class, new String());
+		PRIMITIVE_CLASS_DEFAULT_VALUES.put(BigDecimal.class, BigDecimal.ZERO);
+		PRIMITIVE_CLASS_DEFAULT_VALUES.put(BigInteger.class, BigInteger.ZERO);
+		PRIMITIVE_CLASS_DEFAULT_VALUES.put(Long.class, Long.MIN_VALUE);
+		PRIMITIVE_CLASS_DEFAULT_VALUES.put(Byte.class, Byte.MIN_VALUE);
+		PRIMITIVE_CLASS_DEFAULT_VALUES.put(Short.class, Short.MIN_VALUE);
+		PRIMITIVE_CLASS_DEFAULT_VALUES.put(Boolean.class, Boolean.FALSE);
+
+		VALUE_TYPES.add(String.class);
+		VALUE_TYPES.add(Date.class);
+		VALUE_TYPES.add(Calendar.class);
+		VALUE_TYPES.add(Class.class);
+		VALUE_TYPES.add(List.class);
+		VALUE_TYPES.add(Enum.class);
+
+		PRIMITIVES.add(Integer.TYPE);
+		PRIMITIVES.add(Float.TYPE);
+		PRIMITIVES.add(Double.TYPE);
+		PRIMITIVES.add(Character.TYPE);
+		PRIMITIVES.add(Long.TYPE);
+		PRIMITIVES.add(Byte.TYPE);
+		PRIMITIVES.add(Short.TYPE);
+		PRIMITIVES.add(Boolean.TYPE);
+
+	}
+
+	/*
+	 * Private constructor
+	 */
+	private ClassUtil()
+	{
+		throw new UnsupportedOperationException();
+	}
+
+	/**
+	 * Check the parametrized type actual arguments equals with the class type
+	 * variables at the injection point.
+	 * 
+	 * @param variables
+	 *            type variable
+	 * @param types
+	 *            type
+	 * @return
+	 */
+	public static boolean checkEqual(TypeVariable<?>[] variables, Type[] types)
+	{
+		Asserts.assertNotNull(variables, "variables parameter can not be null");
+		Asserts.assertNotNull(types, "types parameter can not be null");
+
+		for (TypeVariable<?> variable : variables)
+		{
+			for (Type type : types)
+			{
+				if (type instanceof TypeVariable)
+				{
+					TypeVariable<?> t = ((TypeVariable<?>) type);
+					if (t.getGenericDeclaration().equals(variable.getGenericDeclaration()))
+					{
+						if (t.getName().equals(variable.getName()))
+						{
+							continue;
+						} else
+						{
+							return false;
+						}
+
+					} else
+					{
+						return false;
+					}
+				}
+			}
+		}
+
+		return true;
+
+	}
+
+	public static Class<?> getClassFromName(String name)
+	{
+		Class<?> clazz = null;
+
+		try
+		{
+			ClassLoader loader = WebBeansUtil.getCurrentClassLoader();
+			clazz = loader.loadClass(name);
+
+			return clazz;
+
+		} catch (ClassNotFoundException e)
+		{
+			try
+			{
+				clazz = ClassUtil.class.getClassLoader().loadClass(name);
+
+				return clazz;
+
+			} catch (ClassNotFoundException e1)
+			{
+				try
+				{
+					clazz = ClassLoader.getSystemClassLoader().loadClass(name);
+
+					return clazz;
+
+				} catch (ClassNotFoundException e2)
+				{
+					return null;
+				}
+
+			}
+		}
+
+	}
+
+	/**
+	 * Check final modifier.
+	 * 
+	 * @param modifier
+	 *            modifier
+	 * @return true or false
+	 */
+	public static boolean isFinal(Integer modifier)
+	{
+		Asserts.nullCheckForModifier(modifier);
+
+		return Modifier.isFinal(modifier);
+	}
+
+	/**
+	 * Check abstract modifier.
+	 * 
+	 * @param modifier
+	 *            modifier
+	 * @return true or false
+	 */
+	public static boolean isAbstract(Integer modifier)
+	{
+		Asserts.nullCheckForModifier(modifier);
+
+		return Modifier.isAbstract(modifier);
+	}
+
+	/**
+	 * Check interface modifier.
+	 * 
+	 * @param modifier
+	 *            modifier
+	 * @return true or false
+	 */
+	public static boolean isInterface(Integer modifier)
+	{
+		Asserts.nullCheckForModifier(modifier);
+
+		return Modifier.isInterface(modifier);
+	}
+
+	/**
+	 * Check for class that has a final method or not.
+	 * 
+	 * @param clazz
+	 *            check methods of it
+	 * @return true or false
+	 */
+	public static boolean hasFinalMethod(Class<?> clazz)
+	{
+		Asserts.nullCheckForClass(clazz);
+
+		Method[] methods = clazz.getDeclaredMethods();
+		for (Method m : methods)
+		{
+			if (isFinal(m.getModifiers()))
+			{
+				return true;
+			}
+		}
+
+		return false;
+	}
+
+	/**
+	 * Check the class is inner or not
+	 * 
+	 * @param modifier
+	 *            modifier
+	 * @return true or false
+	 */
+	public static boolean isInnerClazz(Class<?> clazz)
+	{
+		Asserts.nullCheckForClass(clazz);
+
+		return clazz.isMemberClass();
+	}
+
+	/**
+	 * Check the modifier contains static keyword.
+	 * 
+	 * @param modifier
+	 *            modifier
+	 * @return true or false
+	 */
+	public static boolean isStatic(Integer modifier)
+	{
+		Asserts.nullCheckForModifier(modifier);
+
+		return Modifier.isStatic(modifier);
+	}
+
+	/**
+	 * Check the modifier contains static keyword.
+	 * 
+	 * @param modifier
+	 *            modifier
+	 * @return true or false
+	 */
+	public static boolean isPublic(Integer modifier)
+	{
+		Asserts.nullCheckForModifier(modifier);
+
+		return Modifier.isPublic(modifier);
+	}
+
+	/**
+	 * Check the modifier contains static keyword.
+	 * 
+	 * @param modifier
+	 *            modifier
+	 * @return true or false
+	 */
+	public static boolean isPrivate(Integer modifier)
+	{
+		Asserts.nullCheckForModifier(modifier);
+
+		return Modifier.isPrivate(modifier);
+	}
+
+	/**
+	 * Gets the Java Standart Class default value.
+	 * 
+	 * @param <T>
+	 *            parametrized type
+	 * @param clazz
+	 *            class instance
+	 * @return default value of the class
+	 */
+	public static <T> T defaultJavaValues(Class<T> clazz)
+	{
+		Asserts.nullCheckForClass(clazz);
+
+		Set<Class<?>> keySet = PRIMITIVE_CLASS_DEFAULT_VALUES.keySet();
+		Iterator<Class<?>> it = keySet.iterator();
+		while (it.hasNext())
+		{
+			Class<?> obj = it.next();
+			if (clazz.equals(obj))
+			{
+				return (T) PRIMITIVE_CLASS_DEFAULT_VALUES.get(obj);
+			}
+		}
+
+		return null;
+
+	}
+
+	/**
+	 * Gets the class of the given type arguments.
+	 * 
+	 * <p>
+	 * If the given type {@link Type} parameters is an instance of the
+	 * {@link ParameterizedType}, it returns the raw type otherwise it return
+	 * the casted {@link Class} of the type argument.
+	 * </p>
+	 * 
+	 * @param type
+	 *            class or parametrized type
+	 * @return
+	 */
+	public static Class<?> getClass(Type type)
+	{
+		Asserts.assertNotNull(type, "type parameter can not be null");
+
+		if (type instanceof ParameterizedType)
+		{
+			return (Class<?>) ((ParameterizedType) type).getRawType();
+		}
+
+		else
+		{
+			return (Class<?>) type;
+		}
+	}
+
+	/**
+	 * Gets the declared methods of the given class.
+	 * 
+	 * @param clazz
+	 *            class instance
+	 * @return the declared methods
+	 */
+	public static Method[] getDeclaredMethods(Class<?> clazz)
+	{
+		Asserts.nullCheckForClass(clazz);
+		return clazz.getDeclaredMethods();
+	}
+
+	/**
+	 * Check that method has any formal arguments.
+	 * 
+	 * @param method
+	 *            method instance
+	 * @return true or false
+	 */
+	public static boolean isMethodHasParameter(Method method)
+	{
+		Asserts.nullCheckForMethod(method);
+
+		Class<?>[] types = method.getParameterTypes();
+		if (types.length != 0)
+		{
+			return true;
+		}
+
+		return false;
+	}
+
+	/**
+	 * Gets the return type of the method.
+	 * 
+	 * @param method
+	 *            method instance
+	 * @return return type
+	 */
+	public static Class<?> getReturnType(Method method)
+	{
+		Asserts.nullCheckForMethod(method);
+		return method.getReturnType();
+	}
+
+	/**
+	 * Check method throws checked exception or not.
+	 * 
+	 * @param method
+	 *            method instance
+	 * @return trur or false
+	 */
+	public static boolean isMethodHasCheckedException(Method method)
+	{
+		Asserts.nullCheckForMethod(method);
+
+		Class<?>[] et = method.getExceptionTypes();
+
+		if (et.length > 0)
+		{
+			for (Class<?> type : et)
+			{
+				if (Error.class.isAssignableFrom(type) || RuntimeException.class.isAssignableFrom(type))
+				{
+					return false;
+				} else
+				{
+					return true;
+				}
+			}
+
+		}
+
+		return false;
+	}
+
+	/**
+	 * Check method throws Exception or not.
+	 * 
+	 * @param method
+	 *            method instance
+	 * @return trur or false
+	 */
+	public static boolean isMethodHasException(Method method)
+	{
+		Asserts.nullCheckForMethod(method);
+
+		Class<?>[] et = method.getExceptionTypes();
+
+		if (et.length == 1)
+		{
+			if (et[0].equals(Exception.class))
+				return true;
+		}
+
+		return false;
+	}
+
+	/**
+	 * Call method on the instance with given arguments.
+	 * 
+	 * @param method
+	 *            method instance
+	 * @param instance
+	 *            object instance
+	 * @param args
+	 *            arguments
+	 * @return the method result
+	 */
+	public static Object callInstanceMethod(Method method, Object instance, Object[] args)
+	{
+		Asserts.nullCheckForMethod(method);
+		Asserts.assertNotNull(instance, "instance parameter can not be null");
+
+		try
+		{
+			if (args == null)
+			{
+				args = new Object[] {};
+			}
+			return method.invoke(instance, args);
+
+		} catch (Throwable e)
+		{
+			throw new WebBeansException("Exception occurs in the method call with method : " + method.getName() + " in class : " + instance.getClass().getName());
+		}
+
+	}
+
+	public static List<Class<?>> getSuperClasses(Class<?> clazz, List<Class<?>> list)
+	{
+		Asserts.nullCheckForClass(clazz);
+
+		Class<?> sc = clazz.getSuperclass();
+		if (sc != null)
+		{
+			list.add(sc);
+			getSuperClasses(sc, list);
+		}
+
+		return list;
+
+	}
+
+	public static Class<?>[] getMethodParameterTypes(Method method)
+	{
+		Asserts.nullCheckForMethod(method);
+		return method.getParameterTypes();
+	}
+
+	public static List<String> getObjectMethodNames()
+	{
+		List<String> list = new ArrayList<String>();
+		Class<?> clazz = Object.class;
+
+		Method[] methods = clazz.getMethods();
+		for (Method method : methods)
+		{
+			list.add(method.getName());
+		}
+
+		return list;
+	}
+
+	public static boolean isObjectMethod(String methodName)
+	{
+		Asserts.assertNotNull(methodName, "methodName parameter can not be null");
+		return getObjectMethodNames().contains(methodName);
+	}
+
+	public static boolean isMoreThanOneMethodWithName(String methodName, Class<?> clazz)
+	{
+		Asserts.assertNotNull(methodName, "methodName parameter can not be null");
+		Asserts.nullCheckForClass(clazz);
+
+		Method[] methods = clazz.getDeclaredMethods();
+		int i = 0;
+		for (Method m : methods)
+		{
+			if (m.getName().equals(methodName))
+			{
+				i++;
+			}
+		}
+
+		if (i > 1)
+			return true;
+
+		return false;
+
+	}
+
+	public static <T> Constructor<T> isContaintNoArgConstructor(Class<T> clazz)
+	{
+		Asserts.nullCheckForClass(clazz);
+		try
+		{
+			return clazz.getConstructor(new Class<?>[] {});
+
+		} catch (Exception e)
+		{
+			return null;
+		}
+
+	}
+
+	/**
+	 * Check the modifiers contains the public keyword.
+	 * 
+	 * @param modifs
+	 *            modifiers
+	 * @return true or false
+	 */
+	public static boolean isPublic(int modifs)
+	{
+		return Modifier.isPublic(modifs);
+	}
+
+	/**
+	 * Gets java package if exist.
+	 * 
+	 * @param packageName
+	 *            package name
+	 * @return the package with given name
+	 */
+	public Package getPackage(String packageName)
+	{
+		Asserts.assertNotNull(packageName, "packageName parameter can not be null");
+
+		return Package.getPackage(packageName);
+	}
+
+	public static boolean isParametrizedType(Type type)
+	{
+		Asserts.assertNotNull(type, "type parameter can not be null");
+		if (type instanceof ParameterizedType)
+		{
+			return true;
+		}
+
+		return false;
+	}
+
+	public static boolean isConcrete(Class<?> clazz)
+	{
+		Asserts.nullCheckForClass(clazz);
+
+		Integer modifier = clazz.getModifiers();
+
+		if (!isAbstract(modifier) && !isInterface(modifier) && clazz.getEnclosingClass() == null)
+		{
+			return true;
+		}
+
+		return false;
+	}
+
+	public static AnnotationLiteral<Annotation> getAnnotationLiteral(final Class<? extends Annotation> clazz)
+	{
+		Asserts.nullCheckForClass(clazz);
+
+		AnnotationLiteral<Annotation> literal = new AnnotationLiteral<Annotation>()
+		{
+
+			/*
+			 * (non-Javadoc)
+			 * 
+			 * @see javax.webbeans.AnnotationLiteral#annotationType()
+			 */
+			@Override
+			public Class<? extends Annotation> annotationType()
+			{
+
+				return clazz;
+			}
+		};
+
+		return literal;
+	}
+
+	public static <T> Constructor<T>[] getConstructors(Class<T> clazz)
+	{
+		Asserts.nullCheckForClass(clazz);
+		return clazz.getConstructors();
+	}
+
+	public static <T> boolean isDefaultConstructorExist(Class<T> clazz)
+	{
+		Asserts.nullCheckForClass(clazz);
+		try
+		{
+			clazz.getConstructor(new Class<?>[] {});
+
+		} catch (SecurityException e)
+		{
+			throw e;
+		} catch (NoSuchMethodException e)
+		{
+			return false;
+		}
+
+		return true;
+	}
+
+	public static boolean isAssignable(Type lhs, Type rhs)
+	{
+		Asserts.assertNotNull(lhs, "lhs parameter can not be null");
+		Asserts.assertNotNull(rhs, "rhs parameter can not be null");
+
+		if (lhs instanceof ParameterizedType && rhs instanceof ParameterizedType)
+		{
+			return isAssignable((ParameterizedType) lhs, (ParameterizedType) rhs);
+		} else
+		{
+			if (lhs instanceof Class && rhs instanceof Class)
+			{
+				return isAssignable((Class) lhs, (Class) rhs);
+			} else
+			{
+				return false;
+			}
+		}
+	}
+
+	public static boolean isAssignable(Class<?> lhs, Class<?> rhs)
+	{
+		Asserts.assertNotNull(lhs, "lhs parameter can not be null");
+		Asserts.assertNotNull(rhs, "rhs parameter can not be null");
+
+		if (lhs.isAssignableFrom(rhs))
+		{
+			return true;
+		}
+
+		return false;
+	}
+
+	public static boolean isAssignableForParametrized(ParameterizedType lhs, ParameterizedType rhs)
+	{
+		Class<?> rowLhs = (Class<?>) lhs.getRawType();
+		Class<?> rowRhs = (Class<?>) rhs.getRawType();
+
+		if (isAssignable(rowLhs, rowRhs))
+		{
+			Type[] lhsArgs = lhs.getActualTypeArguments();
+			Type[] rhsArgs = rhs.getActualTypeArguments();
+
+			if (lhsArgs.equals(rhsArgs))
+			{
+				return true;
+			}
+		}
+
+		return false;
+	}
+
+	public static boolean classHasFieldWithName(Class<?> clazz, String fieldName)
+	{
+		Asserts.nullCheckForClass(clazz);
+		Asserts.assertNotNull(fieldName, "fieldName parameter can not be null");
+		try
+		{
+
+			clazz.getDeclaredField(fieldName);
+
+		} catch (SecurityException e)
+		{
+			// we must throw here!
+			throw new WebBeansException(e);
+		} catch (NoSuchFieldException e2)
+		{
+			return false;
+		}
+
+		return true;
+	}
+
+	public static boolean classHasMoreThanOneFieldWithName(Class<?> clazz, String fieldName)
+	{
+		Asserts.nullCheckForClass(clazz);
+		Asserts.assertNotNull(fieldName, "fieldName parameter can not be null");
+
+		Field[] fields = clazz.getDeclaredFields();
+		boolean ok = false;
+		for (Field field : fields)
+		{
+			if (field.getName().equals(fieldName))
+			{
+				if (ok)
+				{
+					return true;
+				} else
+				{
+					ok = true;
+				}
+			}
+		}
+
+		return false;
+	}
+
+	public static Field getFieldWithName(Class<?> clazz, String fieldName)
+	{
+		Asserts.nullCheckForClass(clazz);
+		Asserts.assertNotNull(fieldName, "fieldName parameter can not be null");
+		try
+		{
+
+			return clazz.getDeclaredField(fieldName);
+
+		} catch (SecurityException e)
+		{
+			// we must throw here!
+			throw new WebBeansException(e);
+		} catch (NoSuchFieldException e2)
+		{
+			return null;
+		}
+
+	}
+
+	public static List<Method> getClassMethodsWithTypes(Class<?> clazz, String methodName, List<Class<?>> parameterTypes)
+	{
+		Asserts.nullCheckForClass(clazz);
+		Asserts.assertNotNull(methodName, "methodName parameter can not be null");
+		Asserts.assertNotNull(parameterTypes, "parameterTypes parameter can not be null");
+
+		List<Method> methodList = new ArrayList<Method>();
+
+		Method[] methods = clazz.getDeclaredMethods();
+
+		int j = 0;
+		for (Method method : methods)
+		{
+			Class<?>[] defineTypes = method.getParameterTypes();
+
+			if (defineTypes.length != parameterTypes.size())
+			{
+				continue;
+			}
+
+			boolean ok = false;
+			for (Class<?> defineType : defineTypes)
+			{
+				if (defineType.isAssignableFrom(parameterTypes.get(j)))
+				{
+					ok = true;
+				} else
+				{
+					ok = false;
+				}
+			}
+
+			if (ok)
+			{
+				methodList.add(method);
+			}
+		}
+
+		return methodList;
+	}
+
+	public static Method getClassMethodWithTypes(Class<?> clazz, String methodName, List<Class<?>> parameterTypes)
+	{
+		Asserts.nullCheckForClass(clazz);
+		Asserts.assertNotNull(methodName, "methodName parameter can not be null");
+		Asserts.assertNotNull(parameterTypes, "parameterTypes parameter can not be null");
+
+		Method[] methods = clazz.getDeclaredMethods();
+
+		int j = 0;
+		for (Method method : methods)
+		{
+			Class<?>[] defineTypes = method.getParameterTypes();
+
+			if (defineTypes.length != parameterTypes.size())
+			{
+				continue;
+			}
+
+			boolean ok = false;
+			for (Class<?> defineType : defineTypes)
+			{
+				if (defineType.equals(parameterTypes.get(j)))
+				{
+					ok = true;
+				} else
+				{
+					ok = false;
+				}
+			}
+
+			if (ok)
+			{
+				return method;
+			}
+		}
+
+		return null;
+	}
+
+	public static boolean isMethodExistWithName(Class<?> clazz, String methodName)
+	{
+		Asserts.nullCheckForClass(clazz);
+		Asserts.assertNotNull(methodName, "methodName parameter can not be null");
+
+		Method[] methods = clazz.getDeclaredMethods();
+
+		for (Method method : methods)
+		{
+			if (method.getName().equals(methodName))
+			{
+				return true;
+			}
+		}
+
+		return false;
+	}
+
+	public static boolean isPrimitive(Class<?> clazz)
+	{
+		Asserts.nullCheckForClass(clazz);
+
+		return clazz.isPrimitive();
+	}
+
+	public static boolean isArray(Class<?> clazz)
+	{
+		Asserts.nullCheckForClass(clazz);
+
+		return clazz.isArray();
+	}
+
+	public static boolean isEnum(Class<?> clazz)
+	{
+		return clazz.isEnum();
+	}
+
+	public static boolean isInValueTypes(Class<?> clazz)
+	{
+		boolean result = VALUE_TYPES.contains(clazz);
+
+		if (!result)
+		{
+			result = PRIMITIVES.contains(clazz);
+		}
+
+		if (!result)
+		{
+			if (Enum.class.isAssignableFrom(clazz))
+			{
+				return true;
+			}
+		}
+
+		return result;
+	}
+
+	public static Object isValueOkForPrimitive(Class<?> type, String value)
+	{
+		try
+		{
+			if (type.equals(Integer.TYPE))
+			{
+				return Integer.valueOf(value);
+			}
+
+			if (type.equals(Float.TYPE))
+			{
+				return Float.valueOf(value);
+			}
+
+			if (type.equals(Double.TYPE))
+			{
+				return Double.valueOf(value);
+			}
+
+			if (type.equals(Character.TYPE))
+			{
+				return value.toCharArray()[0];
+			}
+
+			if (type.equals(Long.TYPE))
+			{
+				return Long.valueOf(value);
+			}
+
+			if (type.equals(Byte.TYPE))
+			{
+				return Byte.valueOf(value);
+			}
+
+			if (type.equals(Short.TYPE))
+			{
+				return Short.valueOf(value);
+			}
+
+			if (type.equals(Boolean.TYPE))
+			{
+				return Boolean.valueOf(value);
+			}
+
+		} catch (Throwable e)
+		{
+			return null;
+		}
+
+		return null;
+	}
+
+	public static Enum isValueOkForEnum(Class clazz, String value)
+	{
+		Asserts.nullCheckForClass(clazz);
+		Asserts.assertNotNull(value, "value parameter can not be null");
+
+		try
+		{
+			return Enum.valueOf(clazz, value);
+
+		} catch (Throwable e)
+		{
+			return null;
+		}
+
+	}
+
+	public static Date isValueOkForDate(String value)
+	{
+		try
+		{
+			Asserts.assertNotNull(value, "value parameter can not be null");
+
+			return DateFormat.getDateTimeInstance().parse(value);
+		} catch (ParseException e)
+		{
+			return null;
+		}
+
+	}
+
+	public static boolean isParametrized(Class<?> clazz)
+	{
+		Asserts.nullCheckForClass(clazz);
+		return (clazz.getTypeParameters().length > 0) ? true : false;
+	}
+
+	public static Type[] getActualTypeArguements(Class<?> clazz)
+	{
+		Asserts.nullCheckForClass(clazz);
+
+		if (clazz.getGenericSuperclass() instanceof ParameterizedType)
+		{
+			return ((ParameterizedType) clazz.getGenericSuperclass()).getActualTypeArguments();
+
+		} else
+		{
+			return new Type[0];
+		}
+	}
+	
+	public static Type[] getActualTypeArguements(Type type)
+	{
+		Asserts.assertNotNull(type,"type parameter can not be null");
+
+		if (type instanceof ParameterizedType)
+		{
+			return ((ParameterizedType)type).getActualTypeArguments();
+
+		} else
+		{
+			return new Type[0];
+		}
+	}
+	
+	public static Class<?> getFirstRawType(Type type)
+	{
+		Asserts.assertNotNull(type,"type argument can not be null");
+		
+		if(type instanceof ParameterizedType)
+		{
+			ParameterizedType pt = (ParameterizedType) type;
+			return (Class<?>)pt.getRawType();
+		}
+		
+		return (Class<?>)type;
+	}
+	
+	
+	public static Set<Class<?>> setTypeHierarchy(Set<Class<?>> set, Class<?> clazz)
+	{
+		Asserts.nullCheckForClass(clazz);
+		
+		set.add(clazz);
+		
+		Class<?> sc = clazz.getSuperclass();
+		
+		if(sc != null)
+		{
+			setTypeHierarchy(set,sc);
+		}
+		
+		Class<?>[] interfaces = clazz.getInterfaces();
+		for(Class<?> cl : interfaces)
+		{
+			setTypeHierarchy(set,cl);
+		}
+		
+		return set;
+	}
+	
+	public static Set<Class<?>> setInterfaceTypeHierarchy(Set<Class<?>> set, Class<?> clazz)
+	{
+		Asserts.nullCheckForClass(clazz);
+		
+		Class<?>[] interfaces = clazz.getInterfaces();
+
+		for(Class<?> cl : interfaces)
+		{
+			set.add(cl);
+			
+			setTypeHierarchy(set,cl);
+		}
+		
+		return set;
+	}
+	
+
+	public static Type[] getGenericSuperClassTypeArguments(Class<?> clazz)
+	{
+		Asserts.nullCheckForClass(clazz);
+		Type type = clazz.getGenericSuperclass();
+		
+		if(type != null)
+		{
+			if(type instanceof ParameterizedType)
+			{
+				ParameterizedType pt = (ParameterizedType) type;
+				
+				if(checkParametrizedType(pt))
+				{
+					return pt.getActualTypeArguments();	
+				}
+			}
+		}
+		
+		return new Type[0];
+		
+	}
+	
+	public static boolean checkParametrizedType(ParameterizedType pType)
+	{
+		Asserts.assertNotNull(pType,"pType argument can not be null");
+		Type[] types = pType.getActualTypeArguments();
+		
+		for(Type type : types)
+		{
+			if(type instanceof ParameterizedType)
+			{
+				return checkParametrizedType((ParameterizedType)type);
+			}
+			else if((type instanceof TypeVariable) || (type instanceof WildcardType))
+			{
+				return false;
+			}
+		}
+		
+		return true;
+	}
+	
+	public static List<Type[]> getGenericSuperInterfacesTypeArguments(Class<?> clazz)
+	{
+		Asserts.nullCheckForClass(clazz);
+		List<Type[]> list = new ArrayList<Type[]>();
+		
+		Type[] types = clazz.getGenericInterfaces();
+		for(Type type : types)
+		{
+			if(type instanceof ParameterizedType)
+			{
+				ParameterizedType pt = (ParameterizedType)type;		
+				
+				if(checkParametrizedType(pt))
+				{
+					list.add(pt.getActualTypeArguments());					
+				}
+			}
+		}
+		
+		return list;
+	}
+	
+	public static Field getFieldWithAnnotation(Class<?> clazz, Class<? extends Annotation> annotation)
+	{
+		Asserts.nullCheckForClass(clazz);
+		Asserts.assertNotNull(annotation, "annotation parameter can not be null");
+		
+		Field[] fields = clazz.getDeclaredFields();
+		for(Field field : fields)
+		{
+			if(AnnotationUtil.isAnnotationExist(field.getAnnotations(), annotation))
+			{
+				return field;
+			}
+			
+		}
+		
+		return null;
+		
+	}
+	
+	public static boolean checkForTypeArguments(Class<?> src, Type[] typeArguments, Class<?> target)
+	{
+		Asserts.assertNotNull(src,"src parameter can not be null");
+		Asserts.assertNotNull(typeArguments,"typeArguments parameter can not be null");
+		Asserts.assertNotNull(target,"target parameter can not be null");
+		
+		Type[] types = getGenericSuperClassTypeArguments(target);		
+		
+		boolean found = false;
+		
+		if(Arrays.equals(typeArguments, types))
+		{
+			return true;
+		}
+		else
+		{
+			Class<?> superClazz = target.getSuperclass();
+			if(superClazz != null)
+			{
+				found =  checkForTypeArguments(src, typeArguments, superClazz);	
+			}	
+		}
+		
+		if(!found)
+		{
+			List<Type[]> list = getGenericSuperInterfacesTypeArguments(target);
+			if(!list.isEmpty())
+			{
+				Iterator<Type[]> it = list.iterator();
+				while(it.hasNext())
+				{
+					types = it.next();
+					if(Arrays.equals(typeArguments, types))
+					{
+						found = true;
+						break;
+					}
+				}
+				
+			}
+		}
+		
+		if(!found)
+		{
+			Class<?>[] superInterfaces = target.getInterfaces();
+			for(Class<?> inter : superInterfaces)
+			{
+				found = checkForTypeArguments(src, typeArguments, inter);
+				if(found)
+				{
+					break;
+				}
+			}
+		}
+		
+		
+		return found;
+	}
+	
+}

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

Added: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/JNDIUtil.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/JNDIUtil.java?rev=719890&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/JNDIUtil.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/JNDIUtil.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.util;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.apache.webbeans.exception.WebBeansException;
+import org.apache.webbeans.logger.WebBeansLogger;
+
+public final class JNDIUtil
+{
+	private static InitialContext initialContext = null;
+	
+	private static final WebBeansLogger LOGGER = WebBeansLogger.getLogger(JNDIUtil.class);
+	
+	static
+	{
+		try
+		{
+			initialContext = new InitialContext();
+			
+		}catch(Throwable e)
+		{
+			LOGGER.error("Unable to initialize InitialContext object", e);
+			throw new ExceptionInInitializerError(e);
+		}
+	}
+	
+	private JNDIUtil()
+	{
+		
+	}
+	
+	public static InitialContext getInitialContext()
+	{
+		return initialContext;
+	}
+	
+	public static void bind(String name, Object object)
+	{
+		Asserts.assertNotNull(name,"name parameter can not be null");
+		Asserts.assertNotNull(object, "object parameter can not be null");
+		
+		try
+		{
+			initialContext.bind(name, object);
+			
+		} catch (NamingException e)
+		{
+			LOGGER.error(e);
+			throw new WebBeansException("Unable to bind object with name : " + name ,e);
+		}
+	}
+	
+	public static void unbind(String name)
+	{
+		Asserts.assertNotNull(name,"name parameter can not be null");
+		
+		try
+		{
+			initialContext.unbind(name);
+			
+		} catch (NamingException e)
+		{
+			LOGGER.error(e);
+			throw new WebBeansException("Unable to unbind object with name : " + name ,e);
+		}
+		
+	}
+
+}

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

Added: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/JSFUtil.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/JSFUtil.java?rev=719890&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/JSFUtil.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/JSFUtil.java Sat Nov 22 10:09:38 2008
@@ -0,0 +1,96 @@
+/*
+ *  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 javax.faces.application.Application;
+import javax.faces.application.ViewHandler;
+import javax.faces.component.UIViewRoot;
+import javax.faces.component.html.HtmlInputHidden;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.servlet.http.HttpSession;
+
+public final class JSFUtil
+{
+	private JSFUtil()
+	{
+		
+	}
+	
+	public static FacesContext getCurrentFacesContext()
+	{
+		return FacesContext.getCurrentInstance();
+	}
+	
+	public static ExternalContext getExternalContext()
+	{
+		return getCurrentFacesContext().getExternalContext();
+	}
+	
+	public static HttpSession getSession()
+	{
+		return (HttpSession)getExternalContext().getSession(true);
+	}
+	
+	public static boolean isPostBack()
+	{ 
+		return getCurrentFacesContext().getRenderKit().getResponseStateManager().isPostback(getCurrentFacesContext());
+	}
+
+	public static String getViewId()
+	{
+		return getCurrentFacesContext().getViewRoot().getViewId();
+	}
+	
+	public static ViewHandler getViewHandler()
+	{
+		return getCurrentFacesContext().getApplication().getViewHandler();
+	}
+	
+	public static Application getApplication()
+	{
+		return getCurrentFacesContext().getApplication();
+	}
+	
+	public static String getRedirectViewId(String redirectId)
+	{
+		Asserts.assertNotNull(redirectId,"redirectId parameter can not be null");
+		String path = getExternalContext().getRequestContextPath();
+		
+		int index = redirectId.indexOf(path);
+		
+		return redirectId.substring(index+path.length(),redirectId.length());
+	}
+	
+	public static UIViewRoot getViewRoot()
+	{
+		return getCurrentFacesContext().getViewRoot();
+	}
+	
+	public static String getConversationId()
+	{
+		UIViewRoot viewRoot = JSFUtil.getViewRoot();
+		HtmlInputHidden conversationId = (HtmlInputHidden) viewRoot.findComponent("javax_webbeans_ConversationId");
+		
+		if(conversationId != null)
+		{
+			return conversationId.getValue().toString();
+		}
+		
+		return null;
+	}
+}

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

Added: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/StringUtil.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/StringUtil.java?rev=719890&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/StringUtil.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/StringUtil.java Sat Nov 22 10:09:38 2008
@@ -0,0 +1,36 @@
+/*
+ *  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.util.UUID;
+
+public final class StringUtil
+{
+
+	private StringUtil()
+	{
+		
+	}
+	
+	public static synchronized String generateUUIDStringWithoutDash()
+	{
+		UUID uuid = UUID.randomUUID();
+		return uuid.toString().replace("-", "");
+	}
+	
+	
+}

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

Added: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java?rev=719890&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java Sat Nov 22 10:09:38 2008
@@ -0,0 +1,1226 @@
+/*
+ *  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.annotation.ElementType;
+import java.lang.annotation.Target;
+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.lang.reflect.TypeVariable;
+import java.lang.reflect.WildcardType;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.ejb.EnterpriseBean;
+import javax.faces.component.UIComponent;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+import javax.persistence.Entity;
+import javax.servlet.Filter;
+import javax.servlet.Servlet;
+import javax.servlet.ServletContextListener;
+import javax.servlet.ServletRequestListener;
+import javax.servlet.http.HttpSessionListener;
+import javax.webbeans.ApplicationScoped;
+import javax.webbeans.BindingType;
+import javax.webbeans.Conversation;
+import javax.webbeans.ConversationScoped;
+import javax.webbeans.Decorator;
+import javax.webbeans.DeploymentType;
+import javax.webbeans.Destructor;
+import javax.webbeans.Disposes;
+import javax.webbeans.DuplicateBindingTypeException;
+import javax.webbeans.InconsistentSpecializationException;
+import javax.webbeans.Initializer;
+import javax.webbeans.InterceptorBindingType;
+import javax.webbeans.Named;
+import javax.webbeans.New;
+import javax.webbeans.Observable;
+import javax.webbeans.Observes;
+import javax.webbeans.Produces;
+import javax.webbeans.RequestScoped;
+import javax.webbeans.ScopeType;
+import javax.webbeans.SessionScoped;
+import javax.webbeans.Stereotype;
+import javax.webbeans.UnproxyableDependencyException;
+import javax.webbeans.manager.Bean;
+import javax.webbeans.manager.Manager;
+
+import org.apache.webbeans.annotation.CurrentLiteral;
+import org.apache.webbeans.annotation.DependentScopeLiteral;
+import org.apache.webbeans.annotation.NewLiteral;
+import org.apache.webbeans.annotation.ProductionLiteral;
+import org.apache.webbeans.annotation.RequestedScopeLiteral;
+import org.apache.webbeans.annotation.StandardLiteral;
+import org.apache.webbeans.component.AbstractComponent;
+import org.apache.webbeans.component.ConversationComponent;
+import org.apache.webbeans.component.ManagerComponentImpl;
+import org.apache.webbeans.component.NewComponentImpl;
+import org.apache.webbeans.component.ObservableComponentImpl;
+import org.apache.webbeans.component.WebBeansType;
+import org.apache.webbeans.config.DefinitionUtil;
+import org.apache.webbeans.config.EJBWebBeansConfigurator;
+import org.apache.webbeans.config.SimpleWebBeansConfigurator;
+import org.apache.webbeans.container.ManagerImpl;
+import org.apache.webbeans.deployment.DeploymentTypeManager;
+import org.apache.webbeans.deployment.StereoTypeManager;
+import org.apache.webbeans.deployment.StereoTypeModel;
+import org.apache.webbeans.ejb.EJBUtil;
+import org.apache.webbeans.ejb.orm.ORMUtil;
+import org.apache.webbeans.event.EventUtil;
+import org.apache.webbeans.exception.WebBeansConfigurationException;
+import org.apache.webbeans.exception.WebBeansException;
+import org.apache.webbeans.intercept.InterceptorData;
+import org.apache.webbeans.intercept.InterceptorDataImpl;
+import org.apache.webbeans.intercept.InterceptorType;
+
+/**
+ * Contains some utility methods used in the all project.
+ * 
+ * @author <a href="mailto:gurkanerdogdu@yahoo.com">Gurkan Erdogdu</a>
+ * @since 1.0
+ */
+public final class WebBeansUtil
+{
+	// No instantiate
+	private WebBeansUtil()
+	{
+		throw new UnsupportedOperationException();
+	}
+
+	/**
+	 * Gets current classloader with current thread.
+	 * 
+	 * @return Current class loader instance
+	 */
+	public static ClassLoader getCurrentClassLoader()
+	{
+		return Thread.currentThread().getContextClassLoader();
+	}
+
+	/**
+	 * Return true if the given class is ok for simple web bean conditions,
+	 * falase otherwise.
+	 * 
+	 * @param clazz
+	 *            class in hand
+	 * @return true if the given class is ok for simple web bean conditions.
+	 */
+	public static void isSimpleWebBeanClass(Class<?> clazz)
+	{
+		try
+		{			
+			Asserts.nullCheckForClass(clazz);
+			int modifier = clazz.getModifiers();
+			
+			if (ClassUtil.isParametrized(clazz))
+				throw new WebBeansConfigurationException("Web Beans component implementation class : " + clazz.getName() + " can not be parametrized type");			
+			
+			if (!ClassUtil.isStatic(modifier) && ClassUtil.isInnerClazz(clazz))
+				throw new WebBeansConfigurationException("Web Beans component implementation class : " + clazz.getName() + " can not be non-static inner class");
+			
+			if (!ClassUtil.isConcrete(clazz) && !AnnotationUtil.isAnnotationExistOnClass(clazz, Decorator.class))
+				throw new WebBeansConfigurationException("Web Beans component implementation class : " + clazz.getName() + " have to be concrete if not defines as @Decorator");
+
+			if (AnnotationUtil.isAnnotationExistOnClass(clazz, Entity.class))
+				throw new WebBeansConfigurationException("Web Beans component implementation class : " + clazz.getName() + " can not be JPA Entity class");
+
+			if (EJBUtil.isEJBClass(clazz))
+				throw new WebBeansConfigurationException("Web Beans component implementation class : " + clazz.getName() + " can not be EJB class");
+
+			if (ClassUtil.isAssignable(Servlet.class, clazz))
+				throw new WebBeansConfigurationException("Web Beans component implementation class : " + clazz.getName() + " can not implement Servlet interface");
+
+			if (ClassUtil.isAssignable(Filter.class, clazz))
+				throw new WebBeansConfigurationException("Web Beans component implementation class : " + clazz.getName() + " can not implement Filter interface");
+
+			if (ClassUtil.isAssignable(ServletContextListener.class, clazz))
+				throw new WebBeansConfigurationException("Web Beans component implementation class : " + clazz.getName() + " can not implement ServletContextListener");
+
+			if (ClassUtil.isAssignable(HttpSessionListener.class, clazz))
+				throw new WebBeansConfigurationException("Web Beans component implementation class : " + clazz.getName() + " can not implement HttpSessionListener");
+
+			if (ClassUtil.isAssignable(ServletRequestListener.class, clazz))
+				throw new WebBeansConfigurationException("Web Beans component implementation class : " + clazz.getName() + " can notimplement ServletRequestListener");
+
+			if (ClassUtil.isAssignable(EnterpriseBean.class, clazz))
+				throw new WebBeansConfigurationException("Web Beans component implementation class : " + clazz.getName() + " can not implement EnterpriseBean");
+
+			if (ClassUtil.isAssignable(UIComponent.class, clazz))
+				throw new WebBeansConfigurationException("Web Beans component implementation class : " + clazz.getName() + " can not implement JSF UIComponent");
+			
+			//TODO ejb-jar.xml check
+			if (EJBUtil.isDefinedInXML(clazz.getName()))
+				throw new WebBeansConfigurationException("Web Beans component implementation class : " + clazz.getName() + " can not defined in the ejb-jar.xml");
+
+			//TODO orm.xml check
+			if (ORMUtil.isDefinedInXML(clazz.getName()))
+				throw new WebBeansConfigurationException("Web Beans component implementation class : " + clazz.getName() + " can not defined in orm.xml");
+
+			if (!isConstructureOk(clazz))
+				throw new WebBeansConfigurationException("Web Beans component implementation class : " + clazz.getName() + " must define at least one Constructor");
+
+		} catch (WebBeansConfigurationException e)
+		{
+			throw e;
+		}
+	}
+
+	public static <T> Constructor<T> defineConstructor(Class<T> clazz) throws WebBeansConfigurationException
+	{
+		Asserts.nullCheckForClass(clazz);
+		Constructor<T> result = null;
+		Constructor<T>[] constructors = ClassUtil.getConstructors(clazz);
+
+		boolean inAnnotation = false;
+		int j = 0;
+
+		for (Constructor<T> constructor : constructors)
+		{
+			j++;
+			if (constructor.getAnnotation(Initializer.class) != null)
+			{
+				if (inAnnotation == true)// duplicate @In
+				{
+					throw new WebBeansConfigurationException("There are more than one Constrcutor with Initializer annotation in class " + clazz.getName());
+				} else
+				{
+					inAnnotation = true;
+					result = constructor;
+				}
+			}
+		}
+
+		if (result != null)
+		{
+			Type[] observableTypes = AnnotationUtil.getConstructorParameterGenericTypesWithGivenAnnotation(result, Observable.class);
+			EventUtil.checkObservableMethodParameterConditions(observableTypes, "constructor parameter", "constructor : " + result.getName() + "in class : " + clazz.getName());
+			
+			Annotation[][] parameterAnns = result.getParameterAnnotations();
+			for (Annotation[] parameters : parameterAnns)
+			{
+				for (Annotation param : parameters)
+				{
+					Annotation btype = param.annotationType().getAnnotation(Disposes.class);
+					if (btype != null)
+					{
+						throw new WebBeansConfigurationException("Constructor parameter binding type annotation can not be @Disposes annotation in class " + clazz.getName());
+					} else
+					{
+						btype = param.annotationType().getAnnotation(Observes.class);
+						if (btype != null)
+						{
+							throw new WebBeansConfigurationException("Constructor parameter binding type annotation can not be @Observes annotation in class " + clazz.getName());
+						}
+					}
+				}
+
+			}
+		}
+
+		if (result == null)
+		{
+			if ((result = ClassUtil.isContaintNoArgConstructor(clazz)) != null)
+			{
+				return result;
+			}
+			else
+			{
+				throw new WebBeansConfigurationException("No constructor is found for the class : " + clazz.getName());	
+			}
+		}
+
+		return result;
+	}
+
+	/**
+	 * Check that simple web beans class has compatible constructor.
+	 * 
+	 * @param clazz
+	 *            web beans simple class
+	 * @throws WebBeansConfigurationException
+	 *             if the web beans has incompatible constructor
+	 */
+	public static boolean isConstructureOk(Class<?> clazz) throws WebBeansConfigurationException
+	{
+		Asserts.nullCheckForClass(clazz);
+
+		if (ClassUtil.isContaintNoArgConstructor(clazz) != null)
+		{
+			return true;
+		}
+
+		Constructor<?>[] constructors = ClassUtil.getConstructors(clazz);
+
+		int j = 0;
+
+		for (Constructor<?> constructor : constructors)
+		{
+			j++;
+			if (constructor.getAnnotation(Initializer.class) != null)
+			{
+				return true;
+			}
+		}
+
+		return false;
+	}
+
+	/**
+	 * Check producer method is ok for deployment.
+	 * 
+	 * @param method
+	 *            producer method
+	 * @param parentImplClazzName
+	 *            parent class name
+	 */
+	public static void checkProducerMethodForDeployment(Method method, String parentImplClazzName)
+	{
+		Asserts.assertNotNull(method, "Method argument can not be null");
+
+		if (ClassUtil.isStatic(method.getModifiers()))
+		{
+			throw new WebBeansConfigurationException("Producer method  : " + method.getName() + " in the class " + parentImplClazzName + " can not be static");
+		}
+
+		Type returnType = method.getGenericReturnType();
+		if (returnType instanceof ParameterizedType)
+		{
+			ParameterizedType pType = (ParameterizedType) returnType;
+
+			Type[] actualArguments = pType.getActualTypeArguments();
+
+			for (Type actualType : actualArguments)
+			{
+				if ((actualType instanceof TypeVariable) || (actualType instanceof WildcardType))
+				{
+					throw new WebBeansConfigurationException("Producer method  : " + method.getName() + " in the class : " + parentImplClazzName + " can not return TypeVariable or WildcardType return type arguments.");
+				}
+			}
+		}
+
+		if (AnnotationUtil.isMethodHasAnnotation(method, Initializer.class) || AnnotationUtil.isMethodHasAnnotation(method, Destructor.class) || AnnotationUtil.isMethodParameterAnnotationExist(method, Disposes.class) || AnnotationUtil.isMethodParameterAnnotationExist(method, Observes.class))
+		{
+			throw new WebBeansConfigurationException("Producer method : " + method.getName() + " in the class : " + parentImplClazzName + " can not be annotated with" + " @Initializer/@Destructor annotation or has a parameter annotated with @Disposes/@Observes");
+		}
+	}
+
+	public static void checkProducerMethodDisposal(Method disposalMethod, String parentImplClazzName)
+	{
+		Type[] observableTypes = AnnotationUtil.getMethodParameterGenericTypesWithGivenAnnotation(disposalMethod, Observable.class);
+		EventUtil.checkObservableMethodParameterConditions(observableTypes, "method parameter", "method : " + disposalMethod.getName() + "in class : " + parentImplClazzName);
+		
+		
+		if (AnnotationUtil.isMethodMultipleParameterAnnotationExist(disposalMethod, Disposes.class))
+		{
+			throw new WebBeansConfigurationException("Disposal method : " + disposalMethod.getName() + " in class " + parentImplClazzName + " has multiple @Disposes annotation parameter");
+		}
+
+		if (AnnotationUtil.isMethodHasAnnotation(disposalMethod, Initializer.class) || AnnotationUtil.isMethodHasAnnotation(disposalMethod, Destructor.class) || AnnotationUtil.isMethodParameterAnnotationExist(disposalMethod, Observes.class) || AnnotationUtil.isMethodHasAnnotation(disposalMethod, Produces.class))
+		{
+			throw new WebBeansConfigurationException("Disposal method : " + disposalMethod.getName() + " in the class : " + parentImplClazzName + " can not be annotated with" + " @Initializer/@Destructor/@Produces annotation or has a parameter annotated with @Observes");
+		}
+
+	}
+
+	/**
+	 * Check conditions for the new binding.
+	 * 
+	 * @param annotations
+	 *            annotations
+	 */
+	public static void checkForNewBindingForDeployment(Type type, Class<?> clazz, String name, Annotation... annotations)
+	{
+		Asserts.assertNotNull(type, "Type argument can not be null");
+		Asserts.assertNotNull(clazz, "Clazz argument can not be null");
+		Asserts.assertNotNull(annotations, "Annotations argument can not be null");
+
+		Annotation[] as = AnnotationUtil.getBindingAnnotations(annotations);
+		for (Annotation a : annotations)
+		{
+			if (a.annotationType().equals(New.class))
+			{
+				if (as.length > 1)
+				{
+					throw new WebBeansConfigurationException("@New binding annotation can not have any binding annotation in class : " + clazz.getName() + " in field/method : " + name);
+				}
+
+				if (ClassUtil.isAbstract(ClassUtil.getClass(type).getModifiers()) || ClassUtil.isInterface(ClassUtil.getClass(type).getModifiers()))
+				{
+					throw new WebBeansConfigurationException("@New binding annotation field can not have interface or abstract type in class : " + clazz.getName() + " in field/method : " + name);
+				}
+			}
+		}
+
+	}
+
+	/**
+	 * Returns true if src scope encloses the target.
+	 * 
+	 * @param src
+	 *            src scope
+	 * @param target
+	 *            target scope
+	 * @return true if src scope encloses the target
+	 */
+	public static boolean isScopeEncloseOther(Class<? extends Annotation> src, Class<? extends Annotation> target)
+	{
+		Asserts.assertNotNull(src, "Src argument can not be null");
+		Asserts.assertNotNull(target, "Target argument can not be null");
+
+		if (src.equals(ConversationScoped.class))
+		{
+			return true;
+		} else if (src.equals(ApplicationScoped.class))
+		{
+			if (target.equals(ConversationScoped.class) || (target.equals(ApplicationScoped.class)))
+			{
+				return false;
+			} else
+			{
+				return true;
+			}
+
+		} else if (src.equals(SessionScoped.class))
+		{
+			if (target.equals(ConversationScoped.class) || target.equals(ApplicationScoped.class) || target.equals(SessionScoped.class))
+			{
+				return false;
+			} else
+			{
+				return true;
+			}
+
+		} else if (src.equals(RequestScoped.class))
+		{
+			return false;
+		} else
+		{
+			throw new WebBeansException("Scope is not correct");
+		}
+
+	}
+
+	/**
+	 * New WebBeans component class.
+	 * 
+	 * @param <T>
+	 * @param clazz
+	 *            impl. class
+	 * @return the new component
+	 */
+	public static <T> NewComponentImpl<T> createNewComponent(Class<T> clazz)
+	{
+		Asserts.assertNotNull(clazz, "Clazz argument can not be null");
+
+		NewComponentImpl<T> comp = null;
+
+		if (SimpleWebBeansConfigurator.isSimpleWebBean(clazz))
+		{
+			comp = new NewComponentImpl<T>(clazz, WebBeansType.SIMPLE);
+			comp.setConstructor(WebBeansUtil.defineConstructor(clazz));
+
+			DefinitionUtil.defineInjectedFields(comp);
+			DefinitionUtil.defineInjectedMethods(comp);
+		} else if (EJBWebBeansConfigurator.isEJBWebBean(clazz))
+		{
+			comp = new NewComponentImpl<T>(clazz, WebBeansType.ENTERPRISE);
+		} else
+		{
+			throw new WebBeansConfigurationException("@New annotation on type : " + clazz.getName() + " must defined as a simple or an enterprise web bean");
+		}
+
+		comp.setImplScopeType(new DependentScopeLiteral());
+		comp.addBindingType(new NewLiteral());
+		comp.setName(null);
+		comp.addApiType(clazz);
+		comp.setType(new ProductionLiteral());
+
+		return comp;
+	}
+	
+	public static <T,K> ObservableComponentImpl<T,K> createObservableImplicitComponent(Class<T> returnType, Class<K> eventType, Annotation... annotations)
+	{
+		ObservableComponentImpl<T,K> component = new ObservableComponentImpl<T,K>(returnType, eventType, WebBeansType.OBSERVABLE);
+		
+		DefinitionUtil.defineApiTypes(component, returnType);
+		DefinitionUtil.defineBindingTypes(component, annotations);
+		
+		Constructor<T> constructor = null;
+		
+		 try
+		{
+			constructor = returnType.getConstructor(new Class<?>[]{Annotation[].class, Class.class});
+			
+		} catch (SecurityException e)
+		{
+			throw new WebBeansException("Security exception for getting EventImpl class constructor",e);
+			
+		} catch (NoSuchMethodException e)
+		{
+			throw new WebBeansException("No constructor found in EventImpl class",e);
+		}
+		
+		component.setConstructor(constructor);
+		component.setType(new StandardLiteral());
+		component.setImplScopeType(new DependentScopeLiteral());
+		
+		return component;
+	}
+	
+	public static ManagerComponentImpl getManagerComponent()
+	{
+		ManagerComponentImpl managerComponent = new ManagerComponentImpl();
+		
+		managerComponent.setImplScopeType(new DependentScopeLiteral());
+		managerComponent.setType(new StandardLiteral());
+		managerComponent.addBindingType(new CurrentLiteral());
+		managerComponent.addApiType(Manager.class);
+		
+		return managerComponent;
+	}
+	
+	public static ConversationComponent getConversationComponent()
+	{
+		ConversationComponent conversationComp = new ConversationComponent();
+		
+		conversationComp.addApiType(Conversation.class);
+		conversationComp.setImplScopeType(new RequestedScopeLiteral());
+		conversationComp.setType(new StandardLiteral());
+		conversationComp.addBindingType(new CurrentLiteral());
+		
+		return conversationComp;
+	}
+
+	/**
+	 * Check the {@link PostConstruct} or {@link PreDestroy} annotated method
+	 * criterias, and return post construct or pre destroy method.
+	 * 
+	 * <p>
+	 * Web Beans container is responsible for setting the post construct or pre
+	 * destroy annotation if the web beans component is not an EJB components,
+	 * in this case EJB container is responsible for this.
+	 * </p>
+	 * 
+	 * @param clazz
+	 *            checked class
+	 * @param commonAnnotation
+	 *            post construct or predestroy annotation
+	 * @return post construct or predestroy method
+	 */
+	public static Method checkCommonAnnotationCriterias(Class<?> clazz, Class<? extends Annotation> commonAnnotation, boolean invocationContext)
+	{
+		Asserts.assertNotNull(clazz, "Clazz argument can not be null");
+
+		Method[] methods = ClassUtil.getDeclaredMethods(clazz);
+		Method result = null;
+		boolean found = false;
+		for (Method method : methods)
+		{
+			if (AnnotationUtil.isMethodHasAnnotation(method, commonAnnotation))
+			{
+				if (ClassUtil.isMoreThanOneMethodWithName(method.getName(), clazz))
+				{
+					continue;
+				}
+
+				if (found == true)
+				{
+					throw new WebBeansConfigurationException("@" + commonAnnotation.getSimpleName() + " annotation is declared more than one method in the class : " + clazz.getName());
+				} else
+				{
+					found = true;
+					result = method;
+
+					// Check method criterias
+					if (ClassUtil.isMethodHasParameter(method))
+					{
+						if (!invocationContext)
+							throw new WebBeansConfigurationException("@" + commonAnnotation.getSimpleName() + " annotated method : " + method.getName() + " in class : " + clazz.getName() + " can not take any formal arguments");
+						else
+						{
+							// Check method criterias
+							Class<?>[] params = ClassUtil.getMethodParameterTypes(method);
+							if (params.length != 1 || !params[0].equals(InvocationContext.class))
+								throw new WebBeansConfigurationException("@" + commonAnnotation.getSimpleName() + " annotated method : " + method.getName() + " in class : " + clazz.getName() + " can not take any formal arguments other than InvocationContext");
+
+						}
+					}
+
+					if (!ClassUtil.getReturnType(method).equals(Void.TYPE))
+					{
+						throw new WebBeansConfigurationException("@" + commonAnnotation.getSimpleName() + " annotated method : " + method.getName() + " in class : " + clazz.getName() + " must return void type");
+					}
+
+					if (ClassUtil.isMethodHasCheckedException(method))
+					{
+						throw new WebBeansConfigurationException("@" + commonAnnotation.getSimpleName() + " annotated method : " + method.getName() + " in class : " + clazz.getName() + " can not throw any checked exception");
+					}
+
+					if (ClassUtil.isStatic(method.getModifiers()))
+					{
+						throw new WebBeansConfigurationException("@" + commonAnnotation.getSimpleName() + " annotated method : " + method.getName() + " in class : " + clazz.getName() + " can not be static");
+					}
+				}
+			}
+		}
+
+		return result;
+	}
+
+	/**
+	 * Check the {@link AroundInvoke} annotated method criterias, and return
+	 * around invoke method.
+	 * 
+	 * <p>
+	 * Web Beans container is responsible for setting around invoke annotation
+	 * if the web beans component is not an EJB components, in this case EJB
+	 * container is responsible for this.
+	 * </p>
+	 * 
+	 * @param clazz
+	 *            checked class
+	 * @return around invoke method
+	 */
+	public static Method checkAroundInvokeAnnotationCriterias(Class<?> clazz)
+	{
+		Asserts.assertNotNull(clazz, "Clazz argument can not be null");
+
+		Method[] methods = ClassUtil.getDeclaredMethods(clazz);
+		Method result = null;
+		boolean found = false;
+		for (Method method : methods)
+		{
+			if (AnnotationUtil.isMethodHasAnnotation(method, AroundInvoke.class))
+			{
+				// Overriden methods
+				if (ClassUtil.isMoreThanOneMethodWithName(method.getName(), clazz))
+				{
+					continue;
+				}
+
+				if (found == true)
+				{
+					throw new WebBeansConfigurationException("@" + AroundInvoke.class.getSimpleName() + " annotation is declared more than one method in the class : " + clazz.getName());
+				} else
+				{
+					found = true;
+					result = method;
+
+					// Check method criterias
+					Class<?>[] params = ClassUtil.getMethodParameterTypes(method);
+					if (params.length != 1 || !params[0].equals(InvocationContext.class))
+						throw new WebBeansConfigurationException("@" + AroundInvoke.class.getSimpleName() + " annotated method : " + method.getName() + " in class : " + clazz.getName() + " can not take any formal arguments other than InvocationContext");
+
+					if (!ClassUtil.getReturnType(method).equals(Object.class))
+					{
+						throw new WebBeansConfigurationException("@" + AroundInvoke.class.getSimpleName() + " annotated method : " + method.getName() + " in class : " + clazz.getName() + " must return Object type");
+					}
+
+					if (!ClassUtil.isMethodHasException(method))
+					{
+						throw new WebBeansConfigurationException("@" + AroundInvoke.class.getSimpleName() + " annotated method : " + method.getName() + " in class : " + clazz.getName() + " must throw Exception");
+					}
+
+					if (ClassUtil.isStatic(method.getModifiers()) || ClassUtil.isFinal(method.getModifiers()))
+					{
+						throw new WebBeansConfigurationException("@" + AroundInvoke.class.getSimpleName() + " annotated method : " + method.getName() + " in class : " + clazz.getName() + " can not be static or final");
+					}
+				}
+			}
+		}
+
+		return result;
+	}
+
+	/**
+	 * Configures the interceptor stack of the web beans component.
+	 * 
+	 * @param clazz
+	 *            interceptor class
+	 * @param annotation
+	 *            annotation type
+	 * @param definedInInterceptorClass
+	 *            check if annotation is defined in interceptor class
+	 * @param definedInMethod
+	 *            check if the interceptor is defined in the comp. method
+	 * @param stack
+	 *            interceptor stack
+	 * @param annotatedInterceptorClassMethod
+	 *            if definedInMethod, this specify method
+	 * @param isDefinedWithWebBeans
+	 *            if interceptor is defined with WebBeans spec, not EJB spec
+	 */
+	public static void configureInterceptorMethods(Class<?> clazz, Class<? extends Annotation> annotation, boolean definedInInterceptorClass, boolean definedInMethod, List<InterceptorData> stack, Method annotatedInterceptorClassMethod, boolean isDefinedWithWebBeans)
+	{
+		InterceptorData intData = null;
+		Method method = null;
+
+		if (annotation.equals(AroundInvoke.class))
+		{
+			method = WebBeansUtil.checkAroundInvokeAnnotationCriterias(clazz);
+		} else if (annotation.equals(PostConstruct.class))
+		{
+			if (definedInInterceptorClass)
+			{
+				method = WebBeansUtil.checkCommonAnnotationCriterias(clazz, PostConstruct.class, true);
+			} else
+			{
+				method = WebBeansUtil.checkCommonAnnotationCriterias(clazz, PostConstruct.class, false);
+			}
+		} else if (annotation.equals(PreDestroy.class))
+		{
+			if (definedInInterceptorClass)
+			{
+				method = WebBeansUtil.checkCommonAnnotationCriterias(clazz, PreDestroy.class, true);
+			} else
+			{
+				method = WebBeansUtil.checkCommonAnnotationCriterias(clazz, PreDestroy.class, false);
+			}
+		}
+
+		if (method != null)
+		{
+			intData = new InterceptorDataImpl(isDefinedWithWebBeans);
+			intData.setDefinedInInterceptorClass(definedInInterceptorClass);
+			intData.setDefinedInMethod(definedInMethod);
+			intData.setAnnotatedMethod(annotatedInterceptorClassMethod);
+
+			if (definedInInterceptorClass)
+			{
+				try
+				{
+					if (ClassUtil.isContaintNoArgConstructor(clazz) == null)
+					{
+						throw new WebBeansConfigurationException("Interceptor class : " + clazz.getName() + " must have no-arg constructor");
+					}
+
+					intData.setInterceptorInstance(clazz.newInstance());
+
+				} catch (WebBeansConfigurationException e1)
+				{
+					throw e1;
+				} catch (Exception e)
+				{
+					throw new WebBeansException(e);
+				}
+			}
+
+			intData.setInterceptor(method, annotation);
+
+			stack.add(intData);
+		}
+	}
+
+	/**
+	 * Returns true if interceptor stack contains interceptor with given type.
+	 * 
+	 * @param stack
+	 *            interceptor stack
+	 * @param type
+	 *            interceptor type
+	 * @return true if stack contains the interceptor with given type
+	 */
+	public static boolean isContainsInterceptorMethod(List<InterceptorData> stack, InterceptorType type)
+	{
+		Iterator<InterceptorData> it = stack.iterator();
+		while (it.hasNext())
+		{
+			Method m = null;
+			InterceptorData data = it.next();
+
+			if (type.equals(InterceptorType.AROUND_INVOKE))
+			{
+				m = data.getAroundInvoke();
+			} else if (type.equals(InterceptorType.POST_CONSTRUCT))
+			{
+				m = data.getPostConstruct();
+
+			} else if (type.equals(InterceptorType.PRE_DESTROY))
+			{
+				m = data.getPreDestroy();
+			}
+
+			if (m != null)
+			{
+				return true;
+			}
+
+		}
+
+		return false;
+	}
+
+	/**
+	 * Gets list of interceptors with the given type.
+	 * 
+	 * @param stack
+	 *            interceptor stack
+	 * @param type
+	 *            interceptor type
+	 * @return list of interceptor
+	 */
+	@SuppressWarnings("unchecked")
+	public static List<InterceptorData> getInterceptorMethods(List<InterceptorData> stack, InterceptorType type)
+	{
+		List<InterceptorData> ai = new ArrayList<InterceptorData>();
+		List<InterceptorData> pc = new ArrayList<InterceptorData>();
+		List<InterceptorData> pd = new ArrayList<InterceptorData>();
+
+		Iterator<InterceptorData> it = stack.iterator();
+		while (it.hasNext())
+		{
+			Method m = null;
+			InterceptorData data = it.next();
+
+			if (type.equals(InterceptorType.AROUND_INVOKE))
+			{
+				m = data.getAroundInvoke();
+				if (m != null)
+				{
+					ai.add(data);
+				}
+
+			} else if (type.equals(InterceptorType.POST_CONSTRUCT))
+			{
+				m = data.getPostConstruct();
+				if (m != null)
+				{
+					pc.add(data);
+				}
+
+			} else if (type.equals(InterceptorType.PRE_DESTROY))
+			{
+				m = data.getPreDestroy();
+				if (m != null)
+				{
+					pd.add(data);
+				}
+
+			}
+
+		}
+
+		if (type.equals(InterceptorType.AROUND_INVOKE))
+		{
+			return ai;
+		} else if (type.equals(InterceptorType.POST_CONSTRUCT))
+		{
+			return pc;
+
+		} else if (type.equals(InterceptorType.PRE_DESTROY))
+		{
+			return pd;
+		}
+
+		return Collections.EMPTY_LIST;
+	}
+
+	/**
+	 * Returns true if array contains the StereoType meta annotation
+	 * 
+	 * @param anns
+	 *            annotation array
+	 * @return true if array contains the StereoType meta annotation
+	 */
+	public static boolean isComponentHasStereoType(Annotation[] anns)
+	{
+		Asserts.assertNotNull(anns, "Anns parameter can not be null");
+
+		if (AnnotationUtil.isMetaAnnotationExist(anns, Stereotype.class))
+		{
+			return true;
+		}
+
+		return false;
+	}
+
+	public static Annotation[] getComponentStereoTypes(Annotation[] anns)
+	{
+		Asserts.assertNotNull(anns, "Anns parameter can not be null");
+		if (isComponentHasStereoType(anns))
+		{
+			return AnnotationUtil.getMetaAnnotations(anns, Stereotype.class);
+		}
+
+		return new Annotation[] {};
+	}
+
+	public static boolean isNamedExistOnStereoTypes(Annotation[] anns)
+	{
+		Annotation[] types = getComponentStereoTypes(anns);
+
+		for (Annotation ann : types)
+		{
+			if (AnnotationUtil.isAnnotationExistOnClass(ann.annotationType(), Named.class))
+			{
+				return true;
+			}
+		}
+
+		return false;
+	}
+
+	public static Annotation getMaxPrecedenceSteroTypeDeploymentType(Annotation[] anns)
+	{
+		Annotation[] deploymentTypes = getComponentStereoTypes(anns);
+		Class<? extends Annotation> maxPrecedDeploymentType = null;
+		Annotation result = null;
+		if (deploymentTypes.length > 0)
+		{
+			for (Annotation dt : deploymentTypes)
+			{
+				if (AnnotationUtil.isMetaAnnotationExist(dt.annotationType().getAnnotations(), DeploymentType.class))
+				{
+					Annotation result2[] = AnnotationUtil.getMetaAnnotations(dt.annotationType().getAnnotations(), DeploymentType.class);
+
+					Class<? extends Annotation> dtAnnot = result2[0].getClass();
+					if (maxPrecedDeploymentType == null)
+					{
+						maxPrecedDeploymentType = dtAnnot;
+						result = result2[0];
+					} else
+					{
+						if (DeploymentTypeManager.getInstance().comparePrecedences(maxPrecedDeploymentType, dtAnnot) < 0)
+						{
+							maxPrecedDeploymentType = dtAnnot;
+							result = result2[0];
+						}
+					}
+				}
+
+			}
+		}
+		
+		//This does not defined in the Specification. Default deploymentType of the implementation class not defined in xML.
+		if(result == null)
+		{
+			return new ProductionLiteral();
+
+		}
+
+		return result;
+	}
+
+	public static String getSimpleWebBeanDefaultName(String clazzName)
+	{
+		StringBuffer name = new StringBuffer(clazzName);
+		name.setCharAt(0, Character.toLowerCase(name.charAt(0)));
+
+		return name.toString();
+	}
+
+	public static String getProducerDefaultName(String methodName)
+	{
+		StringBuffer buffer = new StringBuffer(methodName);
+
+		if (buffer.substring(0, 3).equals("get"))
+		{
+			buffer.setCharAt(3, Character.toLowerCase(buffer.charAt(3)));
+
+			return buffer.substring(3);
+		} else
+		{
+			buffer.setCharAt(0, Character.toLowerCase(buffer.charAt(0)));
+			return buffer.toString();
+		}
+	}
+
+	public static void checkStereoTypeClass(Class<?> clazz)
+	{
+		Asserts.nullCheckForClass(clazz);
+
+		Annotation[] annotations = clazz.getAnnotations();
+
+		boolean deploymentTypeFound = false;
+		boolean scopeTypeFound = false;
+		for (Annotation annotation : annotations)
+		{
+			if (annotation.annotationType().isAnnotationPresent(DeploymentType.class))
+			{
+				if (deploymentTypeFound == true)
+				{
+					throw new WebBeansConfigurationException("@StereoType annotation can not contain more than one @DeploymentType annotation");
+				} else
+				{
+					deploymentTypeFound = true;
+				}
+			} else if (annotation.annotationType().isAnnotationPresent(ScopeType.class))
+			{
+				if (scopeTypeFound == true)
+				{
+					throw new WebBeansConfigurationException("@StereoType annotation can not contain more than one @ScopeType annotation");
+				} else
+				{
+					scopeTypeFound = true;
+				}
+			} else if (annotation.annotationType().equals(Named.class))
+			{
+				Named name = (Named) annotation;
+				if (!name.value().equals(""))
+				{
+					throw new WebBeansConfigurationException("@StereoType annotation can not define @Named annotation with value");
+				}
+			} else if (annotation.annotationType().isAnnotationPresent(BindingType.class))
+			{
+				throw new WebBeansConfigurationException("@StereoType annotation can not define @BindingType annotation");
+			}else if(annotation.annotationType().isAnnotationPresent(InterceptorBindingType.class))
+			{
+				Target target = clazz.getAnnotation(Target.class);
+				ElementType[] type = target.value();
+				
+				if(type.length != 1 && !type[0].equals(ElementType.TYPE))
+				{
+					throw new WebBeansConfigurationException("Stereotype with @InterceptorBindingType must be defined as @Target{TYPE}");
+				}
+				
+			}
+		}
+	}
+
+	public static void configureSpecializations(Class<?> clazz)
+	{
+		Asserts.nullCheckForClass(clazz);
+
+		Bean<?> parent = null;
+		Bean<?> child = null;
+		if ((parent = isConfiguredWebBeans(clazz)) != null)
+		{
+			Class<?> superClass = clazz.getSuperclass();
+			if ((child = isConfiguredWebBeans(superClass)) != null)
+			{
+				int res = DeploymentTypeManager.getInstance().comparePrecedences(parent.getDeploymentType(), child.getDeploymentType());
+				if (res <= 0)
+				{
+					throw new InconsistentSpecializationException("@Specializes exception. Class : " + clazz.getName() + " must have higher deployment type precedence from the class : " + superClass.getName());
+				}
+				parent.getBindingTypes().addAll(child.getBindingTypes());
+			} else
+			{
+				throw new WebBeansConfigurationException("@Specializes exception. WebBean component class : " + clazz.getName() + " does not extends other WebBeans it specialize");
+			}
+		}
+
+	}
+
+	public static Bean<?> isConfiguredWebBeans(Class<?> clazz)
+	{
+		Asserts.nullCheckForClass(clazz);
+
+		Set<Bean<?>> components = ManagerImpl.getManager().getComponents();
+		Iterator<Bean<?>> it = components.iterator();
+
+		while (it.hasNext())
+		{
+			Bean<?> bean = it.next();
+			if (bean.getTypes().contains(clazz))
+			{
+				return bean;
+			}
+		}
+
+		return null;
+	}
+
+	public static void checkSteroTypeRequirements(Set<Class<?>> apiTypes, Class<? extends Annotation> scope, Annotation[] anns, String errorMessage)
+	{
+		Annotation[] stereoTypes = getComponentStereoTypes(anns);
+		for (Annotation stereoType : stereoTypes)
+		{
+			StereoTypeModel model = StereoTypeManager.getInstance().getStereoTypeModel(stereoType.annotationType().getName());
+			Set<Class<?>> rtypes = model.getRestrictedTypes();
+
+			if (rtypes != null)
+			{
+				Iterator<Class<?>> itTypes = rtypes.iterator();
+				while (itTypes.hasNext())
+				{
+					if (!apiTypes.contains(itTypes.next()))
+					{
+						throw new WebBeansConfigurationException(errorMessage + " must contains all supported api types in the @Stereotype annotation " + model.getName());
+
+					}
+				}
+			}
+
+			Set<Class<? extends Annotation>> suppScopes = model.getSupportedScopes();
+			if (suppScopes != null)
+			{
+				if (!suppScopes.isEmpty())
+				{
+					if (!suppScopes.contains(scope))
+					{
+						throw new WebBeansConfigurationException(errorMessage + " must contains all required scope types in the @Stereotype annotation " + model.getName());
+					}
+				}
+			}
+		}
+	}
+
+	public static void checkUnproxiableApiType(Class<?> apiType, ScopeType scopeType)
+	{
+		Asserts.assertNotNull("apiType", "apiType parameter can not be null");
+		Asserts.assertNotNull(scopeType, "scopeType parameter can not be null");
+
+		Constructor<?> cons = ClassUtil.isContaintNoArgConstructor(apiType);
+		if (ClassUtil.isPrivate(cons.getModifiers()) || 
+				ClassUtil.isPrimitive(apiType) || 
+				ClassUtil.isArray(apiType) || 
+				ClassUtil.isFinal(apiType.getModifiers()) 
+				|| ClassUtil.hasFinalMethod(apiType))
+		{
+			if (!scopeType.normal())
+			{
+				throw new UnproxyableDependencyException("WebBeans with api type with normal scope must be proxiable to inject, but class : " + apiType.getName() + " is not proxiable type");
+			}
+		}
+	}
+
+	public static void configureProducerSpecialization(AbstractComponent<?> component, Method method, Class<?> superClass)
+	{
+		Method superMethod = ClassUtil.getClassMethodWithTypes(superClass, method.getName(), Arrays.asList(method.getParameterTypes()));
+		if (superMethod == null)
+		{
+			throw new WebBeansConfigurationException("Producer method specialization is failed. Method " + method.getName() + " not found in supe class : " + superClass.getName());
+		}
+
+		Annotation[] anns = AnnotationUtil.getBindingAnnotations(superMethod.getAnnotations());
+		for (Annotation ann : anns)
+		{
+			component.addBindingType(ann);
+		}
+	}
+
+	public static void checkInjectedMethodParameterConditions(Method method, Class<?> clazz)
+	{
+		Asserts.assertNotNull(method, "method parameter can not be null");
+		Asserts.nullCheckForClass(clazz);
+		
+		Type[] observableTypes = AnnotationUtil.getMethodParameterGenericTypesWithGivenAnnotation(method, Observable.class);
+		EventUtil.checkObservableMethodParameterConditions(observableTypes, "method parameter", "method : " + method.getName() + "in class : " + clazz.getName());
+
+		if(AnnotationUtil.isMethodParameterAnnotationExist(method, Disposes.class) ||
+				AnnotationUtil.isMethodParameterAnnotationExist(method, Observes.class))
+		{
+			throw new WebBeansConfigurationException("Initializer method parameters in method : " + method.getName() + " in class : " + clazz.getName() + 
+				" can not be annotated with @Disposes or @Observers");
+
+		}
+
+	}
+	
+	public static void checkInterceptorResolverParams(Annotation...interceptorBindingTypes)
+	{
+		if(interceptorBindingTypes == null || interceptorBindingTypes.length == 0)
+		{
+			throw new IllegalArgumentException("Manager.resolveInterceptors() method parameter interceptor binding types array argument can not be empty");
+		}
+		
+		Annotation old = null;
+		for(Annotation interceptorBindingType : interceptorBindingTypes)
+		{
+			if(old == null)
+			{
+				old = interceptorBindingType;
+			}
+			else
+			{
+				if(old.equals(interceptorBindingType))
+				{
+					throw new DuplicateBindingTypeException("Manager.resolveInterceptors() method parameter interceptor binding types array argument can not define duplicate binding annotation with name : @" +  old.getClass().getName());
+				}
+				
+				if(!AnnotationUtil.isAnnotationExist(old.annotationType().getDeclaredAnnotations(), InterceptorBindingType.class))
+				{
+					throw new IllegalArgumentException("Manager.resolveInterceptors() method parameter interceptor binding types array can not contain other annotation that is not @InterceptorBindingType"); 
+				}
+			}
+		}	
+	}
+	
+	public static void checkDecoratorResolverParams(Set<Class<?>> apiTypes, Annotation...bindingTypes)
+	{
+		if(apiTypes == null || apiTypes.size() == 0)
+		{
+			throw new IllegalArgumentException("Manager.resolveDecorators() method parameter api types argument can not be empty");
+		}
+		
+		Annotation old = null;
+		for(Annotation bindingType : bindingTypes)
+		{
+			if(old == null)
+			{
+				old = bindingType;
+			}
+			else
+			{
+				if(old.equals(bindingType))
+				{
+					throw new DuplicateBindingTypeException("Manager.resolveDecorators() method parameter binding types array argument can not define duplicate binding annotation with name : @" +  old.getClass().getName());
+				}
+				
+				if(!AnnotationUtil.isAnnotationExist(old.annotationType().getDeclaredAnnotations(), BindingType.class))
+				{
+					throw new IllegalArgumentException("Manager.resolveDecorators() method parameter binding types array can not contain other annotation that is not @BindingType"); 
+				}
+			}
+		}
+		
+	}
+	
+	public static <T> void checkObservableFieldsConditions(Class<T> clazz)
+	{
+		Asserts.nullCheckForClass(clazz);
+		
+		Field[] candidateFields = AnnotationUtil.getClazzFieldsWithGivenAnnotation(clazz, Observable.class);
+		
+		for(Field candidateField : candidateFields)
+		{
+			EventUtil.checkObservableFieldConditions(candidateField.getGenericType(), candidateField.getName(), clazz.getName());
+		}
+
+	}
+	
+	
+	public static <T> void checkPassivationScope(AbstractComponent<T> component, ScopeType scope)
+	{
+		Asserts.assertNotNull(component, "component parameter can not be null");
+		Asserts.assertNotNull(scope, "scope type parameter can not be null");
+		
+		boolean passivating = scope.passivating();
+		Class<T> clazz = component.getReturnType();
+		
+		if(passivating)
+		{
+			if(!component.isSerializable())
+			{
+				throw new WebBeansConfigurationException("WebBeans component implementation class : " + clazz.getName() + " with passivating scope @" + scope.annotationType().getName() + " must be Serializable");
+			}	
+		}		
+	}
+	
+}
\ No newline at end of file

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

Added: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/WebBeansErrorHandler.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/WebBeansErrorHandler.java?rev=719890&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/WebBeansErrorHandler.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/WebBeansErrorHandler.java Sat Nov 22 10:09:38 2008
@@ -0,0 +1,55 @@
+/*
+ *  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.xml;
+
+import org.apache.webbeans.exception.WebBeansException;
+import org.apache.webbeans.logger.WebBeansLogger;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+/**
+ * Implementation of the {@link ErrorHandler} .
+ * <p>
+ * Error handler that is used for handling errors while parsing the document.
+ * </p>
+ * 
+ * @author <a href="mailto:gurkanerdogdu@yahoo.com">Gurkan Erdogdu</a>
+ * @since 1.0
+ */
+public class WebBeansErrorHandler implements ErrorHandler
+{
+	private static WebBeansLogger logger = WebBeansLogger.getLogger(WebBeansErrorHandler.class);
+
+	public void error(SAXParseException exception) throws SAXException
+	{
+		logger.error(exception.getMessage(), exception.getCause());
+		throw new WebBeansException(exception);
+	}
+
+	public void fatalError(SAXParseException exception) throws SAXException
+	{
+		logger.fatal(exception.getMessage(), exception.getCause());
+		throw new WebBeansException(exception);
+	}
+
+	public void warning(SAXParseException exception) throws SAXException
+	{
+		logger.debug(exception.getMessage(),exception.getCause());
+	}
+
+}

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

Added: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/WebBeansNameSpaceContainer.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/WebBeansNameSpaceContainer.java?rev=719890&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/WebBeansNameSpaceContainer.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/WebBeansNameSpaceContainer.java Sat Nov 22 10:09:38 2008
@@ -0,0 +1,85 @@
+/*
+ *  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.xml;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Defines the web beans name space.
+ * 
+ * @author <a href="mailto:gurkanerdogdu@yahoo.com">Gurkan Erdogdu</a>
+ * @since 1.0
+ */
+public class WebBeansNameSpaceContainer
+{
+	/**Hold namespace string to package name*/
+	private Map<String, String> nameSpaceToPackages = new HashMap<String, String>(); 
+
+	/**Singleton instance*/
+	private static WebBeansNameSpaceContainer nameSpaceContainer = new WebBeansNameSpaceContainer();
+	
+	/**
+	 * Private constructor
+	 */
+	private WebBeansNameSpaceContainer()
+	{
+		
+	}
+	
+	/**
+	 * Gets container instance.
+	 * 
+	 * @return singleton instance
+	 */
+	public static WebBeansNameSpaceContainer getInstance()
+	{
+		return nameSpaceContainer;
+	}
+	
+	/**
+	 * Add new name space to package binding.
+	 * 
+	 * @param nameSpace new name space
+	 */
+	public void addNewPackageNameSpace(String nameSpace)
+	{
+		//Check that nameSpace starts with urn:java
+		if(nameSpace.startsWith("urn:java:"))
+		{
+			
+			String packageName = nameSpace.substring("urn:java:".length(), nameSpace.length()) + ".";			
+			nameSpaceToPackages.put(nameSpace, packageName);
+		}
+	}
+	
+	/**
+	 * Gets package string for name space.
+	 * 
+	 * @param nameSpace name space
+	 * @return package for namespace
+	 */
+	public String getPackageNameFromNameSpace(String nameSpace)
+	{
+		if(nameSpaceToPackages.containsKey(nameSpace))
+		{
+			return nameSpaceToPackages.get(nameSpace);
+		}
+		
+		return null;
+	}
+}

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

Added: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/WebBeansResolver.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/WebBeansResolver.java?rev=719890&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/WebBeansResolver.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/WebBeansResolver.java Sat Nov 22 10:09:38 2008
@@ -0,0 +1,89 @@
+/*
+ *  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.xml;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.webbeans.WebBeansConstants;
+import org.apache.webbeans.logger.WebBeansLogger;
+import org.apache.webbeans.util.WebBeansUtil;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+/**
+ * Resolver for the web beans systemId's.
+ * 
+ * @author <a href="mailto:gurkanerdogdu@yahoo.com">Gurkan Erdogdu</a>
+ * @since 1.0
+ */
+public class WebBeansResolver implements EntityResolver
+{
+	/**Logger instance*/
+	private static WebBeansLogger logger = WebBeansLogger.getLogger(WebBeansResolver.class);
+
+	/**
+	 * Resolve entity.
+	 */
+	public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException
+	{
+		logger.debug("Resolving systemId with : " + systemId);
+		
+		if(systemId.equals(WebBeansConstants.WEB_BEANS_XML_SYSID))
+		{
+			InputStream stream = getClass().getClassLoader().getResourceAsStream("org/apache/webbeans/web-beans-1.0.xsd");
+			
+			if(stream != null)
+			{
+				logger.debug("Resolving is success with systemId : " + systemId);
+				return createInputSource(stream, publicId, systemId);
+			}
+		}
+		
+		else if(systemId.startsWith(WebBeansConstants.CLASSPATH_URI_SCHEMA))
+		{
+			String path = systemId.replaceFirst("classpath:", "");
+			InputStream stream = WebBeansUtil.getCurrentClassLoader().getResourceAsStream(path);
+			
+			if(stream != null)
+			{
+				logger.debug("Resolving is success with systemId : " + systemId);
+				return createInputSource(stream, publicId, systemId);
+			}
+		}
+		
+		logger.debug("Resolving is failed with systemId : " + systemId + ", using default SAXResolver");
+		return null;
+	}
+	
+	
+	/*
+	 * Creates the new input source. 
+	 */
+	private InputSource createInputSource(InputStream stream, String publicId, String systemId)
+	{
+		InputSource source = new InputSource();
+		source.setPublicId(publicId);
+		source.setSystemId(systemId);
+		source.setByteStream(stream);
+		
+		return source;
+		
+	}
+
+}