本文整理汇总了Java中org.apache.catalina.Wrapper类的典型用法代码示例。如果您正苦于以下问题:Java Wrapper类的具体用法?Java Wrapper怎么用?Java Wrapper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Wrapper类属于org.apache.catalina包,在下文中一共展示了Wrapper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: unregisterWrapper
import org.apache.catalina.Wrapper; //导入依赖的package包/类
/**
* Unregister wrapper.
*/
private void unregisterWrapper(Wrapper wrapper) {
Context context = (Context) wrapper.getParent();
String contextPath = context.getPath();
String wrapperName = wrapper.getName();
if ("/".equals(contextPath)) {
contextPath = "";
}
String version = context.getWebappVersion();
String hostName = context.getParent().getName();
String[] mappings = wrapper.findMappings();
for (String mapping : mappings) {
mapper.removeWrapper(hostName, contextPath, version, mapping);
}
if(log.isDebugEnabled()) {
log.debug(sm.getString("mapperListener.unregisterWrapper",
wrapperName, contextPath, connector));
}
}
示例2: invoke
import org.apache.catalina.Wrapper; //导入依赖的package包/类
/**
* Select the appropriate child Wrapper to process this request,
* based on the specified request URI. If no matching Wrapper can
* be found, return an appropriate HTTP error.
*
* @param request Request to be processed
* @param response Response to be produced
*
* @exception IOException if an input/output error occurred
* @exception ServletException if a servlet error occurred
*/
@Override
public final void invoke(Request request, Response response)
throws IOException, ServletException {
// Disallow any direct access to resources under WEB-INF or META-INF
MessageBytes requestPathMB = request.getRequestPathMB();
if ((requestPathMB.startsWithIgnoreCase("/META-INF/", 0))
|| (requestPathMB.equalsIgnoreCase("/META-INF"))
|| (requestPathMB.startsWithIgnoreCase("/WEB-INF/", 0))
|| (requestPathMB.equalsIgnoreCase("/WEB-INF"))) {
response.sendError(HttpServletResponse.SC_NOT_FOUND);
return;
}
// Select the Wrapper to be used for this Request
Wrapper wrapper = request.getWrapper();
if (wrapper == null || wrapper.isUnavailable()) {
response.sendError(HttpServletResponse.SC_NOT_FOUND);
return;
}
// Acknowledge the request
try {
response.sendAcknowledgement();
} catch (IOException ioe) {
container.getLogger().error(sm.getString(
"standardContextValve.acknowledgeException"), ioe);
request.setAttribute(RequestDispatcher.ERROR_EXCEPTION, ioe);
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return;
}
if (request.isAsyncSupported()) {
request.setAsyncSupported(wrapper.getPipeline().isAsyncSupported());
}
wrapper.getPipeline().getFirst().invoke(request, response);
}
示例3: doTestDispatchWithSpaces
import org.apache.catalina.Wrapper; //导入依赖的package包/类
private void doTestDispatchWithSpaces(boolean async) throws Exception {
Tomcat tomcat = getTomcatInstance();
Context context = tomcat.addContext("", null);
if (async) {
Servlet s = new AsyncDispatchUrlWithSpacesServlet();
Wrapper w = Tomcat.addServlet(context, "space", s);
w.setAsyncSupported(true);
} else {
Tomcat.addServlet(context, "space", new ForwardDispatchUrlWithSpacesServlet());
}
context.addServletMapping("/space/*", "space");
tomcat.start();
ByteChunk responseBody = new ByteChunk();
int rc = getUrl("http://localhost:" + getPort() + "/sp%61ce/foo%20bar", responseBody, null);
Assert.assertEquals(200, rc);
}
示例4: addChild
import org.apache.catalina.Wrapper; //导入依赖的package包/类
/**
* Add a child Container, only if the proposed child is an implementation
* of Wrapper.
*
* @param child Child container to be added
*
* @exception IllegalArgumentException if the proposed container is
* not an implementation of Wrapper
*/
public void addChild(Container child) {
if (!(child instanceof Wrapper))
throw new IllegalArgumentException
(sm.getString("standardContext.notWrapper"));
Wrapper wrapper = (Wrapper) child;
String jspFile = wrapper.getJspFile();
if ((jspFile != null) && !jspFile.startsWith("/")) {
if (isServlet22()) {
log(sm.getString("standardContext.wrapper.warning", jspFile));
wrapper.setJspFile("/" + jspFile);
} else {
throw new IllegalArgumentException
(sm.getString("standardContext.wrapper.error", jspFile));
}
}
super.addChild(child);
}
示例5: getNamedDispatcher
import org.apache.catalina.Wrapper; //导入依赖的package包/类
/**
* Return a <code>RequestDispatcher</code> object that acts as a
* wrapper for the named servlet.
*
* @param name Name of the servlet for which a dispatcher is requested
*/
public RequestDispatcher getNamedDispatcher(String name) {
// Validate the name argument
if (name == null)
return (null);
// Create and return a corresponding request dispatcher
Wrapper wrapper = (Wrapper) context.findChild(name);
if (wrapper == null)
return (null);
ApplicationDispatcher dispatcher =
new ApplicationDispatcher(wrapper, null, null, null, name);
return ((RequestDispatcher) dispatcher);
}
示例6: super
import org.apache.catalina.Wrapper; //导入依赖的package包/类
/**
* Construct a new instance of this class, configured according to the
* specified parameters. If both servletPath and pathInfo are
* <code>null</code>, it will be assumed that this RequestDispatcher
* was acquired by name, rather than by path.
*
* @param wrapper The Wrapper associated with the resource that will
* be forwarded to or included (required)
* @param requestURI The request URI to this resource (if any)
* @param servletPath The revised servlet path to this resource (if any)
* @param pathInfo The revised extra path information to this resource
* (if any)
* @param queryString Query string parameters included with this request
* (if any)
* @param name Servlet name (if a named dispatcher was created)
* else <code>null</code>
*/
public ApplicationDispatcher
(Wrapper wrapper, String requestURI, String servletPath,
String pathInfo, String queryString, String name) {
super();
// Save all of our configuration parameters
this.wrapper = wrapper;
this.context = (Context) wrapper.getParent();
this.requestURI = requestURI;
this.servletPath = servletPath;
this.pathInfo = pathInfo;
this.queryString = queryString;
this.name = name;
if (wrapper instanceof StandardWrapper)
this.support = ((StandardWrapper) wrapper).getInstanceSupport();
else
this.support = new InstanceSupport(wrapper);
}
示例7: removeServletMapping
import org.apache.catalina.Wrapper; //导入依赖的package包/类
/**
* Remove any servlet mapping for the specified pattern, if it exists;
* otherwise, no action is taken.
*
* @param pattern URL pattern of the mapping to remove
*/
@Override
public void removeServletMapping(String pattern) {
String name = null;
synchronized (servletMappingsLock) {
name = servletMappings.remove(pattern);
}
Wrapper wrapper = (Wrapper) findChild(name);
if( wrapper != null ) {
wrapper.removeMapping(pattern);
}
mapper.removeWrapper(pattern);
fireContainerEvent("removeServletMapping", pattern);
}
示例8: testAsyncRequestURI
import org.apache.catalina.Wrapper; //导入依赖的package包/类
@Test
public void testAsyncRequestURI() throws Exception {
// Setup Tomcat instance
Tomcat tomcat = getTomcatInstance();
// No file system docBase required
Context ctx = tomcat.addContext("", null);
Servlet servlet = new AsyncRequestUriServlet();
Wrapper wrapper1 = Tomcat.addServlet(ctx, "bug57559", servlet);
wrapper1.setAsyncSupported(true);
ctx.addServletMapping("/", "bug57559");
tomcat.start();
String uri = "/foo/%24/bar";
ByteChunk body = getUrl("http://localhost:" + getPort()+ uri);
Assert.assertEquals(uri, body.toString());
}
示例9: doClassUnloadingPrep
import org.apache.catalina.Wrapper; //导入依赖的package包/类
private DefaultInstanceManager doClassUnloadingPrep() throws Exception {
Tomcat tomcat = getTomcatInstance();
// Create the context (don't use addWebapp as we want to modify the
// JSP Servlet settings).
File appDir = new File("test/webapp-3.0");
StandardContext ctxt = (StandardContext) tomcat.addContext(
null, "/test", appDir.getAbsolutePath());
// Configure the defaults and then tweak the JSP servlet settings
// Note: Min value for maxLoadedJsps is 2
Tomcat.initWebappDefaults(ctxt);
Wrapper w = (Wrapper) ctxt.findChild("jsp");
w.addInitParameter("maxLoadedJsps", "2");
tomcat.start();
return (DefaultInstanceManager) ctxt.getInstanceManager();
}
示例10: removeServletMapping
import org.apache.catalina.Wrapper; //导入依赖的package包/类
/**
* Remove any servlet mapping for the specified pattern, if it exists;
* otherwise, no action is taken.
*
* @param pattern
* URL pattern of the mapping to remove
*/
@Override
public void removeServletMapping(String pattern) {
String name = null;
synchronized (servletMappingsLock) {
name = servletMappings.remove(pattern);
}
Wrapper wrapper = (Wrapper) findChild(name);
if (wrapper != null) {
wrapper.removeMapping(pattern);
}
mapper.removeWrapper(pattern);
fireContainerEvent("removeServletMapping", pattern);
}
示例11: testCommitOnComplete
import org.apache.catalina.Wrapper; //导入依赖的package包/类
@Test
public void testCommitOnComplete() throws Exception {
// Setup Tomcat instance
Tomcat tomcat = getTomcatInstance();
// No file system docBase required
Context ctx = tomcat.addContext("", null);
AsyncStatusServlet asyncStatusServlet =
new AsyncStatusServlet(HttpServletResponse.SC_BAD_REQUEST);
Wrapper wrapper =
Tomcat.addServlet(ctx, "asyncStatusServlet", asyncStatusServlet);
wrapper.setAsyncSupported(true);
ctx.addServletMapping("/asyncStatusServlet", "asyncStatusServlet");
TesterAccessLogValve alv = new TesterAccessLogValve();
ctx.getPipeline().addValve(alv);
tomcat.start();
StringBuilder url = new StringBuilder(48);
url.append("http://localhost:");
url.append(getPort());
url.append("/asyncStatusServlet");
int rc = getUrl(url.toString(), new ByteChunk(), null);
assertEquals(HttpServletResponse.SC_BAD_REQUEST, rc);
// Without this test may complete before access log has a chance to log
// the request
Thread.sleep(REQUEST_TIME);
// Check the access log
alv.validateAccessLog(1, HttpServletResponse.SC_BAD_REQUEST, 0,
REQUEST_TIME);
}
示例12: prepareApplicationWithGenericServlet
import org.apache.catalina.Wrapper; //导入依赖的package包/类
private void prepareApplicationWithGenericServlet(String contextPath)
throws Exception {
// Setup Tomcat instance
Tomcat tomcat = getTomcatInstance();
// No file system docBase required
Context ctx = tomcat.addContext(contextPath, null);
DispatchingGenericServlet dispatch = new DispatchingGenericServlet();
Wrapper wrapper = Tomcat.addServlet(ctx, "dispatch", dispatch);
wrapper.setAsyncSupported(true);
ctx.addServletMapping("/dispatch", "dispatch");
CustomGenericServlet customGeneric = new CustomGenericServlet();
Wrapper wrapper2 = Tomcat.addServlet(ctx, "customGeneric",
customGeneric);
wrapper2.setAsyncSupported(true);
ctx.addServletMapping("/target", "customGeneric");
tomcat.start();
}
示例13: addAceqlServlet
import org.apache.catalina.Wrapper; //导入依赖的package包/类
/**
* Add a Servlet using properties with the index
*
* @param properties
* the properties than contain all servlet & configurators info
* @param rootCtx
* the tomcat root context
*/
public void addAceqlServlet(Properties properties, Context rootCtx) {
if (properties == null) {
throw new IllegalArgumentException("properties can not be null");
}
String aceQLManagerServletCallName = TomcatStarterUtil.getAceQLManagerSevletName(properties);
// Add the ServerSqlManager servlet to the context
@SuppressWarnings("unused")
Wrapper wrapper = Tomcat.addServlet(rootCtx, aceQLManagerServletCallName, new ServerSqlManager());
rootCtx.addServletMappingDecoded("/*", aceQLManagerServletCallName);
TomcatStarterUtil.setInitParametersInStore(properties);
// Unecessary because we must start at / because of ou Rest API
// String serverSqlManagerUrlPattern = serverSqlManagerServletName;
// if (!serverSqlManagerUrlPattern.startsWith("/")) {
// serverSqlManagerUrlPattern = "/" + serverSqlManagerUrlPattern;
// }
}
示例14: testBug56042
import org.apache.catalina.Wrapper; //导入依赖的package包/类
@Test
public void testBug56042() throws Exception {
// Setup Tomcat instance
Tomcat tomcat = getTomcatInstance();
// No file system docBase required
Context ctx = tomcat.addContext("", null);
Bug56042Servlet bug56042Servlet = new Bug56042Servlet();
Wrapper wrapper =
Tomcat.addServlet(ctx, "bug56042Servlet", bug56042Servlet);
wrapper.setAsyncSupported(true);
ctx.addServletMapping("/bug56042Servlet", "bug56042Servlet");
tomcat.start();
StringBuilder url = new StringBuilder(48);
url.append("http://localhost:");
url.append(getPort());
url.append("/bug56042Servlet");
ByteChunk res = new ByteChunk();
int rc = getUrl(url.toString(), res, null);
Assert.assertEquals(HttpServletResponse.SC_BAD_REQUEST, rc);
}
示例15: registerWrapper
import org.apache.catalina.Wrapper; //导入依赖的package包/类
/**
* Register wrapper.
*/
private void registerWrapper(Wrapper wrapper) {
Context context = (Context) wrapper.getParent();
String contextPath = context.getPath();
if ("/".equals(contextPath)) {
contextPath = "";
}
String version = context.getWebappVersion();
String hostName = context.getParent().getName();
List<WrapperMappingInfo> wrappers = new ArrayList<WrapperMappingInfo>();
prepareWrapperMappingInfo(context, wrapper, wrappers);
mapper.addWrappers(hostName, contextPath, version, wrappers);
if (log.isDebugEnabled()) {
log.debug(sm.getString("mapperListener.registerWrapper", wrapper.getName(), contextPath, connector));
}
}