/** * Gets the application servlet maps. * * @param context the context * @return the application servlet maps */ public static List<ServletMapping> getApplicationServletMaps(Context context) { String[] sms = context.findServletMappings(); List<ServletMapping> servletMaps = new ArrayList<>(sms.length); for (String servletMapping : sms) { if (servletMapping != null) { String sn = context.findServletMapping(servletMapping); if (sn != null) { ServletMapping sm = new ServletMapping(); sm.setApplicationName(context.getName().length() > 0 ? context.getName() : "/"); sm.setUrl(servletMapping); sm.setServletName(sn); Container container = context.findChild(sn); if (container instanceof Wrapper) { Wrapper wrapper = (Wrapper) container; sm.setServletClass(wrapper.getServletClass()); sm.setAvailable(!wrapper.isUnavailable()); } servletMaps.add(sm); } } } return servletMaps; }
@Override public String getClassName() { return wrapper.getServletClass(); }
@Override public String getClassName() { return wrapper.getServletClass(); }
@Override public String getClassName() { return wrapper.getServletClass(); }
@Override public String getClassName() { return wrapper.getServletClass(); }
@Override public String getClassName() { return wrapper.getServletClass(); }
@Override public String getClassName() { return wrapper.getServletClass(); }
@Override public String getClassName() { return wrapper.getServletClass(); }
@Override public String getClassName() { return wrapper.getServletClass(); }
si.setApplicationName(contextName.length() > 0 ? contextName : "/"); si.setServletName(wrapper.getName()); si.setServletClass(wrapper.getServletClass()); si.setAvailable(!wrapper.isUnavailable()); si.setLoadOnStartup(wrapper.getLoadOnStartup());
if (accept == null) { accept = false; if (!"org.apache.catalina.servlets.DefaultServlet".equals(wrapper.getServletClass())) { for (final String mapping : wrapper.findMappings()) { if (!mapping.isEmpty() && !"/*".equals(mapping) && !"/".equals(mapping) && !mapping.startsWith("*")
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 } } } }
@Override public void addChild(Container container) { if(container instanceof Wrapper) { // Added for Issue http://code.google.com/p/mobicents/issues/detail?id=2382 Wrapper wrapper = (Wrapper) container; SipServletImpl sipServletImpl = (SipServletImpl) childrenMap.get(container.getName()); if(sipServletImpl != null && !sipServletImpl.getServletClass().equals(wrapper.getServletClass())) { throw new SipDeploymentException("Trying to add a servlet with name " + container.getName() + " and servlet class " + wrapper.getServletClass() + " while there is already a SIP Servlet with the same name and a different servlet class " + sipServletImpl.getServletClass()); } } if(children.get(container.getName()) == null) { super.addChild(container); } else { if(logger.isDebugEnabled()) { logger.debug(container.getName() + " already present as a Sip Servlet not adding it again"); } } }
@Override public void addChild(Container container) { if(container instanceof Wrapper) { // Added for Issue http://code.google.com/p/mobicents/issues/detail?id=2382 Wrapper wrapper = (Wrapper) container; SipServletImpl sipServletImpl = (SipServletImpl) childrenMap.get(container.getName()); if(sipServletImpl != null && !sipServletImpl.getServletClass().equals(wrapper.getServletClass())) { throw new SipDeploymentException("Trying to add a servlet with name " + container.getName() + " and servlet class " + wrapper.getServletClass() + " while there is already a SIP Servlet with the same name and a different servlet class " + sipServletImpl.getServletClass()); } } if(children.get(container.getName()) == null) { super.addChild(container); } else { if(logger.isDebugEnabled()) { logger.debug(container.getName() + " already present as a Sip Servlet not adding it again"); } } }
@Override public Dynamic addJspFile(String jspName, String jspFile) { // jspName is validated in addServlet() if (jspFile == null || !jspFile.startsWith("/")) { throw new IllegalArgumentException( sm.getString("applicationContext.addJspFile.iae", jspFile)); } String jspServletClassName = null; Map<String,String> jspFileInitParams = new HashMap<>(); Wrapper jspServlet = (Wrapper) context.findChild("jsp"); if (jspServlet == null) { // No JSP servlet currently defined. // Use default JSP Servlet class name jspServletClassName = Constants.JSP_SERVLET_CLASS; } else { // JSP Servlet defined. // Use same JSP Servlet class name jspServletClassName = jspServlet.getServletClass(); // Use same init parameters String[] params = jspServlet.findInitParameters(); for (String param : params) { jspFileInitParams.put(param, jspServlet.findInitParameter(param)); } } // Add init parameter to specify JSP file jspFileInitParams.put("jspFile", jspFile); return addServlet(jspName, jspServletClassName, null, jspFileInitParams); }
@Override public Dynamic addJspFile(String jspName, String jspFile) { // jspName is validated in addServlet() if (jspFile == null || !jspFile.startsWith("/")) { throw new IllegalArgumentException( sm.getString("applicationContext.addJspFile.iae", jspFile)); } String jspServletClassName = null; Map<String,String> jspFileInitParams = new HashMap<>(); Wrapper jspServlet = (Wrapper) context.findChild("jsp"); if (jspServlet == null) { // No JSP servlet currently defined. // Use default JSP Servlet class name jspServletClassName = Constants.JSP_SERVLET_CLASS; } else { // JSP Servlet defined. // Use same JSP Servlet class name jspServletClassName = jspServlet.getServletClass(); // Use same init parameters String[] params = jspServlet.findInitParameters(); for (String param : params) { jspFileInitParams.put(param, jspServlet.findInitParameter(param)); } } // Add init parameter to specify JSP file jspFileInitParams.put("jspFile", jspFile); return addServlet(jspName, jspServletClassName, null, jspFileInitParams); }
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; }
if (wrapper.getServletClass() == null) { continue; wrapper.getServletClass()); if (classClass == null) { continue;
private Set<String> getNonAsyncClassNames() { Set<String> result = new HashSet<>(); Wrapper wrapper = getWrapper(); if (!wrapper.isAsyncSupported()) { result.add(wrapper.getServletClass()); } FilterChain filterChain = getFilterChain(); if (filterChain instanceof ApplicationFilterChain) { ((ApplicationFilterChain) filterChain).findNonAsyncFilters(result); } else { result.add(sm.getString("coyoteRequest.filterAsyncSupportUnknown")); } Container c = wrapper; while (c != null) { c.getPipeline().findNonAsyncValves(result); c = c.getParent(); } return result; }
private Set<String> getNonAsyncClassNames() { Set<String> result = new HashSet<>(); Wrapper wrapper = getWrapper(); if (!wrapper.isAsyncSupported()) { result.add(wrapper.getServletClass()); } FilterChain filterChain = getFilterChain(); if (filterChain instanceof ApplicationFilterChain) { ((ApplicationFilterChain) filterChain).findNonAsyncFilters(result); } else { result.add(sm.getString("coyoteRequest.filterAsyncSupportUnknown")); } Container c = wrapper; while (c != null) { c.getPipeline().findNonAsyncValves(result); c = c.getParent(); } return result; }