H2ConsoleServlet.java
1.18 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
package org.legrog.util;
import org.apache.deltaspike.core.api.projectstage.ProjectStage;
import org.apache.deltaspike.core.util.ProjectStageProducer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.servlet.annotation.WebInitParam;
import javax.servlet.annotation.WebServlet;
import static org.legrog.util.H2ConsoleServlet.CONSOLE_MAPPING;
@WebServlet(
urlPatterns = CONSOLE_MAPPING,
name = "H2Console",
loadOnStartup = 1,
initParams = {@WebInitParam(name = "webAllowOthers", value = ""), @WebInitParam(name = "trace", value = "")}
)
public class H2ConsoleServlet extends org.h2.server.web.WebServlet {
static final String CONSOLE_MAPPING = "/console/*";
static final Logger logger = LoggerFactory.getLogger(H2ConsoleServlet.class);
@Override
public void init() {
ProjectStage projectStage = ProjectStageProducer.getInstance().getProjectStage();
if (projectStage == ProjectStage.IntegrationTest) {
logger.info("Create a H2 Console Servlet mapped to {}", CONSOLE_MAPPING);
super.init();
} else {
logger.info("Skipping H2 Console Servlet creation");
}
}
}