[jboss-cvs] JBossAS SVN: r95069 - projects/annotations/trunk/core/src/main/java/org/jboss/papaki.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sun Oct 18 07:12:12 EDT 2009
Author: alesj
Date: 2009-10-18 07:12:11 -0400 (Sun, 18 Oct 2009)
New Revision: 95069
Added:
projects/annotations/trunk/core/src/main/java/org/jboss/papaki/ResourceFilter.java
Modified:
projects/annotations/trunk/core/src/main/java/org/jboss/papaki/AnnotationScannerCreator.java
projects/annotations/trunk/core/src/main/java/org/jboss/papaki/AnnotationScannerFactory.java
projects/annotations/trunk/core/src/main/java/org/jboss/papaki/ScanStrategy.java
Log:
Follow Jesper's public api.
Modified: projects/annotations/trunk/core/src/main/java/org/jboss/papaki/AnnotationScannerCreator.java
===================================================================
--- projects/annotations/trunk/core/src/main/java/org/jboss/papaki/AnnotationScannerCreator.java 2009-10-18 10:39:27 UTC (rev 95068)
+++ projects/annotations/trunk/core/src/main/java/org/jboss/papaki/AnnotationScannerCreator.java 2009-10-18 11:12:11 UTC (rev 95069)
@@ -27,12 +27,12 @@
*
* @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
*/
-public interface AnnotationScannerCreator
+abstract class AnnotationScannerCreator
{
/**
* Verify if we can actually use AnnotationScanner created by this creator.
*/
- void verify();
+ abstract void verify();
/**
* Create AnnotationScanner.
@@ -40,5 +40,5 @@
* @param configuration the configuration
* @return new AnnotationScanner
*/
- AnnotationScanner create(Configuration configuration);
+ abstract AnnotationScanner create(Configuration configuration);
}
Modified: projects/annotations/trunk/core/src/main/java/org/jboss/papaki/AnnotationScannerFactory.java
===================================================================
--- projects/annotations/trunk/core/src/main/java/org/jboss/papaki/AnnotationScannerFactory.java 2009-10-18 10:39:27 UTC (rev 95068)
+++ projects/annotations/trunk/core/src/main/java/org/jboss/papaki/AnnotationScannerFactory.java 2009-10-18 11:12:11 UTC (rev 95069)
@@ -22,6 +22,8 @@
package org.jboss.papaki;
+import java.util.Arrays;
+
/**
* An annotation scanner factory
*
@@ -32,17 +34,17 @@
/**
* Javassist using ClassPool
*/
- public static final int JAVASSIST_CLASS_POOL = 0;
+ public static final int JAVASSIST_CLASS_POOL = ScanStrategy.JAVASSIST_CLASS_POOL.ordinal();
/**
* Javassist using InputStream
*/
- public static final int JAVASSIST_INPUT_STREAM = 1;
+ public static final int JAVASSIST_INPUT_STREAM = ScanStrategy.JAVASSIST_INPUT_STREAM.ordinal();
/**
* java.lang.reflect
*/
- public static final int JAVA_LANG_REFLECT = 2;
+ public static final int JAVA_LANG_REFLECT = ScanStrategy.JAVA_LANG_REFLECT.ordinal();
/**
* Default strategy
@@ -125,8 +127,11 @@
public static AnnotationScanner getStrategy(int strategy, Configuration configuration)
{
ScanStrategy[] strategies = ScanStrategy.values();
- if (strategy < 0 || strategy > strategies.length - 1)
- throw new IllegalArgumentException("Unknown strategy key");
+ if (strategy < 0 || strategy >= strategies.length)
+ {
+ String msg = "Unknown strategy key: " + strategy + ", available: " + Arrays.toString(strategies);
+ throw new IllegalArgumentException(msg);
+ }
ScanStrategy ss = strategies[strategy];
ss.verify(); // check if we can use this strategy
Copied: projects/annotations/trunk/core/src/main/java/org/jboss/papaki/ResourceFilter.java (from rev 95062, projects/annotations/trunk/core/src/main/java/org/jboss/papaki/AnnotationScanner.java)
===================================================================
--- projects/annotations/trunk/core/src/main/java/org/jboss/papaki/ResourceFilter.java (rev 0)
+++ projects/annotations/trunk/core/src/main/java/org/jboss/papaki/ResourceFilter.java 2009-10-18 11:12:11 UTC (rev 95069)
@@ -0,0 +1,41 @@
+/*
+ * 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.papaki;
+
+/**
+ * Resource filter.
+ *
+ * TODO - use it :-)
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public interface ResourceFilter
+{
+ /**
+ * Do we accept this resource.
+ *
+ * @param resource the resource
+ * @return true if the resource is accepted, false otherwise
+ */
+ boolean accepts(String resource);
+}
Modified: projects/annotations/trunk/core/src/main/java/org/jboss/papaki/ScanStrategy.java
===================================================================
--- projects/annotations/trunk/core/src/main/java/org/jboss/papaki/ScanStrategy.java 2009-10-18 10:39:27 UTC (rev 95068)
+++ projects/annotations/trunk/core/src/main/java/org/jboss/papaki/ScanStrategy.java 2009-10-18 11:12:11 UTC (rev 95069)
@@ -31,7 +31,7 @@
*
* @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
*/
-public enum ScanStrategy implements AnnotationScannerCreator
+public enum ScanStrategy
{
/** Javassist class pool */
JAVASSIST_CLASS_POOL(new JavassistClassPoolScannerCreator()),
@@ -40,7 +40,7 @@
/** Plain JDK reflect */
JAVA_LANG_REFLECT(new JavaClassScannerCreator());
- private AnnotationScannerCreator creator;
+ private transient AnnotationScannerCreator creator;
/**
* Ctor.
@@ -64,7 +64,7 @@
/**
* Verify.
*/
- public void verify()
+ void verify()
{
creator.verify();
}
@@ -75,7 +75,7 @@
* @param configuration the configuration
* @return new annotation scanner
*/
- public AnnotationScanner create(Configuration configuration)
+ AnnotationScanner create(Configuration configuration)
{
return creator.create(configuration);
}
@@ -83,7 +83,7 @@
/**
* JCPSC
*/
- static class JavassistClassPoolScannerCreator implements AnnotationScannerCreator
+ static class JavassistClassPoolScannerCreator extends AnnotationScannerCreator
{
/**
* Verify.
@@ -108,7 +108,7 @@
/**
* JISC
*/
- static class JavassistInputStreamCreator implements AnnotationScannerCreator
+ static class JavassistInputStreamCreator extends AnnotationScannerCreator
{
/**
* Verify.
@@ -133,7 +133,7 @@
/**
* JCSC
*/
- static class JavaClassScannerCreator implements AnnotationScannerCreator
+ static class JavaClassScannerCreator extends AnnotationScannerCreator
{
/**
* Verify.
More information about the jboss-cvs-commits
mailing list