-
Notifications
You must be signed in to change notification settings - Fork 137
Expand file tree
/
Copy pathRackServlet.java
More file actions
52 lines (42 loc) · 1.25 KB
/
RackServlet.java
File metadata and controls
52 lines (42 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
* Copyright (c) 2010-2012 Engine Yard, Inc.
* Copyright (c) 2007-2009 Sun Microsystems, Inc.
* This source code is available under the MIT license.
* See the file LICENSE.txt for details.
*/
package org.jruby.rack;
import jakarta.servlet.ServletConfig;
@SuppressWarnings("serial")
public class RackServlet extends AbstractServlet {
private RackDispatcher dispatcher;
private RackContext context;
/**
* Default constructor for servlet container
*/
public RackServlet() {
}
/**
* dependency injection ctor, used by unit tests
* @param dispatcher the dispatcher
* @param context the context
*/
public RackServlet(RackDispatcher dispatcher, RackContext context) {
this.dispatcher = dispatcher;
this.context = context;
}
@Override
public void init(ServletConfig config) {
if (dispatcher == null) {
context = (RackContext) config.getServletContext().getAttribute(RackApplicationFactory.RACK_CONTEXT);
dispatcher = new DefaultRackDispatcher(context);
}
}
@Override
public RackDispatcher getDispatcher() {
return dispatcher;
}
@Override
public RackContext getContext() {
return context;
}
}