use of org.apache.catalina.Wrapper in project tomcat by apache.
the class TestTagHandlerPoolPerformance method testConcurrency.
@Test
public void testConcurrency() throws Exception {
// Create a working TagHandlerPool
Tomcat tomcat = getTomcatInstanceTestWebapp(false, true);
Wrapper w = (Wrapper) tomcat.getHost().findChildren()[0].findChild("jsp");
TagHandlerPool tagHandlerPool = new TagHandlerPool();
tagHandlerPool.init(w.getServlet().getServletConfig());
for (int i = 1; i < 9; i++) {
doTestConcurrency(tagHandlerPool, i);
}
}
use of org.apache.catalina.Wrapper in project jaggery by wso2.
the class TomcatJaggeryWebappsDeployer method addServlets.
private static void addServlets(Context ctx, JSONObject jaggeryConfig) {
if (jaggeryConfig != null) {
JSONArray arrServlets = (JSONArray) jaggeryConfig.get(JaggeryCoreConstants.JaggeryConfigParams.SERVLETS);
JSONArray arrServletMappings = (JSONArray) jaggeryConfig.get(JaggeryCoreConstants.JaggeryConfigParams.SERVLET_MAPPINGS);
if (arrServlets != null) {
for (Object servletObj : arrServlets) {
JSONObject servlet = (JSONObject) servletObj;
String name = (String) servlet.get(JaggeryCoreConstants.JaggeryConfigParams.SERVLETS_NAME);
String clazz = (String) servlet.get(JaggeryCoreConstants.JaggeryConfigParams.SERVLETS_CLASS);
Wrapper servletWrapper = Tomcat.addServlet(ctx, name, clazz);
JSONArray arrParams = (JSONArray) servlet.get(JaggeryCoreConstants.JaggeryConfigParams.SERVLETS_PARAMS);
if (arrParams != null) {
for (Object paramObj : arrParams) {
JSONObject param = (JSONObject) paramObj;
String paramName = (String) param.get(JaggeryCoreConstants.JaggeryConfigParams.SERVLETS_PARAMS_NAME);
String paramValue = (String) param.get(JaggeryCoreConstants.JaggeryConfigParams.SERVLETS_PARAMS_VALUE);
servletWrapper.addInitParameter(paramName, paramValue);
}
}
}
}
if (arrServletMappings != null) {
for (Object servletMappingObj : arrServletMappings) {
JSONObject mapping = (JSONObject) servletMappingObj;
String name = (String) mapping.get(JaggeryCoreConstants.JaggeryConfigParams.SERVLET_MAPPINGS_NAME);
String url = (String) mapping.get(JaggeryCoreConstants.JaggeryConfigParams.SERVLET_MAPPINGS_URL);
ctx.addServletMapping(url, name);
}
}
}
}
use of org.apache.catalina.Wrapper in project tomee by apache.
the class TomcatWebAppBuilder method ensureMyFacesDontLooseFacesContext.
private void ensureMyFacesDontLooseFacesContext(final StandardContext standardContext) {
for (final Container w : standardContext.findChildren()) {
if (!Wrapper.class.isInstance(w)) {
continue;
}
final Wrapper wrapper = Wrapper.class.cast(w);
if ("FacesServlet".equals(wrapper.getName()) && "javax.faces.webapp.FacesServlet".equals(wrapper.getServletClass())) {
final ClassLoader loader = standardContext.getLoader().getClassLoader();
try {
if (Files.toFile(loader.getResource("javax/faces/webapp/FacesServlet.class")).getName().startsWith("myfaces")) {
loader.loadClass("org.apache.tomee.myfaces.TomEEWorkaroundFacesServlet");
wrapper.setServletClass("org.apache.tomee.myfaces.TomEEWorkaroundFacesServlet");
break;
}
} catch (final Throwable t) {
// not there, not a big deal in most of cases
}
}
}
}
use of org.apache.catalina.Wrapper in project tomee by apache.
the class TomEERemoteWebapp method initInternal.
@Override
protected void initInternal() throws LifecycleException {
super.initInternal();
final Wrapper servlet = createWrapper();
servlet.setName(ServerServlet.class.getSimpleName());
servlet.setServletClass(ServerServlet.class.getName());
addChild(servlet);
addServletMappingDecoded(MAPPING, ServerServlet.class.getSimpleName());
}
use of org.apache.catalina.Wrapper in project tomee by apache.
the class TomEEMyFacesContainerInitializer method isFacesServletPresent.
private boolean isFacesServletPresent(final ServletContext ctx) {
if (ctx instanceof ApplicationContextFacade) {
try {
final ApplicationContext appCtx = (ApplicationContext) get(ApplicationContextFacade.class, ctx);
final Context tomcatCtx = (Context) get(ApplicationContext.class, appCtx);
if (tomcatCtx instanceof StandardContext) {
final Container[] servlets = tomcatCtx.findChildren();
if (servlets != null) {
for (final Container s : servlets) {
if (s instanceof Wrapper) {
if ("javax.faces.webapp.FacesServlet".equals(((Wrapper) s).getServletClass()) || "Faces Servlet".equals(s.getName())) {
return true;
}
}
}
}
}
} catch (final Exception e) {
// no-op
}
}
return false;
}
Aggregations