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.0.4-SNAPSHOT.war");
47 server.setHandler(webapp);
48
49
50
51 org.eclipse.jetty.plus.jndi.Transaction transactionMgr = new org.eclipse.jetty.plus.jndi.Transaction(new com.acme.MockUserTransaction());
52
53
54 org.eclipse.jetty.plus.jndi.EnvEntry maxAmount = new org.eclipse.jetty.plus.jndi.EnvEntry (webapp, "maxAmount", new Double(100), true);
55
56
57
58 org.eclipse.jetty.plus.jndi.Resource mydatasource = new org.eclipse.jetty.plus.jndi.Resource(webapp, "jdbc/mydatasource", new com.acme.MockDataSource());
59
60
61 HashLoginService loginService = new HashLoginService();
62 loginService.setName("Test Realm");
63 loginService.setConfig("src/test/resources/realm.properties");
64 server.addBean(loginService);
65
66
67 server.start();
68 server.join();
69 }
70
71 }