Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-users] Annotation scanner for non jar resources

Hi


I was wondering if its possible to have the annotation scanner scan for classes outside jar resources.


I have this class in test scope of my war project.
System.setProperty("org.eclipse.jetty.LEVEL", "INFO");

Server srv = new Server(8080);
srv.setStopAtShutdown(true);

Configuration.ClassList classlist = Configuration.ClassList.setServerDefault(srv);
classlist.addBefore("org.eclipse.jetty.webapp.JettyWebXmlConfiguration", "org.eclipse.jetty.annotations.AnnotationConfiguration");

WebAppContext context = new WebAppContext();
context.setContextPath("/");

String dir;
if (new File("src/main/webapp").exists()) dir = "src/main/webapp";
else dir = "war/src/main/webapp";

context.setResourceBase(dir);
context.setDescriptor(dir + "/WEB-INF/web.xml");

context.setAttribute(
"org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern",
".*/[^/]*servlet-api-[^/]*\\.jar$|.*/javax.servlet.jsp.jstl-.*\\.jar$|.*/[^/]*taglibs.*\\.jarquot;);

context.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", "false");

context.setParentLoaderPriority(true);
context.setServer(srv);

// Add the handlers
HandlerList handlers = new HandlerList();
handlers.addHandler(context);
srv.setHandler(handlers);

srv.start();
srv.join();


And want to have this one scan main classes for annotations.


--
Idar Borlaug


Back to the top