use of org.apache.catalina.Wrapper in project tomcat by apache.
the class TestMapper method createWrapper.
private Wrapper createWrapper(String name) {
Wrapper wrapper = new StandardWrapper();
wrapper.setName(name);
return wrapper;
}
use of org.apache.catalina.Wrapper in project async-http-client by AsyncHttpClient.
the class WebDavBasicTest method setUpGlobal.
@BeforeClass(alwaysRun = true)
public void setUpGlobal() throws Exception {
embedded = new Embedded();
String path = new File(".").getAbsolutePath();
embedded.setCatalinaHome(path);
Engine engine = embedded.createEngine();
engine.setDefaultHost("localhost");
Host host = embedded.createHost("localhost", path);
engine.addChild(host);
Context c = embedded.createContext("/", path);
c.setReloadable(false);
Wrapper w = c.createWrapper();
w.addMapping("/*");
w.setServletClass(org.apache.catalina.servlets.WebdavServlet.class.getName());
w.addInitParameter("readonly", "false");
w.addInitParameter("listings", "true");
w.setLoadOnStartup(0);
c.addChild(w);
host.addChild(c);
Connector connector = embedded.createConnector("localhost", 0, Http11NioProtocol.class.getName());
connector.setContainer(host);
embedded.addEngine(engine);
embedded.addConnector(connector);
embedded.start();
port1 = connector.getLocalPort();
}
use of org.apache.catalina.Wrapper in project deltaspike by apache.
the class TomcatTest method createServer.
@Override
protected int createServer() throws Exception {
String baseDir = "target/webapp-runner";
tomcat = new Tomcat();
int port = super.getPort();
tomcat.setPort(port);
File base = new File(baseDir);
if (!base.exists()) {
base.mkdirs();
}
tomcat.setBaseDir(baseDir);
Context ctx = tomcat.addContext("/", base.getAbsolutePath());
StandardContext standardContext = (StandardContext) ctx;
standardContext.addApplicationListener(CdiServletContextListener.class.getName());
Wrapper wrapper = Tomcat.addServlet(ctx, "RequestServlet", RequestServlet.class.getName());
wrapper.addMapping("/*");
tomcat.start();
return port;
}
use of org.apache.catalina.Wrapper in project tomee by apache.
the class TomcatWsRegistry method clearWsContainer.
@Override
public void clearWsContainer(final String contextRoot, String virtualHost, final ServletInfo servletInfo, final String moduleId) {
if (virtualHost == null) {
virtualHost = engine.getDefaultHost();
}
final Container host = engine.findChild(virtualHost);
if (host == null) {
throw new IllegalArgumentException("Invalid virtual host '" + virtualHost + "'. Do you have a matchiing Host entry in the server.xml?");
}
final Context context = (Context) host.findChild("/" + contextRoot);
if (context == null) {
throw new IllegalArgumentException("Could not find web application context " + contextRoot + " in host " + host.getName());
}
final Wrapper wrapper = (Wrapper) context.findChild(servletInfo.servletName);
if (wrapper == null) {
throw new IllegalArgumentException("Could not find servlet " + servletInfo.servletName + " in web application context " + context.getName());
}
// clear the webservice ref in the servlet context
final String webServicecontainerId = wrapper.findInitParameter(WsServlet.WEBSERVICE_CONTAINER);
if (webServicecontainerId != null) {
context.getServletContext().removeAttribute(webServicecontainerId);
wrapper.removeInitParameter(WsServlet.WEBSERVICE_CONTAINER);
}
}
use of org.apache.catalina.Wrapper in project tomee by apache.
the class TomcatWsRegistry method addServlet.
private void addServlet(final Container host, final Context context, final String mapping, final HttpListener httpListener, final String path, final List<String> addresses, final boolean fakeDeployment, final String moduleId) {
// build the servlet
final Wrapper wrapper = context.createWrapper();
wrapper.setName("webservice" + path.substring(1));
wrapper.setServletClass(WsServlet.class.getName());
// add servlet to context
context.addChild(wrapper);
context.addServletMappingDecoded(mapping, wrapper.getName());
final String webServicecontainerID = wrapper.getName() + WsServlet.WEBSERVICE_CONTAINER + httpListener.hashCode();
wrapper.addInitParameter(WsServlet.WEBSERVICE_CONTAINER, webServicecontainerID);
setWsContainer(context, wrapper, httpListener);
webserviceContexts.put(new Key(path, moduleId), context);
// register wsdl locations for service-ref resolution
for (final Connector connector : connectors) {
final StringBuilder fullContextpath;
if (!WEBSERVICE_OLDCONTEXT_ACTIVE && !fakeDeployment) {
String contextPath = context.getPath();
if (contextPath == null || !contextPath.isEmpty()) {
if (contextPath != null && !contextPath.startsWith("/")) {
contextPath = "/" + contextPath;
} else if (contextPath == null) {
contextPath = "/";
}
}
fullContextpath = new StringBuilder(contextPath);
if (!WEBSERVICE_SUB_CONTEXT.equals("/")) {
fullContextpath.append(WEBSERVICE_SUB_CONTEXT);
}
fullContextpath.append(path);
} else {
fullContextpath = new StringBuilder(context.getPath()).append(path);
}
try {
final URI address = new URI(connector.getScheme(), null, host.getName(), connector.getPort(), fullContextpath.toString(), null, null);
addresses.add(address.toString());
} catch (final URISyntaxException ignored) {
// no-op
}
}
}
Aggregations