openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gerdo...@apache.org
Subject svn commit: r726301 [1/2] - in /incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml: WebBeansXMLConfigurator.java XMLAnnotationTypeManager.java XMLDefinitionUtil.java XMLSpecializesManager.java XMLUtil.java
Date Sat, 13 Dec 2008 23:28:04 GMT
Author: gerdogdu
Date: Sat Dec 13 15:28:04 2008
New Revision: 726301

URL: http://svn.apache.org/viewvc?rev=726301&view=rev
Log:
XML configuration specific corrections and new classes.

Added:
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/XMLAnnotationTypeManager.java   (with props)
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/XMLDefinitionUtil.java   (with props)
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/XMLSpecializesManager.java   (with props)
Modified:
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/WebBeansXMLConfigurator.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/XMLUtil.java

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/WebBeansXMLConfigurator.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/WebBeansXMLConfigurator.java?rev=726301&r1=726300&r2=726301&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/WebBeansXMLConfigurator.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/WebBeansXMLConfigurator.java Sat Dec 13 15:28:04 2008
@@ -23,6 +23,10 @@
 import java.lang.reflect.Method;
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.sql.Time;
+import java.sql.Timestamp;
 import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.Date;
@@ -36,6 +40,7 @@
 import javax.webbeans.AfterTransactionSuccess;
 import javax.webbeans.BeforeTransactionCompletion;
 import javax.webbeans.BindingType;
+import javax.webbeans.DefinitionException;
 import javax.webbeans.DeploymentException;
 import javax.webbeans.DeploymentType;
 import javax.webbeans.Destructor;
@@ -43,7 +48,7 @@
 import javax.webbeans.IfExists;
 import javax.webbeans.Initializer;
 import javax.webbeans.InterceptorBindingType;
-import javax.webbeans.Named;
+import javax.webbeans.NonexistentConstructorException;
 import javax.webbeans.NonexistentFieldException;
 import javax.webbeans.NonexistentMethodException;
 import javax.webbeans.NonexistentTypeException;
@@ -51,17 +56,22 @@
 import javax.webbeans.Produces;
 import javax.webbeans.Production;
 import javax.webbeans.ScopeType;
+import javax.webbeans.Stereotype;
 
 import org.apache.webbeans.WebBeansConstants;
 import org.apache.webbeans.component.AbstractComponent;
 import org.apache.webbeans.component.xml.XMLComponentImpl;
 import org.apache.webbeans.config.DefinitionUtil;
 import org.apache.webbeans.config.SimpleWebBeansConfigurator;
+import org.apache.webbeans.container.ManagerImpl;
 import org.apache.webbeans.decorator.DecoratorsManager;
 import org.apache.webbeans.deployment.DeploymentTypeManager;
 import org.apache.webbeans.ejb.EJBUtil;
 import org.apache.webbeans.exception.WebBeansConfigurationException;
+import org.apache.webbeans.inject.xml.XMLInjectableConstructor;
+import org.apache.webbeans.inject.xml.XMLInjectionPointModel;
 import org.apache.webbeans.intercept.InterceptorsManager;
+import org.apache.webbeans.proxy.JavassistProxyFactory;
 import org.apache.webbeans.util.AnnotationUtil;
 import org.apache.webbeans.util.Asserts;
 import org.apache.webbeans.util.ClassUtil;
@@ -77,13 +87,20 @@
 @SuppressWarnings("unchecked")
 public final class WebBeansXMLConfigurator
 {
+	/**Enabled Deploy element check*/
 	private static boolean DEPLOY_IS_DEFINED = false;
-
+	
+	/**Enabled Interceptors element check*/
 	private static boolean INTERCEPTORS_IS_DEFINED = false;
-
+	
+	/**Enabled Decorators element check*/
 	private static boolean DECORATORS_IS_DEFINED = false;
 
+	/**Current configuration file name*/
 	private static String CURRENT_SCAN_FILE_NAME = null;
+	
+	/**Annotation type manager that manages the XML defined annotations*/
+	private static XMLAnnotationTypeManager xmlAnnotTypeManager = XMLAnnotationTypeManager.getInstance();
 
 	/**
 	 * Private constructor
@@ -96,8 +113,8 @@
 	/**
 	 * Configures the web beans from the given input stream.
 	 * 
-	 * @param xmlStream
-	 *            xml file containing the web beans definitions.
+	 * @param xmlStream xml file containing the web beans definitions.
+	 * @param fileName name of the configuration file
 	 */
 	public static void configure(InputStream xmlStream, String fileName)
 	{
@@ -110,7 +127,12 @@
 
 		configure(webBeansRoot);
 	}
-
+	
+	/**
+	 * Configures the xml file root element.
+	 * 
+	 * @param webBeansRoot root element of the configuration xml file
+	 */
 	private static void configure(Element webBeansRoot)
 	{
 		List<Element> webBeanDeclerationList = new ArrayList<Element>();
@@ -121,17 +143,21 @@
 		while (it.hasNext())
 		{
 			child = it.next();
-
+			
+			/*WebBean element decleration*/
 			if (XMLUtil.isElementWebBeanDeclaration(child))
 			{
 				webBeanDeclerationList.add(child);
 
-			} else if (XMLUtil.isElementDeployDeclaration(child))
+			} 
+			/*<Deploy> element decleration*/
+			else if (XMLUtil.isElementDeployDeclaration(child))
 			{
 				if (DEPLOY_IS_DEFINED)
 				{
 					throw new DeploymentException("There can not be more than one web-beans.xml file that declares <Deploy> element");
-				} else
+				} 
+				else
 				{
 					if (!XMLUtil.isElementChildExist(child, WebBeansConstants.WEB_BEANS_XML_STANDART_ELEMENT))
 					{
@@ -142,7 +168,9 @@
 					DEPLOY_IS_DEFINED = true;
 
 				}
-			} else if (XMLUtil.isElementInterceptorsDeclaration(child))
+			} 
+			/*<Interceptors> element decleration*/
+			else if (XMLUtil.isElementInterceptorsDeclaration(child))
 			{
 				if (INTERCEPTORS_IS_DEFINED)
 				{
@@ -153,49 +181,195 @@
 					INTERCEPTORS_IS_DEFINED = true;
 
 				}
-			}else if (XMLUtil.isElementDecoratosDeclaration(child))
+			}
+			/*<Decorators> element decleration*/
+			else if (XMLUtil.isElementDecoratosDeclaration(child))
 			{
 				if (DECORATORS_IS_DEFINED)
 				{
 					throw new WebBeansConfigurationException("There can not be more than one web-beans.xml file that declares <Decorators> element");
-				} else
+				} 
+				else
 				{
 					configureDecoratorsElement(child);
 					DECORATORS_IS_DEFINED = true;
 
 				}
 			}
-
-			if (!DEPLOY_IS_DEFINED)
+			/*<BindingType> annotation element decleration*/
+			else if(XMLUtil.isElementBindingTypeDecleration(child))
 			{
-				DeploymentTypeManager.getInstance().addNewDeploymentType(Production.class, 1);
+				addNewBindingType(child);
+				
 			}
+			/*<InterceptorBindingType> annotation element decleration*/
+			else if(XMLUtil.isElementInterceptorBindingTypeDecleration(child))
+			{
+				addNewInterceptorBindingType(child);
+				
+			}
+			/*<Stereotype> annotation element decleration*/
+			else if(XMLUtil.isElementStereoTypeDecleration(child))
+			{
+				addNewStereoTypeType(child);
+			}			
 		}
 		
+		/*If no <Deploy> element is defined in any webbeans.xml in the current application*/
+		if (!DEPLOY_IS_DEFINED)
+		{
+			DeploymentTypeManager.getInstance().addNewDeploymentType(Production.class, 1);
+		}		
+		
 		//Configures the WebBeans components
 		configureWebBeansComponents(webBeanDeclerationList);
 		
 	}
 	
-	private static void configureWebBeansComponents(List<Element> webBeanDecleration)
+	/**
+	 * Configures the webbeans defined in the xml file.
+	 * 
+	 * @param listOfWebBeanDecleration list of element that specifies new webbean decleration 
+	 */
+	private static void configureWebBeansComponents(List<Element> listOfWebBeanDecleration)
 	{
-		if(!webBeanDecleration.isEmpty())
+		if(!listOfWebBeanDecleration.isEmpty())
 		{
-			Iterator<Element> it = webBeanDecleration.iterator();
+			Iterator<Element> it = listOfWebBeanDecleration.iterator();
 			while (it.hasNext())
 			{
 				Element child = it.next();
+				/*JMS webbeans*/
 				if (XMLUtil.isElementJMSDeclaration(child))
-				{
+				{	
 					configureJMSEndpointComponent(child);
-				} else
+				} 
+				/*Simple or Enterprise webbean*/
+				else
 				{
 					configureNewWebBeanComponent(child);
 				}				
 			}
 		}
 	}
