openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gerdo...@apache.org
Subject svn commit: r728098 - in /incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans: ./ component/xml/ util/ xml/
Date Fri, 19 Dec 2008 18:29:03 GMT
Author: gerdogdu
Date: Fri Dec 19 10:29:03 2008
New Revision: 728098

URL: http://svn.apache.org/viewvc?rev=728098&view=rev
Log:
XML code is updated accrd. to the test.

Modified:
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/WebBeansConstants.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/xml/XMLComponentImpl.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
    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/XMLDefinitionUtil.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/WebBeansConstants.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/WebBeansConstants.java?rev=728098&r1=728097&r2=728098&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/WebBeansConstants.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/WebBeansConstants.java
Fri Dec 19 10:29:03 2008
@@ -47,9 +47,13 @@
 	/**<Interceptors> XML Element*/
 	public static final String WEB_BEANS_XML_INTERCEPTORS_ELEMENT = "Interceptors";
 	
+	public static final String WEB_BEANS_XML_INTERCEPTOR_ELEMENT = "Interceptor";
+	
 	/**<Decorators>  XML Element*/
 	public static final String WEB_BEANS_XML_DECORATORS_ELEMENT = "Decorators";
 	
+	public static final String WEB_BEANS_XML_DECORATOR_ELEMENT = "Decorator";
+	
 	/**<Queue> XML Element*/
 	public static final String WEB_BEANS_XML_TOPIC_ELEMENT = "Queue";
 	

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/xml/XMLComponentImpl.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/xml/XMLComponentImpl.java?rev=728098&r1=728097&r2=728098&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/xml/XMLComponentImpl.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/xml/XMLComponentImpl.java
Fri Dec 19 10:29:03 2008
@@ -65,7 +65,15 @@
 	protected T createInstance()
 	{
 		T instance = null;
-		instance = this.injectableConstructor.doInjection();
+		
+		if(this.injectableConstructor == null)
+		{
+			instance = super.createInstance();
+		}
+		else
+		{
+			instance = this.injectableConstructor.doInjection();	
+		}
 		
 		return instance;
 	}

Modified: 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=728098&r1=728097&r2=728098&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
Fri Dec 19 10:29:03 2008
@@ -193,7 +193,8 @@
 			throw e;
 		}
 	}
-
+	
+	
 	public static <T> Constructor<T> defineConstructor(Class<T> clazz) throws
WebBeansConfigurationException
 	{
 		Asserts.nullCheckForClass(clazz);

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=728098&r1=728097&r2=728098&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
Fri Dec 19 10:29:03 2008
@@ -485,7 +485,7 @@
 
 		if (clazz == null)
 		{
-			throw new NonexistentTypeException(createConfigurationFailedMessage() + "Class : " + className
+ " is not found");
+			throw new NonexistentTypeException(createConfigurationFailedMessage() + "Class with name
: " + className + " is not found");
 		}
 
 		boolean ok = false;
@@ -505,25 +505,29 @@
 				// Configure Simple WebBean
 				configureSimpleWebBean(clazz, webBeanElement);
 				ok = true;
-			}
+			}				
 		}
 
