1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.eclipse.jetty.embedded;
21
22 import org.eclipse.jetty.security.HashLoginService;
23 import org.eclipse.jetty.server.Server;
24 import org.eclipse.jetty.webapp.WebAppContext;
25
26
27
28
29
30
31 public class ServerWithAnnotations
32 {
33 public static final void main(String args[]) throws Exception
34 {
35
36 Server server = new Server(8080);
37
38
39 org.eclipse.jetty.webapp.Configuration.ClassList classlist = org.eclipse.jetty.webapp.Configuration.ClassList.setServerDefault(server);
40 classlist.addAfter("org.eclipse.jetty.webapp.FragmentConfiguration", "org.eclipse.jetty.plus.webapp.EnvConfiguration", "org.eclipse.jetty.plus.webapp.PlusConfiguration");
41 classlist.addBefore("org.eclipse.jetty.webapp.JettyWebXmlConfiguration", "org.eclipse.jetty.annotations.AnnotationConfiguration");
42
43
44 WebAppContext webapp = new WebAppContext();
45 webapp.setContextPath("/");
46 webapp.setWar("../../tests/test-webapps/test-servlet-spec/test-spec-webapp/target/test-spec-webapp-9.1.0-SNAPSHOT.war");
47 webapp.setAttribute("org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern",".*/javax.servlet-[^/]*\\.jar$|.*/servlet-api-[^/]*\\.jar$");
48 server.setHandler(webapp);
49
50
51
52 org.eclipse.jetty.plus.jndi.Transaction transactionMgr = new org.eclipse.jetty.plus.jndi.Transaction(new com.acme.MockUserTransaction());
53
54
55 org.eclipse.jetty.plus.jndi.EnvEntry maxAmount = new org.eclipse.jetty.plus.jndi.EnvEntry (webapp, "maxAmount", new Double(100), true);
56
57
58
59 org.eclipse.jetty.plus.jndi.Resource mydatasource = new org.eclipse.jetty.plus.jndi.Resource(webapp, "jdbc/mydatasource", new com.acme.MockDataSource());
60
61
62 HashLoginService loginService = new HashLoginService();
63 loginService.setName("Test Realm");
64 loginService.setConfig("src/test/resources/realm.properties");
65 server.addBean(loginService);
66
67
68 server.start();
69 server.join();
70 }
71
72 }