-
+	
+	/**
+	 * Configure and add new binding type annotation.
+	 * 
+	 * @param bindingTypeElement new binding type element
+	 */
+	private static void addNewBindingType(Element bindingTypeElement)
+	{
+		Class<?> clazz =XMLUtil.getElementJavaType(bindingTypeElement);
+		if(clazz == null)
+		{
+			throw new NonexistentTypeException(createConfigurationFailedMessage() +"Binding type with given class : " + bindingTypeElement.getName() + " not found");
+		}
+		
+		Class<? extends Annotation> clazzAnnot = null;
+		if(!clazz.isAnnotation())
+		{
+			throw new WebBeansConfigurationException(createConfigurationFailedMessage() + "Binding type with given class : " + bindingTypeElement.getName() + " is not an annotation type");
+		}
+		else
+		{
+			clazzAnnot =  (Class<? extends Annotation>)clazz;
+		}
+		
+		if(clazz.isAnnotationPresent(BindingType.class))
+		{
+			throw new WebBeansConfigurationException(createConfigurationFailedMessage() + "Binding type with given class : " + bindingTypeElement.getName() + " is already defined as @BindingType");
+		}
+		
+		if(xmlAnnotTypeManager.isBindingTypeExist(clazzAnnot))
+		{
+			throw new WebBeansConfigurationException(createConfigurationFailedMessage() + "Binding type with given class : " + bindingTypeElement.getName() + " is already defined in the XML");
+		}
+		
+		xmlAnnotTypeManager.addBindingType(clazzAnnot);
+	}
+	
+	/**
+	 * Configures and adds new interceptor binding type annotation.
+	 * 
+	 * @param interceptorBindingTypeElement new interceptor binding type element
+	 */
+	private static void addNewInterceptorBindingType(Element interceptorBindingTypeElement)
+	{
+		Class<?> clazz =XMLUtil.getElementJavaType(interceptorBindingTypeElement);
+		if(clazz == null)
+		{
+			throw new NonexistentTypeException(createConfigurationFailedMessage() +"InterceptorBinding type with given class : " + interceptorBindingTypeElement.getName() + " not found");
+		}
+		
+		Class<? extends Annotation> clazzAnnot = null;
+		if(!clazz.isAnnotation())
+		{
+			throw new WebBeansConfigurationException(createConfigurationFailedMessage() + "InterceptorBinding type with given class : " + interceptorBindingTypeElement.getName() + " is not an annotation type");
+		}
+		else
+		{
+			clazzAnnot =  (Class<? extends Annotation>)clazz;
+		}
+		
+		if(clazz.isAnnotationPresent(InterceptorBindingType.class))
+		{
+			throw new WebBeansConfigurationException(createConfigurationFailedMessage() + "InterceptorBinding type with given class : " + interceptorBindingTypeElement.getName() + " is already defined as @InterceptorBindingType");
+		}
+		
+		
+		if(xmlAnnotTypeManager.isInterceptorBindingTypeExist(clazzAnnot))
+		{
+			throw new WebBeansConfigurationException(createConfigurationFailedMessage() + "InterceptorBinding type with given class : " + interceptorBindingTypeElement.getName() + " is already defined in the XML");
+		}
+		
+		xmlAnnotTypeManager.addInterceotorBindingType(clazzAnnot);
+		
+	}
+	
+	/**
+	 * Configures and adds new stereotype annotation.
+	 * 
+	 * @param stereoTypeElement new stereotype annotation element
+	 */
+	private static void addNewStereoTypeType(Element stereoTypeElement)
+	{
+		Class<?> clazz =XMLUtil.getElementJavaType(stereoTypeElement);
+		if(clazz == null)
+		{
+			throw new NonexistentTypeException(createConfigurationFailedMessage() +"Stereotype with given class : " + stereoTypeElement.getName() + " not found");
+		}
+		
+		Class<? extends Annotation> clazzAnnot = null;
+		if(!clazz.isAnnotation())
+		{
+			throw new WebBeansConfigurationException(createConfigurationFailedMessage() + "Stereotype with given class : " + stereoTypeElement.getName() + " is not an annotation type");
+		}
+		else
+		{
+			clazzAnnot =  (Class<? extends Annotation>)clazz;
+		}
+		
+		if(clazz.isAnnotationPresent(Stereotype.class))
+		{
+			throw new WebBeansConfigurationException(createConfigurationFailedMessage() + "Stereotype with given class : " + stereoTypeElement.getName() + " is already defined as @StereoType");
+		}
+		
+		
+		if(xmlAnnotTypeManager.isStereoTypeExist(clazzAnnot))
+		{
+			throw new WebBeansConfigurationException(createConfigurationFailedMessage() + "Stereotype with given class : " + stereoTypeElement.getName() + " is already defined in the XML");
+		}
+		
+		xmlAnnotTypeManager.addStereoType(clazzAnnot);
+		
+	}
+	
+	/**
+	 * Configures enablements of the interceptors.
+	 * 
+	 * @param interceptorsElement interceptors element
+	 */
 	private static void configureInterceptorsElement(Element interceptorsElement)
 	{
 		List<Element> childs = interceptorsElement.elements();
@@ -209,17 +383,17 @@
 
 			if (clazz == null)
 			{
-				throw new WebBeansConfigurationException("Interceptor class : " + XMLUtil.getName(child) + " not found");
+				throw new WebBeansConfigurationException(createConfigurationFailedMessage() + "Interceptor class : " + XMLUtil.getName(child) + " not found");
 			} else
 			{
 				if (!AnnotationUtil.isMetaAnnotationExist(clazz.getAnnotations(), InterceptorBindingType.class))
 				{
-					throw new WebBeansConfigurationException("Interceptor class : " + XMLUtil.getName(child) + " must have at least one @InterceptorBindingType");
+					throw new WebBeansConfigurationException(createConfigurationFailedMessage() +"Interceptor class : " + XMLUtil.getName(child) + " must have at least one @InterceptorBindingType");
 				}
 
 				if (manager.isInterceptorEnabled(clazz))
 				{
-					throw new WebBeansConfigurationException("Interceptor class : " + XMLUtil.getName(child) + " is already defined");
+					throw new WebBeansConfigurationException(createConfigurationFailedMessage() +"Interceptor class : " + XMLUtil.getName(child) + " is already defined");
 				}
 
 				manager.addNewInterceptor(clazz);
@@ -229,6 +403,11 @@
 
 	}
 	
+	/**
+	 * Configures enablements of the decorators.
+	 * 
+	 * @param decoratorsElement decorators element
+	 */
 	private static void configureDecoratorsElement(Element decoratorsElement)
 	{
 		List<Element> childs = decoratorsElement.elements();
@@ -242,13 +421,13 @@
 
 			if (clazz == null)
 			{
-				throw new WebBeansConfigurationException("Decorator class : " + XMLUtil.getName(child) + " not found");
+				throw new WebBeansConfigurationException(createConfigurationFailedMessage() +"Decorator class : " + XMLUtil.getName(child) + " not found");
 			} else
 			{
 
 				if (manager.isDecoratorEnabled(clazz))
 				{
-					throw new WebBeansConfigurationException("Decorator class : " + XMLUtil.getName(child) + " is already defined");
+					throw new WebBeansConfigurationException(createConfigurationFailedMessage() +"Decorator class : " + XMLUtil.getName(child) + " is already defined");
 				}
 
 				manager.addNewDecorator(clazz);
@@ -258,7 +437,11 @@
 
 	}
 	
-
+	/**
+	 * Configures enablements of the deployment types.
+	 * 
+	 * @param deployElement deploy element
+	 */
 	private static void configureDeploymentTypes(Element deployElement)
 	{
 		List<Element> childs = deployElement.elements();
@@ -272,17 +455,17 @@
 
 			if (clazz == null)
 			{
-				throw new WebBeansConfigurationException("@DeploymentType annotation with name : " + XMLUtil.getName(child) + " not found");
+				throw new WebBeansConfigurationException(createConfigurationFailedMessage() +"@DeploymentType annotation with name : " + XMLUtil.getName(child) + " not found");
 			} else
 			{
 				if (!clazz.isAnnotation())
-					throw new WebBeansConfigurationException("@DeploymentType annotation with name : " + XMLUtil.getName(child) + " is not annotation type");
+					throw new WebBeansConfigurationException(createConfigurationFailedMessage() +"@DeploymentType annotation with name : " + XMLUtil.getName(child) + " is not annotation type");
 				else
 				{
 					Annotation ann = clazz.getAnnotation(DeploymentType.class);
 					if (ann == null)
 					{
-						throw new WebBeansConfigurationException("@DeploymentType annotation with name : " + XMLUtil.getName(child) + " is not deployment type annotation");
+						throw new WebBeansConfigurationException(createConfigurationFailedMessage() +"@DeploymentType annotation with name : " + XMLUtil.getName(child) + " is not deployment type annotation");
 					} else
 					{
 						DeploymentTypeManager.getInstance().addNewDeploymentType((Class<? extends Annotation>) clazz, j++);
@@ -293,18 +476,15 @@
 	}
 
 	/**
-	 * Configures web beans element.
+	 * Configures new webbeans component from the given webbeans element.
 	 * 
-	 * @param webBeanElement
-	 *            web beans element
+	 * @param webBeanElement web beans element
 	 */
 	private static void configureNewWebBeanComponent(Element webBeanElement)
 	{
 		String ns = XMLUtil.getElementNameSpace(webBeanElement);
 		String packageName = WebBeansNameSpaceContainer.getInstance().getPackageNameFromNameSpace(ns);
-
 		String className = packageName + XMLUtil.getName(webBeanElement);
-
 		Class<?> clazz = ClassUtil.getClassFromName(className);
 
 		if (clazz == null)
@@ -313,16 +493,19 @@
 		}
 
 		boolean ok = false;
-
+		
+		/*Enterprise WebBean*/
 		if (EJBUtil.isEJBClass(clazz))
 		{
 			// Configure for EJB
 			configureEJBWebBean(clazz);
 			ok = true;
-		} else
+		} 
+		else
 		{
 			if (ClassUtil.isConcrete(clazz) && !ClassUtil.isParametrized(clazz))
-			{
+			{	
+				/*Simple WebBeans*/
 				if (SimpleWebBeansConfigurator.isSimpleWebBean(clazz))
 				{
 					// Configure Simple WebBean
@@ -344,14 +527,17 @@
 	/**
 	 * Configures the simple web bean from the class.
 	 * 
-	 * @param simpleClass
-	 *            concrete java class
+	 * @param simpleClass concrete java class
+	 * @param webBeanDecleration webbeans element
 	 */
 	private static <T> void configureSimpleWebBean(Class<T> simpleClass, Element webBeanDecleration)
 	{
 		XMLComponentImpl<T> component = new XMLComponentImpl<T>(simpleClass);
-
+		
+		/*Configures API type of the webbeans component*/
 		DefinitionUtil.defineApiTypes(component, simpleClass);
+		
+		/*Configures child elements of this webbeans decleration element*/
 		configureWebBeanDeclerationChilds(component, webBeanDecleration);
 
 		// Check if the deployment type is enabled.
@@ -359,13 +545,22 @@
 		{
 			component = null;
 			return;
-		} else
+			
+		} 
+		/*Add manager*/
+		else
 		{
-			// Add to manager
+			ManagerImpl.getManager().addBean(component);
 		}
 
 	}
-
+	
+	/**
+	 * Configures the childs element of the given webbeans decleration element.
+	 * 
+	 * @param component xml webbeans element
+	 * @param webBeanDecleration webbeans element
+	 */
 	private static <T> void configureWebBeanDeclerationChilds(XMLComponentImpl<T> component, Element webBeanDecleration)
 	{
 		List<Element> childs = webBeanDecleration.elements();
@@ -373,12 +568,14 @@
 
 		Element child = null;
 
-		/* Constructor api type */
+		/* Constructor api type list*/
 		List<Class<?>> constTypeList = new ArrayList<Class<?>>();
-
-		List<Element> constElement = new ArrayList<Element>();
-
-		Set<Annotation> annotationSet = new HashSet<Annotation>();
+		
+		/*Constructor parameters element*/
+		List<Element> constructorParameterElementList = new ArrayList<Element>();
+		
+		/*Annotation set defined for webbeans*/
+		Set<Class<? extends Annotation>> annotationSet = new HashSet<Class<? extends Annotation>>();
 
 		boolean isConstructor = false;
 		String fieldOrMethodName = null;
@@ -387,14 +584,15 @@
 			child = it.next();
 			Class<?> type = XMLUtil.getElementJavaType(child);
 
+			//Java type then 2 possible outcome, Annotation type meta-data or constructor
 			if (type != null)
 			{
 				if (type.isAnnotation())
 				{
+					//Annotation types defined on the webbeans
 					Class<? extends Annotation> annot = (Class<Annotation>) type;
-					Annotation annotType = ClassUtil.getAnnotationLiteral(annot);
-
-					annotationSet.add(annotType);
+					
+					annotationSet.add(annot);
 
 				} else
 				{
@@ -402,12 +600,16 @@
 					{
 						isConstructor = true;
 					}
-
+					
+					constructorParameterElementList.add(child);
+					
+					//Adding constructor parameter class types
 					constTypeList.add(type);
-					constElement.add(child);
 
 				}
-			} else
+			} 
+			//Field or method decleration
+			else
 			{
 				// Namespace check
 				if (XMLUtil.getElementNameSpace(child).equals(XMLUtil.getElementNameSpace(webBeanDecleration)))
@@ -420,12 +622,20 @@
 						{
 							throw new WebBeansConfigurationException(createConfigurationFailedMessage() + "This field/method with name : " + fieldOrMethodName + " is already defined.");
 						}
-					} else
+						
+						else
+						{
+							configureFieldOrMethodMetaData(component, child);
+							fieldOrMethodName = name;
+						}						
+					}
+					else
 					{
-						fieldOrMethodName = name;
-						configureFieldMethodMetaData(component, child, webBeanDecleration);
+						configureFieldOrMethodMetaData(component, child);
+						fieldOrMethodName = name;						
 					}
-				} else
+				} 
+				else
 				{
 					throw new WebBeansConfigurationException(createConfigurationFailedMessage());
 				}
@@ -434,40 +644,76 @@
 
 		}
 
+		//Check Annotation Types
+		XMLDefinitionUtil.checkTypeMetaDataClasses(annotationSet, createConfigurationFailedMessage());
+		
 		// Configure type-level metadata
 		configureTypeLevelMetaData(component, annotationSet, webBeanDecleration);
-
+			
+		//Constructor decleration
 		if (isConstructor)
 		{
 			// Configure constructor parameters
-			configureConstructorMetaData(component, constTypeList, constElement, webBeanDecleration);
+			configureConstructorMetaData(component, constTypeList, constructorParameterElementList);
+		}
+		else
+		{
+			//Default constructor
+			component.setConstructor(WebBeansUtil.defineConstructor(component.getReturnType()));
 		}
 
 	}
 
-	private static <T> void configureTypeLevelMetaData(XMLComponentImpl<T> component, Set<Annotation> annotationSet, Element webBeanDecleration)
+	private static <T> void configureTypeLevelMetaData(XMLComponentImpl<T> component, Set<Class<? extends Annotation>> annotationSet, Element webBeanDecleration)
 	{
-		Annotation[] anns = new Annotation[annotationSet.size()];
-		anns = annotationSet.toArray(anns);
-
-		configureDeploymentType(component, anns);
-		configureScopeType(component, anns);
-		configureBindingType(component, anns);
-		configureInterceptorBindingType(component, anns);
-		configureStereoType(component, anns);
-		configureNamed(component, anns);
-		configureSpecializes(component, anns);
-		configureInterceptor(component, anns);
-		configureDecorator(component, anns);
-
+		//Deployment Type
+		configureDeploymentType(component, annotationSet);
+		
+		//Scope Type
+		configureScopeType(component, annotationSet);
+		
+		//Binding Type
+		configureBindingType(component, annotationSet);
+		
+		//InterceptorBinding Type
+		configureInterceptorBindingType(component, annotationSet);
+		
+		//StereoType
+		configureStereoType(component, annotationSet);
+		
+		//Name configuration
+		configureNamed(component, annotationSet, webBeanDecleration);
+		
+		//Specializations
+		configureSpecializes(component, annotationSet);
+		
+		//Interceptors
+		configureInterceptor(component, annotationSet);
+		
+		//Decorators
+		configureDecorator(component, annotationSet);
+		
 	}
 
-	private static <T> void configureConstructorMetaData(XMLComponentImpl<T> component, List<Class<?>> typeList, List<Element> typeElement, Element webBeanDecleration)
+	/**
+	 * Configures the component constructor. When resolution
+	 * dependency of the constructor injection points, constructor
+	 * parameter type defined in the xml is used.
+	 * 
+	 * @param component xml webbeans component
+	 * @param typeList list of the constructor parameter types
+	 * @param constructorParameterListElement parameter list element 
+	 * 
+	 * @throws DefinitionException if more than one constructor exists
+	 * @throws NonexistentConstructorException if no constructor exists
+	 */
+	private static <T> void configureConstructorMetaData(XMLComponentImpl<T> component, List<Class<?>> typeList, List<Element> constructorParameterListElement)
 	{
 		Class<T> implClazz = component.getReturnType();
 		Constructor<T> cons[] = ClassUtil.getConstructors(implClazz);
 
 		boolean found = false;
+		Constructor<T> componentConstructor = null;
 		for (Constructor<T> constructor : cons)
 		{
 			Class<?>[] pt = constructor.getParameterTypes();
@@ -478,20 +724,18 @@
 				int j = 0;
 				boolean ok = false;
 
-				for (Class<?> p : pt)
+				for (Class<?> parameterType : pt)
 				{
-					Class<?> type = typeList.get(j);
+					Class<?> xmlType = typeList.get(j);
 
-					if (ClassUtil.isAssignable(p, type))
+					if (ClassUtil.isAssignable(parameterType, xmlType))
 					{
-						if (!p.equals(type))
+						if(!ok)
 						{
-							// sub-type
-							component.addConstructorApiType(type);
+							ok = true;	
 						}
-
-						ok = true;
-					} else
+					} 
+					else
 					{
 						ok = false;
 					}
@@ -504,9 +748,11 @@
 					if (found)
 					{
 						throw new WebBeansConfigurationException(createConfigurationFailedMessage() + "More than one constructor decleration exist.");
-					} else
+					} 
+					else
 					{
 						found = true;
+						componentConstructor = constructor;
 					}
 				}
 
@@ -516,33 +762,64 @@
 
 		if (!found)
 		{
-			throw new WebBeansConfigurationException(createConfigurationFailedMessage() + "Constructor decleration not found in the class.");
+			throw new NonexistentConstructorException(createConfigurationFailedMessage() + "Constructor decleration not found in the class.");
+		}	
+		
+		XMLInjectableConstructor<T> injectableConstructor = new XMLInjectableConstructor<T>(componentConstructor,component);
+		for(Element element : constructorParameterListElement)
+		{
+			XMLInjectionPointModel model = XMLUtil.getInjectionPointModel(element, createConfigurationFailedMessage());
+			injectableConstructor.addInjectionPointModel(model);
 		}
-
+		
+		component.setInjectableConstructor(injectableConstructor);
 	}
 
-	private static <T> void configureFieldMethodMetaData(XMLComponentImpl<T> component, Element child, Element webBeanDecleration)
+	/**
+	 * Configures the field or method of the xml webbeans
+	 * component. Checks for the field or method definition
+	 * and call corresponding method.
+	 * 
+	 * @param component xml webbeans component
+	 * @param child field or method child element
+	 */
+	private static <T> void configureFieldOrMethodMetaData(XMLComponentImpl<T> component, Element child)
 	{
 		if (XMLUtil.isElementField(child))
 		{
-			configureField(component, child, webBeanDecleration);
+			configureField(component, child);
+			
 		} else if (XMLUtil.isElementMethod(child))
 		{
-			configureMethod(component, child, webBeanDecleration);
+			configureMethod(component, child);
 		}
 	}
 
-	private static <T> void configureField(XMLComponentImpl<T> component, Element child, Element webBeanDecleration)
+	/**
+	 * Configures the given child element as field
+	 * of the webbeans component.
+	 * 
+	 * @param component xml webbeans component
+	 * @param child field element
+	 * 
+	 * @throws NonexistentFieldException if field not exist
+	 * @throws DefinitionException if field type declared in 
+	 * 		   the xml is not assignable to the type declared in class
+	 * @throws DefinitionException if contains more than one &lt;valuegt; element childs
+	 * 
+	 */
+	private static <T> void configureField(XMLComponentImpl<T> component, Element child)
 	{
 		Class<?> clazz = component.getReturnType();
+
 		String fieldName = XMLUtil.getName(child);
 		Field field = ClassUtil.getFieldWithName(clazz, fieldName);
 
-		if (!ClassUtil.classHasFieldWithName(clazz, fieldName))
+		if (field == null)
 		{
 			throw new NonexistentFieldException(createConfigurationFailedMessage() + "Field name : " + fieldName + " decleration not found in the class : " + clazz.getName());
 		}
-
+		
 		boolean isValueElement = false;
 
 		if (child.isTextOnly())
@@ -562,8 +839,6 @@
 		while (itChilds.hasNext())
 		{
 			Element directChild = itChilds.next();
-			String directChildName = XMLUtil.getName(directChild);
-
 			if (XMLUtil.isElementInWebBeansNameSpaceWithName(directChild, WebBeansConstants.WEB_BEANS_XML_VALUE_ELEMENT))
 			{
 				if (!isValueElement)
@@ -573,19 +848,17 @@
 
 			} else
 			{
-				// TODO injection field
-				Class<?> directChildType = ClassUtil.getClassFromName(directChildName);
-
+				Class<?> directChildType = XMLUtil.getElementJavaType(directChild);
 				if (!ClassUtil.isAssignable(field.getType(), directChildType))
 				{
-					throw new WebBeansConfigurationException(createConfigurationFailedMessage() + "Declared field type is not assginable to class field type");
+					throw new WebBeansConfigurationException(createConfigurationFailedMessage() + "Declared field type is not assignable to class field type");
 				} else
 				{
-					if (!directChildType.equals(field.getType()))
-					{
-						component.addFieldApiType(directChildType, fieldName);
-
-					}
+//					if (!directChildType.equals(field.getType()))
+//					{
+//						component.addFieldApiType(directChildType, fieldName);
+//
+//					}
 
 					isTypeElement = true;
 				}
@@ -606,12 +879,22 @@
 			}
 		}
 
-		// value decleration
-		configureFieldValues(component, field, child, webBeanDecleration, isValueElement);
+		// configure field values if available.
+		configureFieldValues(component, field, child, isValueElement);
 
 	}
-
-	private static <T> void configureMethod(XMLComponentImpl<T> component, Element child, Element webBeanDecleration)
+	
+	/**
+	 * Configures the method of the webbeans component.
+	 * 
+	 * @param component xml webbeans component
+	 * @param child method element
+	 * 
+	 * @throws NonexistentMethodException if method with name does not exist
+	 * @throws NonexistentTypeException if method parameter types can not found
+	 * @throws DefinitionException if any other configuration related exception occurs.
+	 */
+	private static <T> void configureMethod(XMLComponentImpl<T> component, Element child)
 	{
 		if (!ClassUtil.isMethodExistWithName(component.getReturnType(), XMLUtil.getName(child)))
 		{
@@ -621,168 +904,323 @@
 		List<Element> methodChilds = child.elements();
 		Iterator<Element> itMethodChilds = methodChilds.iterator();
 
-		boolean isDefineDisposes = false;
-		boolean isDefineObserves = false;
-		boolean isDefineInitializes = false;
-		boolean isDefineDestructor = false;
-		boolean isDefineProduces = false;
-
+		boolean isDefineType = false;
+		
+		/*
+		<Initializes>  = 0;
+		<Produces> = 1;
+		<Disposes> = 2;
+		<Observes> = 3;
+		<Destructor> = 4;
+		InterceptorBindingType annotation on method = 5; 
+		*/
+		int type = 0;
+		
 		List<Class<?>> methodParameters = new ArrayList<Class<?>>();
-
+		List<Element> methodParameterElements = new ArrayList<Element>();
+		
+		Element methodChild = null;
+		
 		while (itMethodChilds.hasNext())
 		{
-			Element methodChild = itMethodChilds.next();
+			methodChild = itMethodChilds.next();
 			Class<?> childClazz = XMLUtil.getElementJavaType(methodChild);
 
+			final String moreThanOneChildTypeErrorMesg = createConfigurationFailedMessage() + XMLUtil.getName(methodChild) + "method declaration can not contain more than one <Initializer>, <Destructor>, <Produces>, <Disposes> or <Observes> element";
+			
 			if (childClazz == null)
 			{
 				throw new NonexistentTypeException(createConfigurationFailedMessage() + "Direct child element of method : " + XMLUtil.getName(methodChild) + " does not corresponds to any Java type");
-			} else
+			} 
+			else
 			{
 				if (childClazz.isAnnotation())
 				{
 					if (childClazz.equals(Disposes.class))
 					{
-						if (isDefineDisposes)
+						if (isDefineType)
 						{
-							throw new WebBeansConfigurationException(createConfigurationFailedMessage() + XMLUtil.getName(methodChild) + "method declaration can not contain more than one @Disposes annotation");
-						} else
+							throw new WebBeansConfigurationException(moreThanOneChildTypeErrorMesg);
+						} 
+						else
 						{
-							configureDisposes(component, methodChild);
-							isDefineDisposes = true;
+							checkConfigureDisposes(component, methodChild);
+							isDefineType = true;
+							type = 2;
 						}
 
-					} else if (childClazz.equals(Observes.class))
+					} 
+					else if (childClazz.equals(Observes.class))
 					{
-						if (isDefineObserves)
+						if (isDefineType)
 						{
-							throw new WebBeansConfigurationException(createConfigurationFailedMessage() + XMLUtil.getName(methodChild) + "method declaration can not contain more than one @Observes annotation");
+							throw new WebBeansConfigurationException(moreThanOneChildTypeErrorMesg);
 						} else
 						{
-							configureObserves(component, methodChild);
-							isDefineObserves = true;
+							checkConfigureObserves(component, methodChild);
+							isDefineType = true;
+							type = 3;
 						}
-					} else
+					} 
+					else if (childClazz.equals(Initializer.class))
 					{
-						if (childClazz.equals(Initializer.class))
+						if (isDefineType)
+						{
+							throw new WebBeansConfigurationException(moreThanOneChildTypeErrorMesg);
+						} else
 						{
-							if (isDefineInitializes)
-							{
-								throw new WebBeansConfigurationException(createConfigurationFailedMessage() + XMLUtil.getName(methodChild) + "method declaration can not contain more than one @Initializer annotation");
-							} else
-							{
-								isDefineInitializes = true;
-							}
-
-						} else if (childClazz.equals(Destructor.class))
-						{
-							if (isDefineDestructor)
-							{
-								throw new WebBeansConfigurationException(createConfigurationFailedMessage() + XMLUtil.getName(methodChild) + "method declaration can not contain more than one @Destructor annotation");
-							} else
-							{
-								isDefineDestructor = true;
-							}
-
-						} else if (childClazz.equals(Produces.class))
-						{
-							if (isDefineProduces)
-							{
-								throw new WebBeansConfigurationException(createConfigurationFailedMessage() + XMLUtil.getName(methodChild) + "method declaration can not contain more than one @Produces annotation");
-							} else
-							{
-								isDefineProduces = true;
-							}
+							isDefineType = true;
+							type = 0;
+						}
 
+					} 
+					else if (childClazz.equals(Destructor.class))
+					{
+						if (isDefineType)
+						{
+							throw new WebBeansConfigurationException(moreThanOneChildTypeErrorMesg);
 						} else
 						{
-							throw new WebBeansConfigurationException(createConfigurationFailedMessage() + "Direct child element of method : " + XMLUtil.getName(methodChild) + " with Java type : " + childClazz + " is unknown");
+							isDefineType = true;
+							type = 4;
+						}
+
+					} 
+					else if (childClazz.equals(Produces.class))
+					{
+						if (isDefineType)
+						{
+							throw new WebBeansConfigurationException(moreThanOneChildTypeErrorMesg);
+						} 
+						else
+						{
+							isDefineType = true;
+							type = 1;
 						}
 					}
+					else if(childClazz.isAnnotationPresent(InterceptorBindingType.class))
+					{
+						//InterceptorBindingType with method
+						type = 5;
+					}
+					else
+					{
+							throw new WebBeansConfigurationException(createConfigurationFailedMessage() + "Direct child element of method : " + XMLUtil.getName(methodChild) + " with Java type : " + childClazz + " is unknown");
+					}
 				}
 				// Method parameter
 				else
 				{
 					methodParameters.add(childClazz);
+					methodParameterElements.add(methodChild);
 				}
 			}
 		}
