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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations