[jboss-cvs] JBossAS SVN: r93184 - in projects/annotations/trunk: core/src/main/java/org/jboss/annotations and 8 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Sep 3 13:44:59 EDT 2009
Author: jesper.pedersen
Date: 2009-09-03 13:44:59 -0400 (Thu, 03 Sep 2009)
New Revision: 93184
Added:
projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/tests/classconstructorwithparameterannotation/
projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/tests/classconstructorwithparameterannotation/Test.java
projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/tests/classconstructorwithparameterannotation/package.html
projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/tests/classmethodwithparameterannotation/
projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/tests/classmethodwithparameterannotation/Test.java
projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/tests/classmethodwithparameterannotation/package.html
projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/tests/interfacemethodwithparameterannotation/
projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/tests/interfacemethodwithparameterannotation/Test.java
projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/tests/interfacemethodwithparameterannotation/package.html
Modified:
projects/annotations/trunk/core/build.xml
projects/annotations/trunk/core/src/main/java/org/jboss/annotations/Annotation.java
projects/annotations/trunk/core/src/main/java/org/jboss/annotations/AnnotationType.java
projects/annotations/trunk/core/src/main/java/org/jboss/annotations/Configuration.java
projects/annotations/trunk/core/src/main/java/org/jboss/annotations/Settings.java
projects/annotations/trunk/core/src/main/java/org/jboss/annotations/impl/AbstractAnnotationScanner.java
projects/annotations/trunk/core/src/main/java/org/jboss/annotations/impl/AbstractJavassistAnnotationScanner.java
projects/annotations/trunk/core/src/main/java/org/jboss/annotations/impl/AnnotationRepositoryImpl.java
projects/annotations/trunk/core/src/main/java/org/jboss/annotations/impl/ConfigurationImpl.java
projects/annotations/trunk/core/src/main/java/org/jboss/annotations/impl/SettingsImpl.java
projects/annotations/trunk/core/src/main/java/org/jboss/annotations/javalangreflect/JavaClass.java
projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/AnnotationRepositoryTests.java
projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/ClassInfoTests.java
projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/ClassTests.java
projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/InterfaceTests.java
projects/annotations/trunk/doc/userguide/en/modules/introduction.xml
Log:
[JBANN-14] Add support for parameter level annotations
Modified: projects/annotations/trunk/core/build.xml
===================================================================
--- projects/annotations/trunk/core/build.xml 2009-09-03 16:32:43 UTC (rev 93183)
+++ projects/annotations/trunk/core/build.xml 2009-09-03 17:44:59 UTC (rev 93184)
@@ -82,6 +82,9 @@
<jar destfile="${build.core.dir}/testjars/classconstructorwithparameter.jar"
basedir="${build.core.dir}/test"
includes="**/common/**, **/classconstructorwithparameter/**"/>
+ <jar destfile="${build.core.dir}/testjars/classconstructorwithparameterannotation.jar"
+ basedir="${build.core.dir}/test"
+ includes="**/common/**, **/classconstructorwithparameterannotation/**"/>
<jar destfile="${build.core.dir}/testjars/classempty.jar"
basedir="${build.core.dir}/test"
includes="**/common/**, **/classempty/**"/>
@@ -100,6 +103,9 @@
<jar destfile="${build.core.dir}/testjars/classmethodwithparameter.jar"
basedir="${build.core.dir}/test"
includes="**/common/**, **/classmethodwithparameter/**"/>
+ <jar destfile="${build.core.dir}/testjars/classmethodwithparameterannotation.jar"
+ basedir="${build.core.dir}/test"
+ includes="**/common/**, **/classmethodwithparameterannotation/**"/>
<jar destfile="${build.core.dir}/testjars/classfield.jar"
basedir="${build.core.dir}/test"
includes="**/common/**, **/classfield/**"/>
@@ -131,6 +137,9 @@
<jar destfile="${build.core.dir}/testjars/interfacemethodwithparameter.jar"
basedir="${build.core.dir}/test"
includes="**/common/**, **/interfacemethodwithparameter/**"/>
+ <jar destfile="${build.core.dir}/testjars/interfacemethodwithparameterannotation.jar"
+ basedir="${build.core.dir}/test"
+ includes="**/common/**, **/interfacemethodwithparameterannotation/**"/>
</target>
<!-- =================================
@@ -145,12 +154,14 @@
<indexer input="${build.core.dir}/testjars/classabstract.jar"/>
<indexer input="${build.core.dir}/testjars/classconstructor.jar"/>
<indexer input="${build.core.dir}/testjars/classconstructorwithparameter.jar"/>
+ <indexer input="${build.core.dir}/testjars/classconstructorwithparameterannotation.jar"/>
<indexer input="${build.core.dir}/testjars/classempty.jar"/>
<indexer input="${build.core.dir}/testjars/classinterface.jar"/>
<indexer input="${build.core.dir}/testjars/classinterfacemethod.jar"/>
<indexer input="${build.core.dir}/testjars/classlevel.jar"/>
<indexer input="${build.core.dir}/testjars/classmethod.jar"/>
<indexer input="${build.core.dir}/testjars/classmethodwithparameter.jar"/>
+ <indexer input="${build.core.dir}/testjars/classmethodwithparameterannotation.jar"/>
<indexer input="${build.core.dir}/testjars/classfield.jar"/>
<!-- Inheritance based tests -->
@@ -164,6 +175,7 @@
<indexer input="${build.core.dir}/testjars/interfacelevel.jar"/>
<indexer input="${build.core.dir}/testjars/interfacemethod.jar"/>
<indexer input="${build.core.dir}/testjars/interfacemethodwithparameter.jar"/>
+ <indexer input="${build.core.dir}/testjars/interfacemethodwithparameterannotation.jar"/>
<mkdir dir="${reports.dir}"/>
<mkdir dir="${reports.dir}/indexer"/>
Modified: projects/annotations/trunk/core/src/main/java/org/jboss/annotations/Annotation.java
===================================================================
--- projects/annotations/trunk/core/src/main/java/org/jboss/annotations/Annotation.java 2009-09-03 16:32:43 UTC (rev 93183)
+++ projects/annotations/trunk/core/src/main/java/org/jboss/annotations/Annotation.java 2009-09-03 17:44:59 UTC (rev 93184)
@@ -41,6 +41,7 @@
private String className;
private String memberName;
private List<String> parameterTypes;
+ private int parameterIndex;
private transient Integer hashCode;
/**
@@ -51,9 +52,10 @@
* @param className The fully qualified class name of the class where the annotation is located
* @param memberName The name of the field or method; <code>null</code> if class or constructor
* @param parameterTypes The fully qualified class names of all parameters if any otherwise <code>null</code>
+ * @param parameterIndex The parameter index for parameter annotations; <code>-1</code> if not needed
*/
public Annotation(String annotationClassName, Object annotation, AnnotationType type,
- String className, String memberName, String[] parameterTypes)
+ String className, String memberName, String[] parameterTypes, int parameterIndex)
{
if (annotationClassName == null)
throw new IllegalArgumentException("AnnotationClassName is null");
@@ -73,6 +75,7 @@
this.className = className;
this.memberName = memberName;
this.parameterTypes = null;
+ this.parameterIndex = parameterIndex;
if (parameterTypes != null)
{
@@ -142,6 +145,15 @@
}
/**
+ * Get the parameter index for parameter annotation
+ * @return The index
+ */
+ public int getParameterIndex()
+ {
+ return parameterIndex;
+ }
+
+ /**
* Hash code of the object
* @return The hash code
*/
@@ -155,6 +167,7 @@
result += 7 * className.hashCode();
result += 7 * (memberName != null ? memberName.hashCode() : 1);
result += 7 * (parameterTypes != null ? parameterTypes.hashCode() : 1);
+ result += 7 * parameterIndex;
return result;
}
@@ -217,6 +230,9 @@
}
}
+ if (result)
+ result = parameterIndex == a.getParameterIndex();
+
return result;
}
@@ -235,6 +251,7 @@
sb = sb.append("Class=" + className + ",");
sb = sb.append("Member=" + memberName + ",");
sb = sb.append("Parameters=" + parameterTypes);
+ sb = sb.append("ParameterIndex=" + parameterIndex);
sb = sb.append("]");
return sb.toString();
}
Modified: projects/annotations/trunk/core/src/main/java/org/jboss/annotations/AnnotationType.java
===================================================================
--- projects/annotations/trunk/core/src/main/java/org/jboss/annotations/AnnotationType.java 2009-09-03 16:32:43 UTC (rev 93183)
+++ projects/annotations/trunk/core/src/main/java/org/jboss/annotations/AnnotationType.java 2009-09-03 17:44:59 UTC (rev 93184)
@@ -38,5 +38,8 @@
CONSTRUCTOR,
/** Method level */
- METHOD
+ METHOD,
+
+ /** Parameter level */
+ PARAMETER
}
Modified: projects/annotations/trunk/core/src/main/java/org/jboss/annotations/Configuration.java
===================================================================
--- projects/annotations/trunk/core/src/main/java/org/jboss/annotations/Configuration.java 2009-09-03 16:32:43 UTC (rev 93183)
+++ projects/annotations/trunk/core/src/main/java/org/jboss/annotations/Configuration.java 2009-09-03 17:44:59 UTC (rev 93184)
@@ -131,4 +131,17 @@
* @return The visibility
*/
public Visibility getMethodVisibility();
+
+ /**
+ * Scan for annotations at parameter level - default is <code>true</code>
+ * @param scan True if scanning should be performed; otherwise false
+ * @return The configuration
+ */
+ public Configuration parameterLevel(boolean scan);
+
+ /**
+ * Is the parameter level enabled ?
+ * @return True if enabled; otherwise false
+ */
+ public boolean isParameterLevel();
}
Modified: projects/annotations/trunk/core/src/main/java/org/jboss/annotations/Settings.java
===================================================================
--- projects/annotations/trunk/core/src/main/java/org/jboss/annotations/Settings.java 2009-09-03 16:32:43 UTC (rev 93183)
+++ projects/annotations/trunk/core/src/main/java/org/jboss/annotations/Settings.java 2009-09-03 17:44:59 UTC (rev 93184)
@@ -79,6 +79,12 @@
public Visibility getMethodVisibility();
/**
+ * Is the parameter level enabled ?
+ * @return True if enabled; otherwise false
+ */
+ public boolean isParameterLevel();
+
+ /**
* Fold annotations on to classes that extends/implements the class
* where the annotation is located - default: true
* @param fold True if folding should be performed; otherwise false
Modified: projects/annotations/trunk/core/src/main/java/org/jboss/annotations/impl/AbstractAnnotationScanner.java
===================================================================
--- projects/annotations/trunk/core/src/main/java/org/jboss/annotations/impl/AbstractAnnotationScanner.java 2009-09-03 16:32:43 UTC (rev 93183)
+++ projects/annotations/trunk/core/src/main/java/org/jboss/annotations/impl/AbstractAnnotationScanner.java 2009-09-03 17:44:59 UTC (rev 93184)
@@ -234,7 +234,8 @@
configuration.isConstructorLevel(),
configuration.getConstructorVisibility(),
configuration.isMethodLevel(),
- configuration.getMethodVisibility());
+ configuration.getMethodVisibility(),
+ configuration.isParameterLevel());
}
/**
Modified: projects/annotations/trunk/core/src/main/java/org/jboss/annotations/impl/AbstractJavassistAnnotationScanner.java
===================================================================
--- projects/annotations/trunk/core/src/main/java/org/jboss/annotations/impl/AbstractJavassistAnnotationScanner.java 2009-09-03 16:32:43 UTC (rev 93183)
+++ projects/annotations/trunk/core/src/main/java/org/jboss/annotations/impl/AbstractJavassistAnnotationScanner.java 2009-09-03 17:44:59 UTC (rev 93184)
@@ -121,7 +121,7 @@
{
processAnnotation(annotation,
AnnotationType.CLASS,
- ctClass.getName(), null, null,
+ ctClass.getName(), null, null, -1,
ari, annotationToClasses, classInfo);
}
}
@@ -163,10 +163,28 @@
{
processAnnotation(annotation,
AnnotationType.CONSTRUCTOR,
- ctClass.getName(), null, parameterTypes,
+ ctClass.getName(), null, parameterTypes, -1,
ari, annotationToClasses, classInfo);
}
}
+
+ if (parameterTypes != null && configuration.isParameterLevel())
+ {
+ Object[][] parameterAnnotations = constructor.getAvailableParameterAnnotations();
+
+ for (int i = 0; i < parameterAnnotations.length; i++)
+ {
+ for (int j = 0; j < parameterAnnotations[i].length; j++)
+ {
+ Object annotation = parameterAnnotations[i][j];
+ processAnnotation(annotation,
+ AnnotationType.PARAMETER,
+ ctClass.getName(), null, parameterTypes, i,
+ ari, annotationToClasses, classInfo);
+
+ }
+ }
+ }
}
}
}
@@ -207,10 +225,29 @@
{
processAnnotation(annotation,
AnnotationType.METHOD,
- ctClass.getName(), method.getName(), parameterTypes,
+ ctClass.getName(), method.getName(), parameterTypes, -1,
ari, annotationToClasses, classInfo);
}
}
+
+
+ if (parameterTypes != null && configuration.isParameterLevel())
+ {
+ Object[][] parameterAnnotations = method.getAvailableParameterAnnotations();
+
+ for (int i = 0; i < parameterAnnotations.length; i++)
+ {
+ for (int j = 0; j < parameterAnnotations[i].length; j++)
+ {
+ Object annotation = parameterAnnotations[i][j];
+ processAnnotation(annotation,
+ AnnotationType.PARAMETER,
+ ctClass.getName(), method.getName(), parameterTypes, i,
+ ari, annotationToClasses, classInfo);
+
+ }
+ }
+ }
}
}
}
@@ -236,7 +273,7 @@
{
processAnnotation(annotation,
AnnotationType.FIELD,
- ctClass.getName(), field.getName(), null,
+ ctClass.getName(), field.getName(), null, -1,
ari, annotationToClasses, classInfo);
}
}
@@ -279,12 +316,14 @@
* @param className The class name
* @param memberName The member name
* @param parameterTypes The parameter types
+ * @param parameterIndex The parameter index
* @param ari The annotation repository implementation loaded from metadata
* @param annotationToClasses The annotation to classes mapping
* @param classInfo The class information map
*/
protected void processAnnotation(Object annotation,
- AnnotationType type, String className, String memberName, String[] parameterTypes,
+ AnnotationType type, String className, String memberName,
+ String[] parameterTypes, int parameterIndex,
AnnotationRepositoryImpl ari,
Map<String, Collection<String>> annotationToClasses,
Map<String, ClassInfo> classInfo)
@@ -295,7 +334,8 @@
Annotation a = new Annotation(acn,
annotationClass.cast(annotation),
type,
- className, memberName, parameterTypes);
+ className, memberName,
+ parameterTypes, parameterIndex);
if (trace)
log.finest("Annotation=" + a);
Modified: projects/annotations/trunk/core/src/main/java/org/jboss/annotations/impl/AnnotationRepositoryImpl.java
===================================================================
--- projects/annotations/trunk/core/src/main/java/org/jboss/annotations/impl/AnnotationRepositoryImpl.java 2009-09-03 16:32:43 UTC (rev 93183)
+++ projects/annotations/trunk/core/src/main/java/org/jboss/annotations/impl/AnnotationRepositoryImpl.java 2009-09-03 17:44:59 UTC (rev 93184)
@@ -321,7 +321,8 @@
{
Annotation na = new Annotation(a.getAnnotationClassName(), a.getAnnotation(),
a.getType(), chdi.getClassName(),
- a.getMemberName(), a.getParameterTypes());
+ a.getMemberName(),
+ a.getParameterTypes(), a.getParameterIndex());
result.add(na);
}
}
Modified: projects/annotations/trunk/core/src/main/java/org/jboss/annotations/impl/ConfigurationImpl.java
===================================================================
--- projects/annotations/trunk/core/src/main/java/org/jboss/annotations/impl/ConfigurationImpl.java 2009-09-03 16:32:43 UTC (rev 93183)
+++ projects/annotations/trunk/core/src/main/java/org/jboss/annotations/impl/ConfigurationImpl.java 2009-09-03 17:44:59 UTC (rev 93184)
@@ -39,6 +39,7 @@
private Visibility constructorVisibility;
private boolean methodLevel;
private Visibility methodVisibility;
+ private boolean parameterLevel;
/**
* Constructor
@@ -53,6 +54,7 @@
constructorVisibility = Visibility.PRIVATE;
methodLevel = true;
methodVisibility = Visibility.PRIVATE;
+ parameterLevel = true;
}
@@ -223,4 +225,25 @@
{
return methodVisibility;
}
+
+ /**
+ * Scan for annotations at parameter level - default is <code>true</code>
+ * @param scan True if scanning should be performed; otherwise false
+ * @return The configuration
+ */
+ public Configuration parameterLevel(boolean scan)
+ {
+ parameterLevel = scan;
+
+ return this;
+ }
+
+ /**
+ * Is the parameter level enabled ?
+ * @return True if enabled; otherwise false
+ */
+ public boolean isParameterLevel()
+ {
+ return parameterLevel;
+ }
}
Modified: projects/annotations/trunk/core/src/main/java/org/jboss/annotations/impl/SettingsImpl.java
===================================================================
--- projects/annotations/trunk/core/src/main/java/org/jboss/annotations/impl/SettingsImpl.java 2009-09-03 16:32:43 UTC (rev 93183)
+++ projects/annotations/trunk/core/src/main/java/org/jboss/annotations/impl/SettingsImpl.java 2009-09-03 17:44:59 UTC (rev 93184)
@@ -42,6 +42,7 @@
private Visibility constructorVisibility;
private boolean methodLevel;
private Visibility methodVisibility;
+ private boolean parameterLevel;
private boolean foldAnnotations;
private boolean includeAbstract;
@@ -55,6 +56,7 @@
* @param constructorVisibility The constructor visibility setting
* @param methodLevel Was the method level enabled
* @param methodVisibility The method visibility setting
+ * @param parameterLevel Was the parameter level enabled
*/
public SettingsImpl(boolean classLevel,
Visibility classVisibility,
@@ -63,7 +65,8 @@
boolean constructorLevel,
Visibility constructorVisibility,
boolean methodLevel,
- Visibility methodVisibility)
+ Visibility methodVisibility,
+ boolean parameterLevel)
{
this.classLevel = classLevel;
this.classVisibility = classVisibility;
@@ -73,6 +76,7 @@
this.constructorVisibility = constructorVisibility;
this.methodLevel = methodLevel;
this.methodVisibility = methodVisibility;
+ this.parameterLevel = parameterLevel;
this.foldAnnotations = true;
this.includeAbstract = false;
}
@@ -150,6 +154,15 @@
}
/**
+ * Is the parameter level enabled ?
+ * @return True if enabled; otherwise false
+ */
+ public boolean isParameterLevel()
+ {
+ return parameterLevel;
+ }
+
+ /**
* Fold annotations on to classes that extends/implements the class
* where the annotation is located
* @param fold True if folding should be performed; otherwise false
Modified: projects/annotations/trunk/core/src/main/java/org/jboss/annotations/javalangreflect/JavaClass.java
===================================================================
--- projects/annotations/trunk/core/src/main/java/org/jboss/annotations/javalangreflect/JavaClass.java 2009-09-03 16:32:43 UTC (rev 93183)
+++ projects/annotations/trunk/core/src/main/java/org/jboss/annotations/javalangreflect/JavaClass.java 2009-09-03 17:44:59 UTC (rev 93184)
@@ -153,7 +153,7 @@
{
processAnnotation(annotation,
AnnotationType.CLASS,
- clz.getName(), null, null,
+ clz.getName(), null, null, -1,
ari, annotationToClasses, classInfo);
}
}
@@ -195,10 +195,31 @@
for (java.lang.annotation.Annotation annotation : constructorAnnotations)
{
processAnnotation(annotation, AnnotationType.CONSTRUCTOR,
- clz.getName(), null, parameterTypes,
+ clz.getName(), null, parameterTypes, -1,
ari, annotationToClasses, classInfo);
}
}
+
+ if (parameterTypes != null && configuration.isParameterLevel())
+ {
+ java.lang.annotation.Annotation[][] parameterAnnotations =
+ constructor.getParameterAnnotations();
+
+ for (int i = 0; i < parameterAnnotations.length; i++)
+ {
+ for (int j = 0; j < parameterAnnotations[i].length; j++)
+ {
+ java.lang.annotation.Annotation annotation =
+ parameterAnnotations[i][j];
+
+ processAnnotation(annotation,
+ AnnotationType.PARAMETER,
+ clz.getName(), null, parameterTypes, i,
+ ari, annotationToClasses, classInfo);
+
+ }
+ }
+ }
}
}
}
@@ -239,10 +260,31 @@
for (java.lang.annotation.Annotation annotation : methodAnnotations)
{
processAnnotation(annotation, AnnotationType.METHOD,
- clz.getName(), method.getName(), parameterTypes,
+ clz.getName(), method.getName(), parameterTypes, -1,
ari, annotationToClasses, classInfo);
}
}
+
+ if (parameterTypes != null && configuration.isParameterLevel())
+ {
+ java.lang.annotation.Annotation[][] parameterAnnotations =
+ method.getParameterAnnotations();
+
+ for (int i = 0; i < parameterAnnotations.length; i++)
+ {
+ for (int j = 0; j < parameterAnnotations[i].length; j++)
+ {
+ java.lang.annotation.Annotation annotation =
+ parameterAnnotations[i][j];
+
+ processAnnotation(annotation,
+ AnnotationType.PARAMETER,
+ clz.getName(), method.getName(), parameterTypes, i,
+ ari, annotationToClasses, classInfo);
+
+ }
+ }
+ }
}
}
}
@@ -270,7 +312,7 @@
for (java.lang.annotation.Annotation annotation : fieldAnnotations)
{
processAnnotation(annotation, AnnotationType.FIELD,
- clz.getName(), field.getName(), null,
+ clz.getName(), field.getName(), null, -1,
ari, annotationToClasses, classInfo);
}
}
@@ -382,12 +424,14 @@
* @param className The class name
* @param memberName The member name
* @param parameterTypes The parameter types
+ * @param parameterIndex The parameter index
* @param ari The annotation repository implementation loaded from metadata
* @param annotationToClasses The annotation to classes mapping
* @param classInfo The class information map
*/
private void processAnnotation(java.lang.annotation.Annotation annotation,
- AnnotationType type, String className, String memberName, String[] parameterTypes,
+ AnnotationType type, String className, String memberName,
+ String[] parameterTypes, int parameterIndex,
AnnotationRepositoryImpl ari,
Map<String, Collection<String>> annotationToClasses,
Map<String, ClassInfo> classInfo)
@@ -398,7 +442,8 @@
Annotation a = new Annotation(acn,
annotationClass.cast(annotation),
type,
- className, memberName, parameterTypes);
+ className, memberName,
+ parameterTypes, parameterIndex);
if (trace)
log.finest("Annotation=" + a);
Modified: projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/AnnotationRepositoryTests.java
===================================================================
--- projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/AnnotationRepositoryTests.java 2009-09-03 16:32:43 UTC (rev 93183)
+++ projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/AnnotationRepositoryTests.java 2009-09-03 17:44:59 UTC (rev 93184)
@@ -87,7 +87,8 @@
Settings s = new SettingsImpl(true, Visibility.PUBLIC,
true, Visibility.PUBLIC,
true, Visibility.PUBLIC,
- true, Visibility.PUBLIC);
+ true, Visibility.PUBLIC,
+ true);
AnnotationRepositoryImpl ar = new AnnotationRepositoryImpl(null, m, s);
fail("Operation success");
@@ -111,7 +112,8 @@
Settings s = new SettingsImpl(true, Visibility.PUBLIC,
true, Visibility.PUBLIC,
true, Visibility.PUBLIC,
- true, Visibility.PUBLIC);
+ true, Visibility.PUBLIC,
+ true);
AnnotationRepositoryImpl ar = new AnnotationRepositoryImpl(m, null, s);
fail("Operation success");
@@ -155,7 +157,8 @@
Settings s = new SettingsImpl(true, Visibility.PUBLIC,
true, Visibility.PUBLIC,
true, Visibility.PUBLIC,
- true, Visibility.PUBLIC);
+ true, Visibility.PUBLIC,
+ true);
AnnotationRepositoryImpl ar = new AnnotationRepositoryImpl(m1, m2, s);
assertNotNull(ar);
@@ -343,7 +346,7 @@
assertTrue(l.size() == 1);
Annotation annotation = new Annotation("nothing", new Object(), AnnotationType.CLASS,
- "org.jboss.annotations.test.DE", null, (String[])null);
+ "org.jboss.annotations.test.DE", null, (String[])null, -1);
try
{
l.add(annotation);
Modified: projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/ClassInfoTests.java
===================================================================
--- projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/ClassInfoTests.java 2009-09-03 16:32:43 UTC (rev 93183)
+++ projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/ClassInfoTests.java 2009-09-03 17:44:59 UTC (rev 93184)
@@ -172,7 +172,7 @@
String key = "key";
Annotation annotation = new Annotation(key, new Object(), AnnotationType.CLASS,
- ClassInfoTests.class.getName(), null, null);
+ ClassInfoTests.class.getName(), null, null, -1);
try
{
Modified: projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/ClassTests.java
===================================================================
--- projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/ClassTests.java 2009-09-03 16:32:43 UTC (rev 93183)
+++ projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/ClassTests.java 2009-09-03 17:44:59 UTC (rev 93184)
@@ -245,6 +245,66 @@
}
/**
+ * Parameter
+ * @throws Throwable throwable exception
+ */
+ @Test
+ public void testParameterClassConstrcutor() throws Throwable
+ {
+ URL archive = getURL("classconstructorwithparameterannotation.jar");
+ AnnotationRepository ar = scanner.scan(new URL[] {archive});
+
+ assertNotNull(ar);
+
+ assertTrue(ar.hasAnnotation(MyAnnotation.class));
+
+ Collection<Annotation> l = ar.getAnnotation(MyAnnotation.class);
+
+ assertNotNull(l);
+ assertTrue("Size=" + l.size(), l.size() == 1);
+
+ Annotation annotation = l.iterator().next();
+ assertNotNull(annotation.getAnnotationClassName());
+ assertNotNull(annotation.getAnnotation());
+ assertTrue(annotation.getType() == AnnotationType.PARAMETER);
+ assertEquals("org.jboss.annotations.test.tests.classconstructorwithparameterannotation.Test",
+ annotation.getClassName());
+ assertNull(annotation.getMemberName());
+ assertArrayEquals(new String[] {String.class.getName()}, annotation.getParameterTypes());
+ assertTrue("ParameterIndex=" + annotation.getParameterIndex(), annotation.getParameterIndex() == 0);
+ }
+
+ /**
+ * Parameter
+ * @throws Throwable throwable exception
+ */
+ @Test
+ public void testParameterClassMethod() throws Throwable
+ {
+ URL archive = getURL("classmethodwithparameterannotation.jar");
+ AnnotationRepository ar = scanner.scan(new URL[] {archive});
+
+ assertNotNull(ar);
+
+ assertTrue(ar.hasAnnotation(MyAnnotation.class));
+
+ Collection<Annotation> l = ar.getAnnotation(MyAnnotation.class);
+
+ assertNotNull(l);
+ assertTrue("Size=" + l.size(), l.size() == 1);
+
+ Annotation annotation = l.iterator().next();
+ assertNotNull(annotation.getAnnotationClassName());
+ assertNotNull(annotation.getAnnotation());
+ assertTrue(annotation.getType() == AnnotationType.PARAMETER);
+ assertEquals("org.jboss.annotations.test.tests.classmethodwithparameterannotation.Test",
+ annotation.getClassName());
+ assertEquals("myMethod", annotation.getMemberName());
+ assertArrayEquals(new String[] {String.class.getName()}, annotation.getParameterTypes());
+ assertTrue("ParameterIndex=" + annotation.getParameterIndex(), annotation.getParameterIndex() == 0);
+ }
+
+ /**
* Field level
* @throws Throwable throwable exception
*/
Modified: projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/InterfaceTests.java
===================================================================
--- projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/InterfaceTests.java 2009-09-03 16:32:43 UTC (rev 93183)
+++ projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/InterfaceTests.java 2009-09-03 17:44:59 UTC (rev 93184)
@@ -26,6 +26,7 @@
import org.jboss.annotations.AnnotationRepository;
import org.jboss.annotations.AnnotationScanner;
import org.jboss.annotations.AnnotationType;
+import org.jboss.annotations.test.tests.common.MyAnnotation;
import java.net.URL;
import java.util.Collection;
@@ -167,4 +168,34 @@
assertEquals("myMethod", annotation.getMemberName());
assertArrayEquals(new String[] {String.class.getName()}, annotation.getParameterTypes());
}
+
+ /**
+ * Parameter level
+ * @throws Throwable throwable exception
+ */
+ @Test
+ public void testParameter() throws Throwable
+ {
+ URL archive = getURL("interfacemethodwithparameterannotation.jar");
+ AnnotationRepository ar = scanner.scan(new URL[] {archive});
+
+ assertNotNull(ar);
+
+ assertTrue(ar.hasAnnotation(MyAnnotation.class));
+
+ Collection<Annotation> l = ar.getAnnotation(MyAnnotation.class);
+
+ assertNotNull(l);
+ assertTrue("Size=" + l.size(), l.size() == 1);
+
+ Annotation annotation = l.iterator().next();
+ assertNotNull(annotation.getAnnotationClassName());
+ assertNotNull(annotation.getAnnotation());
+ assertTrue(annotation.getType() == AnnotationType.PARAMETER);
+ assertEquals("org.jboss.annotations.test.tests.interfacemethodwithparameterannotation.Test",
+ annotation.getClassName());
+ assertEquals("myMethod", annotation.getMemberName());
+ assertArrayEquals(new String[] {String.class.getName()}, annotation.getParameterTypes());
+ assertTrue("ParameterIndex=" + annotation.getParameterIndex(), annotation.getParameterIndex() == 0);
+ }
}
Added: projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/tests/classconstructorwithparameterannotation/Test.java
===================================================================
--- projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/tests/classconstructorwithparameterannotation/Test.java (rev 0)
+++ projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/tests/classconstructorwithparameterannotation/Test.java 2009-09-03 17:44:59 UTC (rev 93184)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008-2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.annotations.test.tests.classconstructorwithparameterannotation;
+
+import org.jboss.annotations.test.tests.common.MyAnnotation;
+
+/**
+ * Test
+ */
+public class Test
+{
+ /**
+ * My constructor
+ * @param p A parameter
+ */
+ public Test(@MyAnnotation String p)
+ {
+ }
+}
Added: projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/tests/classconstructorwithparameterannotation/package.html
===================================================================
--- projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/tests/classconstructorwithparameterannotation/package.html (rev 0)
+++ projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/tests/classconstructorwithparameterannotation/package.html 2009-09-03 17:44:59 UTC (rev 93184)
@@ -0,0 +1,3 @@
+<body>
+Annotation on a constructor parameter.
+</body>
Added: projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/tests/classmethodwithparameterannotation/Test.java
===================================================================
--- projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/tests/classmethodwithparameterannotation/Test.java (rev 0)
+++ projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/tests/classmethodwithparameterannotation/Test.java 2009-09-03 17:44:59 UTC (rev 93184)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008-2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.annotations.test.tests.classmethodwithparameterannotation;
+
+import org.jboss.annotations.test.tests.common.MyAnnotation;
+
+/**
+ * Test
+ */
+public class Test
+{
+ /**
+ * My method
+ * @param p A parameter
+ */
+ public void myMethod(@MyAnnotation String p)
+ {
+ }
+}
Added: projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/tests/classmethodwithparameterannotation/package.html
===================================================================
--- projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/tests/classmethodwithparameterannotation/package.html (rev 0)
+++ projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/tests/classmethodwithparameterannotation/package.html 2009-09-03 17:44:59 UTC (rev 93184)
@@ -0,0 +1,3 @@
+<body>
+Annotation on a parameter on a method.
+</body>
Added: projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/tests/interfacemethodwithparameterannotation/Test.java
===================================================================
--- projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/tests/interfacemethodwithparameterannotation/Test.java (rev 0)
+++ projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/tests/interfacemethodwithparameterannotation/Test.java 2009-09-03 17:44:59 UTC (rev 93184)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008-2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.annotations.test.tests.interfacemethodwithparameterannotation;
+
+import org.jboss.annotations.test.tests.common.MyAnnotation;
+
+/**
+ * Test
+ */
+public interface Test
+{
+
+ /**
+ * My method
+ * @param p A parameter
+ */
+ public void myMethod(@MyAnnotation String p);
+}
Added: projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/tests/interfacemethodwithparameterannotation/package.html
===================================================================
--- projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/tests/interfacemethodwithparameterannotation/package.html (rev 0)
+++ projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/tests/interfacemethodwithparameterannotation/package.html 2009-09-03 17:44:59 UTC (rev 93184)
@@ -0,0 +1,3 @@
+<body>
+Annotation on a interface method parameter.
+</body>
Modified: projects/annotations/trunk/doc/userguide/en/modules/introduction.xml
===================================================================
--- projects/annotations/trunk/doc/userguide/en/modules/introduction.xml 2009-09-03 16:32:43 UTC (rev 93183)
+++ projects/annotations/trunk/doc/userguide/en/modules/introduction.xml 2009-09-03 17:44:59 UTC (rev 93184)
@@ -41,15 +41,13 @@
<listitem>
Method level: Annotations located on methods.
</listitem>
+ <listitem>
+ Parameter level: Annotations located on parameters.
+ </listitem>
</itemizedlist>
<para>The scanner scans from private to public visibility in all levels.</para>
- <para>Parameter level annotation scanning is on the project's roadmap (JBANN-14).</para>
-
- <para>Also on the roadmap is the ability to define which of the above levels
- that should be scanned (JBANN-13).</para>
-
<section id="metadata">
<title>Metadata</title>
More information about the jboss-cvs-commits
mailing list