use of org.mortbay.jetty.servlet.FilterHolder in project gradle by gradle.
the class JettyConfiguration method parseAnnotations.
public void parseAnnotations() throws Exception {
String v = System.getProperty("java.version");
String[] version = v.split("\\.");
if (version == null) {
Log.info("Unable to determine jvm version, annotations will not be supported");
return;
}
int major = Integer.parseInt(version[0]);
int minor = Integer.parseInt(version[1]);
if ((major >= 1) && (minor >= 5)) {
//TODO it would be nice to be able to re-use the parseAnnotations() method on
//the org.mortbay.jetty.annotations.Configuration class, but it's too difficult?
//able to use annotations on jdk1.5 and above
Class<?> annotationParserClass = Thread.currentThread().getContextClassLoader().loadClass("org.mortbay.jetty.annotations.AnnotationParser");
Method parseAnnotationsMethod = annotationParserClass.getMethod("parseAnnotations", WebAppContext.class, Class.class, RunAsCollection.class, InjectionCollection.class, LifeCycleCallbackCollection.class);
//look thru _servlets
Iterator itor = LazyList.iterator(_servlets);
while (itor.hasNext()) {
ServletHolder holder = (ServletHolder) itor.next();
//TODO: Some paths within Jetty can acquire persistent file locks on the jars containing these classes.
Class servlet = getWebAppContext().loadClass(holder.getClassName());
parseAnnotationsMethod.invoke(null, getWebAppContext(), servlet, _runAsCollection, _injections, _callbacks);
}
//look thru _filters
itor = LazyList.iterator(_filters);
while (itor.hasNext()) {
FilterHolder holder = (FilterHolder) itor.next();
Class filter = getWebAppContext().loadClass(holder.getClassName());
parseAnnotationsMethod.invoke(null, getWebAppContext(), filter, null, _injections, _callbacks);
}
//look thru _listeners
itor = LazyList.iterator(_listeners);
while (itor.hasNext()) {
Object listener = itor.next();
parseAnnotationsMethod.invoke(null, getWebAppContext(), listener.getClass(), null, _injections, _callbacks);
}
} else {
Log.info("Annotations are not supported on jvms prior to jdk1.5");
}
}
Aggregations