1
2
3
4
5
6
7
8
9
10
11 package org.eclipse.jgit.http.server.glue;
12
13 import static javax.servlet.http.HttpServletResponse.SC_NOT_FOUND;
14
15 import java.io.IOException;
16
17 import javax.servlet.ServletConfig;
18 import javax.servlet.ServletContext;
19 import javax.servlet.ServletException;
20 import javax.servlet.ServletRequest;
21 import javax.servlet.ServletResponse;
22 import javax.servlet.http.HttpServlet;
23 import javax.servlet.http.HttpServletRequest;
24 import javax.servlet.http.HttpServletResponse;
25
26
27
28
29
30
31
32
33
34
35
36
37
38 public class MetaServlet extends HttpServlet {
39 private static final long serialVersionUID = 1L;
40
41 private final MetaFilter filter;
42
43
44
45
46 public MetaServlet() {
47 this(new MetaFilter());
48 }
49
50
51
52
53
54
55
56 protected MetaServlet(MetaFilter delegateFilter) {
57 filter = delegateFilter;
58 }
59
60
61
62
63
64
65 protected MetaFilter getDelegateFilter() {
66 return filter;
67 }
68
69
70
71
72
73
74
75
76 public ServletBinder serve(String path) {
77 return filter.serve(path);
78 }
79
80
81
82
83
84
85
86
87 public ServletBinder serveRegex(String expression) {
88 return filter.serveRegex(expression);
89 }
90
91
92 @Override
93 public void init(ServletConfig config) throws ServletException {
94 String name = filter.getClass().getName();
95 ServletContext ctx = config.getServletContext();
96 filter.init(new NoParameterFilterConfig(name, ctx));
97 }
98
99
100 @Override
101 public void destroy() {
102 filter.destroy();
103 }
104
105
106 @Override
107 protected void service(HttpServletRequest req, HttpServletResponse res)
108 throws ServletException, IOException {
109 filter.doFilter(req, res,
110 (ServletRequest request, ServletResponse response) -> {
111 ((HttpServletResponse) response).sendError(SC_NOT_FOUND);
112 });
113 }
114
115
116
117
118
119
120
121
122
123 protected ServletBinder../../../../org/eclipse/jgit/http/server/glue/ServletBinder.html#ServletBinder">ServletBinder register(ServletBinder b) {
124 return filter.register(b);
125 }
126 }