+		
+		//Check method conditions with method name and its parameter types.
+		Method annotatedMethod = checkConfigureMethodConditions(component, child, methodParameters);
+		
+		//Configures method according to the type of the element in 0,1,2,3,4,5
+		configureMethodAnnotationType(component, annotatedMethod, child, type, methodParameterElements);
 
-		List<Method> definedMethods = ClassUtil.getClassMethodsWithTypes(component.getReturnType(), XMLUtil.getName(child), methodParameters);
+	}
+	
+	/**
+	 * Configures the webbeans component methods that are
+	 * defines in the xml.
+	 * 
+	 * @param component xml webbeans component
+	 * @param annotatedMethod annotated method to configure
+	 * @param annotChild element child
+	 * @param type type of the configuration method
+	 */
+	private static <T> void configureMethodAnnotationType(XMLComponentImpl<T> component, Method annotatedMethod, Element annotChild, int type, List<Element> methodParameterElements)
+	{
+		switch (type)
+		{
+		case 0:
+			
+			configureMethodInitializeAnnotation(component, annotatedMethod, methodParameterElements);
+			break;
+
+		case 1:
+			configureMethodProducesAnnotation(component, annotatedMethod, annotChild);
+			break;
+			
+		case 2:
+			configureMethodDisposesAnnotation(component, annotatedMethod, annotChild);
+			break;
+		
+		case 3:
+			configureMethodObservesAnnotation(component, annotatedMethod, annotChild);
+			break;
+		
+		case 4:
+			configureMethodDestructorAnnotation(component, annotatedMethod, annotChild);
+			break;
+		
+		case 5:
+			configureMethodInterceptorBindingTypeAnnotation(component, annotatedMethod, annotChild);
+			break;
+		}
+	}
+	
+	/**
+	 * Configures the initializor method of the webbeans component.
+	 * 
+	 * @param component xml webbeans component
+	 * @param initializeMethod initialize method of the webbeans component
+	 * @param annotChild element child
+	 */
+	private static <T> void configureMethodInitializeAnnotation(XMLComponentImpl<T> component, Method initializeMethod, List<Element> methodParameterElements)
+	{
+		for(Element element : methodParameterElements)
+		{
+			XMLInjectionPointModel model = XMLUtil.getInjectionPointModel(element, createConfigurationFailedMessage());
+			component.addMethodInjectionPoint(initializeMethod, model);
+		}
+	}
+	
+	private static <T> void configureMethodDestructorAnnotation(XMLComponentImpl<T> component, Method destructorMethod, Element annotChild)
+	{
+		//TODO
+	}
+
+	private static <T> void configureMethodProducesAnnotation(XMLComponentImpl<T> component, Method producesMethod, Element annotChild)
+	{
+		
+		
+	}
 
