[jboss-cvs] JBossAS SVN: r93204 - in projects/annotations/trunk: doc/userguide/en/modules and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Sep 4 10:08:47 EDT 2009
Author: jesper.pedersen
Date: 2009-09-04 10:08:46 -0400 (Fri, 04 Sep 2009)
New Revision: 93204
Modified:
projects/annotations/trunk/core/src/main/java/org/jboss/papaki/impl/AnnotationRepositoryImpl.java
projects/annotations/trunk/doc/userguide/en/modules/ant.xml
projects/annotations/trunk/indexer/src/main/java/org/jboss/papaki/indexer/IndexerTask.java
Log:
[JBANN-8] Support exclusion of annotations
Modified: projects/annotations/trunk/core/src/main/java/org/jboss/papaki/impl/AnnotationRepositoryImpl.java
===================================================================
--- projects/annotations/trunk/core/src/main/java/org/jboss/papaki/impl/AnnotationRepositoryImpl.java 2009-09-04 14:04:04 UTC (rev 93203)
+++ projects/annotations/trunk/core/src/main/java/org/jboss/papaki/impl/AnnotationRepositoryImpl.java 2009-09-04 14:08:46 UTC (rev 93204)
@@ -414,6 +414,43 @@
}
/**
+ * Remove annotations from the repository
+ * @param clz The annotation class
+ */
+ public void removeAnnotations(String clz)
+ {
+ Set<String> remove = new HashSet<String>();
+
+ boolean isPackage = false;
+ if (clz.endsWith(".*"))
+ {
+ clz = clz.substring(0, clz.indexOf(".*"));
+ isPackage = true;
+ }
+
+ Iterator<String> it = annotationToClasses.keySet().iterator();
+ while (it.hasNext())
+ {
+ String key = it.next();
+
+ if (key.equals(clz) ||
+ (isPackage && key.startsWith(clz)))
+ {
+ remove.add(key);
+ }
+ }
+
+ if (remove.size() > 0)
+ {
+ it = remove.iterator();
+ while (it.hasNext())
+ {
+ annotationToClasses.remove(it.next());
+ }
+ }
+ }
+
+ /**
* String representation
* @return The string
*/
Modified: projects/annotations/trunk/doc/userguide/en/modules/ant.xml
===================================================================
--- projects/annotations/trunk/doc/userguide/en/modules/ant.xml 2009-09-04 14:04:04 UTC (rev 93203)
+++ projects/annotations/trunk/doc/userguide/en/modules/ant.xml 2009-09-04 14:08:46 UTC (rev 93204)
@@ -55,6 +55,15 @@
The metadata location if update is false (Default: Current directory).
</entry>
</row>
+ <row>
+ <entry>exclude</entry>
+ <entry>
+ A comma-separated list of annotation classes that should be excluded.
+ F.ex. "java.lang.*,com.mycompany.myproject.MyAnnotation" will exclude all
+ annotations in the java.lang package and the com.mycompany.myproject.MyAnnotation
+ annotation from the metadata.
+ </entry>
+ </row>
</tbody>
</tgroup>
</table>
Modified: projects/annotations/trunk/indexer/src/main/java/org/jboss/papaki/indexer/IndexerTask.java
===================================================================
--- projects/annotations/trunk/indexer/src/main/java/org/jboss/papaki/indexer/IndexerTask.java 2009-09-04 14:04:04 UTC (rev 93203)
+++ projects/annotations/trunk/indexer/src/main/java/org/jboss/papaki/indexer/IndexerTask.java 2009-09-04 14:08:46 UTC (rev 93204)
@@ -29,6 +29,7 @@
import java.io.File;
import java.io.IOException;
import java.net.URL;
+import java.util.StringTokenizer;
import java.util.logging.Logger;
import org.apache.tools.ant.BuildException;
@@ -46,6 +47,7 @@
private File output;
private boolean update;
private File metadata;
+ private String exclude;
/**
* Constructor
@@ -56,6 +58,7 @@
output = null;
update = true;
metadata = null;
+ exclude = null;
}
/**
@@ -131,6 +134,24 @@
}
/**
+ * Get the exclude
+ * @return The exclude
+ */
+ public String getExclude()
+ {
+ return exclude;
+ }
+
+ /**
+ * Set the exclude
+ * @param s The exclude
+ */
+ public void setExclude(String s)
+ {
+ exclude = s;
+ }
+
+ /**
* Execute Ant task
* @exception BuildException If an error occurs
*/
@@ -146,6 +167,21 @@
AnnotationScanner as = AnnotationScannerFactory.getStrategy(AnnotationScannerFactory.JAVA_LANG_REFLECT);
AnnotationRepositoryImpl ari = (AnnotationRepositoryImpl)as.scan(new URL[] {input.toURI().toURL()});
+ if (exclude != null)
+ {
+ StringTokenizer st = new StringTokenizer(exclude, ",");
+ while (st.hasMoreTokens())
+ {
+ String s = st.nextToken();
+ s = s.trim();
+
+ if (s.endsWith(".class"))
+ s = s.substring(0, s.indexOf(".class"));
+
+ ari.removeAnnotations(s);
+ }
+ }
+
if (update)
{
File tmp = new File(System.getProperty("java.io.tmpdir"));
More information about the jboss-cvs-commits
mailing list