Author: vitold
Date: 2009-03-27 07:16:11 -0400 (Fri, 27 Mar 2009)
New Revision: 2223
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/ext/NotSimpleBeanChildrenChecker.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/ext/SimpleBeanChildrenChecker.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/impl/BeanChildrenCheckerImpl.java
Log:
finish with 9.5.3
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/ext/NotSimpleBeanChildrenChecker.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/ext/NotSimpleBeanChildrenChecker.java 2009-03-27
08:06:18 UTC (rev 2222)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/ext/NotSimpleBeanChildrenChecker.java 2009-03-27
11:16:11 UTC (rev 2223)
@@ -6,6 +6,7 @@
import javax.inject.DefinitionException;
import org.dom4j.Element;
+import org.jboss.webbeans.introspector.AnnotatedClass;
import org.jboss.webbeans.xml.ParseXmlHelper;
import org.jboss.webbeans.xml.XmlConstants;
import org.jboss.webbeans.xml.XmlEnvironment;
@@ -43,4 +44,9 @@
throw new DefinitionException("Declaration of not a simple bean '" +
beanChildElement.getParent().getName() +
"' contains a child <" + beanChildElement.getName() +
"> which type is javax.decorator.Decorator");
}
+
+ public void checkForConstructor(Element beanElement, AnnotatedClass<?>
beanClass)
+ {
+ //There is nothing to validate
+ }
}
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/ext/SimpleBeanChildrenChecker.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/ext/SimpleBeanChildrenChecker.java 2009-03-27
08:06:18 UTC (rev 2222)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/ext/SimpleBeanChildrenChecker.java 2009-03-27
11:16:11 UTC (rev 2223)
@@ -1,11 +1,16 @@
package org.jboss.webbeans.xml.checker.beanchildren.ext;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.inject.DefinitionException;
import org.dom4j.Element;
+import org.jboss.webbeans.introspector.AnnotatedClass;
+import org.jboss.webbeans.introspector.AnnotatedConstructor;
+import org.jboss.webbeans.introspector.AnnotatedParameter;
import org.jboss.webbeans.xml.ParseXmlHelper;
import org.jboss.webbeans.xml.XmlConstants;
import org.jboss.webbeans.xml.XmlEnvironment;
@@ -47,4 +52,42 @@
"> in bean '" + beanChildElement.getParent().getName() +
"'");
haveBeanDecoratorDeclaration = true;
}
+
+ public void checkForConstructor(Element beanElement, AnnotatedClass<?>
beanClass)
+ {
+ if(constructorParameters.size() == 0)
+ return;
+
+ List<AnnotatedConstructor<?>> matchableConstructors = new
ArrayList<AnnotatedConstructor<?>>();
+
+ for(AnnotatedConstructor<?> constructor : beanClass.getConstructors())
+ {
+ List<? extends AnnotatedParameter<?>> parameters =
constructor.getParameters();
+
+ if(parameters.size() != constructorParameters.size())
+ continue;
+
+ boolean isMacthable = true;
+
+ for(int i = 0; i < parameters.size(); i++)
+ {
+ if(!parameters.get(i).isAssignableFrom(constructorParameters.get(i)))
+ {
+ isMacthable = false;
+ break;
+ }
+ }
+
+ if(isMacthable)
+ matchableConstructors.add(constructor);
+ }
+
+ if(matchableConstructors.size() == 0)
+ throw new DefinitionException("There is no constructor of the simple bean
'" + beanElement.getName() +
+ "' with the same number and types of parameters as
declared");
+
+ if(matchableConstructors.size() > 1)
+ throw new DefinitionException("There is more than one constructor of the
simple bean '" + beanElement.getName() +
+ "' with the same number and types of parameters as
declared");
+ }
}
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/impl/BeanChildrenCheckerImpl.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/impl/BeanChildrenCheckerImpl.java 2009-03-27
08:06:18 UTC (rev 2222)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/impl/BeanChildrenCheckerImpl.java 2009-03-27
11:16:11 UTC (rev 2223)
@@ -1,6 +1,8 @@
package org.jboss.webbeans.xml.checker.beanchildren.impl;
+import java.util.ArrayList;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -41,6 +43,8 @@
protected boolean haveBeanInterceptorDeclaration = false;
protected boolean haveBeanDecoratorDeclaration = false;
+
+ protected List<AnnotatedClass<?>> constructorParameters = new
ArrayList<AnnotatedClass<?>>();
public abstract void checkForInterceptorChild(Element beanElement);
@@ -50,6 +54,8 @@
public abstract void checkChildForDecoratorType(Element beanElement);
+ public abstract void checkForConstructor(Element beanElement, AnnotatedClass<?>
beanClass);
+
public BeanChildrenCheckerImpl(XmlEnvironment environment, Map<String,
Set<String>> packagesMap)
{
this.environment = environment;
@@ -70,11 +76,12 @@
while(beanIterator.hasNext())
{
Element beanChildElement = (Element)beanIterator.next();
- checkBeanChild(beanChildElement);
+ checkBeanChild(beanChildElement, beanClass);
}
+ checkForConstructor(beanElement, beanClass);
}
- private void checkBeanChild(Element beanChildElement)
+ private void checkBeanChild(Element beanChildElement, AnnotatedClass<?>
beanClass)
{
//TODO: not finished
try
@@ -91,7 +98,8 @@
}
if(isJavaClass || isInterface)
{
- //TODO: bean child element declaring a parameter of the bean constructor
+ //bean child element declaring a parameter of the bean constructor
+ constructorParameters.add(beanChildClass);
return;
}
throw new DefinitionException(new DefinitionException(beanChildElement.getName()
+ " can't be interpreted as a Java class or interface or Java Annotation
type"));
@@ -108,7 +116,8 @@
Namespace beanChildNamespace = beanChildElement.getNamespace();
if(beanChildNamespace.equals(beanNamespace))
{
- //TODO: bean child element declaring a method or field of the bean.
+ //bean child element declaring a method or field of the bean.
+ checkFieldOrMethodChild(beanChildElement, beanClass);
return;
}
throw new DefinitionException("Can't determine type of element
<" + beanChildElement.getName() + "> in bean '" +
@@ -155,5 +164,9 @@
throw new DefinitionException("Can't determine annotation type of
<" + beanChildElement.getName() + "> element in bean '" +
beanChildElement.getParent().getName() + "'");
}
-
+
+ private void checkFieldOrMethodChild(Element beanChildElement, AnnotatedClass<?>
beanClass)
+ {
+ //TODO: not finished
+ }
}
Show replies by date