+	private static <T> void configureMethodDisposesAnnotation(XMLComponentImpl<T> component, Method disposesMethod, Element annotChild)
+	{
+		
+	}
+
+	private static <T> void configureMethodObservesAnnotation(XMLComponentImpl<T> component, Method observesMethod, Element annotChild)
+	{
+		
+	}
+	
+	private static <T> void configureMethodInterceptorBindingTypeAnnotation(XMLComponentImpl<T> component, Method interceptorMethod, Element annotChild)
+	{
+		
+	}
+	
+	
+	/**
+	 * Check method conditions for the webbeans component.
+	 * 
+	 * @param component xml webbeans component
+	 * @param child method element
+	 * @param methodParameters method parameter types
+	 * 
+	 * @throws NonexistentMethodException if no method is exist with given name and method parameter types
+	 * @throws DefinitionException if more than one method satisfies the conditions 
+	 */
+	private static <T> Method checkConfigureMethodConditions(XMLComponentImpl<T> component, Element child, List<Class<?>> methodParameters)
+	{
+		//Check with name and also parameter types
+		List<Method> definedMethods = ClassUtil.getClassMethodsWithTypes(component.getReturnType(), XMLUtil.getName(child), methodParameters);
+		
 		if (definedMethods.size() == 0)
 		{
 			throw new NonexistentMethodException(createConfigurationFailedMessage() + "Method declaration with name " + XMLUtil.getName(child) + " is not found in the class : " + component.getReturnType().getName());
-		} else if (definedMethods.size() > 1)
+			
+		} 
+		else if (definedMethods.size() > 1)
 		{
 			throw new WebBeansConfigurationException(createConfigurationFailedMessage() + "More than one method : " + XMLUtil.getName(child) + " is found in the class : " + component.getReturnType().getName());
-		} else
-		{
-			Method result = definedMethods.get(0);
-			Class<?>[] actualParams = result.getParameterTypes();
-			int j = 0;
-			for (Class<?> paramClazz : methodParameters)
-			{
-				if (actualParams[j].isAssignableFrom(paramClazz))
-				{
-					if (!actualParams[j].equals(paramClazz))
-					{
-						component.addMethodApiType(paramClazz, XMLUtil.getName(child));
-					}
-				}
-			}
-		}
+		} 
+		
+//		else
+//		{
+//			for (Class<?> paramClazz : methodParameters)
+//			{
+//				component.addMethodParametersApiType(paramClazz, XMLUtil.getName(child));
+//			}
+//		}
+		
+		return definedMethods.get(0);
 	}
 
