1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package com.acme.osgi;
20
21 import java.util.Dictionary;
22 import java.util.Hashtable;
23
24 import javax.servlet.ServletContextEvent;
25 import javax.servlet.ServletContextListener;
26
27 import org.eclipse.jetty.server.handler.ContextHandler;
28 import org.osgi.framework.BundleActivator;
29 import org.osgi.framework.BundleContext;
30
31
32
33
34
35
36 public class Activator implements BundleActivator
37 {
38
39
40
41
42
43 public void start(final BundleContext context) throws Exception
44 {
45 ContextHandler ch = new ContextHandler();
46 ch.addEventListener(new ServletContextListener () {
47
48 @Override
49 public void contextInitialized(ServletContextEvent sce)
50 {
51
52 }
53
54 @Override
55 public void contextDestroyed(ServletContextEvent sce)
56 {
57
58 }
59
60 });
61 Dictionary props = new Hashtable();
62 props.put("contextPath","/acme");
63 props.put("Jetty-ContextFilePath", "acme.xml");
64 context.registerService(ContextHandler.class.getName(),ch,props);
65 }
66
67
68
69
70
71
72
73 public void stop(BundleContext context) throws Exception
74 {
75 }
76 }