1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package org.cometd.oort;
16
17
18 import java.io.IOException;
19
20 import javax.servlet.Servlet;
21 import javax.servlet.ServletConfig;
22 import javax.servlet.ServletException;
23 import javax.servlet.ServletRequest;
24 import javax.servlet.ServletResponse;
25 import javax.servlet.UnavailableException;
26 import javax.servlet.http.HttpServletResponse;
27
28
29 public class SetiServlet implements Servlet
30 {
31 private ServletConfig _config;
32
33
34 public void destroy()
35 {
36 try
37 {
38 Seti seti= (Seti)_config.getServletContext().getAttribute(Oort.OORT_ATTRIBUTE);
39 if (seti!=null)
40 seti.stop();
41 }
42 catch(Exception e)
43 {
44 _config.getServletContext().log("destroy",e);
45 }
46 }
47
48
49 public ServletConfig getServletConfig()
50 {
51 return _config;
52 }
53
54
55 public String getServletInfo()
56 {
57 return SetiServlet.class.toString();
58 }
59
60
61 public void init(ServletConfig config) throws ServletException
62 {
63 _config=config;
64
65 Oort oort = (Oort)config.getServletContext().getAttribute(Oort.OORT_ATTRIBUTE);
66 if (oort==null)
67 {
68 _config.getServletContext().log("No "+Oort.OORT_ATTRIBUTE+" initialized");
69 throw new UnavailableException(Oort.OORT_ATTRIBUTE);
70 }
71
72 String shard=_config.getInitParameter(Seti.SETI_SHARD);
73
74 Seti seti= new Seti(oort,shard);
75 _config.getServletContext().setAttribute(Seti.SETI_ATTRIBUTE,seti);
76
77 try
78 {
79 seti.start();
80 }
81 catch(Exception e)
82 {
83 throw new ServletException(e);
84 }
85
86 }
87
88
89 public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException
90 {
91 HttpServletResponse response = (HttpServletResponse)res;
92 response.sendError(503);
93 }
94 }