1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.eclipse.jetty.osgi.boot.warurl;
20
21 import java.util.Dictionary;
22 import java.util.Hashtable;
23
24 import org.osgi.framework.BundleActivator;
25 import org.osgi.framework.BundleContext;
26 import org.osgi.framework.ServiceRegistration;
27 import org.osgi.service.url.URLConstants;
28 import org.osgi.service.url.URLStreamHandlerService;
29
30
31
32
33
34 public class WarUrlActivator implements BundleActivator
35 {
36
37 private ServiceRegistration _reg;
38
39
40
41
42
43
44 @SuppressWarnings("unchecked")
45 public void start(BundleContext context) throws Exception
46 {
47 Dictionary props = new Hashtable();
48 props.put(URLConstants.URL_HANDLER_PROTOCOL,new String[] {"war"});
49 context.registerService(URLStreamHandlerService.class.getName(),
50 new WarUrlStreamHandler(), props);
51 }
52
53
54
55
56
57
58 public void stop(BundleContext context) throws Exception
59 {
60 try
61 {
62 if (_reg != null)
63 {
64 _reg.unregister();
65 }
66 }
67 catch (Exception e)
68 {
69 e.printStackTrace();
70 }
71 }
72
73 }