[jboss-cvs] JBossAS SVN: r92136 - projects/annotations/trunk/core/src/main/java/org/jboss/annotations.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Aug 7 11:32:58 EDT 2009
Author: jesper.pedersen
Date: 2009-08-07 11:32:58 -0400 (Fri, 07 Aug 2009)
New Revision: 92136
Modified:
projects/annotations/trunk/core/src/main/java/org/jboss/annotations/AnnotationScannerFactory.java
Log:
[JBANN-11] Make Javassist based implementations optional
Modified: projects/annotations/trunk/core/src/main/java/org/jboss/annotations/AnnotationScannerFactory.java
===================================================================
--- projects/annotations/trunk/core/src/main/java/org/jboss/annotations/AnnotationScannerFactory.java 2009-08-07 15:10:17 UTC (rev 92135)
+++ projects/annotations/trunk/core/src/main/java/org/jboss/annotations/AnnotationScannerFactory.java 2009-08-07 15:32:58 UTC (rev 92136)
@@ -41,6 +41,34 @@
/** java.lang.reflect */
public static final int JAVA_LANG_REFLECT = 2;
+ /** Default strategy */
+ private static int defaultStrategy;
+
+ /** Is Javassist available */
+ private static boolean haveJavassist = false;
+
+ static
+ {
+ try
+ {
+ Class.forName("javassist.CtClass");
+ haveJavassist = true;
+ }
+ catch (ClassNotFoundException ignore)
+ {
+ // Ok - use java.lang.reflect then
+ }
+
+ if (haveJavassist)
+ {
+ defaultStrategy = JAVASSIST_INPUT_STREAM;
+ }
+ else
+ {
+ defaultStrategy = JAVA_LANG_REFLECT;
+ }
+ }
+
/**
* Constructor
*/
@@ -54,7 +82,7 @@
*/
public static AnnotationScanner getDefault()
{
- return getStrategy(JAVASSIST_INPUT_STREAM);
+ return getStrategy(defaultStrategy);
}
/**
@@ -69,11 +97,25 @@
if (strategy == JAVASSIST_CLASS_POOL)
{
- return new JavassistClassPool();
+ if (haveJavassist)
+ {
+ return new JavassistClassPool();
+ }
+ else
+ {
+ throw new IllegalArgumentException("Javassist not available");
+ }
}
else if (strategy == JAVASSIST_INPUT_STREAM)
{
- return new JavassistInputStream();
+ if (haveJavassist)
+ {
+ return new JavassistInputStream();
+ }
+ else
+ {
+ throw new IllegalArgumentException("Javassist not available");
+ }
}
else
{
More information about the jboss-cvs-commits
mailing list