+		/*If not applicable for configuration*/
 		if (!ok)
 		{
-			// Actually this does not happen!
-			throw new WebBeansConfigurationException(createConfigurationFailedMessage() + "Given Java
class : " + clazz.getName() + " is not resolved to any WebBeans type in {Simple WebBeans,
Enterprise WebBeans}");
+			throw new WebBeansConfigurationException(createConfigurationFailedMessage() + "Given class
with name : " + clazz.getName() + " is not resolved to any WebBeans type in {Simple WebBeans,
Enterprise WebBeans, JMS WebBeans}");
 		}
 
 	}
 
 	/**
-	 * Configures the simple web bean from the class.
+	 * Configures the simple webbean from the class.
 	 * 
-	 * @param simpleClass concrete java class
-	 * @param webBeanDecleration webbeans element
+	 * @param simpleClass concrete java class defined in XML
+	 * @param webBeanDecleration webbeans decleration root element
 	 */
-	private static <T> void configureSimpleWebBean(Class<T> simpleClass, Element
webBeanDecleration)
+	public static <T> XMLComponentImpl<T> configureSimpleWebBean(Class<T>
simpleClass, Element webBeanDecleration)
 	{
+		/*Checking XML defined simple webbeans condition check. Spec : 3.2.4*/
+		XMLDefinitionUtil.checkSimpleWebBeansInXML(simpleClass, webBeanDecleration, createConfigurationFailedMessage());
+		
+		/*Create new XML component with class name*/
 		XMLComponentImpl<T> component = new XMLComponentImpl<T>(simpleClass);
 		
 		/*Configures API type of the webbeans component*/
@@ -532,19 +536,19 @@
 		/*Configures child elements of this webbeans decleration element*/
 		configureWebBeanDeclerationChilds(component, webBeanDecleration);
 
-		// Check if the deployment type is enabled.
-		if (!DeploymentTypeManager.getInstance().isDeploymentTypeEnabled(component.getDeploymentType()))
+		/*Check if the deployment type is enabled.*/
+		if (!DeploymentTypeManager.getInstance().isDeploymentTypeEnabled(component.getDeploymentType()))
//Maybe it is checked before the creation!
 		{
 			component = null;
-			return;
 			
 		} 
-		/*Add manager*/
+		/*Adda to the manager*/
 		else
 		{
 			ManagerImpl.getManager().addBean(component);
 		}
-
+		
+		return component;
 	}
 	
 	/**
@@ -1215,6 +1219,10 @@
 			
 			DefinitionUtil.defineScopeType(component, component.getReturnType().getAnnotations(),
createConfigurationFailedMessage() + "@ScopeType annotation is not configured correctly");
 		}
+		else
+		{
+			component.setImplScopeType(JavassistProxyFactory.createNewAnnotationProxy(scopeType));
+		}
 
 	}
 
@@ -1269,7 +1277,7 @@
 		}
 		else
 		{
-			DefinitionUtil.defineName(component, component.getReturnType().getAnnotations(), WebBeansUtil.getSimpleWebBeanDefaultName(component.getReturnType().getName()));
+			DefinitionUtil.defineName(component, component.getReturnType().getAnnotations(), WebBeansUtil.getSimpleWebBeanDefaultName(component.getReturnType().getSimpleName()));
 		}
 	}
 

Modified: 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=728098&r1=728097&r2=728098&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/XMLDefinitionUtil.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/XMLDefinitionUtil.java
Fri Dec 19 10:29:03 2008
@@ -38,6 +38,8 @@
 import org.apache.webbeans.exception.WebBeansConfigurationException;
 import org.apache.webbeans.proxy.JavassistProxyFactory;
 import org.apache.webbeans.util.AnnotationUtil;
+import org.apache.webbeans.util.Asserts;
+import org.apache.webbeans.util.ClassUtil;
 import org.apache.webbeans.util.WebBeansUtil;
 import org.dom4j.Element;
 
@@ -49,6 +51,55 @@
 		
 	}
 	
+	/**
+	 * Checks the conditions for simple webbeans class defined
+	 * in the XML file.
+	 * 
+	 * @param clazz simple webbeans class declared in XML
+	 * 
+	 * @throws WebBeansConfigurationException if check is fail
+	 */
+	public static void checkSimpleWebBeansInXML(Class<?> clazz, Element webBeanDecleration,
String errorMessage) throws WebBeansConfigurationException
+	{
+		Asserts.nullCheckForClass(clazz);
+		if(errorMessage == null)
+		{
+			errorMessage = "XML defined simple webbeans failed. ";
+		}
+		
+		int modifier = clazz.getModifiers();
+		
+		if (ClassUtil.isParametrized(clazz))
+		{
+			throw new WebBeansConfigurationException(errorMessage + "Simple WebBeans component implementation
class : " + clazz.getName() + " can not be parametrized type");	
+		}			
+		
+		if (!ClassUtil.isStatic(modifier) && ClassUtil.isInnerClazz(clazz))
+		{
+			throw new WebBeansConfigurationException(errorMessage + "Simple WebBeans component implementation
class : " + clazz.getName() + " can not be non-static inner class");	
+		}				
+		
+		if(clazz.isAnnotationPresent(Interceptor.class))
+		{
+			boolean found = XMLUtil.isElementChildExistWithWebBeansNameSpace(webBeanDecleration, WebBeansConstants.WEB_BEANS_XML_INTERCEPTOR_ELEMENT);
+			if(!found)
+			{
+				throw new WebBeansConfigurationException(errorMessage + "Simple WebBeans component implementation
class : " + clazz.getName() + " must be declared as <Interceptor> element in the XML");
+			}
+		}
+		
+		if(clazz.isAnnotationPresent(Decorator.class))
+		{
+			boolean found = XMLUtil.isElementChildExistWithWebBeansNameSpace(webBeanDecleration, WebBeansConstants.WEB_BEANS_XML_DECORATOR_ELEMENT);
+			if(!found)
+			{
+				throw new WebBeansConfigurationException(errorMessage + "Simple WebBeans component implementation
class : " + clazz.getName() + " must be declared as <Decorator> element in the XML");
+			}
+		}
+		
+	}
+	
+	
 	public static void checkTypeMetaDataClasses(Set<Class<? extends Annotation>>
typeSet, String errorMessage)
 	{
 		if(typeSet != null && !typeSet.isEmpty())
@@ -235,7 +286,7 @@
 				else
 				{
 					found = true;
-					WebBeansUtil.defineSimpleWebBeansInterceptors(temp);
+					WebBeansUtil.defineSimpleWebBeansDecorators(temp);
 				}
 			}
 		}
@@ -300,5 +351,4 @@
 		return null;
 	}
 	
-	
 }

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/XMLUtil.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/XMLUtil.java?rev=728098&r1=728097&r2=728098&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/XMLUtil.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/XMLUtil.java
Fri Dec 19 10:29:03 2008
@@ -310,6 +310,15 @@
 	}
 	
 	
+	/**
+	 * Returns true if this element defines JMS webbeans, false
+	 * otherwise.
+
+	 * @param element webbeans element decleration
+	 * 
+	 * @return true if this element defines JMS webbeans, false
+	 * otherwise 
+	 */
 	public static boolean isElementJMSDeclaration(Element element)
 	{
 		nullCheckForElement(element);
@@ -318,14 +327,21 @@
 		{
 			if(isElementInWebBeansNameSpaceWithName(element, WebBeansConstants.WEB_BEANS_XML_QUEUE_ELEMENT)
||
 					isElementInWebBeansNameSpaceWithName(element, WebBeansConstants.WEB_BEANS_XML_TOPIC_ELEMENT))
-				
-				return true;
+			{
+				return true;	
+			}
 		}
 		
 		return false;
-		
 	}
 	
+	/**
+	 * Returns true if this element defines field, false otherwise.
+	 * 
+	 * @param element webbeans decleration child element
+	 * 
+	 * @return true if this element defines field, false otherwise
+	 */
 	public static boolean isElementField(Element element)
 	{
 		nullCheckForElement(element);



Mime
View raw message