-	private static <T> void configureDisposes(AbstractComponent<T> component, Element disposes)
+	/**
+	 * Configures the disposal method of the webbeans component.
+	 * 
+	 * @param component xml webbeans component
+	 * @param disposes disposes element
+	 * 
+	 * @throws DefinitionException if disposes element can not contain exactly one child element 
+	 */
+	private static <T> void checkConfigureDisposes(AbstractComponent<T> component, Element disposes)
 	{
 		List<Element> disposesChilds = disposes.elements();
 
-		if (disposesChilds.size() > 1)
+		if (disposesChilds.size() != 1)
 		{
 			throw new WebBeansConfigurationException(createConfigurationFailedMessage() + "Disposes element : " + XMLUtil.getName(disposes) + " can not contain more than one direct child elements");
 		}
 
 	}
-
-	private static <T> void configureObserves(AbstractComponent<T> component, Element observes)
+	
+	/**
+	 * Configures the observer method of the webbeans component
+	 * 
+	 * @param component xml webbeans component
+	 * @param observes observes element
+	 * 
+	 * @throws DefinitionException if disposes element can not contain exactly one child element and
+	 * 		   it is not one of the {IfExists, AfterTransactionCompletion, AfterTransactionSuccess, 
+	 * 		   AfterTransactionFailure, BeforeTransactionCompletion} element.
+	 */
+	private static <T> void checkConfigureObserves(AbstractComponent<T> component, Element observes)
 	{
 		List<Element> observesChilds = observes.elements();
 
-		if (observesChilds.size() > 1)
+		if (observesChilds.size() != 1)
 		{
-			throw new WebBeansConfigurationException(createConfigurationFailedMessage() + "Disposes element : " + XMLUtil.getName(observes) + " can not contain more than one direct child elements");
+			throw new WebBeansConfigurationException(createConfigurationFailedMessage() + "Observes element : " + XMLUtil.getName(observes) + " can not contain more than one direct child elements");
 		} else
 		{
 			Element child = observesChilds.iterator().next();
 			Class<?> clazz = XMLUtil.getElementJavaType(child);
 
-			if (!clazz.equals(IfExists.class) || !clazz.equals(AfterTransactionCompletion.class) || !clazz.equals(AfterTransactionSuccess.class) || !clazz.equals(AfterTransactionFailure.class) || !clazz.equals(BeforeTransactionCompletion.class))
+			if ((clazz == null) || !clazz.equals(IfExists.class) || !clazz.equals(AfterTransactionCompletion.class) || !clazz.equals(AfterTransactionSuccess.class) || !clazz.equals(AfterTransactionFailure.class) || !clazz.equals(BeforeTransactionCompletion.class))
 			{
-				throw new WebBeansConfigurationException(createConfigurationFailedMessage() + "Disposes element : " + XMLUtil.getName(observes) + " must have one of the {<IfExists>, <AfterTransactionCompletion>, <AfterTransactionSuccess>, <AfterTransactionFailure>, <BeforeTransactionCompletion>} as a direct child.");
+				throw new WebBeansConfigurationException(createConfigurationFailedMessage() + "Observes element : " + XMLUtil.getName(observes) + " must have one of the {<IfExists>, <AfterTransactionCompletion>, <AfterTransactionSuccess>, <AfterTransactionFailure>, <BeforeTransactionCompletion>} as a direct child.");
 			}
 		}
 
 	}
-
-	private static <T> void configureDeploymentType(XMLComponentImpl<T> component, Annotation[] anns)
+	
+	/**
+	 * Configures the deployment type of the XML component.
+	 * 
+	 * @param component xml defined simple web beans component
+	 * @param annotationSet all annotation defined in XML
+	 */
+	private static <T> void configureDeploymentType(XMLComponentImpl<T> component, Set<Class<? extends Annotation>> annotationSet)
 	{
-		Class<? extends Annotation> deploymentType = DefinitionUtil.defineDeploymentType(component, anns, createConfigurationFailedMessage() + "@DeploymentType annotation is not configured correctly");
+		Class<? extends Annotation> deploymentType = XMLDefinitionUtil.defineXMLTypeMetaData(component, annotationSet, DeploymentType.class ,createConfigurationFailedMessage() + "@DeploymentType annotation is not configured correctly");
 
 		if (deploymentType == null)
 		{
 			DefinitionUtil.defineDeploymentType(component, component.getReturnType().getAnnotations(), createConfigurationFailedMessage() + "@DeploymentType annotation is not configured correctly");
 		}
+		else
+		{
+			component.setType(JavassistProxyFactory.createNewAnnotationProxy(deploymentType));
+		}
 	}
 
