Search in sources :

Example 11 with StandardWrapper

use of org.apache.catalina.core.StandardWrapper in project geode by apache.

the class EmbeddedTomcat8 method addServlet.

public StandardWrapper addServlet(String path, String name, String clazz) throws ServletException {
    StandardWrapper servlet = (StandardWrapper) rootContext.createWrapper();
    servlet.setName(name);
    servlet.setServletClass(clazz);
    servlet.setLoadOnStartup(1);
    rootContext.addChild(servlet);
    rootContext.addServletMapping(path, name);
    servlet.setParent(rootContext);
    return servlet;
}
Also used : StandardWrapper(org.apache.catalina.core.StandardWrapper)

Example 12 with StandardWrapper

use of org.apache.catalina.core.StandardWrapper in project uavstack by uavorg.

the class SpringBootTomcatPlusIT method onServletStop.

/**
 * onServletStop
 *
 * @param args
 */
@Override
public void onServletStop(Object... args) {
    StandardWrapper sw = (StandardWrapper) args[0];
    Servlet servlet = (Servlet) args[1];
    InterceptSupport iSupport = InterceptSupport.instance();
    InterceptContext context = iSupport.createInterceptContext(Event.BEFORE_SERVLET_DESTROY);
    context.put(InterceptConstants.SERVLET_INSTANCE, servlet);
    /**
     * NOTE: spring boot rewrite the tomcat webappclassloader, makes the addURL for nothing, then we can't do
     * anything on this we may use its webappclassloader's parent as the classloader
     */
    context.put(InterceptConstants.WEBAPPLOADER, Thread.currentThread().getContextClassLoader().getParent());
    context.put(InterceptConstants.CONTEXTPATH, sw.getServletContext().getContextPath());
    iSupport.doIntercept(context);
}
Also used : InterceptContext(com.creditease.monitor.interceptframework.spi.InterceptContext) InterceptSupport(com.creditease.monitor.interceptframework.InterceptSupport) Servlet(javax.servlet.Servlet) StandardWrapper(org.apache.catalina.core.StandardWrapper)

Example 13 with StandardWrapper

use of org.apache.catalina.core.StandardWrapper in project uavstack by uavorg.

the class SpringBootTomcatPlusIT method onServletStart.

/**
 * onServletStart
 *
 * @param args
 */
@Override
public void onServletStart(Object... args) {
    StandardWrapper sw = (StandardWrapper) args[0];
    Servlet servlet = (Servlet) args[1];
    InterceptSupport iSupport = InterceptSupport.instance();
    InterceptContext context = iSupport.createInterceptContext(Event.AFTER_SERVET_INIT);
    context.put(InterceptConstants.SERVLET_INSTANCE, servlet);
    /**
     * NOTE: spring boot rewrite the tomcat webappclassloader, makes the addURL for nothing, then we can't do
     * anything on this we may use its webappclassloader's parent as the classloader
     */
    context.put(InterceptConstants.WEBAPPLOADER, Thread.currentThread().getContextClassLoader().getParent());
    context.put(InterceptConstants.CONTEXTPATH, sw.getServletContext().getContextPath());
    iSupport.doIntercept(context);
}
Also used : InterceptContext(com.creditease.monitor.interceptframework.spi.InterceptContext) InterceptSupport(com.creditease.monitor.interceptframework.InterceptSupport) Servlet(javax.servlet.Servlet) StandardWrapper(org.apache.catalina.core.StandardWrapper)

Example 14 with StandardWrapper

use of org.apache.catalina.core.StandardWrapper in project uavstack by uavorg.

the class TomcatPlusIT method onServletStart.

/**
 * onServletStart
 *
 * @param args
 */
public void onServletStart(Object... args) {
    StandardWrapper sw = (StandardWrapper) args[0];
    Servlet servlet = (Servlet) args[1];
    InterceptSupport iSupport = InterceptSupport.instance();
    InterceptContext context = iSupport.createInterceptContext(Event.AFTER_SERVET_INIT);
    context.put(InterceptConstants.SERVLET_INSTANCE, servlet);
    context.put(InterceptConstants.WEBAPPLOADER, Thread.currentThread().getContextClassLoader());
    context.put(InterceptConstants.CONTEXTPATH, sw.getServletContext().getContextPath());
    iSupport.doIntercept(context);
}
Also used : InterceptContext(com.creditease.monitor.interceptframework.spi.InterceptContext) InterceptSupport(com.creditease.monitor.interceptframework.InterceptSupport) Servlet(javax.servlet.Servlet) StandardWrapper(org.apache.catalina.core.StandardWrapper)

Example 15 with StandardWrapper

use of org.apache.catalina.core.StandardWrapper in project tomcat by apache.

the class TestMultipartConfig method testPartialMultipartConfigMaxFileSize.

@Test
public void testPartialMultipartConfigMaxFileSize() throws Exception {
    MultipartDef multipartDef = new MultipartDef();
    multipartDef.setMaxFileSize("1024");
    StandardWrapper servlet = config(multipartDef);
    MultipartConfigElement mce = servlet.getMultipartConfigElement();
    Assert.assertNotNull(mce);
    Assert.assertEquals("", mce.getLocation());
    Assert.assertEquals(1024, mce.getMaxFileSize());
    Assert.assertEquals(-1, mce.getMaxRequestSize());
    Assert.assertEquals(0, mce.getFileSizeThreshold());
}
Also used : MultipartConfigElement(jakarta.servlet.MultipartConfigElement) MultipartDef(org.apache.tomcat.util.descriptor.web.MultipartDef) StandardWrapper(org.apache.catalina.core.StandardWrapper) Test(org.junit.Test)

Aggregations

StandardWrapper (org.apache.catalina.core.StandardWrapper)23 MultipartConfigElement (jakarta.servlet.MultipartConfigElement)6 Test (org.junit.Test)6 Container (org.apache.catalina.Container)5 MultipartDef (org.apache.tomcat.util.descriptor.web.MultipartDef)5 InterceptSupport (com.creditease.monitor.interceptframework.InterceptSupport)4 InterceptContext (com.creditease.monitor.interceptframework.spi.InterceptContext)4 Servlet (javax.servlet.Servlet)4 HashMap (java.util.HashMap)3 Wrapper (org.apache.catalina.Wrapper)3 WebContainer (com.sun.enterprise.web.WebContainer)2 IOException (java.io.IOException)2 StandardContext (org.apache.catalina.core.StandardContext)2 WebAppInfo (org.apache.openejb.assembler.classic.WebAppInfo)2 VirtualServer (com.sun.enterprise.config.serverbeans.VirtualServer)1 WebModule (com.sun.enterprise.web.WebModule)1 Method (java.lang.reflect.Method)1 MalformedURLException (java.net.MalformedURLException)1 Enumeration (java.util.Enumeration)1 Map (java.util.Map)1