Search in sources :

Example 6 with StandardWrapper

use of org.apache.catalina.core.StandardWrapper in project Payara by payara.

the class PwcWebModule method createWrapper.

/**
 * Factory method to create and return a new Wrapper instance, of
 * the Java implementation class appropriate for this Context
 * implementation.  The constructor of the instantiated Wrapper
 * will have been called, but no properties will have been set.
 */
@Override
public Wrapper createWrapper() {
    Wrapper wrapper = super.createWrapper();
    ((StandardWrapper) wrapper).setMaxInstances(stmPoolSize);
    return wrapper;
}
Also used : Wrapper(org.apache.catalina.Wrapper) StandardWrapper(org.apache.catalina.core.StandardWrapper) StandardWrapper(org.apache.catalina.core.StandardWrapper)

Example 7 with StandardWrapper

use of org.apache.catalina.core.StandardWrapper in project Payara by payara.

the class DynamicWebServletRegistrationImpl method createAdHocWrapper.

/**
 * Creates an ad-hoc servlet wrapper from the given ad-hoc servlet info.
 *
 * @param servletInfo Ad-hoc servlet info from which to generate
 * ad-hoc servlet wrapper
 *
 * @return The generated ad-hoc servlet wrapper
 */
private Wrapper createAdHocWrapper(AdHocServletInfo servletInfo) {
    Wrapper adHocWrapper = new StandardWrapper();
    adHocWrapper.setServletClassName(servletInfo.getServletClass().getName());
    adHocWrapper.setName(servletInfo.getServletName());
    Map<String, String> initParams = servletInfo.getServletInitParams();
    if (initParams != null && !initParams.isEmpty()) {
        for (Map.Entry<String, String> entry : initParams.entrySet()) {
            adHocWrapper.addInitParameter(entry.getKey(), entry.getValue());
        }
    }
    return adHocWrapper;
}
Also used : StandardWrapper(org.apache.catalina.core.StandardWrapper) Wrapper(org.apache.catalina.Wrapper) Map(java.util.Map) LocaleCharsetMap(org.glassfish.web.deployment.runtime.LocaleCharsetMap) HashMap(java.util.HashMap) StandardWrapper(org.apache.catalina.core.StandardWrapper)

Example 8 with StandardWrapper

use of org.apache.catalina.core.StandardWrapper in project Payara by payara.

the class TomcatDeploymentConfig method addWebComponentDescriptor.

private static StandardWrapper addWebComponentDescriptor(WebModule webModule, WebComponentDescriptor webComponentDesc) {
    if (!webComponentDesc.isEnabled()) {
        return null;
    }
    StandardWrapper wrapper = (StandardWrapper) webModule.createWrapper();
    wrapper.setName(webComponentDesc.getCanonicalName());
    String impl = webComponentDesc.getWebComponentImplementation();
    if (impl != null && !impl.isEmpty()) {
        if (webComponentDesc.isServlet()) {
            wrapper.setServletClassName(impl);
        } else {
            wrapper.setJspFile(impl);
        }
    }
    /*
             * Add the wrapper only after we have set its 
             * servletClassName, so we know whether we're dealing with
             * a JSF app
         */
    webModule.addChild(wrapper);
    Enumeration enumeration = webComponentDesc.getInitializationParameters();
    InitializationParameter initP = null;
    while (enumeration.hasMoreElements()) {
        initP = (InitializationParameter) enumeration.nextElement();
        wrapper.addInitParameter(initP.getName(), initP.getValue());
    }
    if (webComponentDesc.getLoadOnStartUp() != null) {
        wrapper.setLoadOnStartup(webComponentDesc.getLoadOnStartUp());
    }
    if (webComponentDesc.isAsyncSupported() != null) {
        wrapper.setIsAsyncSupported(webComponentDesc.isAsyncSupported());
    }
    if (webComponentDesc.getRunAsIdentity() != null) {
        wrapper.setRunAs(webComponentDesc.getRunAsIdentity().getRoleName());
    }
    for (String pattern : webComponentDesc.getUrlPatternsSet()) {
        webModule.addServletMapping(pattern, webComponentDesc.getCanonicalName());
    }
    enumeration = webComponentDesc.getSecurityRoleReferences();
    while (enumeration.hasMoreElements()) {
        SecurityRoleReference securityRoleReference = (SecurityRoleReference) enumeration.nextElement();
        wrapper.addSecurityReference(securityRoleReference.getRoleName(), securityRoleReference.getSecurityRoleLink().getName());
    }
    MultipartConfig mpConfig = webComponentDesc.getMultipartConfig();
    if (mpConfig != null) {
        wrapper.setMultipartLocation(mpConfig.getLocation());
        wrapper.setMultipartMaxFileSize(mpConfig.getMaxFileSize());
        wrapper.setMultipartMaxRequestSize(mpConfig.getMaxRequestSize());
        wrapper.setMultipartFileSizeThreshold(mpConfig.getFileSizeThreshold());
    }
    return wrapper;
}
Also used : Enumeration(java.util.Enumeration) StandardWrapper(org.apache.catalina.core.StandardWrapper)

Example 9 with StandardWrapper

use of org.apache.catalina.core.StandardWrapper in project Payara by payara.

the class ListRestEndpointsCommand method getSpecifiedJerseyApplications.

/**
 * Gets a map of Jersey container to the Jersey container name, from a given component name and list of web modules.
 * If the component name is null, then this will return all Jersey applications.
 * @param componentName the name of the Jersey component.
 * @param modules a list of web modules.
 * @return a map of Jersey containers to their names.
 */
private Map<ServletContainer, String> getSpecifiedJerseyApplications(String componentName, List<WebModule> modules) {
    Map<ServletContainer, String> jerseyApplicationMap = new HashMap<>();
    for (WebModule webModule : modules) {
        // loop through all servlets in the given web module
        for (Container container : webModule.findChildren()) {
            // check that it is actually a servlet
            if (container instanceof StandardWrapper) {
                // cast to a servlet from generic container
                StandardWrapper servlet = (StandardWrapper) container;
                // if it is a jersey application servlet, and if a component name has been specified and this servlet matches
                if (servlet.getServletClass() == ServletContainer.class && (componentName == null ^ servlet.getName().equals(componentName))) {
                    Collection<String> mappings = servlet.getMappings();
                    String servletMapping = null;
                    if (mappings.size() > 0) {
                        // May be represented as "path/to/resource/*", which needs to be removed
                        servletMapping = mappings.toArray()[0].toString().replaceAll("/\\*", "");
                    }
                    jerseyApplicationMap.put((ServletContainer) servlet.getServlet(), servletMapping);
                }
            }
        }
    }
    return jerseyApplicationMap;
}
Also used : ServletContainer(org.glassfish.jersey.servlet.ServletContainer) WebContainer(com.sun.enterprise.web.WebContainer) Container(org.apache.catalina.Container) HashMap(java.util.HashMap) ServletContainer(org.glassfish.jersey.servlet.ServletContainer) WebModule(com.sun.enterprise.web.WebModule) StandardWrapper(org.apache.catalina.core.StandardWrapper)

Example 10 with StandardWrapper

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

the class EmbeddedTomcat 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)

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