-	private static <T> void configureScopeType(XMLComponentImpl<T> component, Annotation[] anns)
+	private static <T> void configureScopeType(XMLComponentImpl<T> component,  Set<Class<? extends Annotation>> annotationSet)
 	{
-		boolean isDefined = AnnotationUtil.isMetaAnnotationExist(anns, ScopeType.class);
-		if (isDefined)
-		{
-			DefinitionUtil.defineScopeType(component, anns, createConfigurationFailedMessage() + "@ScopeType annotation is not configured correctly");
-		} else
+		Class<? extends Annotation> scopeType = XMLDefinitionUtil.defineXMLTypeMetaData(component, annotationSet, ScopeType.class ,createConfigurationFailedMessage() + "@ScopeType annotation is not configured correctly");
+		
+		if(scopeType == null)
 		{
+			//TODO XML Stereotype Check
+			
 			DefinitionUtil.defineScopeType(component, component.getReturnType().getAnnotations(), createConfigurationFailedMessage() + "@ScopeType annotation is not configured correctly");
 		}
 
@@ -794,55 +1232,69 @@
 	 * @param component web beans xml component
 	 * @param anns annotations defined in the xml documents
 	 */
-	private static <T> void configureBindingType(XMLComponentImpl<T> component, Annotation[] anns)
+	private static <T> void configureBindingType(XMLComponentImpl<T> component, Set<Class<? extends Annotation>> annotationSet)
 	{
-		boolean isDefined = AnnotationUtil.isMetaAnnotationExist(anns, BindingType.class);
-		if (isDefined)
-		{
-			DefinitionUtil.defineBindingTypes(component, anns);
-		} else
+		boolean isDefined = XMLDefinitionUtil.defineXMLBindingType(component, annotationSet);
+		
+		if(!isDefined)
 		{
 			DefinitionUtil.defineBindingTypes(component, component.getReturnType().getAnnotations());
 		}
 
 	}
 
-	private static <T> void configureInterceptorBindingType(XMLComponentImpl<T> component, Annotation[] anns)
+	private static <T> void configureInterceptorBindingType(XMLComponentImpl<T> component, Set<Class<? extends Annotation>> annotationSet)
 	{
-
+		boolean isDefined = XMLDefinitionUtil.defineXMLInterceptorType(component, annotationSet);
+		
+		if(!isDefined)
+		{
+			DefinitionUtil.defineSimpleWebBeanInterceptorStack(component);
+		}
 	}
 
-	private static <T> void configureStereoType(XMLComponentImpl<T> component, Annotation[] anns)
+	private static <T> void configureStereoType(XMLComponentImpl<T> component, Set<Class<? extends Annotation>> annotationSet)
 	{
-		WebBeansUtil.checkSteroTypeRequirements(component.getTypes(), component.getScopeType(), anns, "WebBeans XML configuration defined in " + CURRENT_SCAN_FILE_NAME + " is failed. Defined WebBeans ");
-
+		XMLDefinitionUtil.defineXMLStereoType(component, annotationSet);
 	}
 
-	private static <T> void configureNamed(XMLComponentImpl<T> component, Annotation[] anns)
+	private static <T> void configureNamed(XMLComponentImpl<T> component, Set<Class<? extends Annotation>> annotationSet, Element webBeanDecleration)
 	{
-		boolean isDefined = AnnotationUtil.isAnnotationExist(anns, Named.class);
-		if (isDefined)
+		boolean isDefined = XMLDefinitionUtil.defineXMLName(component, annotationSet);
+		if(isDefined)
 		{
-			DefinitionUtil.defineName(component, anns, WebBeansUtil.getSimpleWebBeanDefaultName(component.getReturnType().getName()));
-		} else
+			Element element = webBeanDecleration.element(WebBeansConstants.WEB_BEANS_XML_NAMED_ELEMENT);
+			String name = element.getTextTrim();
+			
+			if(name != null && !name.equals(""))
+			{
+				component.setName(name);
+			}
+			else
+			{
+				component.setName(WebBeansUtil.getSimpleWebBeanDefaultName(component.getReturnType().getName()));
+			}
+		}
+		else
 		{
 			DefinitionUtil.defineName(component, component.getReturnType().getAnnotations(), WebBeansUtil.getSimpleWebBeanDefaultName(component.getReturnType().getName()));
 		}
 	}
 
-	private static <T> void configureSpecializes(XMLComponentImpl<T> component, Annotation[] anns)
+	private static <T> void configureSpecializes(XMLComponentImpl<T> component, Set<Class<? extends Annotation>> annotationSet)
 	{
-
+		XMLDefinitionUtil.defineXMLSpecializes(component, annotationSet);
 	}
 
-	private static <T> void configureInterceptor(XMLComponentImpl<T> component, Annotation[] anns)
+	private static <T> void configureInterceptor(XMLComponentImpl<T> component, Set<Class<? extends Annotation>> annotationSet)
 	{
+		XMLDefinitionUtil.defineXMLInterceptors(component, annotationSet, createConfigurationFailedMessage() + "More than one <Interceptor> element exist");
 
 	}
 
-	private static <T> void configureDecorator(XMLComponentImpl<T> component, Annotation[] anns)
+	private static <T> void configureDecorator(XMLComponentImpl<T> component, Set<Class<? extends Annotation>> annotationSet)
 	{
-
+		XMLDefinitionUtil.defineXMLDecorators(component, annotationSet, createConfigurationFailedMessage() + "More than one <Decorator> element exist");
 	}
 
 	/**
@@ -867,46 +1319,66 @@
 		// TODO JMS Endpoint
 	}
 
-	private static <T> void configureFieldValues(XMLComponentImpl<T> component, Field field, Element child, Element webBeanDecleration, boolean isValueElement)
+	/**
+	 * Cofigures the initial value of the given field.
+	 * 
+	 * @param component webbeans component
+	 * @param field field of the webbean
+	 * @param child child element that declares field
+	 * @param isValueElement is it applicable for value setting
+	 */
+	private static <T> void configureFieldValues(XMLComponentImpl<T> component, Field field, Element child, boolean isValueElement)
 	{
 		if (isValueElement)
 		{
 			String errorMessage = createConfigurationFailedMessage() + "Field value of field name : " + field.getName() + " is not applicable for initial value assignment";
-			Class<?> fieldType = field.getType();
-
+			
+			Class<?> fieldType = field.getType(); /*Field type*/
+			
 			if (!ClassUtil.isInValueTypes(fieldType))
 			{
 				throw new WebBeansConfigurationException(createConfigurationFailedMessage() + "Field type with field name : " + field.getName() + " is not compatible for initial value assignment");
 			}
 
-			if (ClassUtil.isPrimitive(fieldType))
+			if (ClassUtil.isPrimitive(fieldType) || ClassUtil.isPrimitiveWrapper(fieldType)) /*Primitive type value*/
 			{
 				String value = child.getTextTrim();
 				Object objVal = null;
-				if ((objVal = ClassUtil.isValueOkForPrimitive(fieldType, value)) != null)
+				
+				if ((objVal = ClassUtil.isValueOkForPrimitiveOrWrapper(fieldType, value)) != null)
 				{
 					component.addFieldValue(field.getName(), objVal);
+					
 				} else
 				{
 					throw new WebBeansConfigurationException(errorMessage);
 				}
-			} else if (ClassUtil.isEnum(fieldType))
+				
+			} 
+			else if (ClassUtil.isEnum(fieldType)) /*Enumeration value*/
 			{
 				String value = child.getTextTrim();
-				Enum enVal = ClassUtil.isValueOkForEnum(fieldType, value);
+				Enum enumValue = ClassUtil.isValueOkForEnum(fieldType, value);
 
-				if (enVal == null)
+				if (enumValue == null)
 				{
 					throw new WebBeansConfigurationException(errorMessage);
 				}
 
-				component.addFieldValue(field.getName(), enVal);
-			} else if (fieldType.equals(String.class))
+				component.addFieldValue(field.getName(), enumValue);
+				
+			} 
+			else if (fieldType.equals(String.class)) /*String value*/
 			{
 				String value = child.getTextTrim();
 				component.addFieldValue(field.getName(), value);
 
-			} else if (fieldType.equals(Date.class) || fieldType.equals(Calendar.class))
+			} 
+			else if (fieldType.equals(Date.class) /*Date, Time, Sql Date, Time stamp, Calendar value*/ 
+					|| fieldType.equals(Calendar.class)
+					|| fieldType.equals(java.sql.Date.class)
+					|| fieldType.equals(Time.class)
+					|| fieldType.equals(Timestamp.class))
 			{
 				String value = child.getTextTrim();
 				Date date = ClassUtil.isValueOkForDate(value);
@@ -919,7 +1391,22 @@
 					component.addFieldValue(field.getName(), value);
 				}
 
