[webbeans-commits] Webbeans SVN: r2027 - in extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd: model and 1 other directory.
by webbeans-commits@lists.jboss.org
Author: nickarls
Date: 2009-03-16 04:12:30 -0400 (Mon, 16 Mar 2009)
New Revision: 2027
Modified:
extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/helpers/DataSetter.java
extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/FieldModel.java
extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/MethodModel.java
extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/NamedModel.java
extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/ParameterModel.java
Log:
simle meta-annotation model
Modified: extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/helpers/DataSetter.java
===================================================================
--- extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/helpers/DataSetter.java 2009-03-16 07:16:55 UTC (rev 2026)
+++ extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/helpers/DataSetter.java 2009-03-16 08:12:30 UTC (rev 2027)
@@ -17,8 +17,10 @@
package org.jboss.webbeans.xsd.helpers;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.Element;
@@ -61,7 +63,7 @@
*/
public static void populateClassModel(ClassModel classModel, Element element, ClassModel parent)
{
- List<String> annotations = getAnnotations(element);
+ Map<String, Set<String>> annotations = getAnnotations(element);
TypeElement typeElement = (TypeElement) element;
classModel.setName(typeElement.getQualifiedName().toString());
classModel.setParent(parent);
@@ -82,7 +84,7 @@
}
String name = element.getSimpleName().toString();
String type = element.asType().toString();
- List<String> annotations = getAnnotations(element);
+ Map<String, Set<String>> annotations = getAnnotations(element);
classModel.addField(new FieldModel(name, type, annotations));
}
@@ -102,15 +104,15 @@
String name = element.getSimpleName().toString();
String returnType = executableElement.getReturnType().toString();
- List<String> annotations = getAnnotations(element);
+ Map<String, Set<String>> annotations = getAnnotations(element);
MethodModel method = new MethodModel(name, returnType, annotations);
for (VariableElement parameterElement : executableElement.getParameters())
{
String paramName = parameterElement.getSimpleName().toString();
String paramType = parameterElement.asType().toString();
- List<String> paramAnotations = getAnnotations(parameterElement);
- ParameterModel parameter = new ParameterModel(paramName, paramType, paramAnotations);
+ Map<String, Set<String>> paramAnnotations = getAnnotations(element);
+ ParameterModel parameter = new ParameterModel(paramName, paramType, paramAnnotations);
method.addParameter(parameter);
}
// OK, cheating a little with a common model for methods and constructors
@@ -124,12 +126,17 @@
}
}
- public static List<String> getAnnotations(Element element)
+ private static Map<String, Set<String>> getAnnotations(Element element)
{
- List<String> annotations = new ArrayList<String>();
+ Map<String, Set<String>> annotations = new HashMap<String, Set<String>>();
for (AnnotationMirror annotation : element.getAnnotationMirrors())
{
- annotations.add(annotation.getAnnotationType().toString());
+ Set<String> metaAnnotations = new HashSet<String>();
+ for (AnnotationMirror metaAnnotation : annotation.getAnnotationType().asElement().getAnnotationMirrors())
+ {
+ metaAnnotations.add(metaAnnotation.getAnnotationType().toString());
+ }
+ annotations.put(annotation.getAnnotationType().toString(), metaAnnotations);
}
return annotations;
}
Modified: extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/FieldModel.java
===================================================================
--- extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/FieldModel.java 2009-03-16 07:16:55 UTC (rev 2026)
+++ extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/FieldModel.java 2009-03-16 08:12:30 UTC (rev 2027)
@@ -17,19 +17,20 @@
package org.jboss.webbeans.xsd.model;
-import java.util.List;
+import java.util.Map;
+import java.util.Set;
/**
* A model of a field
*
- * @author Nicklas Karlsosn
+ * @author Nicklas Karlsson
*
*/
public class FieldModel extends NamedModel
{
protected String type;
- public FieldModel(String name, String type, List<String> annotations)
+ public FieldModel(String name, String type, Map<String, Set<String>> annotations)
{
super(name, annotations);
this.type = type;
Modified: extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/MethodModel.java
===================================================================
--- extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/MethodModel.java 2009-03-16 07:16:55 UTC (rev 2026)
+++ extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/MethodModel.java 2009-03-16 08:12:30 UTC (rev 2027)
@@ -19,6 +19,8 @@
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
+import java.util.Set;
/**
* The model of a method
@@ -31,7 +33,7 @@
private String returnType;
private List<ParameterModel> parameters = new ArrayList<ParameterModel>();
- public MethodModel(String name, String returnType, List<String> annotations)
+ public MethodModel(String name, String returnType, Map<String, Set<String>> annotations)
{
super(name, annotations);
this.returnType = returnType;
Modified: extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/NamedModel.java
===================================================================
--- extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/NamedModel.java 2009-03-16 07:16:55 UTC (rev 2026)
+++ extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/NamedModel.java 2009-03-16 08:12:30 UTC (rev 2027)
@@ -17,8 +17,8 @@
package org.jboss.webbeans.xsd.model;
-import java.util.HashSet;
-import java.util.List;
+import java.util.HashMap;
+import java.util.Map;
import java.util.Set;
/**
@@ -30,35 +30,35 @@
public class NamedModel
{
protected String name;
- protected Set<String> annotations = new HashSet<String>();
+ protected Map<String, Set<String>> annotations = new HashMap<String, Set<String>>();
public NamedModel()
{
}
- public NamedModel(String name, List<String> annotations)
+ public NamedModel(String name, Map<String, Set<String>> annotations)
{
this.name = name;
- this.annotations.addAll(annotations);
+ this.annotations.putAll(annotations);
}
- public void setAnnotations(List<String> annotations)
+ public String getName()
{
- this.annotations.addAll(annotations);
+ return name;
}
- public Set<String> getAnnotations()
+ public void setName(String name)
{
- return annotations;
+ this.name = name;
}
- public String getName()
+ public Map<String, Set<String>> getAnnotations()
{
- return name;
+ return annotations;
}
- public void setName(String name)
+ public void setAnnotations(Map<String, Set<String>> annotations)
{
- this.name = name;
+ this.annotations = annotations;
}
}
Modified: extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/ParameterModel.java
===================================================================
--- extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/ParameterModel.java 2009-03-16 07:16:55 UTC (rev 2026)
+++ extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/ParameterModel.java 2009-03-16 08:12:30 UTC (rev 2027)
@@ -17,7 +17,8 @@
package org.jboss.webbeans.xsd.model;
-import java.util.List;
+import java.util.Map;
+import java.util.Set;
/**
* The model of a method or constrcutor parameter
@@ -28,7 +29,7 @@
public class ParameterModel extends FieldModel
{
- public ParameterModel(String name, String type, List<String> annotations)
+ public ParameterModel(String name, String type, Map<String, Set<String>> annotations)
{
super(name, type, annotations);
}
15 years, 10 months
[webbeans-commits] Webbeans SVN: r2026 - in extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd: helpers and 2 other directories.
by webbeans-commits@lists.jboss.org
Author: nickarls
Date: 2009-03-16 03:16:55 -0400 (Mon, 16 Mar 2009)
New Revision: 2026
Added:
extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/test/
extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/test/Foo.java
extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/test/Test.java
Modified:
extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/PackageSchemaGenerator.java
extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/helpers/DataSetter.java
extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/ClassModel.java
extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/FieldModel.java
extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/MethodModel.java
extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/NamedModel.java
extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/ParameterModel.java
Log:
annotation detection
Modified: extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/PackageSchemaGenerator.java
===================================================================
--- extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/PackageSchemaGenerator.java 2009-03-16 06:58:11 UTC (rev 2025)
+++ extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/PackageSchemaGenerator.java 2009-03-16 07:16:55 UTC (rev 2026)
@@ -118,6 +118,7 @@
}
// Place the new class model in the cache
helper.cacheClassModel(classModel);
+ System.out.println(classModel);
return classModel;
}
Modified: extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/helpers/DataSetter.java
===================================================================
--- extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/helpers/DataSetter.java 2009-03-16 06:58:11 UTC (rev 2025)
+++ extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/helpers/DataSetter.java 2009-03-16 07:16:55 UTC (rev 2026)
@@ -17,6 +17,10 @@
package org.jboss.webbeans.xsd.helpers;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.Element;
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.Modifier;
@@ -32,7 +36,7 @@
* Helper for examining classes and members and populating the model
*
* @author Nicklas Karlsson
- *
+ *
*/
public class DataSetter
{
@@ -50,16 +54,18 @@
/**
* Inspects a type element and populates a class model
- *
+ *
* @param classModel The class model to populate
* @param element The element to inspect
* @param parent The parent of the class
*/
public static void populateClassModel(ClassModel classModel, Element element, ClassModel parent)
{
+ List<String> annotations = getAnnotations(element);
TypeElement typeElement = (TypeElement) element;
classModel.setName(typeElement.getQualifiedName().toString());
classModel.setParent(parent);
+ classModel.setAnnotations(annotations);
}
/**
@@ -76,7 +82,8 @@
}
String name = element.getSimpleName().toString();
String type = element.asType().toString();
- classModel.addField(new FieldModel(name, type));
+ List<String> annotations = getAnnotations(element);
+ classModel.addField(new FieldModel(name, type, annotations));
}
/**
@@ -95,16 +102,18 @@
String name = element.getSimpleName().toString();
String returnType = executableElement.getReturnType().toString();
- MethodModel method = new MethodModel(name, returnType);
+ List<String> annotations = getAnnotations(element);
+ MethodModel method = new MethodModel(name, returnType, annotations);
for (VariableElement parameterElement : executableElement.getParameters())
{
String paramName = parameterElement.getSimpleName().toString();
String paramType = parameterElement.asType().toString();
- ParameterModel parameter = new ParameterModel(paramName, paramType);
+ List<String> paramAnotations = getAnnotations(parameterElement);
+ ParameterModel parameter = new ParameterModel(paramName, paramType, paramAnotations);
method.addParameter(parameter);
}
- // OK, checting a little with a common model for methods and constructors
+ // OK, cheating a little with a common model for methods and constructors
if ("<init>".equals(name))
{
classModel.addConstructor(method);
@@ -115,4 +124,14 @@
}
}
+ public static List<String> getAnnotations(Element element)
+ {
+ List<String> annotations = new ArrayList<String>();
+ for (AnnotationMirror annotation : element.getAnnotationMirrors())
+ {
+ annotations.add(annotation.getAnnotationType().toString());
+ }
+ return annotations;
+ }
+
}
Modified: extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/ClassModel.java
===================================================================
--- extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/ClassModel.java 2009-03-16 06:58:11 UTC (rev 2025)
+++ extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/ClassModel.java 2009-03-16 07:16:55 UTC (rev 2026)
@@ -81,10 +81,11 @@
public String toString()
{
StringBuilder buffer = new StringBuilder();
- buffer.append("Name: " + name + "\n");
- buffer.append("Constructors: " + getMergedConstructors() + "\n");
- buffer.append("Methods: " + getMergedMethods() + "\n");
- buffer.append("Fields: " + getMergedFields() + "\n");
+ String annotationString = (annotations.isEmpty()) ? "" : "@" + annotations + ": ";
+ buffer.append("----------------------------------\n" + annotationString + name + "\n");
+ buffer.append("Constructors:\n " + getMergedConstructors() + "\n");
+ buffer.append("Methods:\n" + getMergedMethods() + "\n");
+ buffer.append("Fields:\n" + getMergedFields() + "\n");
return buffer.toString();
}
Modified: extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/FieldModel.java
===================================================================
--- extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/FieldModel.java 2009-03-16 06:58:11 UTC (rev 2025)
+++ extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/FieldModel.java 2009-03-16 07:16:55 UTC (rev 2026)
@@ -17,6 +17,8 @@
package org.jboss.webbeans.xsd.model;
+import java.util.List;
+
/**
* A model of a field
*
@@ -27,9 +29,9 @@
{
protected String type;
- public FieldModel(String name, String type)
+ public FieldModel(String name, String type, List<String> annotations)
{
- super(name);
+ super(name, annotations);
this.type = type;
}
@@ -54,7 +56,8 @@
@Override
public String toString()
{
- return type + " " + name;
+ String annotationString = (annotations.isEmpty()) ? "" : "@" + annotations + ": ";
+ return "\n " + annotationString + type + " " + name;
}
}
Modified: extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/MethodModel.java
===================================================================
--- extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/MethodModel.java 2009-03-16 06:58:11 UTC (rev 2025)
+++ extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/MethodModel.java 2009-03-16 07:16:55 UTC (rev 2026)
@@ -31,9 +31,9 @@
private String returnType;
private List<ParameterModel> parameters = new ArrayList<ParameterModel>();
- public MethodModel(String name, String returnType)
+ public MethodModel(String name, String returnType, List<String> annotations)
{
- super(name);
+ super(name, annotations);
this.returnType = returnType;
}
@@ -68,7 +68,8 @@
@Override
public String toString()
{
- return returnType + " " + name + "(" + (parameters.isEmpty() ? "" : parameters) + ")";
+ String annotationString = (annotations.isEmpty()) ? "" : "@" + annotations + ": ";
+ return "\n " + annotationString + returnType + " " + name + "(" + (parameters.isEmpty() ? "" : parameters) + ")";
}
}
Modified: extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/NamedModel.java
===================================================================
--- extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/NamedModel.java 2009-03-16 06:58:11 UTC (rev 2025)
+++ extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/NamedModel.java 2009-03-16 07:16:55 UTC (rev 2026)
@@ -17,25 +17,41 @@
package org.jboss.webbeans.xsd.model;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
/**
* A superclass for named models
*
* @author Nicklas Karlsson
- *
+ *
*/
public class NamedModel
{
protected String name;
+ protected Set<String> annotations = new HashSet<String>();
public NamedModel()
{
}
- public NamedModel(String name)
+ public NamedModel(String name, List<String> annotations)
{
this.name = name;
+ this.annotations.addAll(annotations);
}
+ public void setAnnotations(List<String> annotations)
+ {
+ this.annotations.addAll(annotations);
+ }
+
+ public Set<String> getAnnotations()
+ {
+ return annotations;
+ }
+
public String getName()
{
return name;
Modified: extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/ParameterModel.java
===================================================================
--- extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/ParameterModel.java 2009-03-16 06:58:11 UTC (rev 2025)
+++ extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/ParameterModel.java 2009-03-16 07:16:55 UTC (rev 2026)
@@ -17,6 +17,8 @@
package org.jboss.webbeans.xsd.model;
+import java.util.List;
+
/**
* The model of a method or constrcutor parameter
*
@@ -26,9 +28,9 @@
public class ParameterModel extends FieldModel
{
- public ParameterModel(String name, String type)
+ public ParameterModel(String name, String type, List<String> annotations)
{
- super(name, type);
+ super(name, type, annotations);
}
@Override
@@ -43,5 +45,12 @@
{
return type.hashCode();
}
+
+ @Override
+ public String toString()
+ {
+ String annotationString = (annotations.isEmpty()) ? "" : "@" + annotations + ": ";
+ return "\n " + annotationString + type + " " + name;
+ }
}
Added: extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/test/Foo.java
===================================================================
--- extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/test/Foo.java (rev 0)
+++ extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/test/Foo.java 2009-03-16 07:16:55 UTC (rev 2026)
@@ -0,0 +1,23 @@
+package org.jboss.webbeans.xsd.test;
+
+import javax.inject.Current;
+import javax.inject.Initializer;
+
+@Current
+public class Foo
+{
+ @Current
+ public String foo;
+
+ @Initializer
+ public Foo(String foo)
+ {
+ }
+
+ @Current
+ public String foo(@Current String foo)
+ {
+ return foo;
+ }
+
+}
Added: extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/test/Test.java
===================================================================
--- extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/test/Test.java (rev 0)
+++ extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/test/Test.java 2009-03-16 07:16:55 UTC (rev 2026)
@@ -0,0 +1,30 @@
+package org.jboss.webbeans.xsd.test;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.annotation.processing.AbstractProcessor;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.ToolProvider;
+import javax.tools.JavaCompiler.CompilationTask;
+
+import org.jboss.webbeans.xsd.PackageSchemaGenerator;
+
+public class Test
+{
+
+ public static void main(String[] args)
+ {
+ JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
+ StandardJavaFileManager fileManager = compiler.getStandardFileManager(null, null, null);
+ Iterable<? extends JavaFileObject> compilationUnits = fileManager.getJavaFileObjects(args);
+ CompilationTask task = compiler.getTask(null, fileManager, null, null, null, compilationUnits);
+ List<AbstractProcessor> processors = new ArrayList<AbstractProcessor>();
+ processors.add(new PackageSchemaGenerator());
+ task.setProcessors(processors);
+ task.call();
+ }
+
+}
15 years, 10 months
[webbeans-commits] Webbeans SVN: r2025 - tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/stereotype.
by webbeans-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2009-03-16 02:58:11 -0400 (Mon, 16 Mar 2009)
New Revision: 2025
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/stereotype/StereotypeDefinitionTest.java
Log:
implemented 2.7.c
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/stereotype/StereotypeDefinitionTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/stereotype/StereotypeDefinitionTest.java 2009-03-16 05:57:51 UTC (rev 2024)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/stereotype/StereotypeDefinitionTest.java 2009-03-16 06:58:11 UTC (rev 2025)
@@ -78,11 +78,12 @@
assert false;
}
- @Test(groups = "stub")
+ @Test
@SpecAssertion(section = "2.7", id = "c")
public void testOneStereotype()
{
- assert false;
+ Bean<LongHairedDog> bean = getCurrentManager().resolveByType(LongHairedDog.class).iterator().next();
+ assert bean.getScopeType().equals(RequestScoped.class);
}
@Test
@@ -123,7 +124,7 @@
{
assert false;
- }
+ }
@Test
@SpecAssertions( { @SpecAssertion(section = "2.7.1.4", id = "b"),
15 years, 10 months
[webbeans-commits] Webbeans SVN: r2024 - in tck/trunk/impl/src/main: java/org/jboss/jsr299/tck/tests/definition/stereotype and 1 other directories.
by webbeans-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2009-03-16 01:57:51 -0400 (Mon, 16 Mar 2009)
New Revision: 2024
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/deployment/Goat.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/stereotype/Goat.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/stereotype/NonStereotype.java
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/deployment/DeploymentTypeDefinitionTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/stereotype/StereotypeDefinitionTest.java
tck/trunk/impl/src/main/resources/tck-audit.xml
Log:
marked more assertions untestable, implemented 2.7.1.b, 2.5.3.i
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/deployment/DeploymentTypeDefinitionTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/deployment/DeploymentTypeDefinitionTest.java 2009-03-16 05:18:54 UTC (rev 2023)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/deployment/DeploymentTypeDefinitionTest.java 2009-03-16 05:57:51 UTC (rev 2024)
@@ -46,7 +46,7 @@
@Test(groups = { "deploymentType" })
@SpecAssertion(section = "2.5.3", id = "c")
- public void testDeploymentTypeInhertitedFromDeclaringBean() throws Exception
+ public void testDeploymentTypeInheritedFromDeclaringBean() throws Exception
{
assert getCurrentManager().resolveByType(BlackWidow.class).size() == 1;
Bean<BlackWidow> blackWidowSpiderModel = getCurrentManager().resolveByType(BlackWidow.class).iterator().next();
@@ -108,6 +108,15 @@
Bean<Reindeer> bean = getCurrentManager().resolveByType(Reindeer.class).iterator().next();
assert bean.getDeploymentType().equals(Production.class);
}
+
+ @Test
+ @SpecAssertion(section = "2.5.3", id = "i")
+ public void testDeploymentTypeMayBeSpecifiedByStereotype()
+ {
+ assert getCurrentManager().resolveByType(Goat.class).size() == 1;
+ Bean<Goat> bean = getCurrentManager().resolveByType(Goat.class).iterator().next();
+ assert bean.getDeploymentType().equals(HornedAnimalDeploymentType.class);
+ }
@Test(groups = { "deploymentType" })
@SpecAssertion(section = "4.1", id = "ca")
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/deployment/Goat.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/deployment/Goat.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/deployment/Goat.java 2009-03-16 05:57:51 UTC (rev 2024)
@@ -0,0 +1,7 @@
+package org.jboss.jsr299.tck.tests.definition.deployment;
+
+@HornedMammalStereotype
+class Goat implements Animal
+{
+
+}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/stereotype/Goat.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/stereotype/Goat.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/stereotype/Goat.java 2009-03-16 05:57:51 UTC (rev 2024)
@@ -0,0 +1,7 @@
+package org.jboss.jsr299.tck.tests.definition.stereotype;
+
+@NonStereotype
+class Goat
+{
+
+}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/stereotype/NonStereotype.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/stereotype/NonStereotype.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/stereotype/NonStereotype.java 2009-03-16 05:57:51 UTC (rev 2024)
@@ -0,0 +1,15 @@
+package org.jboss.jsr299.tck.tests.definition.stereotype;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+@Target( { TYPE })
+@Retention(RUNTIME)
+@HornedAnimalDeploymentType
+@interface NonStereotype
+{
+
+}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/stereotype/StereotypeDefinitionTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/stereotype/StereotypeDefinitionTest.java 2009-03-16 05:18:54 UTC (rev 2023)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/stereotype/StereotypeDefinitionTest.java 2009-03-16 05:57:51 UTC (rev 2024)
@@ -24,34 +24,15 @@
@Artifact
@BeansXml("beans.xml")
public class StereotypeDefinitionTest extends AbstractJSR299Test
-{
-
+{
private static final Annotation TAME_LITERAL = new AnnotationLiteral<Tame>() {};
- /**
- * TODO Difficult to test since all user defined stereotypes are not known
- * here
- *
- * PLM - agreed, as the spec doesn't say what exception to throw. Probably this won't be tested
- */
- @Test(groups = { "stub", "annotationDefinition" })
- @SpecAssertion(section = "2.7.1", id = "aa")
- public void testHasCorrectTarget()
- {
- assert false;
- }
-
- /**
- * TODO If the stereotype does not have a stereotype annotation, then it
- * isn't one and is difficult to test
- *
- * PLM - just test that a stereotype which doesn't have the annotation isn't used as such
- */
- @Test(groups = { "stub", "annotationDefinition" })
+ @Test(groups = { "annotationDefinition" })
@SpecAssertion(section = "2.7.1", id = "b")
public void testHasStereotypeAnnotation()
{
- assert false;
+ Bean<Goat> bean = getCurrentManager().resolveByType(Goat.class).iterator().next();
+ assert !bean.getDeploymentType().equals(HornedAnimalDeploymentType.class);
}
@Test
Modified: tck/trunk/impl/src/main/resources/tck-audit.xml
===================================================================
--- tck/trunk/impl/src/main/resources/tck-audit.xml 2009-03-16 05:18:54 UTC (rev 2023)
+++ tck/trunk/impl/src/main/resources/tck-audit.xml 2009-03-16 05:57:51 UTC (rev 2024)
@@ -538,19 +538,19 @@
</section>
<section id="2.7.1" title="Defining new stereotypes">
- <assertion id="aa">
+ <assertion id="aa" testable="false">
<text>A beans stereotype is a Java annotation defined as @Target({TYPE, METHOD, FIELD})~, @Target(TYPE), @Target(METHOD), @Target(FIELD) or @Target({METHOD, FIELD}) and @Retention(RUNTIME)~</text>
</assertion>
- <assertion id="ab">
+ <assertion id="ab" testable="false">
<text>A beans stereotype is a Java annotation defined as ~@Target({TYPE, METHOD, FIELD}),~ @Target(TYPE)~, @Target(METHOD), @Target(FIELD) or @Target({METHOD, FIELD}) and @Retention(RUNTIME)~</text>
</assertion>
- <assertion id="ac">
+ <assertion id="ac" testable="false">
<text>A beans stereotype is a Java annotation defined as ~@Target({TYPE, METHOD, FIELD}), @Target(TYPE), @Target(METHOD), ~@Target(FIELD) ~or @Target({METHOD, FIELD}) and @Retention(RUNTIME)~</text>
</assertion>
- <assertion id="ad">
+ <assertion id="ad" testable="false">
<text>A beans stereotype is a Java annotation defined as ~@Target({TYPE, METHOD, FIELD}), @Target(TYPE), @Target(METHOD), @Target(FIELD) or~ @Target({METHOD, FIELD})~ and @Retention(RUNTIME)~</text>
</assertion>
15 years, 10 months
[webbeans-commits] Webbeans SVN: r2023 - in tck/trunk/impl/src/main: java/org/jboss/jsr299/tck/tests/implementation/producer/method/definition and 2 other directories.
by webbeans-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2009-03-16 01:18:54 -0400 (Mon, 16 Mar 2009)
New Revision: 2023
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/definition/Deadliest.java
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/binding/BindingDefinitionTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/definition/DefangedTarantula.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/definition/ProducerMethodDefinitionTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/definition/Spider.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/definition/SpiderProducer.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/definition/Tarantula.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/InjectionTest.java
tck/trunk/impl/src/main/resources/tck-audit.xml
Log:
test for 2.3.6.a, removed empty test for untestable assertion
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/binding/BindingDefinitionTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/binding/BindingDefinitionTest.java 2009-03-16 01:42:30 UTC (rev 2022)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/binding/BindingDefinitionTest.java 2009-03-16 05:18:54 UTC (rev 2023)
@@ -41,16 +41,6 @@
assert injectionPoint.getBean().getBindings().iterator().next().annotationType().equals(Current.class);
}
- @Test(groups = { "annotationDefinition", "stub" })
- @SpecAssertion(section = "2.3.2", id = "aa")
- public void testBindingHasCorrectTarget()
- {
- // TODO This is only a definition without any real assertion about a given
- // binding type
- // If there are many binding types, how do we find them?
- assert false;
- }
-
@Test(groups = { "annotationDefinition" })
@SpecAssertion(section = "2.3.2", id = "b")
public void testBindingDeclaresBindingAnnotation()
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/definition/Deadliest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/definition/Deadliest.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/definition/Deadliest.java 2009-03-16 05:18:54 UTC (rev 2023)
@@ -0,0 +1,22 @@
+package org.jboss.jsr299.tck.tests.implementation.producer.method.definition;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.inject.BindingType;
+
+@Target( { TYPE, METHOD, PARAMETER, FIELD })
+@Retention(RUNTIME)
+@Documented
+@BindingType
+@interface Deadliest
+{
+
+}
\ No newline at end of file
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/definition/DefangedTarantula.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/definition/DefangedTarantula.java 2009-03-16 01:42:30 UTC (rev 2022)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/definition/DefangedTarantula.java 2009-03-16 05:18:54 UTC (rev 2023)
@@ -2,5 +2,5 @@
class DefangedTarantula extends Tarantula
{
-
+ @Override public int getDeathsCaused() { return 0; }
}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/definition/ProducerMethodDefinitionTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/definition/ProducerMethodDefinitionTest.java 2009-03-16 01:42:30 UTC (rev 2022)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/definition/ProducerMethodDefinitionTest.java 2009-03-16 05:18:54 UTC (rev 2023)
@@ -26,6 +26,7 @@
{
private static final Annotation TAME_LITERAL = new AnnotationLiteral<Tame>() {};
+ private static final Annotation DEADLIEST_LITERAL = new AnnotationLiteral<Deadliest>() {};
@Test(groups = "producerMethod")
@SpecAssertion(section = "2.5.3", id = "g")
@@ -203,4 +204,13 @@
System.out.println(getCurrentManager().getInstanceByType(Egg.class, new AnnotationLiteral<Yummy>() {}).getMother().getClass());
assert getCurrentManager().getInstanceByType(Egg.class, new AnnotationLiteral<Yummy>() {}).getMother().getClass().equals(Chicken.class);
}
+
+ @Test
+ @SpecAssertion(section = "2.3.6", id = "a")
+ public void testBindingTypesAppliedToProducerMethodParameters()
+ {
+ Bean<Tarantula> tarantula = getCurrentManager().resolveByType(Tarantula.class, DEADLIEST_LITERAL).iterator().next();
+ Tarantula instance = getCurrentManager().getInstance(tarantula);
+ assert instance.getDeathsCaused() == 1;
+ }
}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/definition/Spider.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/definition/Spider.java 2009-03-16 01:42:30 UTC (rev 2022)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/definition/Spider.java 2009-03-16 05:18:54 UTC (rev 2023)
@@ -3,5 +3,5 @@
class Spider implements Animal
{
-
+
}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/definition/SpiderProducer.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/definition/SpiderProducer.java 2009-03-16 01:42:30 UTC (rev 2022)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/definition/SpiderProducer.java 2009-03-16 05:18:54 UTC (rev 2023)
@@ -2,6 +2,7 @@
import javax.annotation.Named;
import javax.context.RequestScoped;
+import javax.inject.Current;
import javax.inject.Produces;
@AnotherDeploymentType
@@ -15,6 +16,13 @@
return new DefangedTarantula();
}
+ @Produces @Deadliest public Tarantula producesDeadliestTarantula(@Tame Tarantula tameTarantula,
+ @Current Tarantula tarantula)
+ {
+ return tameTarantula.getDeathsCaused() >= tarantula.getDeathsCaused() ?
+ tameTarantula : tarantula;
+ }
+
@Produces public Tarantula produceTarantula()
{
return new Tarantula();
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/definition/Tarantula.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/definition/Tarantula.java 2009-03-16 01:42:30 UTC (rev 2022)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/definition/Tarantula.java 2009-03-16 05:18:54 UTC (rev 2023)
@@ -1,6 +1,6 @@
package org.jboss.jsr299.tck.tests.implementation.producer.method.definition;
class Tarantula extends Spider implements DeadlySpider
-{
-
+{
+ public int getDeathsCaused() { return 1; }
}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/InjectionTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/InjectionTest.java 2009-03-16 01:42:30 UTC (rev 2022)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/InjectionTest.java 2009-03-16 05:18:54 UTC (rev 2023)
@@ -49,10 +49,10 @@
assert foxRun.fox.getName().equals("gavin");
}
- @Test @SpecAssertion(section="4.2", id = "aa")
+ @Test
+ @SpecAssertion(section="4.2", id = "aa")
public void testFieldDeclaredInSuperclassInjected() throws Exception
- {
-
+ {
new RunInDependentContext()
{
@Override
Modified: tck/trunk/impl/src/main/resources/tck-audit.xml
===================================================================
--- tck/trunk/impl/src/main/resources/tck-audit.xml 2009-03-16 01:42:30 UTC (rev 2022)
+++ tck/trunk/impl/src/main/resources/tck-audit.xml 2009-03-16 05:18:54 UTC (rev 2023)
@@ -112,7 +112,7 @@
</section>
<section id="2.3.2" title="Defining new binding types">
- <assertion id="aa">
+ <assertion id="aa" testable="false">
<text>A binding type is a Java annotation defined as @Target({METHOD, FIELD, PARAMETER, TYPE})~ and @Retention(RUNTIME)~.</text>
</assertion>
15 years, 10 months
[webbeans-commits] Webbeans SVN: r2021 - tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/interceptor.
by webbeans-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2009-03-15 21:39:20 -0400 (Sun, 15 Mar 2009)
New Revision: 2021
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/interceptor/InterceptorDefinitionTest.java
Log:
test stub
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/interceptor/InterceptorDefinitionTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/interceptor/InterceptorDefinitionTest.java 2009-03-16 01:38:54 UTC (rev 2020)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/interceptor/InterceptorDefinitionTest.java 2009-03-16 01:39:20 UTC (rev 2021)
@@ -11,16 +11,25 @@
public class InterceptorDefinitionTest
{
- @Test(groups="stub") @SpecAssertion(section="4.2", id = "ca")
+ @Test(groups="stub")
+ @SpecAssertion(section="4.2", id = "ca")
public void testNonStaticWithInterceptorBindingInherited()
{
assert false;
}
- @Test(groups="stub") @SpecAssertion(section="4.2", id = "ca")
+ @Test(groups="stub")
+ @SpecAssertion(section="4.2", id = "ca")
public void testNonStaticWithInterceptorBindingBlockedByIntermediateClass()
{
assert false;
}
+ @Test(groups="stub")
+ @SpecAssertion(section = "4.1", id="ac")
+ public void testDirectInheritedClassInheritsInterceptor()
+ {
+ assert false;
+ }
+
}
15 years, 10 months
[webbeans-commits] Webbeans SVN: r2020 - in tck/trunk/impl/src/main: resources and 1 other directory.
by webbeans-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2009-03-15 21:38:54 -0400 (Sun, 15 Mar 2009)
New Revision: 2020
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/manager/ManagerTest.java
tck/trunk/impl/src/main/resources/tck-audit.xml
Log:
5.7.2 tests, reword assertions
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/manager/ManagerTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/manager/ManagerTest.java 2009-03-16 01:13:04 UTC (rev 2019)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/manager/ManagerTest.java 2009-03-16 01:38:54 UTC (rev 2020)
@@ -1,5 +1,11 @@
package org.jboss.jsr299.tck.tests.lookup.manager;
+import javax.context.Dependent;
+import javax.inject.Current;
+import javax.inject.Standard;
+import javax.inject.manager.Bean;
+import javax.inject.manager.Manager;
+
import org.hibernate.tck.annotations.SpecAssertion;
import org.jboss.jsr299.tck.AbstractJSR299Test;
import org.jboss.testharness.impl.packaging.Artifact;
@@ -27,7 +33,34 @@
assert fishFarmOffice.manager != null;
}
- }.run();
-
+ }.run();
}
+
+ @Test
+ @SpecAssertion(section = "5.7.2", id = "aa")
+ public void testContainerProvidesManagerBean()
+ {
+ assert getCurrentManager().resolveByType(Manager.class).size() > 0;
+ }
+
+ @SpecAssertion(section = "5.7.2", id = "ab")
+ public void testManagerBeanIsDependentScoped()
+ {
+ Bean<Manager> manager = getCurrentManager().resolveByType(Manager.class).iterator().next();
+ assert manager.getScopeType().equals(Dependent.class);
+ }
+
+ @SpecAssertion(section = "5.7.2", id = "ac")
+ public void testManagerBeanHasStandardDeployment()
+ {
+ Bean<Manager> manager = getCurrentManager().resolveByType(Manager.class).iterator().next();
+ assert manager.getDeploymentType().equals(Standard.class);
+ }
+
+ @SpecAssertion(section = "5.7.2", id = "ad")
+ public void testManagerBeanHasCurrentBinding()
+ {
+ Bean<Manager> manager = getCurrentManager().resolveByType(Manager.class).iterator().next();
+ assert manager.getBindings().iterator().next() instanceof Current;
+ }
}
Modified: tck/trunk/impl/src/main/resources/tck-audit.xml
===================================================================
--- tck/trunk/impl/src/main/resources/tck-audit.xml 2009-03-16 01:13:04 UTC (rev 2019)
+++ tck/trunk/impl/src/main/resources/tck-audit.xml 2009-03-16 01:38:54 UTC (rev 2020)
@@ -2989,15 +2989,15 @@
</assertion>
<assertion id="ab">
- <text>The container provides a built-in bean with scope @Dependent</text>
+ <text>The container-provided Manager bean has a scope type of @Dependent</text>
</assertion>
<assertion id="ac">
- <text>The container provides a built-in bean with deployment type @Standard</text>
+ <text>The container-provided Manager bean has a deployment type of @Standard</text>
</assertion>
<assertion id="ad">
- <text>The container provides a built-in bean with binding @Current.</text>
+ <text>The container-provided Manager bean has a binding type of @Current.</text>
</assertion>
<assertion id="b">
15 years, 10 months
[webbeans-commits] Webbeans SVN: r2019 - ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap and 7 other directories.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-03-15 21:13:04 -0400 (Sun, 15 Mar 2009)
New Revision: 2019
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanValidator.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/ManagerImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/ResolvableAnnotatedClass.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedItem.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedMember.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedType.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedAnnotationImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedClassImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedFieldImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedMethodImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedParameterImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/Types.java
ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/implementation/producer/field/ParameterizedListInjection.java
ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/implementation/producer/field/ParameterizedProducerTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/EventTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/register/fires1/ImplicitEventBeanTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dynamic/DynamicLookupTest.java
Log:
WBRI-186
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanValidator.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanValidator.java 2009-03-16 01:07:06 UTC (rev 2018)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanValidator.java 2009-03-16 01:13:04 UTC (rev 2019)
@@ -36,6 +36,8 @@
import org.jboss.webbeans.bean.NewEnterpriseBean;
import org.jboss.webbeans.bean.NewSimpleBean;
import org.jboss.webbeans.bean.RIBean;
+import org.jboss.webbeans.injection.ResolvableAnnotatedClass;
+import org.jboss.webbeans.introspector.AnnotatedItem;
import org.jboss.webbeans.metadata.MetaDataCache;
import org.jboss.webbeans.util.Beans;
import org.jboss.webbeans.util.ListComparator;
@@ -72,41 +74,34 @@
{
for (InjectionPoint injectionPoint : bean.getInjectionPoints())
{
- if (injectionPoint.getType() instanceof Class)
+ if (injectionPoint.getAnnotation(New.class) != null && injectionPoint.getBindings().size() > 1)
{
- Class<?> type = (Class<?>) injectionPoint.getType();
- if (injectionPoint.getAnnotation(New.class) != null && injectionPoint.getBindings().size() > 1)
- {
- throw new DefinitionException("The injection point " + injectionPoint + " is annotated with @New which cannot be combined with other binding types");
- }
- Annotation[] bindings = injectionPoint.getBindings().toArray(new Annotation[0]);
- Set<?> resolvedBeans = manager.resolveByType(type, bindings);
- if (resolvedBeans.isEmpty())
- {
- throw new UnsatisfiedDependencyException("The injection point " + injectionPoint + " with binding types " + Names.annotationsToString(injectionPoint.getBindings()) + " in " + bean + " has unsatisfied dependencies with binding types ");
- }
- if (resolvedBeans.size() > 1)
- {
- throw new AmbiguousDependencyException("The injection point " + injectionPoint + " with binding types " + Names.annotationsToString(injectionPoint.getBindings()) + " in " + bean + " has ambiguous dependencies");
- }
- Bean<?> resolvedBean = (Bean<?>) resolvedBeans.iterator().next();
- if (MetaDataCache.instance().getScopeModel(resolvedBean.getScopeType()).isNormal() && !Proxies.isTypeProxyable(type))
- {
- throw new UnproxyableDependencyException("The injection point " + injectionPoint + " has non-proxyable dependencies");
- }
- if (Reflections.isPrimitive((Class<?>) injectionPoint.getType()) && resolvedBean.isNullable())
- {
- throw new NullableDependencyException("The injection point " + injectionPoint + " has nullable dependencies");
- }
- if (Beans.isPassivatingBean(bean) && !resolvedBean.isSerializable())
- {
- throw new UnserializableDependencyException("The bean " + bean + " declares a passivating scopes but has non-serializable dependencies");
- }
+ throw new DefinitionException("The injection point " + injectionPoint + " is annotated with @New which cannot be combined with other binding types");
}
- else
+ Annotation[] bindings = injectionPoint.getBindings().toArray(new Annotation[0]);
+ AnnotatedItem<?, ?> annotatedItem = ResolvableAnnotatedClass.of(injectionPoint.getType(), bindings);
+ Set<?> resolvedBeans = manager.resolveByType(annotatedItem, bindings);
+ if (resolvedBeans.isEmpty())
{
- throw new UnsupportedOperationException("Not yet implemented");
+ throw new UnsatisfiedDependencyException("The injection point " + injectionPoint + " with binding types " + Names.annotationsToString(injectionPoint.getBindings()) + " in " + bean + " has unsatisfied dependencies with binding types ");
}
+ if (resolvedBeans.size() > 1)
+ {
+ throw new AmbiguousDependencyException("The injection point " + injectionPoint + " with binding types " + Names.annotationsToString(injectionPoint.getBindings()) + " in " + bean + " has ambiguous dependencies");
+ }
+ Bean<?> resolvedBean = (Bean<?>) resolvedBeans.iterator().next();
+ if (MetaDataCache.instance().getScopeModel(resolvedBean.getScopeType()).isNormal() && !Proxies.isTypeProxyable(injectionPoint.getType()))
+ {
+ throw new UnproxyableDependencyException("The injection point " + injectionPoint + " has non-proxyable dependencies");
+ }
+ if (Reflections.isPrimitive(annotatedItem.getRawType()) && resolvedBean.isNullable())
+ {
+ throw new NullableDependencyException("The injection point " + injectionPoint + " has nullable dependencies");
+ }
+ if (Beans.isPassivatingBean(bean) && !resolvedBean.isSerializable())
+ {
+ throw new UnserializableDependencyException("The bean " + bean + " declares a passivating scopes but has non-serializable dependencies");
+ }
}
if (bean instanceof RIBean && !(bean instanceof NewSimpleBean) && !(bean instanceof NewEnterpriseBean))
{
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/ManagerImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/ManagerImpl.java 2009-03-16 01:07:06 UTC (rev 2018)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/ManagerImpl.java 2009-03-16 01:13:04 UTC (rev 2019)
@@ -350,7 +350,7 @@
}
if (bindings.length > element.getMetaAnnotations(BindingType.class).size())
{
- throw new DuplicateBindingTypeException("Duplicate bindings type passed " + element.toString());
+ throw new DuplicateBindingTypeException("Duplicate bindings (" + Arrays.asList(bindings) + ") type passed " + element.toString());
}
return resolver.get(element);
}
@@ -640,7 +640,7 @@
{
currentInjectionPoint.get().push(injectionPoint);
}
- AnnotatedItem<T, ?> element = ResolvableAnnotatedClass.of((Class<T>) injectionPoint.getType(), injectionPoint.getBindings().toArray(new Annotation[0]));
+ AnnotatedItem<T, ?> element = ResolvableAnnotatedClass.of(injectionPoint.getType(), injectionPoint.getBindings().toArray(new Annotation[0]));
Bean<T> bean = getBeanByType(element, element.getBindingsAsArray());
if (creationalContext instanceof CreationalContextImpl)
{
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java 2009-03-16 01:07:06 UTC (rev 2018)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java 2009-03-16 01:13:04 UTC (rev 2019)
@@ -66,7 +66,7 @@
public void addClass(Class<?> clazz)
{
- if (!clazz.isAnnotation())
+ if (!clazz.isAnnotation() && !clazz.isEnum())
{
deferredClasses.add(AnnotatedClassImpl.of(clazz));
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/ResolvableAnnotatedClass.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/ResolvableAnnotatedClass.java 2009-03-16 01:07:06 UTC (rev 2018)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/ResolvableAnnotatedClass.java 2009-03-16 01:13:04 UTC (rev 2019)
@@ -39,6 +39,22 @@
return new ResolvableAnnotatedClass<T>(clazz, clazz, annotations);
}
+ public static <T> ResolvableAnnotatedClass<T> of(Type type, Annotation[] annotations)
+ {
+ if (type instanceof Class)
+ {
+ return new ResolvableAnnotatedClass<T>((Class<T>) type, type, annotations);
+ }
+ else if (type instanceof ParameterizedType)
+ {
+ return new ResolvableAnnotatedClass<T>((Class<T>) ((ParameterizedType) type).getRawType(), type, annotations);
+ }
+ else
+ {
+ throw new UnsupportedOperationException("Cannot create annotated item of " + type);
+ }
+ }
+
public static <T> ResolvableAnnotatedClass<T> of(Member member, Annotation[] annotations)
{
if (member instanceof Field)
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedItem.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedItem.java 2009-03-16 01:07:06 UTC (rev 2018)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedItem.java 2009-03-16 01:13:04 UTC (rev 2019)
@@ -52,16 +52,13 @@
AnnotationStore getAnnotationStore();
}
-
- public Type getType()
- {
- return getRawType();
- }
// Cached string representation
private String toString;
private final AnnotationStore annotationStore;
private final Class<T> rawType;
+ private final Type[] actualTypeArguments;
+ private final Type type;
private final Set<? extends Type> flattenedTypes;
private final boolean proxyable;
private final boolean _parameterizedType;
@@ -75,12 +72,21 @@
* @param annotationMap A map of annotation to register
*
*/
- public AbstractAnnotatedItem(AnnotationStore annotatedItemHelper, Class<T> rawType)
+ public AbstractAnnotatedItem(AnnotationStore annotatedItemHelper, Class<T> rawType, Type type)
{
this.annotationStore = annotatedItemHelper;
this.rawType = rawType;
+ this.type = type;
+ if (type instanceof ParameterizedType)
+ {
+ this.actualTypeArguments = ((ParameterizedType) type).getActualTypeArguments();
+ }
+ else
+ {
+ this.actualTypeArguments = new Type[0];
+ }
this._parameterizedType = Reflections.isParameterizedType(rawType);
- this.flattenedTypes = new Reflections.HierarchyDiscovery<Type>(rawType).getFlattenedTypes();
+ this.flattenedTypes = new Reflections.HierarchyDiscovery<Type>(type).getFlattenedTypes();
this.proxyable = Proxies.isTypesProxyable(flattenedTypes);
}
@@ -88,6 +94,8 @@
{
this.annotationStore = annotatedItemHelper;
this.rawType = null;
+ this.type = null;
+ this.actualTypeArguments = new Type[0];
this._parameterizedType = false;
this.flattenedTypes = null;
this.proxyable = false;
@@ -280,6 +288,16 @@
return rawType;
}
+ public Type getType()
+ {
+ return type;
+ }
+
+ public Type[] getActualTypeArguments()
+ {
+ return actualTypeArguments;
+ }
+
public Set<? extends Type> getFlattenedTypeHierarchy()
{
return flattenedTypes;
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedMember.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedMember.java 2009-03-16 01:07:06 UTC (rev 2018)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedMember.java 2009-03-16 01:13:04 UTC (rev 2019)
@@ -20,6 +20,7 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.Member;
import java.lang.reflect.Modifier;
+import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -110,9 +111,9 @@
*
* @param annotationMap The annotation map
*/
- public AbstractAnnotatedMember(AnnotationStore annotatedItemHelper, Member member, Class<T> type)
+ protected AbstractAnnotatedMember(AnnotationStore annotatedItemHelper, Member member, Class<T> rawType, Type type)
{
- super(annotatedItemHelper, type);
+ super(annotatedItemHelper, rawType, type);
name = member.getName();
_public = Modifier.isPublic(member.getModifiers());
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedType.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedType.java 2009-03-16 01:07:06 UTC (rev 2018)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedType.java 2009-03-16 01:13:04 UTC (rev 2019)
@@ -18,6 +18,7 @@
package org.jboss.webbeans.introspector.jlr;
import java.lang.reflect.Modifier;
+import java.lang.reflect.Type;
import org.jboss.webbeans.introspector.AnnotatedClass;
import org.jboss.webbeans.introspector.AnnotatedType;
@@ -52,20 +53,20 @@
*
* @param annotationMap The annotation map
*/
- public AbstractAnnotatedType(AnnotationStore annotatedItemHelper, Class<T> type)
+ public AbstractAnnotatedType(AnnotationStore annotatedItemHelper, Class<T> rawType, Type type)
{
- super(annotatedItemHelper, type);
- this.name = type.getName();
- this._simpleName = type.getSimpleName();
- if (type.getSuperclass() != null)
+ super(annotatedItemHelper, rawType, type);
+ this.name = rawType.getName();
+ this._simpleName = rawType.getSimpleName();
+ if (rawType.getSuperclass() != null)
{
- this.superclass = AnnotatedClassImpl.of(type.getSuperclass());
+ this.superclass = AnnotatedClassImpl.of(rawType.getSuperclass());
}
else
{
this.superclass = null;
}
- this._public = Modifier.isFinal(type.getModifiers());
+ this._public = Modifier.isFinal(rawType.getModifiers());
}
/**
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedAnnotationImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedAnnotationImpl.java 2009-03-16 01:07:06 UTC (rev 2018)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedAnnotationImpl.java 2009-03-16 01:13:04 UTC (rev 2019)
@@ -19,7 +19,6 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
-import java.lang.reflect.Type;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
@@ -111,7 +110,7 @@
*/
public AnnotatedAnnotationImpl(Class<T> annotationType)
{
- super(AnnotationStore.of(annotationType), annotationType);
+ super(AnnotationStore.of(annotationType), annotationType, annotationType);
this.clazz = annotationType;
members = new HashSet<AnnotatedMethod<?>>();
annotatedMembers = new AnnotatedMemberMap();
@@ -127,18 +126,6 @@
}
/**
- * Gets the actual type arguments
- *
- * @return The type arguments
- *
- * @see org.jboss.webbeans.introspector.AnnotatedAnnotation#getActualTypeArguments()
- */
- public Type[] getActualTypeArguments()
- {
- return new Type[0];
- }
-
- /**
* Gets all members of the annotation
*
* Initializes the members first if they are null
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedClassImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedClassImpl.java 2009-03-16 01:07:06 UTC (rev 2018)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedClassImpl.java 2009-03-16 01:13:04 UTC (rev 2019)
@@ -21,7 +21,6 @@
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
-import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.Arrays;
import java.util.Collections;
@@ -211,11 +210,6 @@
}
}
- // The implementing class
- private final Class<T> clazz;
- // The type arguments
- private final Type[] actualTypeArguments;
-
// The set of abstracted fields
private final Set<AnnotatedField<?>> fields;
// The map from annotation type to abstracted field with annotation
@@ -265,16 +259,7 @@
private AnnotatedClassImpl(Class<T> rawType, Type type, Annotation[] annotations, Annotation[] declaredAnnotations)
{
- super(AnnotationStore.of(annotations, declaredAnnotations), rawType);
- this.clazz = rawType;
- if (type instanceof ParameterizedType)
- {
- actualTypeArguments = ((ParameterizedType) type).getActualTypeArguments();
- }
- else
- {
- actualTypeArguments = new Type[0];
- }
+ super(AnnotationStore.of(annotations, declaredAnnotations), rawType, type);
this.fields = new HashSet<AnnotatedField<?>>();
this.annotatedFields = new AnnotatedFieldMap();
@@ -284,7 +269,7 @@
this.declaredMetaAnnotatedFields = new AnnotatedFieldMap();
this._nonStaticMemberClass = Reflections.isNonMemberInnerClass(rawType);
this._abstract = Reflections.isAbstract(rawType);
- for (Class<?> c = clazz; c != Object.class && c != null; c = c.getSuperclass())
+ for (Class<?> c = rawType; c != Object.class && c != null; c = c.getSuperclass())
{
for (Field field : c.getDeclaredFields())
{
@@ -294,21 +279,21 @@
}
AnnotatedField<?> annotatedField = new AnnotatedFieldImpl<Object>(field, this);
this.fields.add(annotatedField);
- if (c == clazz)
+ if (c == rawType)
{
this.declaredFields.add(annotatedField);
}
for (Annotation annotation : annotatedField.getAnnotationsAsSet())
{
this.annotatedFields.put(annotation.annotationType(), annotatedField);
- if (c == clazz)
+ if (c == rawType)
{
this.declaredAnnotatedFields.put(annotation.annotationType(), annotatedField);
}
for (Annotation metaAnnotation : annotation.annotationType().getAnnotations())
{
this.metaAnnotatedFields.put(metaAnnotation.annotationType(), annotatedField);
- if (c == clazz)
+ if (c == rawType)
{
this.declaredMetaAnnotatedFields.put(metaAnnotation.annotationType(), annotatedField);
}
@@ -321,7 +306,7 @@
this.constructors = new HashSet<AnnotatedConstructor<T>>();
this.constructorsByArgumentMap = new ConstructorsByArgumentMap();
this.annotatedConstructors = new AnnotatedConstructorMap();
- for (Constructor<?> constructor : clazz.getDeclaredConstructors())
+ for (Constructor<?> constructor : rawType.getDeclaredConstructors())
{
@SuppressWarnings("unchecked")
Constructor<T> c = (Constructor<T>) constructor;
@@ -349,7 +334,7 @@
this.declaredMethods = new HashSet<AnnotatedMethod<?>>();
this.declaredAnnotatedMethods = new AnnotatedMethodMap();
this.declaredMethodsByAnnotatedParameters = new AnnotatedMethodMap();
- for (Class<?> c = clazz; c != Object.class && c != null; c = c.getSuperclass())
+ for (Class<?> c = rawType; c != Object.class && c != null; c = c.getSuperclass())
{
for (Method method : c.getDeclaredMethods())
{
@@ -360,14 +345,14 @@
AnnotatedMethod<?> annotatedMethod = AnnotatedMethodImpl.of(method, this);
this.methods.add(annotatedMethod);
- if (c == clazz)
+ if (c == rawType)
{
this.declaredMethods.add(annotatedMethod);
}
for (Annotation annotation : annotatedMethod.getAnnotationsAsSet())
{
annotatedMethods.put(annotation.annotationType(), annotatedMethod);
- if (c == clazz)
+ if (c == rawType)
{
this.declaredAnnotatedMethods.put(annotation.annotationType(), annotatedMethod);
}
@@ -377,7 +362,7 @@
if (annotatedMethod.getAnnotatedParameters(annotationType).size() > 0)
{
methodsByAnnotatedParameters.put(annotationType, annotatedMethod);
- if (c == clazz)
+ if (c == rawType)
{
this.declaredMethodsByAnnotatedParameters.put(annotationType, annotatedMethod);
}
@@ -394,7 +379,7 @@
*/
public Class<? extends T> getAnnotatedClass()
{
- return clazz;
+ return getRawType();
}
/**
@@ -404,7 +389,7 @@
*/
public Class<T> getDelegate()
{
- return clazz;
+ return getRawType();
}
/**
@@ -485,18 +470,6 @@
}
/**
- * Gets the actual type arguments
- *
- * @return The type arguments
- *
- * @see org.jboss.webbeans.introspector.AnnotatedClass#getActualTypeArguments()
- */
- public Type[] getActualTypeArguments()
- {
- return actualTypeArguments;
- }
-
- /**
* Gets the abstracted methods that have a certain annotation type present
*
* If the annotated methods map is null, initialize it first
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java 2009-03-16 01:07:06 UTC (rev 2018)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java 2009-03-16 01:13:04 UTC (rev 2019)
@@ -45,9 +45,6 @@
public class AnnotatedConstructorImpl<T> extends AbstractAnnotatedMember<T, Constructor<T>> implements AnnotatedConstructor<T>
{
-
- // The type arguments
- private static final Type[] actualTypeArguments = new Type[0];
// The underlying constructor
private final Constructor<T> constructor;
@@ -77,7 +74,7 @@
*/
public AnnotatedConstructorImpl(Constructor<T> constructor, AnnotatedType<T> declaringClass)
{
- super(AnnotationStore.of(constructor), constructor, constructor.getDeclaringClass());
+ super(AnnotationStore.of(constructor), constructor, constructor.getDeclaringClass(), constructor.getDeclaringClass());
this.constructor = constructor;
this.declaringClass = declaringClass;
@@ -88,7 +85,8 @@
if (constructor.getParameterAnnotations()[i].length > 0)
{
Class<?> clazz = constructor.getParameterTypes()[i];
- AnnotatedParameter<?> parameter = AnnotatedParameterImpl.of(constructor.getParameterAnnotations()[i], clazz, this);
+ Type type = constructor.getGenericParameterTypes()[i];
+ AnnotatedParameter<?> parameter = AnnotatedParameterImpl.of(constructor.getParameterAnnotations()[i], clazz, type, this);
parameters.add(parameter);
for (Annotation annotation : parameter.getAnnotationsAsSet())
@@ -99,7 +97,8 @@
else
{
Class<?> clazz = constructor.getParameterTypes()[i];
- AnnotatedParameter<?> parameter = AnnotatedParameterImpl.of(new Annotation[0], clazz, this);
+ Type type = constructor.getGenericParameterTypes()[i];
+ AnnotatedParameter<?> parameter = AnnotatedParameterImpl.of(new Annotation[0], clazz, type, this);
parameters.add(parameter);
for (Annotation annotation : parameter.getAnnotationsAsSet())
@@ -131,18 +130,6 @@
}
/**
- * Gets the actual type arguments
- *
- * @return The type arguments
- *
- * @see org.jboss.webbeans.introspector.AnnotatedConstructor#getActualTypeArguments()
- */
- public Type[] getActualTypeArguments()
- {
- return actualTypeArguments;
- }
-
- /**
* Gets the abstracted parameters
*
* If the parameters are null, initalize them first
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedFieldImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedFieldImpl.java 2009-03-16 01:07:06 UTC (rev 2018)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedFieldImpl.java 2009-03-16 01:13:04 UTC (rev 2019)
@@ -18,8 +18,6 @@
package org.jboss.webbeans.introspector.jlr;
import java.lang.reflect.Field;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
import org.jboss.webbeans.introspector.AnnotatedField;
import org.jboss.webbeans.introspector.AnnotatedType;
@@ -39,8 +37,6 @@
public class AnnotatedFieldImpl<T> extends AbstractAnnotatedMember<T, Field> implements AnnotatedField<T>
{
- // The actual type arguments
- private final Type[] actualTypeArguments;
// The underlying field
private final Field field;
// The abstraction of the declaring class
@@ -60,19 +56,10 @@
*/
public AnnotatedFieldImpl(Field field, AnnotatedType<?> declaringClass)
{
- super(AnnotationStore.of(field), field, (Class<T>) field.getType());
+ super(AnnotationStore.of(field), field, (Class<T>) field.getType(), field.getGenericType());
this.field = field;
field.setAccessible(true);
this.declaringClass = declaringClass;
- if (field.getGenericType() instanceof ParameterizedType)
- {
- ParameterizedType type = (ParameterizedType) field.getGenericType();
- actualTypeArguments = type.getActualTypeArguments();
- }
- else
- {
- actualTypeArguments = new Type[0];
- }
}
/**
@@ -89,18 +76,6 @@
{
return field;
}
-
- /**
- * Gets the actual type arguments
- *
- * @return The type arguments
- *
- * @see org.jboss.webbeans.introspector.AnnotatedField#getActualTypeArguments()
- */
- public Type[] getActualTypeArguments()
- {
- return actualTypeArguments;
- }
public void set(Object instance, Object value) throws IllegalArgumentException, IllegalAccessException
{
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedMethodImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedMethodImpl.java 2009-03-16 01:07:06 UTC (rev 2018)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedMethodImpl.java 2009-03-16 01:13:04 UTC (rev 2019)
@@ -20,13 +20,11 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
-import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
-import java.util.Set;
import org.jboss.webbeans.introspector.AnnotatedMethod;
import org.jboss.webbeans.introspector.AnnotatedParameter;
@@ -47,10 +45,6 @@
public class AnnotatedMethodImpl<T> extends AbstractAnnotatedMember<T, Method> implements AnnotatedMethod<T>
{
- // The actual type arguments
- private final Type[] actualTypeArguments;
- private final Type underlyingType;
- private final Class<T> type;
// The underlying method
private final Method method;
@@ -69,8 +63,6 @@
// Cached string representation
private String toString;
- private final Set<? extends Type> flattenedTypes;
-
public static <T> AnnotatedMethodImpl<T> of(Method method, AnnotatedType<?> declaringClass)
{
return new AnnotatedMethodImpl<T>(method, declaringClass);
@@ -88,24 +80,10 @@
@SuppressWarnings("unchecked")
protected AnnotatedMethodImpl(Method method, AnnotatedType<?> declaringClass)
{
- super(AnnotationStore.of(method), method, (Class<T>) method.getReturnType());
+ super(AnnotationStore.of(method), method, (Class<T>) method.getReturnType(), method.getGenericReturnType());
this.method = method;
this.method.setAccessible(true);
this.declaringClass = declaringClass;
- this.type = (Class<T>) method.getReturnType();
- if (method.getGenericReturnType() instanceof ParameterizedType)
- {
- this.underlyingType = method.getGenericReturnType();
- this.flattenedTypes = new Reflections.HierarchyDiscovery<Type>(underlyingType).getFlattenedTypes();
- this.actualTypeArguments = ((ParameterizedType) underlyingType).getActualTypeArguments();
- }
- else
- {
- this.underlyingType = type;
- this.flattenedTypes = super.getFlattenedTypeHierarchy();
- this.actualTypeArguments = new Type[0];
- }
-
this.parameters = new ArrayList<AnnotatedParameter<?>>();
this.annotatedParameters = new AnnotatedParameterMap();
for (int i = 0; i < method.getParameterTypes().length; i++)
@@ -113,7 +91,8 @@
if (method.getParameterAnnotations()[i].length > 0)
{
Class<? extends Object> clazz = method.getParameterTypes()[i];
- AnnotatedParameter<?> parameter = AnnotatedParameterImpl.of(method.getParameterAnnotations()[i], (Class<Object>) clazz, this);
+ Type type = method.getGenericParameterTypes()[i];
+ AnnotatedParameter<?> parameter = AnnotatedParameterImpl.of(method.getParameterAnnotations()[i], (Class<Object>) clazz, type, this);
this.parameters.add(parameter);
for (Annotation annotation : parameter.getAnnotationsAsSet())
{
@@ -126,7 +105,8 @@
else
{
Class<? extends Object> clazz = method.getParameterTypes()[i];
- AnnotatedParameter<?> parameter = AnnotatedParameterImpl.of(new Annotation[0], (Class<Object>) clazz, this);
+ Type type = method.getGenericParameterTypes()[i];
+ AnnotatedParameter<?> parameter = AnnotatedParameterImpl.of(new Annotation[0], (Class<Object>) clazz, type, this);
this.parameters.add(parameter);
}
}
@@ -151,18 +131,7 @@
{
return method;
}
-
- @Override
- public Type getType()
- {
- return underlyingType;
- }
- public Type[] getActualTypeArguments()
- {
- return actualTypeArguments;
- }
-
public List<AnnotatedParameter<?>> getParameters()
{
return Collections.unmodifiableList(parameters);
@@ -240,10 +209,4 @@
return toString;
}
- @Override
- public Set<? extends Type> getFlattenedTypeHierarchy()
- {
- return flattenedTypes;
- }
-
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedParameterImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedParameterImpl.java 2009-03-16 01:07:06 UTC (rev 2018)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedParameterImpl.java 2009-03-16 01:13:04 UTC (rev 2019)
@@ -40,10 +40,6 @@
public class AnnotatedParameterImpl<T> extends AbstractAnnotatedItem<T, Object> implements AnnotatedParameter<T>
{
- // The type
- private final Class<T> type;
- // The actual type arguments
- private final Type[] actualTypeArguments = new Type[0];
// The final state
private final boolean _final = false;
// The static state
@@ -54,9 +50,9 @@
// Cached string representation
private String toString;
- public static <T> AnnotatedParameter<T> of(Annotation[] annotations, Class<T> clazz, AnnotatedMember<?, ?> declaringMember)
+ public static <T> AnnotatedParameter<T> of(Annotation[] annotations, Class<T> rawType, Type type, AnnotatedMember<?, ?> declaringMember)
{
- return new AnnotatedParameterImpl<T>(annotations, clazz, declaringMember);
+ return new AnnotatedParameterImpl<T>(annotations, rawType, type, declaringMember);
}
/**
@@ -65,26 +61,13 @@
* @param annotations The annotations array
* @param type The type of the parameter
*/
- private AnnotatedParameterImpl(Annotation[] annotations, Class<T> type, AnnotatedMember<?, ?> declaringMember)
+ protected AnnotatedParameterImpl(Annotation[] annotations, Class<T> rawType, Type type, AnnotatedMember<?, ?> declaringMember)
{
- super(AnnotationStore.of(annotations, annotations), type);
- this.type = type;
+ super(AnnotationStore.of(annotations, annotations), rawType, type);
this.declaringMember = declaringMember;
}
/**
- * Gets the actual type arguments
- *
- * @return The type arguments
- *
- * @see org.jboss.webbeans.introspector.AnnotatedItem#getActualTypeArguments()
- */
- public Type[] getActualTypeArguments()
- {
- return actualTypeArguments;
- }
-
- /**
* Gets the delegate
*
* @return The delegate (null)
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/Types.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/util/Types.java 2009-03-16 01:07:06 UTC (rev 2018)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/util/Types.java 2009-03-16 01:13:04 UTC (rev 2019)
@@ -68,6 +68,10 @@
{
return Double.class;
}
+ else if (type.equals(Void.TYPE))
+ {
+ return Void.class;
+ }
else
{
throw new IllegalStateException("Some weird type!!!");
Modified: ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/implementation/producer/field/ParameterizedListInjection.java
===================================================================
--- ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/implementation/producer/field/ParameterizedListInjection.java 2009-03-16 01:07:06 UTC (rev 2018)
+++ ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/implementation/producer/field/ParameterizedListInjection.java 2009-03-16 01:13:04 UTC (rev 2019)
@@ -2,27 +2,30 @@
import java.util.List;
+import javax.inject.Current;
+import javax.inject.Initializer;
+
public class ParameterizedListInjection
{
private List<String> value;
- //@Current
+ @Current
private List<String> fieldInjection;
private List<String> setterInjection;
- //@Initializer
+ @Initializer
public void init(List<String> setterInjection)
{
this.setterInjection = setterInjection;
}
- /*@Initializer
+ @Initializer
public ParameterizedListInjection(List<String> com)
{
this.value = com;
- }*/
+ }
public java.util.List<String> getValue()
{
Modified: ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/implementation/producer/field/ParameterizedProducerTest.java
===================================================================
--- ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/implementation/producer/field/ParameterizedProducerTest.java 2009-03-16 01:07:06 UTC (rev 2018)
+++ ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/implementation/producer/field/ParameterizedProducerTest.java 2009-03-16 01:13:04 UTC (rev 2019)
@@ -6,19 +6,20 @@
import org.jboss.testharness.impl.packaging.Artifact;
import org.jboss.webbeans.test.unit.AbstractWebBeansTest;
+import org.testng.annotations.Test;
@Artifact
public class ParameterizedProducerTest extends AbstractWebBeansTest
{
- //@Test
+ @Test
public void testInjectManagerProducer()
{
assert manager.getInstanceByType(new TypeLiteral<List<String>>(){}).size() == 2;
ParameterizedListInjection item = manager.getInstanceByType(ParameterizedListInjection.class);
+ assert item.getFieldInjection().size() == 2;
assert item.getValue().size() == 2;
- assert item.getFieldInjection().size() == 2;
assert item.getSetterInjection().size() == 2;
}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/EventTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/EventTest.java 2009-03-16 01:07:06 UTC (rev 2018)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/EventTest.java 2009-03-16 01:13:04 UTC (rev 2019)
@@ -9,6 +9,7 @@
import javax.event.Observer;
import javax.inject.DuplicateBindingTypeException;
import javax.inject.Standard;
+import javax.inject.TypeLiteral;
import javax.inject.manager.Bean;
import javax.inject.manager.Manager;
@@ -584,7 +585,7 @@
}.run();
}
- @Test(groups = { "events" })
+ @Test(groups = { "events", "ri-broken" })
@SpecAssertions( { @SpecAssertion(section = "7.6", id = "n") } )
public void testImplicitEventBeanMatchesAPITypeOfInectionPoint() throws Exception
{
@@ -596,14 +597,14 @@
{
// Retrieve the implicit event bean from the manager only by
// its API type
- Set<?> eventBeans = getCurrentManager().resolveByType(Event.class, new FiresBinding());
+ Set<?> eventBeans = getCurrentManager().resolveByType(new TypeLiteral<Event<AnEventType>>() {}, new FiresBinding());
assert !eventBeans.isEmpty();
}
}.run();
}
- @Test(groups = { "events" })
+ @Test(groups = { "events", "ri-broken" })
@SpecAssertions( { @SpecAssertion(section = "7.6", id = "n") } )
public void testImplicitEventBeanMatchesBindingAnnotationsOfInjectionPoint() throws Exception
{
@@ -615,14 +616,14 @@
{
// Retrieve the implicit event bean from the manager
// by its binding types (uses OrangeCheekedWaxbill)
- Set<?> eventBeans = getCurrentManager().resolveByType(Event.class, new FiresBinding(), new TameAnnotationLiteral(), new RoleBinding("Admin"));
+ Set<?> eventBeans = getCurrentManager().resolveByType(new TypeLiteral<Event<AnEventType>>() {}, new FiresBinding(), new TameAnnotationLiteral(), new RoleBinding("Admin"));
assert !eventBeans.isEmpty();
}
}.run();
}
- @Test(groups = { "events" })
+ @Test(groups = { "events", "ri-broken" })
@SpecAssertion(section = "7.6", id = "o")
public void testImplicitEventBeanHasStandardDeploymentType() throws Exception
{
@@ -634,7 +635,7 @@
{
// Retrieve the implicit event bean from the manager
// only by its API type (uses BlueFacedParrotFinch)
- Set<?> eventBeans = getCurrentManager().resolveByType(Event.class, new FiresBinding());
+ Set<?> eventBeans = getCurrentManager().resolveByType(new TypeLiteral<Event<AnEventType>>() {}, new FiresBinding());
assert eventBeans.size() == 1;
Bean<?> eventBean = (Bean<?>) eventBeans.iterator().next();
assert eventBean.getDeploymentType().equals(Standard.class);
@@ -643,7 +644,7 @@
}.run();
}
- @Test(groups = { "events" })
+ @Test(groups = { "events", "ri-broken" })
@SpecAssertion(section = "7.6", id = "p")
public void testImplicitEventBeanHasDependentScope() throws Exception
{
@@ -654,7 +655,7 @@
{
// Retrieve the implicit event bean from the manager only
// by its API type (uses BlueFacedParrotFinch)
- Set<?> eventBeans = getCurrentManager().resolveByType(Event.class, new FiresBinding());
+ Set<?> eventBeans = getCurrentManager().resolveByType(new TypeLiteral<Event<AnEventType>>() {}, new FiresBinding());
assert eventBeans.size() == 1;
Bean<?> eventBean = (Bean<?>) eventBeans.iterator().next();
assert eventBean.getScopeType().equals(Dependent.class);
@@ -662,7 +663,7 @@
}.run();
}
- @Test(groups = { "events" })
+ @Test(groups = { "events", "ri-broken" })
@SpecAssertion(section = "7.6", id = "q")
public void testImplicitEventBeanHasNoName() throws Exception
{
@@ -673,7 +674,7 @@
{
// Retrieve the implicit event bean from the manager only
// by its API type (uses BlueFacedParrotFinch)
- Set<?> eventBeans = getCurrentManager().resolveByType(Event.class, new FiresBinding());
+ Set<?> eventBeans = getCurrentManager().resolveByType(new TypeLiteral<Event<AnEventType>>() {}, new FiresBinding());
assert eventBeans.size() == 1;
Bean<?> eventBean = (Bean<?>) eventBeans.iterator().next();
assert eventBean.getName() == null;
@@ -681,7 +682,7 @@
}.run();
}
- @Test(groups = { "events" })
+ @Test(groups = { "events", "ri-broken" })
@SpecAssertions( { @SpecAssertion(section = "7.6", id = "a"), @SpecAssertion(section = "7.6", id = "r") } )
public void testImplicitEventBeanProvidedByContainer() throws Exception
{
@@ -692,7 +693,7 @@
{
// Retrieve the implicit event bean from the manager only
// by its API type (uses BlueFacedParrotFinch)
- Set<?> eventBeans = getCurrentManager().resolveByType(Event.class, new FiresBinding());
+ Set<?> eventBeans = getCurrentManager().resolveByType(new TypeLiteral<Event<AnEventType>>() {}, new FiresBinding());
assert eventBeans.size() == 1;
}
}.run();
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/register/fires1/ImplicitEventBeanTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/register/fires1/ImplicitEventBeanTest.java 2009-03-16 01:07:06 UTC (rev 2018)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/register/fires1/ImplicitEventBeanTest.java 2009-03-16 01:13:04 UTC (rev 2019)
@@ -17,10 +17,8 @@
package org.jboss.jsr299.tck.tests.event.register.fires1;
-import java.lang.annotation.Annotation;
import java.util.Set;
-import javax.event.Event;
import javax.event.Observer;
import org.hibernate.tck.annotations.SpecAssertion;
@@ -110,11 +108,4 @@
}.run();
}
- @Test(groups = { "events" })
- @SpecAssertions( { @SpecAssertion(section = "7.6", id = "e"), @SpecAssertion(section = "7.6", id = "f") })
- public void testImplicitEventBeanFireSignature() throws Exception
- {
- // All implicit event beans directly use the Event interface
- assert Event.class.getDeclaredMethod("fire", Object.class, Annotation[].class) != null;
- }
}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dynamic/DynamicLookupTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dynamic/DynamicLookupTest.java 2009-03-16 01:07:06 UTC (rev 2018)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dynamic/DynamicLookupTest.java 2009-03-16 01:13:04 UTC (rev 2019)
@@ -2,10 +2,13 @@
import static org.jboss.jsr299.tck.tests.lookup.dynamic.PayBy.PaymentMethod.CHEQUE;
+import java.util.Set;
+
import javax.context.Dependent;
import javax.inject.DuplicateBindingTypeException;
import javax.inject.Instance;
import javax.inject.Standard;
+import javax.inject.TypeLiteral;
import javax.inject.manager.Bean;
import org.hibernate.tck.annotations.SpecAssertion;
@@ -83,9 +86,9 @@
})
public void testImplicitBeanExists()
{
- Bean<Instance> instanceBean = getCurrentManager().resolveByType(Instance.class,
- new PayByBinding() { public PaymentMethod value() { return CHEQUE; }}).iterator().next();
-
+ Set<Bean<Instance<PaymentProcessor>>> beans = getCurrentManager().resolveByType(new TypeLiteral<Instance<PaymentProcessor>>() {}, new PayByBinding() { public PaymentMethod value() { return CHEQUE; }});
+ assert beans.size() == 1;
+ Bean<Instance<PaymentProcessor>> instanceBean = beans.iterator().next();
assert instanceBean != null;
assert instanceBean.getDeploymentType().equals(Standard.class);
assert instanceBean.getScopeType().equals(Dependent.class);
15 years, 10 months
[webbeans-commits] Webbeans SVN: r2018 - doc/trunk/reference/en-US.
by webbeans-commits@lists.jboss.org
Author: alartin
Date: 2009-03-15 21:07:06 -0400 (Sun, 15 Mar 2009)
New Revision: 2018
Modified:
doc/trunk/reference/en-US/Author_Group.xml
Log:
add Simplified Chinese translator
Modified: doc/trunk/reference/en-US/Author_Group.xml
===================================================================
--- doc/trunk/reference/en-US/Author_Group.xml 2009-03-15 21:07:30 UTC (rev 2017)
+++ doc/trunk/reference/en-US/Author_Group.xml 2009-03-16 01:07:06 UTC (rev 2018)
@@ -52,4 +52,11 @@
<surname>Milesi</surname>
<contrib>Italian Translation</contrib>
</othercredit>
+ <othercredit>
+ <firstname>Sean</firstname>
+ <surname>Wu</surname>
+ <contrib>Simplified Chinese Translation</contrib>
+ <affiliation>
+ <orgname>Kava Community</orgname>
+ </affiliation>
</authorgroup>
15 years, 10 months