diff --git a/jetty-annotations/pom.xml b/jetty-annotations/pom.xml
index 43cc4584bfc..33965ca5747 100644
--- a/jetty-annotations/pom.xml
+++ b/jetty-annotations/pom.xml
@@ -102,8 +102,12 @@
javax.annotation-api
- org.eclipse.jetty.orbit
- org.objectweb.asm
+ org.ow2.asm
+ asm
+
+
+ org.ow2.asm
+ asm-commons
diff --git a/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AbstractDiscoverableAnnotationHandler.java b/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AbstractDiscoverableAnnotationHandler.java
index a9afd8996ad..446e27c566a 100644
--- a/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AbstractDiscoverableAnnotationHandler.java
+++ b/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AbstractDiscoverableAnnotationHandler.java
@@ -21,7 +21,7 @@ package org.eclipse.jetty.annotations;
import java.util.ArrayList;
import java.util.List;
-import org.eclipse.jetty.annotations.AnnotationParser.DiscoverableAnnotationHandler;
+import org.eclipse.jetty.annotations.AnnotationParser.AbstractHandler;
import org.eclipse.jetty.util.resource.Resource;
import org.eclipse.jetty.webapp.DiscoveredAnnotation;
import org.eclipse.jetty.webapp.WebAppContext;
@@ -31,7 +31,7 @@ import org.eclipse.jetty.webapp.WebAppContext;
*
*
*/
-public abstract class AbstractDiscoverableAnnotationHandler implements DiscoverableAnnotationHandler
+public abstract class AbstractDiscoverableAnnotationHandler extends AbstractHandler
{
protected WebAppContext _context;
protected List _annotations;
diff --git a/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationConfiguration.java b/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationConfiguration.java
index c26901f73e6..133ac3ed9c1 100644
--- a/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationConfiguration.java
+++ b/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationConfiguration.java
@@ -20,18 +20,14 @@ package org.eclipse.jetty.annotations;
import java.net.URI;
import java.util.ArrayList;
-import java.util.EventListener;
import java.util.Iterator;
import java.util.List;
import java.util.ServiceLoader;
-import java.util.StringTokenizer;
import javax.servlet.ServletContainerInitializer;
import javax.servlet.annotation.HandlesTypes;
-import org.eclipse.jetty.annotations.AnnotationParser.DiscoverableAnnotationHandler;
import org.eclipse.jetty.plus.annotation.ContainerInitializer;
-import org.eclipse.jetty.util.ArrayUtil;
import org.eclipse.jetty.util.MultiMap;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
@@ -55,7 +51,7 @@ public class AnnotationConfiguration extends AbstractConfiguration
public static final String CONTAINER_INITIALIZER_LISTENER = "org.eclipse.jetty.containerInitializerListener";
- protected List _discoverableAnnotationHandlers = new ArrayList();
+ protected List _discoverableAnnotationHandlers = new ArrayList();
protected ClassInheritanceHandler _classInheritanceHandler;
protected List _containerInitializerAnnotationHandlers = new ArrayList();
@@ -141,7 +137,7 @@ public class AnnotationConfiguration extends AbstractConfiguration
}
- public void addDiscoverableAnnotationHandler(DiscoverableAnnotationHandler handler)
+ public void addDiscoverableAnnotationHandler(AbstractDiscoverableAnnotationHandler handler)
{
_discoverableAnnotationHandlers.add(handler);
}
@@ -203,7 +199,7 @@ public class AnnotationConfiguration extends AbstractConfiguration
parseWebInfClasses(context, parser);
parseWebInfLib (context, parser);
- for (DiscoverableAnnotationHandler h:_discoverableAnnotationHandlers)
+ for (AbstractDiscoverableAnnotationHandler h:_discoverableAnnotationHandlers)
context.getMetaData().addDiscoveredAnnotations(((AbstractDiscoverableAnnotationHandler)h).getAnnotationList());
}
}
@@ -414,7 +410,7 @@ public class AnnotationConfiguration extends AbstractConfiguration
//always parse for discoverable annotations as well as class hierarchy and servletcontainerinitializer related annotations
parser.clearHandlers();
- for (DiscoverableAnnotationHandler h:_discoverableAnnotationHandlers)
+ for (AbstractDiscoverableAnnotationHandler h:_discoverableAnnotationHandlers)
{
if (h instanceof AbstractDiscoverableAnnotationHandler)
((AbstractDiscoverableAnnotationHandler)h).setResource(null); //
@@ -482,7 +478,7 @@ public class AnnotationConfiguration extends AbstractConfiguration
//only register the discoverable annotation handlers if this fragment is not metadata complete, or has no fragment descriptor
if (f == null || !isMetaDataComplete(f))
{
- for (DiscoverableAnnotationHandler h:_discoverableAnnotationHandlers)
+ for (AbstractDiscoverableAnnotationHandler h:_discoverableAnnotationHandlers)
{
if (h instanceof AbstractDiscoverableAnnotationHandler)
((AbstractDiscoverableAnnotationHandler)h).setResource(r);
@@ -508,7 +504,7 @@ public class AnnotationConfiguration extends AbstractConfiguration
LOG.debug("Scanning classes in WEB-INF/classes");
parser.clearHandlers();
- for (DiscoverableAnnotationHandler h:_discoverableAnnotationHandlers)
+ for (AbstractDiscoverableAnnotationHandler h:_discoverableAnnotationHandlers)
{
if (h instanceof AbstractDiscoverableAnnotationHandler)
((AbstractDiscoverableAnnotationHandler)h).setResource(null); //
diff --git a/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationParser.java b/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationParser.java
index 057d0ea22af..3e215c4ba19 100644
--- a/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationParser.java
+++ b/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationParser.java
@@ -25,13 +25,13 @@ import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import java.util.jar.JarEntry;
import java.util.jar.JarInputStream;
+import org.eclipse.jetty.util.ConcurrentHashSet;
import org.eclipse.jetty.util.Loader;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
@@ -39,23 +39,43 @@ import org.eclipse.jetty.util.resource.Resource;
import org.eclipse.jetty.webapp.JarScanner;
import org.objectweb.asm.AnnotationVisitor;
import org.objectweb.asm.ClassReader;
+import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.FieldVisitor;
import org.objectweb.asm.MethodVisitor;
-import org.objectweb.asm.commons.EmptyVisitor;
+import org.objectweb.asm.Opcodes;
+
/**
* AnnotationParser
*
- * Use asm to scan classes for annotations. A SAX-style parsing is done, with
- * a handler being able to be registered to handle each annotation type.
+ * Use asm to scan classes for annotations. A SAX-style parsing is done.
+ * Handlers are registered which will be called back when various types of
+ * entity are encountered, eg a class, a method, a field.
+ *
+ * Handlers are not called back in any particular order and are assumed
+ * to be order-independent.
+ *
+ * As a registered Handler will be called back for each annotation discovered
+ * on a class, a method, a field, the Handler should test to see if the annotation
+ * is one that it is interested in.
+ *
+ * For the servlet spec, we are only interested in annotations on classes, methods and fields,
+ * so the callbacks for handling finding a class, a method a field are themselves
+ * not fully implemented.
*/
public class AnnotationParser
{
private static final Logger LOG = Log.getLogger(AnnotationParser.class);
- protected Set _parsedClassNames = new HashSet();
- protected List _handlers = new ArrayList();
+ protected Set _parsedClassNames = new ConcurrentHashSet();
+ protected Set _handlers = new ConcurrentHashSet();
+ /**
+ * Convert internal name to simple name
+ *
+ * @param name
+ * @return
+ */
public static String normalize (String name)
{
if (name==null)
@@ -69,292 +89,354 @@ public class AnnotationParser
return name.replace('/', '.');
}
-
-
-
- public abstract class Value
+
+ /**
+ * Convert internal names to simple names.
+ *
+ * @param list
+ * @return
+ */
+ public static String[] normalize (String[] list)
{
- String _name;
-
- public Value (String name)
- {
- _name = name;
- }
-
- public String getName()
- {
- return _name;
- }
-
- public abstract Object getValue();
-
+ if (list == null)
+ return null;
+ String[] normalList = new String[list.length];
+ int i=0;
+ for (String s : list)
+ normalList[i++] = normalize(s);
+ return normalList;
}
-
-
-
- public class SimpleValue extends Value
+
+ /**
+ * ClassInfo
+ *
+ * Immutable information gathered by parsing class header.
+ *
+ */
+ public class ClassInfo
{
- Object _val;
-
- public SimpleValue(String name)
+ final String _className;
+ final int _version;
+ final int _access;
+ final String _signature;
+ final String _superName;
+ final String[] _interfaces;
+
+ public ClassInfo(String className, int version, int access, String signature, String superName, String[] interfaces)
{
- super(name);
+ super();
+ _className = className;
+ _version = version;
+ _access = access;
+ _signature = signature;
+ _superName = superName;
+ _interfaces = interfaces;
}
- public void setValue(Object val)
+ public String getClassName()
{
- _val=val;
+ return _className;
}
- @Override
+
+ public int getVersion()
+ {
+ return _version;
+ }
+
+ public int getAccess()
+ {
+ return _access;
+ }
+
+ public String getSignature()
+ {
+ return _signature;
+ }
+
+ public String getSuperName()
+ {
+ return _superName;
+ }
+
+ public String[] getInterfaces()
+ {
+ return _interfaces;
+ }
+ }
+
+
+ /**
+ * MethodInfo
+ *
+ * Immutable information gathered by parsing a method on a class.
+ */
+ public class MethodInfo
+ {
+ final String _className;
+ final String _methodName;
+ final int _access;
+ final String _desc;
+ final String _signature;
+ final String[] _exceptions;
+
+ public MethodInfo(String className, String methodName, int access, String desc, String signature, String[] exceptions)
+ {
+ super();
+ _className = className;
+ _methodName = methodName;
+ _access = access;
+ _desc = desc;
+ _signature = signature;
+ _exceptions = exceptions;
+ }
+
+ public String getClassName()
+ {
+ return _className;
+ }
+
+ public String getMethodName()
+ {
+ return _methodName;
+ }
+
+ public int getAccess()
+ {
+ return _access;
+ }
+
+ public String getDesc()
+ {
+ return _desc;
+ }
+
+ public String getSignature()
+ {
+ return _signature;
+ }
+
+ public String[] getExceptions()
+ {
+ return _exceptions;
+ }
+ }
+
+
+
+ /**
+ * FieldInfo
+ *
+ * Immutable information gathered by parsing a field on a class.
+ *
+ */
+ public class FieldInfo
+ {
+ final String _className;
+ final String _fieldName;
+ final int _access;
+ final String _fieldType;
+ final String _signature;
+ final Object _value;
+
+ public FieldInfo(String className, String fieldName, int access, String fieldType, String signature, Object value)
+ {
+ super();
+ _className = className;
+ _fieldName = fieldName;
+ _access = access;
+ _fieldType = fieldType;
+ _signature = signature;
+ _value = value;
+ }
+
+ public String getClassName()
+ {
+ return _className;
+ }
+
+ public String getFieldName()
+ {
+ return _fieldName;
+ }
+
+ public int getAccess()
+ {
+ return _access;
+ }
+
+ public String getFieldType()
+ {
+ return _fieldType;
+ }
+
+ public String getSignature()
+ {
+ return _signature;
+ }
+
public Object getValue()
{
- return _val;
- }
-
- @Override
- public String toString()
- {
- return "("+getName()+":"+_val+")";
+ return _value;
}
}
-
- public class ListValue extends Value
- {
- List _val;
-
- public ListValue (String name)
- {
- super(name);
- _val = new ArrayList();
- }
-
- @Override
- public Object getValue()
- {
- return _val;
- }
-
- public List getList()
- {
- return _val;
- }
-
- public void addValue (Value v)
- {
- _val.add(v);
- }
-
- public int size ()
- {
- return _val.size();
- }
-
- @Override
- public String toString()
- {
- StringBuffer buff = new StringBuffer();
- buff.append("(");
- buff.append(getName());
- buff.append(":");
- for (Value n: _val)
- {
- buff.append(" "+n.toString());
- }
- buff.append(")");
-
- return buff.toString();
- }
- }
-
-
-
+
+
/**
* Handler
*
* Signature for all handlers that respond to parsing class files.
*/
- public interface Handler
+ public static interface Handler
{
-
+ public void handle(ClassInfo classInfo);
+ public void handle(MethodInfo methodInfo);
+ public void handle (FieldInfo fieldInfo);
+ public void handle (ClassInfo info, String annotationName);
+ public void handle (MethodInfo info, String annotationName);
+ public void handle (FieldInfo info, String annotationName);
}
/**
- * DiscoverableAnnotationHandler
+ * AbstractHandler
*
- * Processes an annotation when it is discovered on a class.
+ * Convenience base class to provide no-ops for all Handler methods.
+ *
*/
- public interface DiscoverableAnnotationHandler extends Handler
+ public static abstract class AbstractHandler implements Handler
{
- /**
- * Process an annotation that was discovered on a class
- * @param className
- * @param version
- * @param access
- * @param signature
- * @param superName
- * @param interfaces
- * @param annotation
- * @param values
- */
- public void handleClass (String className, int version, int access,
- String signature, String superName, String[] interfaces,
- String annotation, Listvalues);
+ @Override
+ public void handle(ClassInfo classInfo)
+ {
+ //no-op
+ }
+
+ @Override
+ public void handle(MethodInfo methodInfo)
+ {
+ // no-op
+ }
+
+ @Override
+ public void handle(FieldInfo fieldInfo)
+ {
+ // no-op
+ }
+
+ @Override
+ public void handle(ClassInfo info, String annotationName)
+ {
+ // no-op
+ }
+
+ @Override
+ public void handle(MethodInfo info, String annotationName)
+ {
+ // no-op
+ }
+
+ @Override
+ public void handle(FieldInfo info, String annotationName)
+ {
+ // no-op
+ }
+ }
+
+
+
+ /**
+ * MyMethodVisitor
+ *
+ * ASM Visitor for parsing a method. We are only interested in the annotations on methods.
+ */
+ public class MyMethodVisitor extends MethodVisitor
+ {
+ final MethodInfo _mi;
+
/**
- * Process an annotation that was discovered on a method
- * @param className
- * @param methodName
+ * @param classname
* @param access
- * @param desc
+ * @param name
+ * @param methodDesc
* @param signature
* @param exceptions
- * @param annotation
- * @param values
*/
- public void handleMethod (String className, String methodName, int access,
- String desc, String signature,String[] exceptions,
- String annotation, Listvalues);
+ public MyMethodVisitor(final String className,
+ final int access,
+ final String name,
+ final String methodDesc,
+ final String signature,
+ final String[] exceptions)
+ {
+ super(Opcodes.ASM4);
+ _mi = new MethodInfo(className, name, access, methodDesc,signature, exceptions);
+ }
/**
- * Process an annotation that was discovered on a field
- * @param className
- * @param fieldName
- * @param access
- * @param fieldType
- * @param signature
- * @param value
- * @param annotation
- * @param values
+ * We are only interested in finding the annotations on methods.
+ *
+ * @see org.objectweb.asm.MethodVisitor#visitAnnotation(java.lang.String, boolean)
*/
- public void handleField (String className, String fieldName, int access,
- String fieldType, String signature, Object value,
- String annotation, Listvalues);
-
+ @Override
+ public AnnotationVisitor visitAnnotation(String desc, boolean visible)
+ {
+ String annotationName = normalize(desc);
+ for (Handler h:_handlers)
+ h.handle(_mi, annotationName);
+ return null;
+ }
+ }
+
+
+
+ /**
+ * MyFieldVisitor
+ *
+ * An ASM visitor for parsing Fields.
+ * We are only interested in visiting annotations on Fields.
+ *
+ */
+ public class MyFieldVisitor extends FieldVisitor
+ {
+ final FieldInfo _fieldInfo;
+
/**
- * Get the name of the annotation processed by this handler. Can be null
+ * @param classname
*/
- public String getAnnotationName();
- }
-
-
-
- /**
- * ClassHandler
- *
- * Responds to finding a Class
- */
- public interface ClassHandler extends Handler
- {
- public void handle (String className, int version, int access, String signature, String superName, String[] interfaces);
- }
-
-
-
- /**
- * MethodHandler
- *
- * Responds to finding a Method
- */
- public interface MethodHandler extends Handler
- {
- public void handle (String className, String methodName, int access, String desc, String signature,String[] exceptions);
- }
-
-
- /**
- * FieldHandler
- *
- * Responds to finding a Field
- */
- public interface FieldHandler extends Handler
- {
- public void handle (String className, String fieldName, int access, String fieldType, String signature, Object value);
- }
-
-
-
- /**
- * MyAnnotationVisitor
- *
- * ASM Visitor for Annotations
- */
- public class MyAnnotationVisitor implements AnnotationVisitor
- {
- List _annotationValues;
- String _annotationName;
-
- public MyAnnotationVisitor (String annotationName, List values)
+ public MyFieldVisitor(final String className,
+ final int access,
+ final String fieldName,
+ final String fieldType,
+ final String signature,
+ final Object value)
{
- _annotationValues = values;
- _annotationName = annotationName;
+ super(Opcodes.ASM4);
+ _fieldInfo = new FieldInfo(className, fieldName, access, fieldType, signature, value);
}
- public List getAnnotationValues()
- {
- return _annotationValues;
- }
/**
- * Visit a single-valued (name,value) pair for this annotation
- * @see org.objectweb.asm.AnnotationVisitor#visit(java.lang.String, java.lang.Object)
+ * Parse an annotation found on a Field.
+ *
+ * @see org.objectweb.asm.FieldVisitor#visitAnnotation(java.lang.String, boolean)
*/
@Override
- public void visit(String aname, Object avalue)
+ public AnnotationVisitor visitAnnotation(String desc, boolean visible)
{
- SimpleValue v = new SimpleValue(aname);
- v.setValue(avalue);
- _annotationValues.add(v);
- }
+ String annotationName = normalize(desc);
+ for (Handler h : _handlers)
+ h.handle(_fieldInfo, annotationName);
- /**
- * Visit a (name,value) pair whose value is another Annotation
- * @see org.objectweb.asm.AnnotationVisitor#visitAnnotation(java.lang.String, java.lang.String)
- */
- @Override
- public AnnotationVisitor visitAnnotation(String name, String desc)
- {
- String s = normalize(desc);
- ListValue v = new ListValue(s);
- _annotationValues.add(v);
- MyAnnotationVisitor visitor = new MyAnnotationVisitor(s, v.getList());
- return visitor;
- }
-
- /**
- * Visit an array valued (name, value) pair for this annotation
- * @see org.objectweb.asm.AnnotationVisitor#visitArray(java.lang.String)
- */
- @Override
- public AnnotationVisitor visitArray(String name)
- {
- ListValue v = new ListValue(name);
- _annotationValues.add(v);
- MyAnnotationVisitor visitor = new MyAnnotationVisitor(null, v.getList());
- return visitor;
- }
-
- /**
- * Visit a enum-valued (name,value) pair for this annotation
- * @see org.objectweb.asm.AnnotationVisitor#visitEnum(java.lang.String, java.lang.String, java.lang.String)
- */
- @Override
- public void visitEnum(String name, String desc, String value)
- {
- //TODO
- }
-
- @Override
- public void visitEnd()
- {
+ return null;
}
}
-
+
/**
@@ -362,77 +444,55 @@ public class AnnotationParser
*
* ASM visitor for a class.
*/
- public class MyClassVisitor extends EmptyVisitor
+ public class MyClassVisitor extends ClassVisitor
{
- String _className;
- int _access;
- String _signature;
- String _superName;
- String[] _interfaces;
- int _version;
+
+ ClassInfo _ci;
+
+ public MyClassVisitor()
+ {
+ super(Opcodes.ASM4);
+ }
@Override
- public void visit (int version,
+ public void visit (final int version,
final int access,
final String name,
final String signature,
final String superName,
final String[] interfaces)
- {
- _className = normalize(name);
- _access = access;
- _signature = signature;
- _superName = superName;
- _interfaces = interfaces;
- _version = version;
+ {
+ _ci = new ClassInfo(normalize(name), version, access, signature, normalize(superName), normalize(interfaces));
+
+ _parsedClassNames.add(_ci.getClassName());
- _parsedClassNames.add(_className);
- //call all registered ClassHandlers
- String[] normalizedInterfaces = null;
- if (interfaces!= null)
- {
- normalizedInterfaces = new String[interfaces.length];
- int i=0;
- for (String s : interfaces)
- normalizedInterfaces[i++] = normalize(s);
- }
-
- for (Handler h : AnnotationParser.this._handlers)
- {
- if (h instanceof ClassHandler)
- {
- ((ClassHandler)h).handle(_className, _version, _access, _signature, normalize(_superName), normalizedInterfaces);
- }
- }
+ for (Handler h:_handlers)
+ h.handle(_ci);
}
+
+ /**
+ * Visit an annotation on a Class
+ *
+ * @see org.objectweb.asm.ClassVisitor#visitAnnotation(java.lang.String, boolean)
+ */
@Override
public AnnotationVisitor visitAnnotation (String desc, boolean visible)
{
- MyAnnotationVisitor visitor = new MyAnnotationVisitor(normalize(desc), new ArrayList())
- {
- @Override
- public void visitEnd()
- {
- super.visitEnd();
+ String annotationName = normalize(desc);
+ for (Handler h : _handlers)
+ h.handle(_ci, annotationName);
- //call all AnnotationHandlers with classname, annotation name + values
- for (Handler h : AnnotationParser.this._handlers)
- {
- if (h instanceof DiscoverableAnnotationHandler)
- {
- DiscoverableAnnotationHandler dah = (DiscoverableAnnotationHandler)h;
- if (_annotationName.equalsIgnoreCase(dah.getAnnotationName()))
- dah.handleClass(_className, _version, _access, _signature, _superName, _interfaces, _annotationName, _annotationValues);
- }
- }
- }
- };
-
- return visitor;
+ return null;
}
+
+ /**
+ * Visit a method to extract its annotations
+ *
+ * @see org.objectweb.asm.ClassVisitor#visitMethod(int, java.lang.String, java.lang.String, java.lang.String, java.lang.String[])
+ */
@Override
public MethodVisitor visitMethod (final int access,
final String name,
@@ -441,35 +501,14 @@ public class AnnotationParser
final String[] exceptions)
{
- return new EmptyVisitor ()
- {
- @Override
- public AnnotationVisitor visitAnnotation(String desc, boolean visible)
- {
- MyAnnotationVisitor visitor = new MyAnnotationVisitor (normalize(desc), new ArrayList())
- {
- @Override
- public void visitEnd()
- {
- super.visitEnd();
- //call all AnnotationHandlers with classname, method, annotation name + values
- for (Handler h : AnnotationParser.this._handlers)
- {
- if (h instanceof DiscoverableAnnotationHandler)
- {
- DiscoverableAnnotationHandler dah = (DiscoverableAnnotationHandler)h;
- if (_annotationName.equalsIgnoreCase(dah.getAnnotationName()))
- dah.handleMethod(_className, name, access, methodDesc, signature, exceptions, _annotationName, _annotationValues);
- }
- }
- }
- };
-
- return visitor;
- }
- };
+ return new MyMethodVisitor(_ci.getClassName(), access, name, methodDesc, signature, exceptions);
}
+ /**
+ * Visit a field to extract its annotations
+ *
+ * @see org.objectweb.asm.ClassVisitor#visitField(int, java.lang.String, java.lang.String, java.lang.String, java.lang.Object)
+ */
@Override
public FieldVisitor visitField (final int access,
final String fieldName,
@@ -477,99 +516,11 @@ public class AnnotationParser
final String signature,
final Object value)
{
-
- return new EmptyVisitor ()
- {
- @Override
- public AnnotationVisitor visitAnnotation(String desc, boolean visible)
- {
- MyAnnotationVisitor visitor = new MyAnnotationVisitor(normalize(desc), new ArrayList())
- {
- @Override
- public void visitEnd()
- {
- super.visitEnd();
- for (Handler h : AnnotationParser.this._handlers)
- {
- if (h instanceof DiscoverableAnnotationHandler)
- {
- DiscoverableAnnotationHandler dah = (DiscoverableAnnotationHandler)h;
- if (_annotationName.equalsIgnoreCase(dah.getAnnotationName()))
- dah.handleField(_className, fieldName, access, fieldType, signature, value, _annotationName, _annotationValues);
- }
- }
- }
- };
- return visitor;
- }
- };
+ return new MyFieldVisitor(_ci.getClassName(), access, fieldName, fieldType, signature, value);
}
}
-
- /**
- * Register a handler that will be called back when the named annotation is
- * encountered on a class.
- *
- * @deprecated see {@link #registerHandler(Handler)}
- * @param annotationName
- * @param handler
- */
- @Deprecated
- public void registerAnnotationHandler (String annotationName, DiscoverableAnnotationHandler handler)
- {
- _handlers.add(handler);
- }
-
-
- /**
- * @deprecated no replacement provided
- * @param annotationName
- */
- @Deprecated
- public List getAnnotationHandlers(String annotationName)
- {
- List handlers = new ArrayList();
- for (Handler h:_handlers)
- {
- if (h instanceof DiscoverableAnnotationHandler)
- {
- DiscoverableAnnotationHandler dah = (DiscoverableAnnotationHandler)h;
- if (annotationName.equals(dah.getAnnotationName()))
- handlers.add(dah);
- }
- }
- return handlers;
- }
-
- /**
- * @deprecated no replacement available
- */
- @Deprecated
- public List getAnnotationHandlers()
- {
- List allAnnotationHandlers = new ArrayList();
- for (Handler h:_handlers)
- {
- if (h instanceof DiscoverableAnnotationHandler)
- allAnnotationHandlers.add((DiscoverableAnnotationHandler)h);
- }
- return allAnnotationHandlers;
- }
-
- /**
- * @deprecated see {@link #registerHandler(Handler)}
- * @param handler
- */
- @Deprecated
- public void registerClassHandler (ClassHandler handler)
- {
- _handlers.add(handler);
- }
-
-
-
/**
* Add a particular handler
*
diff --git a/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/ClassInheritanceHandler.java b/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/ClassInheritanceHandler.java
index 50892a851a8..42f8d8021ba 100644
--- a/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/ClassInheritanceHandler.java
+++ b/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/ClassInheritanceHandler.java
@@ -20,7 +20,8 @@ package org.eclipse.jetty.annotations;
import java.util.List;
-import org.eclipse.jetty.annotations.AnnotationParser.ClassHandler;
+import org.eclipse.jetty.annotations.AnnotationParser.AbstractHandler;
+import org.eclipse.jetty.annotations.AnnotationParser.ClassInfo;
import org.eclipse.jetty.util.MultiMap;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
@@ -30,7 +31,7 @@ import org.eclipse.jetty.util.log.Logger;
*
* As asm scans for classes, remember the type hierarchy.
*/
-public class ClassInheritanceHandler implements ClassHandler
+public class ClassInheritanceHandler extends AbstractHandler
{
private static final Logger LOG = Log.getLogger(ClassInheritanceHandler.class);
@@ -46,17 +47,17 @@ public class ClassInheritanceHandler implements ClassHandler
_inheritanceMap = map;
}
- public void handle(String className, int version, int access, String signature, String superName, String[] interfaces)
+ public void handle(ClassInfo classInfo)
{
try
{
- for (int i=0; interfaces != null && i values)
- {
- _initializer.addAnnotatedTypeName(className);
+ public void handle(FieldInfo info, String annotationName)
+ {
+ if (annotationName == null || !_annotation.getName().equals(annotationName))
+ return;
+ _initializer.addAnnotatedTypeName(info.getClassName());
}
- public void handleField(String className, String fieldName, int access, String fieldType, String signature, Object value, String annotation,
- List values)
+ /**
+ * Handle finding a method that is annotated with the annotation we were constructed with.
+ *
+ * @see org.eclipse.jetty.annotations.AnnotationParser.DiscoverableAnnotationHandler#handle(org.eclipse.jetty.annotations.AnnotationParser.MethodAnnotationInfo)
+ */
+ public void handle(MethodInfo info, String annotationName)
{
- _initializer.addAnnotatedTypeName(className);
+ if (annotationName == null || !_annotation.getName().equals(annotationName))
+ return;
+ _initializer.addAnnotatedTypeName(info.getClassName());
}
- public void handleMethod(String className, String methodName, int access, String params, String signature, String[] exceptions, String annotation,
- List values)
- {
- _initializer.addAnnotatedTypeName(className);
- }
-
- @Override
- public String getAnnotationName()
- {
- return _annotation.getName();
- }
public ContainerInitializer getContainerInitializer()
{
return _initializer;
}
-
}
diff --git a/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/RunAsAnnotationHandler.java b/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/RunAsAnnotationHandler.java
index 6b4a6382ed5..c80257f752b 100644
--- a/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/RunAsAnnotationHandler.java
+++ b/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/RunAsAnnotationHandler.java
@@ -23,7 +23,6 @@ import java.util.List;
import javax.servlet.Servlet;
import org.eclipse.jetty.annotations.AnnotationIntrospector.AbstractIntrospectableAnnotationHandler;
-import org.eclipse.jetty.annotations.AnnotationParser.Value;
import org.eclipse.jetty.plus.annotation.RunAsCollection;
import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.util.log.Log;
@@ -87,14 +86,12 @@ public class RunAsAnnotationHandler extends AbstractIntrospectableAnnotationHand
}
- public void handleField(String className, String fieldName, int access, String fieldType, String signature, Object value, String annotation,
- List values)
+ public void handleField(String className, String fieldName, int access, String fieldType, String signature, Object value, String annotation)
{
LOG.warn ("@RunAs annotation not applicable for fields: "+className+"."+fieldName);
}
- public void handleMethod(String className, String methodName, int access, String params, String signature, String[] exceptions, String annotation,
- List values)
+ public void handleMethod(String className, String methodName, int access, String params, String signature, String[] exceptions, String annotation)
{
LOG.warn("@RunAs annotation ignored on method: "+className+"."+methodName+" "+signature);
}
diff --git a/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/WebFilterAnnotationHandler.java b/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/WebFilterAnnotationHandler.java
index 15459779370..356199ad97b 100644
--- a/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/WebFilterAnnotationHandler.java
+++ b/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/WebFilterAnnotationHandler.java
@@ -20,7 +20,9 @@ package org.eclipse.jetty.annotations;
import java.util.List;
-import org.eclipse.jetty.annotations.AnnotationParser.Value;
+import org.eclipse.jetty.annotations.AnnotationParser.ClassInfo;
+import org.eclipse.jetty.annotations.AnnotationParser.FieldInfo;
+import org.eclipse.jetty.annotations.AnnotationParser.MethodInfo;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.webapp.DiscoveredAnnotation;
@@ -46,31 +48,28 @@ public class WebFilterAnnotationHandler extends AbstractDiscoverableAnnotationHa
}
@Override
- public void handleClass(String className, int version, int access, String signature, String superName, String[] interfaces, String annotation,
- List values)
+ public void handle(ClassInfo info, String annotationName)
{
- WebFilterAnnotation wfAnnotation = new WebFilterAnnotation(_context, className, _resource);
+ if (annotationName == null || !"javax.servlet.annotation.WebFilter".equals(annotationName))
+ return;
+
+ WebFilterAnnotation wfAnnotation = new WebFilterAnnotation(_context, info.getClassName(), _resource);
addAnnotation(wfAnnotation);
}
@Override
- public void handleField(String className, String fieldName, int access, String fieldType, String signature, Object value, String annotation,
- List values)
- {
- LOG.warn ("@WebFilter not applicable for fields: "+className+"."+fieldName);
+ public void handle(FieldInfo info, String annotationName)
+ {
+ if (annotationName == null || !"javax.servlet.annotation.WebFilter".equals(annotationName))
+ return;
+ LOG.warn ("@WebFilter not applicable for fields: "+info.getClassName()+"."+info.getFieldName());
}
@Override
- public void handleMethod(String className, String methodName, int access, String params, String signature, String[] exceptions, String annotation,
- List values)
- {
- LOG.warn ("@WebFilter not applicable for methods: "+className+"."+methodName+" "+signature);
+ public void handle(MethodInfo info, String annotationName)
+ {
+ if (annotationName == null || !"javax.servlet.annotation.WebFilter".equals(annotationName))
+ return;
+ LOG.warn ("@WebFilter not applicable for methods: "+info.getClassName()+"."+info.getMethodName()+" "+info.getSignature());
}
-
- @Override
- public String getAnnotationName()
- {
- return "javax.servlet.annotation.WebFilter";
- }
-
}
diff --git a/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/WebListenerAnnotationHandler.java b/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/WebListenerAnnotationHandler.java
index ab1670230ae..81df82f4b7f 100644
--- a/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/WebListenerAnnotationHandler.java
+++ b/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/WebListenerAnnotationHandler.java
@@ -20,7 +20,9 @@ package org.eclipse.jetty.annotations;
import java.util.List;
-import org.eclipse.jetty.annotations.AnnotationParser.Value;
+import org.eclipse.jetty.annotations.AnnotationParser.ClassInfo;
+import org.eclipse.jetty.annotations.AnnotationParser.FieldInfo;
+import org.eclipse.jetty.annotations.AnnotationParser.MethodInfo;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.webapp.DiscoveredAnnotation;
@@ -41,31 +43,28 @@ public class WebListenerAnnotationHandler extends AbstractDiscoverableAnnotation
}
/**
- * @see org.eclipse.jetty.annotations.AnnotationParser.DiscoverableAnnotationHandler#handleClass(java.lang.String, int, int, java.lang.String, java.lang.String, java.lang.String[], java.lang.String, java.util.List)
+ * @see org.eclipse.jetty.annotations.AnnotationParser.DiscoverableAnnotationHandler#handle(ClassAnnotationInfo)
*/
- public void handleClass(String className, int version, int access, String signature, String superName, String[] interfaces, String annotation,
- List values)
+ public void handle(ClassInfo info, String annotationName)
{
- WebListenerAnnotation wlAnnotation = new WebListenerAnnotation(_context, className, _resource);
+ if (annotationName == null || !"javax.servlet.annotation.WebListener".equals(annotationName))
+ return;
+
+ WebListenerAnnotation wlAnnotation = new WebListenerAnnotation(_context, info.getClassName(), _resource);
addAnnotation(wlAnnotation);
}
- public void handleField(String className, String fieldName, int access, String fieldType, String signature, Object value, String annotation,
- List values)
+ public void handle(FieldInfo info, String annotationName)
{
- LOG.warn ("@WebListener is not applicable to fields: "+className+"."+fieldName);
+ if (annotationName == null || !"javax.servlet.annotation.WebListener".equals(annotationName))
+ return;
+ LOG.warn ("@WebListener is not applicable to fields: "+info.getClassName()+"."+info.getFieldName());
}
- public void handleMethod(String className, String methodName, int access, String params, String signature, String[] exceptions, String annotation,
- List values)
+ public void handle(MethodInfo info, String annotationName)
{
- LOG.warn ("@WebListener is not applicable to methods: "+className+"."+methodName+" "+signature);
+ if (annotationName == null || !"javax.servlet.annotation.WebListener".equals(annotationName))
+ return;
+ LOG.warn ("@WebListener is not applicable to methods: "+info.getClassName()+"."+info.getMethodName()+" "+info.getSignature());
}
-
- @Override
- public String getAnnotationName()
- {
- return "javax.servlet.annotation.WebListener";
- }
-
}
diff --git a/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/WebServletAnnotationHandler.java b/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/WebServletAnnotationHandler.java
index 65227734de0..67fee219264 100644
--- a/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/WebServletAnnotationHandler.java
+++ b/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/WebServletAnnotationHandler.java
@@ -20,7 +20,9 @@ package org.eclipse.jetty.annotations;
import java.util.List;
-import org.eclipse.jetty.annotations.AnnotationParser.Value;
+import org.eclipse.jetty.annotations.AnnotationParser.ClassInfo;
+import org.eclipse.jetty.annotations.AnnotationParser.FieldInfo;
+import org.eclipse.jetty.annotations.AnnotationParser.MethodInfo;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.webapp.DiscoveredAnnotation;
@@ -54,34 +56,30 @@ public class WebServletAnnotationHandler extends AbstractDiscoverableAnnotationH
* @see org.eclipse.jetty.annotations.AnnotationParser.DiscoverableAnnotationHandler#handleClass(java.lang.String, int, int, java.lang.String, java.lang.String, java.lang.String[], java.lang.String, java.util.List)
*/
@Override
- public void handleClass(String className, int version, int access, String signature, String superName, String[] interfaces, String annotationName,
- List values)
+ public void handle(ClassInfo info, String annotationName)
{
- if (!"javax.servlet.annotation.WebServlet".equals(annotationName))
+ if (annotationName == null || !"javax.servlet.annotation.WebServlet".equals(annotationName))
return;
-
- WebServletAnnotation annotation = new WebServletAnnotation (_context, className, _resource);
+
+ WebServletAnnotation annotation = new WebServletAnnotation (_context, info.getClassName(), _resource);
addAnnotation(annotation);
}
@Override
- public void handleField(String className, String fieldName, int access, String fieldType, String signature, Object value, String annotation,
- List values)
+ public void handle(FieldInfo info, String annotationName)
{
+ if (annotationName == null || !"javax.servlet.annotation.WebServlet".equals(annotationName))
+ return;
+
LOG.warn ("@WebServlet annotation not supported for fields");
}
@Override
- public void handleMethod(String className, String methodName, int access, String params, String signature, String[] exceptions, String annotation,
- List values)
+ public void handle(MethodInfo info, String annotationName)
{
+ if (annotationName == null || !"javax.servlet.annotation.WebServlet".equals(annotationName))
+ return;
+
LOG.warn ("@WebServlet annotation not supported for methods");
}
-
-
- @Override
- public String getAnnotationName()
- {
- return "javax.servlet.annotation.WebServlet";
- }
}
diff --git a/jetty-annotations/src/test/java/org/eclipse/jetty/annotations/TestAnnotationInheritance.java b/jetty-annotations/src/test/java/org/eclipse/jetty/annotations/TestAnnotationInheritance.java
index b589f3da5c1..ce668d015c8 100644
--- a/jetty-annotations/src/test/java/org/eclipse/jetty/annotations/TestAnnotationInheritance.java
+++ b/jetty-annotations/src/test/java/org/eclipse/jetty/annotations/TestAnnotationInheritance.java
@@ -30,8 +30,10 @@ import java.util.Map;
import javax.naming.Context;
import javax.naming.InitialContext;
-import org.eclipse.jetty.annotations.AnnotationParser.DiscoverableAnnotationHandler;
-import org.eclipse.jetty.annotations.AnnotationParser.Value;
+import org.eclipse.jetty.annotations.AnnotationParser.AbstractHandler;
+import org.eclipse.jetty.annotations.AnnotationParser.ClassInfo;
+import org.eclipse.jetty.annotations.AnnotationParser.FieldInfo;
+import org.eclipse.jetty.annotations.AnnotationParser.MethodInfo;
import org.eclipse.jetty.util.MultiMap;
import org.junit.After;
import org.junit.Test;
@@ -44,34 +46,32 @@ public class TestAnnotationInheritance
List classNames = new ArrayList();
- class SampleHandler implements DiscoverableAnnotationHandler
+ class SampleHandler extends AbstractHandler
{
public final List annotatedClassNames = new ArrayList();
public final List annotatedMethods = new ArrayList();
public final List annotatedFields = new ArrayList();
- public void handleClass(String className, int version, int access, String signature, String superName, String[] interfaces, String annotation,
- List values)
+ public void handle(ClassInfo info, String annotation)
{
- annotatedClassNames.add(className);
+ if (annotation == null || !"org.eclipse.jetty.annotations.Sample".equals(annotation))
+ return;
+
+ annotatedClassNames.add(info.getClassName());
}
- public void handleField(String className, String fieldName, int access, String fieldType, String signature, Object value, String annotation,
- List values)
- {
- annotatedFields.add(className+"."+fieldName);
+ public void handle(FieldInfo info, String annotation)
+ {
+ if (annotation == null || !"org.eclipse.jetty.annotations.Sample".equals(annotation))
+ return;
+ annotatedFields.add(info.getClassName()+"."+info.getFieldName());
}
- public void handleMethod(String className, String methodName, int access, String params, String signature, String[] exceptions, String annotation,
- List values)
+ public void handle(MethodInfo info, String annotation)
{
- annotatedMethods.add(className+"."+methodName);
- }
-
- @Override
- public String getAnnotationName()
- {
- return "org.eclipse.jetty.annotations.Sample";
+ if (annotation == null || !"org.eclipse.jetty.annotations.Sample".equals(annotation))
+ return;
+ annotatedMethods.add(info.getClassName()+"."+info.getMethodName());
}
}
@@ -129,7 +129,7 @@ public class TestAnnotationInheritance
{
SampleHandler handler = new SampleHandler();
AnnotationParser parser = new AnnotationParser();
- parser.registerAnnotationHandler("org.eclipse.jetty.annotations.Sample", handler);
+ parser.registerHandler(handler);
parser.parse(ClassB.class, new ClassNameResolver ()
{
public boolean isExcluded(String name)
@@ -166,7 +166,7 @@ public class TestAnnotationInheritance
{
AnnotationParser parser = new AnnotationParser();
SampleHandler handler = new SampleHandler();
- parser.registerAnnotationHandler("org.eclipse.jetty.annotations.Sample", handler);
+ parser.registerHandler(handler);
parser.parse(ClassA.class.getName(), new ClassNameResolver()
{
public boolean isExcluded(String name)
@@ -207,7 +207,7 @@ public class TestAnnotationInheritance
{
AnnotationParser parser = new AnnotationParser();
ClassInheritanceHandler handler = new ClassInheritanceHandler();
- parser.registerClassHandler(handler);
+ parser.registerHandler(handler);
class Foo implements InterfaceD
{
diff --git a/jetty-annotations/src/test/java/org/eclipse/jetty/annotations/TestAnnotationParser.java b/jetty-annotations/src/test/java/org/eclipse/jetty/annotations/TestAnnotationParser.java
index 6e56a0def15..a0142d4fcc9 100644
--- a/jetty-annotations/src/test/java/org/eclipse/jetty/annotations/TestAnnotationParser.java
+++ b/jetty-annotations/src/test/java/org/eclipse/jetty/annotations/TestAnnotationParser.java
@@ -18,8 +18,11 @@
package org.eclipse.jetty.annotations;
-import static org.hamcrest.Matchers.*;
-import static org.junit.Assert.*;
+import static org.hamcrest.Matchers.contains;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.io.File;
import java.io.FileOutputStream;
@@ -32,20 +35,20 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import org.eclipse.jetty.annotations.AnnotationParser.DiscoverableAnnotationHandler;
-import org.eclipse.jetty.annotations.AnnotationParser.Value;
+import org.eclipse.jetty.annotations.AnnotationParser.ClassInfo;
+import org.eclipse.jetty.annotations.AnnotationParser.FieldInfo;
+import org.eclipse.jetty.annotations.AnnotationParser.MethodInfo;
import org.eclipse.jetty.toolchain.test.FS;
import org.eclipse.jetty.toolchain.test.IO;
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
import org.eclipse.jetty.toolchain.test.TestingDir;
import org.junit.Assert;
import org.junit.Rule;
-import org.junit.Rule;
import org.junit.Test;
public class TestAnnotationParser
{
- public static class TrackingAnnotationHandler implements DiscoverableAnnotationHandler
+ public static class TrackingAnnotationHandler extends AnnotationParser.AbstractHandler
{
private final String annotationName;
public final Set foundClasses;
@@ -57,30 +60,11 @@ public class TestAnnotationParser
}
@Override
- public void handleClass(String className, int version, int access, String signature, String superName, String[] interfaces, String annotation,
- List values)
+ public void handle(ClassInfo info, String annotation)
{
- foundClasses.add(className);
- }
-
- @Override
- public void handleMethod(String className, String methodName, int access, String desc, String signature, String[] exceptions, String annotation,
- List values)
- {
- /* ignore */
- }
-
- @Override
- public void handleField(String className, String fieldName, int access, String fieldType, String signature, Object value, String annotation,
- List values)
- {
- /* ignore */
- }
-
- @Override
- public String getAnnotationName()
- {
- return this.annotationName;
+ if (annotation == null || !annotationName.equals(annotation))
+ return;
+ foundClasses.add(info.getClassName());
}
}
@@ -94,41 +78,34 @@ public class TestAnnotationParser
{ "org.eclipse.jetty.annotations.ClassA" };
AnnotationParser parser = new AnnotationParser();
- class SampleAnnotationHandler implements DiscoverableAnnotationHandler
+ class SampleAnnotationHandler extends AnnotationParser.AbstractHandler
{
private List methods = Arrays.asList("a","b","c","d","l");
- public void handleClass(String className, int version, int access, String signature, String superName, String[] interfaces, String annotation,
- List values)
+ public void handle(ClassInfo info, String annotation)
{
- assertEquals("org.eclipse.jetty.annotations.ClassA",className);
+ if (annotation == null || !"org.eclipse.jetty.annotations.Sample".equals(annotation))
+ return;
+
+ assertEquals("org.eclipse.jetty.annotations.ClassA",info.getClassName());
}
- public void handleField(String className, String fieldName, int access, String fieldType, String signature, Object value, String annotation,
- List values)
- {
- assertEquals("m",fieldName);
- assertEquals(org.objectweb.asm.Type.OBJECT,org.objectweb.asm.Type.getType(fieldType).getSort());
- assertEquals(1,values.size());
- Value anv1 = values.get(0);
- assertEquals("value",anv1.getName());
- assertEquals(7,anv1.getValue());
-
+ public void handle(FieldInfo info, String annotation)
+ {
+ if (annotation == null || !"org.eclipse.jetty.annotations.Sample".equals(annotation))
+ return;
+ assertEquals("m",info.getFieldName());
+ assertEquals(org.objectweb.asm.Type.OBJECT,org.objectweb.asm.Type.getType(info.getFieldType()).getSort());
}
- public void handleMethod(String className, String methodName, int access, String desc, String signature, String[] exceptions, String annotation,
- List values)
- {
- assertEquals("org.eclipse.jetty.annotations.ClassA",className);
- assertTrue(methods.contains(methodName));
+ public void handle(MethodInfo info, String annotation)
+ {
+ if (annotation == null || !"org.eclipse.jetty.annotations.Sample".equals(annotation))
+ return;
+ assertEquals("org.eclipse.jetty.annotations.ClassA",info.getClassName());
+ assertTrue(methods.contains(info.getMethodName()));
assertEquals("org.eclipse.jetty.annotations.Sample",annotation);
}
-
- @Override
- public String getAnnotationName()
- {
- return "org.eclipse.jetty.annotations.Sample";
- }
}
parser.registerHandler(new SampleAnnotationHandler());
@@ -159,34 +136,30 @@ public class TestAnnotationParser
{ "org.eclipse.jetty.annotations.ClassB" };
AnnotationParser parser = new AnnotationParser();
- class MultiAnnotationHandler implements DiscoverableAnnotationHandler
+ class MultiAnnotationHandler extends AnnotationParser.AbstractHandler
{
- public void handleClass(String className, int version, int access, String signature, String superName, String[] interfaces, String annotation,
- List values)
+ public void handle(ClassInfo info, String annotation)
{
- assertTrue("org.eclipse.jetty.annotations.ClassB".equals(className));
+ if (annotation == null || ! "org.eclipse.jetty.annotations.Multi".equals(annotation))
+ return;
+ assertTrue("org.eclipse.jetty.annotations.ClassB".equals(info.getClassName()));
}
- public void handleField(String className, String fieldName, int access, String fieldType, String signature, Object value, String annotation,
- List values)
- {
+ public void handle(FieldInfo info, String annotation)
+ {
+ if (annotation == null || ! "org.eclipse.jetty.annotations.Multi".equals(annotation))
+ return;
// there should not be any
fail();
}
- public void handleMethod(String className, String methodName, int access, String params, String signature, String[] exceptions, String annotation,
- List values)
- {
- assertTrue("org.eclipse.jetty.annotations.ClassB".equals(className));
- assertTrue("a".equals(methodName));
+ public void handle(MethodInfo info, String annotation)
+ {
+ if (annotation == null || ! "org.eclipse.jetty.annotations.Multi".equals(annotation))
+ return;
+ assertTrue("org.eclipse.jetty.annotations.ClassB".equals(info.getClassName()));
+ assertTrue("a".equals(info.getMethodName()));
}
-
- @Override
- public String getAnnotationName()
- {
- return "org.eclipse.jetty.annotations.Multi";
- }
-
}
parser.registerHandler(new MultiAnnotationHandler());
diff --git a/jetty-annotations/src/test/java/org/eclipse/jetty/annotations/TestServletAnnotations.java b/jetty-annotations/src/test/java/org/eclipse/jetty/annotations/TestServletAnnotations.java
index b407dc852d8..dd80616d6cd 100644
--- a/jetty-annotations/src/test/java/org/eclipse/jetty/annotations/TestServletAnnotations.java
+++ b/jetty-annotations/src/test/java/org/eclipse/jetty/annotations/TestServletAnnotations.java
@@ -50,7 +50,7 @@ public class TestServletAnnotations
WebAppContext wac = new WebAppContext();
WebServletAnnotationHandler handler = new WebServletAnnotationHandler(wac);
- parser.registerAnnotationHandler("javax.servlet.annotation.WebServlet", handler);
+ parser.registerHandler(handler);
parser.parse(classes, new ClassNameResolver ()
{
diff --git a/jetty-distribution/pom.xml b/jetty-distribution/pom.xml
index 901b55ccf81..371d01dc7b0 100644
--- a/jetty-distribution/pom.xml
+++ b/jetty-distribution/pom.xml
@@ -399,8 +399,8 @@
copy-dependencies
- javax.annotation,org.eclipse.jetty.orbit
- javax.annotation-api,org.objectweb.asm
+ javax.annotation,org.eclipse.jetty.orbit,org.ow2.asm
+ javax.annotation-api,asm,asm-commons
jar
${assembly-directory}/lib/annotations
@@ -541,10 +541,6 @@
javax.annotation
javax.annotation-api
-
- org.eclipse.jetty.orbit
- org.objectweb.asm
-
org.eclipse.jetty.orbit
javax.activation
@@ -579,6 +575,15 @@
javax.el
+
+ org.ow2.asm
+ asm
+
+
+ org.ow2.asm
+ asm-commons
+
+
org.eclipse.jetty
diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/MavenAnnotationConfiguration.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/MavenAnnotationConfiguration.java
index 8d5b502a4c6..c61dc1581a3 100644
--- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/MavenAnnotationConfiguration.java
+++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/MavenAnnotationConfiguration.java
@@ -23,7 +23,6 @@ import java.io.File;
import org.eclipse.jetty.annotations.AbstractDiscoverableAnnotationHandler;
import org.eclipse.jetty.annotations.AnnotationConfiguration;
import org.eclipse.jetty.annotations.AnnotationParser;
-import org.eclipse.jetty.annotations.AnnotationParser.DiscoverableAnnotationHandler;
import org.eclipse.jetty.annotations.ClassNameResolver;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
@@ -52,7 +51,7 @@ public class MavenAnnotationConfiguration extends AnnotationConfiguration
throw new IllegalStateException ("No metadata");
parser.clearHandlers();
- for (DiscoverableAnnotationHandler h:_discoverableAnnotationHandlers)
+ for (AbstractDiscoverableAnnotationHandler h:_discoverableAnnotationHandlers)
{
if (h instanceof AbstractDiscoverableAnnotationHandler)
((AbstractDiscoverableAnnotationHandler)h).setResource(null); //
diff --git a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/annotations/AnnotationConfiguration.java b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/annotations/AnnotationConfiguration.java
index b4ae909819d..4b15ae5b9d7 100644
--- a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/annotations/AnnotationConfiguration.java
+++ b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/annotations/AnnotationConfiguration.java
@@ -18,16 +18,11 @@
package org.eclipse.jetty.osgi.annotations;
-import java.util.ArrayList;
-import java.util.List;
-
import org.eclipse.jetty.annotations.AbstractDiscoverableAnnotationHandler;
-import org.eclipse.jetty.annotations.AnnotationParser.DiscoverableAnnotationHandler;
import org.eclipse.jetty.annotations.ClassNameResolver;
import org.eclipse.jetty.osgi.boot.OSGiWebappConstants;
import org.eclipse.jetty.osgi.boot.utils.internal.PackageAdminServiceTracker;
import org.eclipse.jetty.util.resource.Resource;
-import org.eclipse.jetty.webapp.DiscoveredAnnotation;
import org.eclipse.jetty.webapp.WebAppContext;
import org.osgi.framework.Bundle;
import org.osgi.framework.Constants;
@@ -157,7 +152,7 @@ public class AnnotationConfiguration extends org.eclipse.jetty.annotations.Annot
Resource bundleRes = parser.getResource(bundle);
parser.clearHandlers();
- for (DiscoverableAnnotationHandler h:_discoverableAnnotationHandlers)
+ for (AbstractDiscoverableAnnotationHandler h:_discoverableAnnotationHandlers)
{
if (h instanceof AbstractDiscoverableAnnotationHandler)
{
diff --git a/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/deploy/ServerEndpointAnnotationHandler.java b/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/deploy/ServerEndpointAnnotationHandler.java
index 7b97671e45e..47d8086c511 100644
--- a/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/deploy/ServerEndpointAnnotationHandler.java
+++ b/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/deploy/ServerEndpointAnnotationHandler.java
@@ -23,7 +23,7 @@ import java.util.List;
import javax.websocket.server.ServerEndpoint;
import org.eclipse.jetty.annotations.AbstractDiscoverableAnnotationHandler;
-import org.eclipse.jetty.annotations.AnnotationParser.Value;
+import org.eclipse.jetty.annotations.AnnotationParser.ClassInfo;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.webapp.DiscoveredAnnotation;
@@ -47,19 +47,13 @@ public class ServerEndpointAnnotationHandler extends AbstractDiscoverableAnnotat
super(context,list);
}
- @Override
- public String getAnnotationName()
- {
- return ANNOTATION_NAME;
- }
@Override
- public void handleClass(String className, int version, int access, String signature, String superName, String[] interfaces, String annotationName,
- List values)
+ public void handle(ClassInfo info, String annotationName)
{
if (LOG.isDebugEnabled())
{
- LOG.debug("handleClass: {}, {}, {}",className,annotationName,values);
+ LOG.debug("handleClass: {}, {}, {}",info.getClassName(),annotationName);
}
if (!ANNOTATION_NAME.equals(annotationName))
@@ -68,21 +62,7 @@ public class ServerEndpointAnnotationHandler extends AbstractDiscoverableAnnotat
return;
}
- ServerEndpointAnnotation annotation = new ServerEndpointAnnotation(_context,className,_resource);
+ ServerEndpointAnnotation annotation = new ServerEndpointAnnotation(_context,info.getClassName(),_resource);
addAnnotation(annotation);
}
-
- @Override
- public void handleField(String className, String fieldName, int access, String fieldType, String signature, Object value, String annotation,
- List values)
- {
- /* @ServerEndpoint annotation not supported for fields */
- }
-
- @Override
- public void handleMethod(String className, String methodName, int access, String desc, String signature, String[] exceptions, String annotation,
- List values)
- {
- /* @ServerEndpoint annotation not supported for methods */
- }
}
diff --git a/pom.xml b/pom.xml
index 8f97ba80b83..7b3b952ff7a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -467,10 +467,16 @@
1.2
- org.eclipse.jetty.orbit
- org.objectweb.asm
- 3.1.0.v200803061910
+ org.ow2.asm
+ asm
+ 4.1
+
+ org.ow2.asm
+ asm-commons
+ 4.1
+
+
org.eclipse.jetty.orbit
javax.security.auth.message