-			} else if (fieldType.equals(Class.class))
+			} 
+			else if(fieldType.equals(BigDecimal.class) || fieldType.equals(BigInteger.class)) /*BigDecimal or BigInteger value*/
+			{
+				String value = child.getTextTrim();
+				Object bigValue = ClassUtil.isValueOkForBigDecimalOrInteger(fieldType, value);
+				
+				if (bigValue == null)
+				{
+					throw new WebBeansConfigurationException(errorMessage);
+				} else
+				{
+					component.addFieldValue(field.getName(), bigValue);
+				}
+				
+			}
+			else if (fieldType.equals(Class.class)) /*Class value*/
 			{
 				String value = child.getTextTrim();
 				Class<?> clazz = ClassUtil.getClassFromName(value);
@@ -931,60 +1418,212 @@
 				{
 					component.addFieldValue(field.getName(), value);
 				}
-			} else if (List.class.isAssignableFrom(fieldType))
+			} 
+			else if (List.class.isAssignableFrom(fieldType)) /*List value*/
 			{
-				boolean isString = false;
-				Type type = field.getGenericType();
-				Class<?> argClazz = null;
-				List list = null;
-				if (type instanceof ParameterizedType)
-				{
-					ParameterizedType pt = (ParameterizedType) type;
-					Type arg = pt.getActualTypeArguments()[0];
-					argClazz = (Class<?>) arg;
-
-					if (((Class) arg).equals(String.class))
-					{
-						isString = true;
-						list = new ArrayList<String>();
-					} else if (Enum.class.isAssignableFrom(((Class) arg)))
-					{
-						isString = false;
-						list = new ArrayList<Enum>();
-					}
-				} else
+				configureFieldListValue(component, field, child, errorMessage);
+			}
+			else if(Set.class.isAssignableFrom(fieldType)) /*Set value*/
+			{
+				configureFieldSetValue(component, field, child, errorMessage);
+			}
+		}
+	}
+	
+	/**
+	 * Configures the xml field with {@link List} type.
+	 * 
+	 * @param component xml component
+	 * @param field list field
+	 * @param child list field xml element
+	 * @param errorMessage error message
+	 */
+	private static void configureFieldListValue(XMLComponentImpl<?> component, Field field, Element child, String errorMessage)
+	{
+		boolean isString = false;
+		boolean isEnum = false;
+		boolean isClazz = false;
+		Type type = field.getGenericType();
+		Class<?> argClazz = null;
+		List list = null;
+		
+		if (type instanceof ParameterizedType) /*Type must be parametrized type to mark type*/
+		{
+			ParameterizedType pt = (ParameterizedType) type;
+			Type arg = pt.getActualTypeArguments()[0];
+			
+			if(ClassUtil.isFirstParametricTypeArgGeneric(pt))
+			{
+				throw new WebBeansConfigurationException(createConfigurationFailedMessage() + "List field type with field name : " + field.getName() + " must be declared as ParametrizedType " +
+						"but parametric type can not be TypeVariable or Wildcard Type");
+			}
+			
+			else
+			{
+				argClazz = (Class<?>) arg;
+
+				if (argClazz.equals(String.class))
 				{
-					throw new WebBeansConfigurationException(createConfigurationFailedMessage() + "List field type with field name : " + field.getName() + " must be declared as ParametrizedType");
+					isString = true;
+					list = new ArrayList<String>();
+				} 
+				else if (Enum.class.isAssignableFrom(argClazz))
+				{
+					isEnum = true;
+					list = new ArrayList<Enum>();
 				}
-
-				List<Element> valueElements = child.elements();
-				for (Element valueElement : valueElements)
+				else if(argClazz.equals(Class.class))
 				{
-					String value = valueElement.getTextTrim();
-					if (isString)
-					{
-						list.add(value);
-					} else
-					{
-						Enum en = ClassUtil.isValueOkForEnum(argClazz, value);
-						if (en == null)
-						{
-							throw new WebBeansConfigurationException(errorMessage);
-						} else
-						{
-							list.add(en);
-						}
-					}
+					isClazz = true;
+					list = new ArrayList<Class>();
 				}
+			}					
+		} 
+		else
+		{
+			throw new WebBeansConfigurationException(createConfigurationFailedMessage() + "List field type with field name : " + field.getName() + " must be declared as ParametrizedType");
+		}
 
-				component.addFieldValue(field.getName(), list);
+		List<Element> valueElements = child.elements();
+		for (Element valueElement : valueElements)
+		{
+			String value = valueElement.getTextTrim();
+			if (isString)
+			{
+				list.add(value);
+			} 
+			else if(isEnum)
+			{
+				Enum en = ClassUtil.isValueOkForEnum(argClazz, value);
+				if (en == null)
+				{
+					throw new WebBeansConfigurationException(errorMessage);
+				} 
+				else
+				{
+					list.add(en);
+				}
+			}
+			else if(isClazz)
+			{
+				Class<?> clazz = ClassUtil.getClassFromName(value);
+				
+				if (clazz == null)
+				{
+					throw new WebBeansConfigurationException(errorMessage);
+				} 
+				else
+				{
+					list.add(clazz);
+				}						
 			}
 		}
+
+		component.addFieldValue(field.getName(), list);
+		
 	}
+	
+	/**
+	 * Configures the xml field with {@link Set} type.
+	 * 
+	 * @param component xml component
+	 * @param field list field
+	 * @param child list field xml element
+	 * @param errorMessage error message
+	 */	
+	private static void configureFieldSetValue(XMLComponentImpl<?> component, Field field, Element child, String errorMessage)
+	{
+		boolean isString = false;
+		boolean isEnum = false;
+		boolean isClazz = false;
+		Type type = field.getGenericType();
+		Class<?> argClazz = null;
+		Set set = null;
+		
+		if (type instanceof ParameterizedType) /*Type must be parametrized type to mark type*/
+		{
+			ParameterizedType pt = (ParameterizedType) type;
+			Type arg = pt.getActualTypeArguments()[0];
+			
+			if(ClassUtil.isFirstParametricTypeArgGeneric(pt))
+			{
+				throw new WebBeansConfigurationException(createConfigurationFailedMessage() + "Set field type with field name : " + field.getName() + " must be declared as ParametrizedType " +
+						"but parametric type can not be TypeVariable or Wildcard Type");
+			}
+			
+			else
+			{
+				argClazz = (Class<?>) arg;
+
+				if (argClazz.equals(String.class))
+				{
+					isString = true;
+					set = new HashSet<String>();
+				} 
+				else if (Enum.class.isAssignableFrom(argClazz))
+				{
+					isEnum = true;
+					set = new HashSet<Enum>();
+				}
+				else if(argClazz.equals(Class.class))
+				{
+					isClazz = true;
+					set = new HashSet<Class>();
+				}
+			}					
+		} 
+		else
+		{
+			throw new WebBeansConfigurationException(createConfigurationFailedMessage() + "Set field type with field name : " + field.getName() + " must be declared as ParametrizedType");
+		}
 
+		List<Element> valueElements = child.elements();
+		for (Element valueElement : valueElements)
+		{
+			String value = valueElement.getTextTrim();
+			if (isString)
+			{
+				set.add(value);
+			} 
+			else if(isEnum)
+			{
+				Enum en = ClassUtil.isValueOkForEnum(argClazz, value);
+				if (en == null)
+				{
+					throw new WebBeansConfigurationException(errorMessage);
+				} 
+				else
+				{
+					set.add(en);
+				}
+			}
+			else if(isClazz)
+			{
+				Class<?> clazz = ClassUtil.getClassFromName(value);
+				
+				if (clazz == null)
+				{
+					throw new WebBeansConfigurationException(errorMessage);
+				} 
+				else
+				{
+					set.add(clazz);
+				}						
+			}
+		}
+
+		component.addFieldValue(field.getName(), set);
+		
+	}
+	
+	/**
+	 * Gets error message for XML parsing of the current XML file.
+	 * 
+	 * @return the error messages
+	 */
 	private static String createConfigurationFailedMessage()
 	{
 		return "WebBeans XML configuration defined in " + CURRENT_SCAN_FILE_NAME + " is failed. Reason is : ";
 	}
 
-}
+}
\ No newline at end of file

