经过跟踪和分析发现是Axis2的源码中做了判断:
package org.apache.axis2.jaxrs;
import org.apache.axis2.Constants;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.HEAD;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import java.lang.reflect.Method;
import java.lang.annotation.Annotation;
public class JAXRSUtils {
private static Log log = LogFactory.getLog(JAXRSModel.class);
/**
* returns a jaxrs class model reading class level annotation given the service class
* @param serviceClass
* @return
*/
public static JAXRSModel getClassModel(Class serviceClass) {
JAXRSModel model = new JAXRSModel();
Annotation[] annotation = serviceClass.getAnnotations();
for (Annotation a : annotation) {
if (a != null) {
if (a instanceof Produces) {
addProducesToClassModel((Produces) a, model);
} else if (a instanceof Consumes) {
addConsumesToClassModel((Consumes) a, model);
} else if (a instanceof Path) {
addPathToClassModel((Path) a, model);
} else {
//如果返回的注解类型不是上面三种,系统会打印
System.out.println("Could not identify the Annotation....");
}
}
}
return model;
}
通过断点调试发现:serviceClass对应的类