Skip to main content

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

Thanks, tried that yesterday. But i must have made a mistake in the regexp :)

On Wed, Jul 15, 2015 at 5:46 AM Jan Bartel <janb@xxxxxxxxxxx> wrote:
Idar,

Scanning non-jar resources on the container path works just fine. The
trick is to ensure your regexp matches correctly.

In my test environment, a classes url looks like:
file:/home/janb/src/jetty-eclipse/jetty-9/examples/embedded/target/classes/

To match it I use a regexp like: .*/classes/

The full regexp is:
".*/javax.servlet-[^/]*\\.jar$|.*/servlet-api-[^/]*\\.jar$|.*/classes/"

Jan

On 14 July 2015 at 21:32, Idar Borlaug <idar.borlaug@xxxxxxxxx> wrote:
> 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
>
>
> _______________________________________________
> jetty-users mailing list
> jetty-users@xxxxxxxxxxx
> To change your delivery options, retrieve your password, or unsubscribe from
> this list, visit
> https://dev.eclipse.org/mailman/listinfo/jetty-users



--
Jan Bartel <janb@xxxxxxxxxxx>
www.webtide.com
'Expert assistance from the creators of Jetty and CometD'
_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users
--
Idar Borlaug


Back to the top