Added: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/XMLAnnotationTypeManager.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/XMLAnnotationTypeManager.java?rev=726301&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/XMLAnnotationTypeManager.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/XMLAnnotationTypeManager.java Sat Dec 13 15:28:04 2008
@@ -0,0 +1,109 @@
+/*
+ *  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.lang.annotation.Annotation;
+import java.util.Collections;
+import java.util.Set;
+import java.util.concurrent.CopyOnWriteArraySet;
+
+public class XMLAnnotationTypeManager
+{
+	private static XMLAnnotationTypeManager manager = null;
+	
+	private Set<Class<? extends Annotation>> xmlBindingTypes = new CopyOnWriteArraySet<Class<? extends Annotation>>();
+	
+	private Set<Class<? extends Annotation>> xmlInterceptorBindingTypes = new CopyOnWriteArraySet<Class<? extends Annotation>>();
+	
+	private Set<Class<? extends Annotation>> xmlStereoTypes = new CopyOnWriteArraySet<Class<? extends Annotation>>();
+	
+	private XMLAnnotationTypeManager()
+	{
+		
+	}
+	
+	public static XMLAnnotationTypeManager getInstance()
+	{
+		if(manager == null)
+		{
+			manager = new XMLAnnotationTypeManager();
+		}
+		
+		return manager;
+	}
+	
+	public void addBindingType(Class<? extends Annotation> bindingType)
+	{
+		xmlBindingTypes.add(bindingType);
+	}
+	
+	public boolean isBindingTypeExist(Class<? extends Annotation> bindingType)
+	{
+		if(xmlBindingTypes.contains(bindingType))
+		{
+			return true;
+		}
+		
+		return false;
+	}
+	
+	public void addStereoType(Class<? extends Annotation> bindingType)
+	{
+		xmlStereoTypes.add(bindingType);
+	}
+	
+	public boolean isStereoTypeExist(Class<? extends Annotation> bindingType)
+	{
+		if(xmlStereoTypes.contains(bindingType))
+		{
+			return true;
+		}
+		
+		return false;
+	}
+
+	public void addInterceotorBindingType(Class<? extends Annotation> bindingType)
+	{
+		xmlInterceptorBindingTypes.add(bindingType);
+	}
+	
+	public boolean isInterceptorBindingTypeExist(Class<? extends Annotation> bindingType)
+	{
+		if(xmlInterceptorBindingTypes.contains(bindingType))
+		{
+			return true;
+		}
+		
+		return false;
+	}
+
+	public Set<Class<? extends Annotation>> getBindingTypes()
+	{
+		return Collections.unmodifiableSet(xmlBindingTypes);
+	}
+	
+	public Set<Class<? extends Annotation>> getInterceptorBindingTypes()
+	{
+		return Collections.unmodifiableSet(xmlInterceptorBindingTypes);
+	}
+
+	public Set<Class<? extends Annotation>> getStereotypes()
+	{
+		return Collections.unmodifiableSet(xmlStereoTypes);
+	}
+
+}

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

Added: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/XMLDefinitionUtil.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/XMLDefinitionUtil.java?rev=726301&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/XMLDefinitionUtil.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/XMLDefinitionUtil.java Sat Dec 13 15:28:04 2008
@@ -0,0 +1,306 @@
+/*
+ *  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.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import javax.webbeans.BindingType;
+import javax.webbeans.Decorator;
+import javax.webbeans.DeploymentType;
+import javax.webbeans.Interceptor;
+import javax.webbeans.InterceptorBindingType;
+import javax.webbeans.Named;
+import javax.webbeans.NonexistentTypeException;
+import javax.webbeans.ScopeType;
+import javax.webbeans.Specializes;
+import javax.webbeans.Stereotype;
+
+import org.apache.webbeans.WebBeansConstants;
+import org.apache.webbeans.component.xml.XMLComponentImpl;
+import org.apache.webbeans.component.xml.XMLProducerComponentImpl;
+import org.apache.webbeans.deployment.StereoTypeManager;
+import org.apache.webbeans.deployment.StereoTypeModel;
+import org.apache.webbeans.exception.WebBeansConfigurationException;
+import org.apache.webbeans.proxy.JavassistProxyFactory;
+import org.apache.webbeans.util.WebBeansUtil;
+import org.dom4j.Element;
+
+@SuppressWarnings("unchecked")
+public final class XMLDefinitionUtil
+{
+	private XMLDefinitionUtil()
+	{
+		
+	}
+	
+	public static void checkTypeMetaDataClasses(Set<Class<? extends Annotation>> typeSet, String errorMessage)
+	{
+		if(typeSet != null && !typeSet.isEmpty())
+		{
+			Iterator<Class<? extends Annotation>> it = typeSet.iterator();
+			while(it.hasNext())
+			{
+				Class<? extends Annotation> clazz = it.next();
+				if(clazz.isAnnotationPresent(DeploymentType.class) ||
+						clazz.isAnnotationPresent(ScopeType.class) ||
+						clazz.isAnnotationPresent(BindingType.class) ||
+						clazz.isAnnotationPresent(InterceptorBindingType.class) ||
+						clazz.isAnnotationPresent(Stereotype.class) ||
+						clazz.equals(Named.class) ||
+						clazz.equals(Specializes.class) ||
+						clazz.equals(Interceptor.class) ||
+						clazz.equals(Decorator.class))
+				{
+					continue;
+				}
+				else
+				{
+					throw new WebBeansConfigurationException(errorMessage + " TypeLevelMeta data configuration is failed because of the class : " + clazz.getName() + " is not applicable type");
+				}
+			}
+		}
+		
+	}
+
+	public static <T> Class<? extends Annotation> defineXMLTypeMetaData(XMLComponentImpl<T> component, Set<Class<? extends Annotation>> annotationSet, Class<? extends Annotation> defineType, String errorMessage)
+	{
+		Class<? extends Annotation> metaType = null;
+		
+		Iterator<Class<? extends Annotation>> it = annotationSet.iterator();
+		boolean found = false;
+		while(it.hasNext())
+		{
+			Class<? extends Annotation> temp = it.next();
+			if(temp.isAnnotationPresent(defineType))
+			{
+				if(found)
+				{
+					throw new WebBeansConfigurationException(errorMessage);
+				}
+				else
+				{
+					metaType = temp;
+					found = true;
+				}
+			}
+		}
+		
+		return metaType;
+	}
+	
+	public static <T> boolean defineXMLBindingType(XMLComponentImpl<T> component, Set<Class<? extends Annotation>> annotationSet)
+	{
+		Iterator<Class<? extends Annotation>> it = annotationSet.iterator();
+		boolean found = false;
+		while(it.hasNext())
+		{
+			Class<? extends Annotation> temp = it.next();
+			if(temp.isAnnotationPresent(BindingType.class))
+			{
+				if(!found)
+				{
+					found = true;
+				}
+				
+				component.addBindingType(JavassistProxyFactory.createNewAnnotationProxy(temp));
+			}
+		}
+		
+		return found;
+	}
+	
+	public static <T> boolean defineXMLInterceptorType(XMLComponentImpl<T> component, Set<Class<? extends Annotation>> annotationSet)
+	{
+		Iterator<Class<? extends Annotation>> it = annotationSet.iterator();
+		boolean found = false;
+		while(it.hasNext())
+		{
+			Class<? extends Annotation> temp = it.next();
+			if(temp.isAnnotationPresent(InterceptorBindingType.class))
+			{
+				if(!found)
+				{
+					found = true;
+				}
+				
+				//component.add(temp);
+			}
+		}
+		
+		return found;
+	}
+	
+	public static <T> boolean defineXMLStereoType(XMLComponentImpl<T> component, Set<Class<? extends Annotation>> annotationSet)
+	{
+		Iterator<Class<? extends Annotation>> it = annotationSet.iterator();
+		boolean found = false;
+		while(it.hasNext())
+		{
+			Class<? extends Annotation> temp = it.next();
+			if(temp.isAnnotationPresent(Stereotype.class))
+			{
+				if(!found)
+				{
+					found = true;
+				}
+				
+				//Add new stereotype model
+				StereoTypeManager.getInstance().addStereoTypeModel(new StereoTypeModel(temp));
+				//component.addXMLStereoType(temp);
+			}
+		}
+		
+		return found;
+	}
+	
+	public static <T> boolean defineXMLName(XMLComponentImpl<T> component, Set<Class<? extends Annotation>> annotationSet)
+	{
+		Iterator<Class<? extends Annotation>> it = annotationSet.iterator();
+		while(it.hasNext())
+		{
+			Class<? extends Annotation> temp = it.next();
+			if(temp.equals(Named.class))
+			{
+				return true;
+			}
+		}
+		
+		return false;
+	}
+	
+	public static <T> void defineXMLSpecializes(XMLComponentImpl<T> component, Set<Class<? extends Annotation>> annotationSet)
+	{
+		Iterator<Class<? extends Annotation>> it = annotationSet.iterator();
+		while(it.hasNext())
+		{
+			Class<? extends Annotation> temp = it.next();
+			if(temp.equals(Specializes.class))
+			{
+				XMLSpecializesManager.getInstance().addXMLSpecializeClass(temp);
+			}
+		}
+	}
+	
+	public static <T> void defineXMLInterceptors(XMLComponentImpl<T> component, Set<Class<? extends Annotation>> annotationSet, String errorMessage)
+	{
+		Iterator<Class<? extends Annotation>> it = annotationSet.iterator();
+		boolean found = false;
+		while(it.hasNext())
+		{
+			Class<? extends Annotation> temp = it.next();
+			if(temp.equals(Interceptor.class))
+			{
+				if(found)
+				{
+					throw new WebBeansConfigurationException(errorMessage);
+				}
+				else
+				{
+					found = true;
+					WebBeansUtil.defineSimpleWebBeansInterceptors(temp);
+				}
+			}
+		}
+	}
+	
+	public static <T> void defineXMLDecorators(XMLComponentImpl<T> component, Set<Class<? extends Annotation>> annotationSet, String errorMessage)
+	{
+		Iterator<Class<? extends Annotation>> it = annotationSet.iterator();
+		boolean found = false;
+		while(it.hasNext())
+		{
+			Class<? extends Annotation> temp = it.next();
+			if(temp.equals(Decorator.class))
+			{
+				if(found)
+				{
+					throw new WebBeansConfigurationException(errorMessage);
+				}
+				else
+				{
+					found = true;
+					WebBeansUtil.defineSimpleWebBeansInterceptors(temp);
+				}
+			}
+		}
+	}
+	
+	public static <T> XMLProducerComponentImpl<T> defineXMLProducerMethod(XMLComponentImpl<T> component, Method producesMethod, Element producerMethodElement, String errorMessage)
+	{
+		List<Element> childElements = producerMethodElement.elements();
+		boolean producesDefined = false;
+		for(Element childElement : childElements)
+		{
+			if(XMLUtil.isElementInWebBeansNameSpaceWithName(childElement, WebBeansConstants.WEB_BEANS_XML_PRODUCES_ELEMENT))
+			{
+				if(producesDefined == false)
+				{
+					producesDefined = true;
+				}
+				else
+				{
+					throw new WebBeansConfigurationException(errorMessage + "More than one <Produces> element is defined");
+				}
+				
+				List<Element> producesElementChilds = childElement.elements();
+				boolean definedType = false;
+				for(Element producesElementChild : producesElementChilds)
+				{
+					Class<?> type = XMLUtil.getElementJavaType(producesElementChild);
+					if(type == null)
+					{
+						throw new NonexistentTypeException(errorMessage + "Java type : " + XMLUtil.getElementJavaClassName(producesElementChild) + " does not exist in the <Produces> element child");
+					}
+					else if(type.isArray() || type.isEnum())
+					{
+						throw new WebBeansConfigurationException(errorMessage + "Java type must be class, interface or annotation type in the <Produces> childs");
+					}
+					else if(type.isAnnotation())
+					{
+						//Class<? extends Annotation> annotationType = (Class<? extends Annotation>)type;
+						
+						
+					}
+					else
+					{
+						if(definedType)
+						{
+							throw new WebBeansConfigurationException(errorMessage + "More than one Java type in the <Produces> element");
+						}
+						else
+						{
+							definedType = true;
+						}
+					}
+				}
+				
+				if(!definedType)
+				{
+					throw new WebBeansConfigurationException(errorMessage + "<Produces> element must define at least one java type child");
+				}
+			}
+		}
+		
+		return null;
+	}
+	
+	
+}

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

Added: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/XMLSpecializesManager.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/XMLSpecializesManager.java?rev=726301&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/XMLSpecializesManager.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/XMLSpecializesManager.java Sat Dec 13 15:28:04 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.xml;
+
+import java.util.Collections;
+import java.util.Set;
+import java.util.concurrent.CopyOnWriteArraySet;
+
+import org.apache.webbeans.util.Asserts;
+
+public class XMLSpecializesManager
+{
+
+	private static XMLSpecializesManager instance = null;
+	
+	private Set<Class<?>> specializeClasses = new CopyOnWriteArraySet<Class<?>>();
+	
+	private XMLSpecializesManager()
+	{
+		
+	}
+	
+	
+	public static XMLSpecializesManager getInstance()
+	{
+		if(instance == null)
+		{
+			instance = new XMLSpecializesManager();
+		}
+		
+		return instance;
+	}
+	
+	public Set<Class<?>> getXMLSpecializationClasses()
+	{
+		return Collections.unmodifiableSet(specializeClasses);
+	}
+	
+	public void addXMLSpecializeClass(Class<?> clazz)
+	{
+		Asserts.assertNotNull(clazz,"clazz parameter can not be null");
+		specializeClasses.add(clazz);
+	}	
+}
\ No newline at end of file

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



Mime
View raw message