Java Code Examples for org.apache.catalina.Wrapper#findMappings()
The following examples show how to use
org.apache.catalina.Wrapper#findMappings() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MapperListener.java From Tomcat8-Source-Read with MIT License | 6 votes |
/** * Unregister wrapper. */ private void unregisterWrapper(Wrapper wrapper) { Context context = ((Context) wrapper.getParent()); String contextPath = context.getPath(); String wrapperName = wrapper.getName(); if ("/".equals(contextPath)) { contextPath = ""; } String version = context.getWebappVersion(); String hostName = context.getParent().getName(); String[] mappings = wrapper.findMappings(); for (String mapping : mappings) { mapper.removeWrapper(hostName, contextPath, version, mapping); } if(log.isDebugEnabled()) { log.debug(sm.getString("mapperListener.unregisterWrapper", wrapperName, contextPath, service)); } }
Example 2
Source File: MapperListener.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
/** * Unregister wrapper. */ private void unregisterWrapper(Wrapper wrapper) { Context context = (Context) wrapper.getParent(); String contextPath = context.getPath(); String wrapperName = wrapper.getName(); if ("/".equals(contextPath)) { contextPath = ""; } String version = context.getWebappVersion(); String hostName = context.getParent().getName(); String[] mappings = wrapper.findMappings(); for (String mapping : mappings) { mapper.removeWrapper(hostName, contextPath, version, mapping); } if(log.isDebugEnabled()) { log.debug(sm.getString("mapperListener.unregisterWrapper", wrapperName, contextPath, connector)); } }
Example 3
Source File: MapperListener.java From tomcatsrc with Apache License 2.0 | 6 votes |
/** * Unregister wrapper. */ private void unregisterWrapper(Wrapper wrapper) { Context context = (Context) wrapper.getParent(); String contextPath = context.getPath(); String wrapperName = wrapper.getName(); if ("/".equals(contextPath)) { contextPath = ""; } String version = context.getWebappVersion(); String hostName = context.getParent().getName(); String[] mappings = wrapper.findMappings(); for (String mapping : mappings) { mapper.removeWrapper(hostName, contextPath, version, mapping); } if(log.isDebugEnabled()) { log.debug(sm.getString("mapperListener.unregisterWrapper", wrapperName, contextPath, connector)); } }
Example 4
Source File: MapperListener.java From Tomcat8-Source-Read with MIT License | 5 votes |
/** * Populate <code>wrappers</code> list with information for registration of * mappings for this wrapper in this context. * * @param context * @param wrapper * @param wrappers */ private void prepareWrapperMappingInfo(Context context, Wrapper wrapper, List<WrapperMappingInfo> wrappers) { String wrapperName = wrapper.getName(); boolean resourceOnly = context.isResourceOnlyServlet(wrapperName); String[] mappings = wrapper.findMappings(); for (String mapping : mappings) { boolean jspWildCard = (wrapperName.equals("jsp") && mapping.endsWith("/*")); wrappers.add(new WrapperMappingInfo(mapping, wrapper, jspWildCard, resourceOnly)); } }
Example 5
Source File: MapperListener.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
/** * Populate <code>wrappers</code> list with information for registration of * mappings for this wrapper in this context. * * @param context * @param wrapper * @param list */ private void prepareWrapperMappingInfo(Context context, Wrapper wrapper, List<WrapperMappingInfo> wrappers) { String wrapperName = wrapper.getName(); boolean resourceOnly = context.isResourceOnlyServlet(wrapperName); String[] mappings = wrapper.findMappings(); for (String mapping : mappings) { boolean jspWildCard = (wrapperName.equals("jsp") && mapping.endsWith("/*")); wrappers.add(new WrapperMappingInfo(mapping, wrapper, jspWildCard, resourceOnly)); } }
Example 6
Source File: MapperListener.java From tomcatsrc with Apache License 2.0 | 5 votes |
/** * Populate <code>wrappers</code> list with information for registration of * mappings for this wrapper in this context. * * @param context * @param wrapper * @param list */ private void prepareWrapperMappingInfo(Context context, Wrapper wrapper, List<WrapperMappingInfo> wrappers) { String wrapperName = wrapper.getName(); boolean resourceOnly = context.isResourceOnlyServlet(wrapperName); String[] mappings = wrapper.findMappings(); for (String mapping : mappings) { boolean jspWildCard = (wrapperName.equals("jsp") && mapping.endsWith("/*")); wrappers.add(new WrapperMappingInfo(mapping, wrapper, jspWildCard, resourceOnly)); } }
Example 7
Source File: TomcatWsRegistry.java From tomee with Apache License 2.0 | 4 votes |
@Override public List<String> setWsContainer(final HttpListener httpListener, final ClassLoader classLoader, String contextRoot, String virtualHost, final ServletInfo servletInfo, final String realmName, final String transportGuarantee, final String authMethod, final String moduleId) throws Exception { if (virtualHost == null) { virtualHost = engine.getDefaultHost(); } final Container host = engine.findChild(virtualHost); if (host == null) { throw new IllegalArgumentException("Invalid virtual host '" + virtualHost + "'. Do you have a matchiing Host entry in the server.xml?"); } if ("ROOT".equals(contextRoot)) { // doesn't happen in tomee itself but with all our tooling around contextRoot = ""; } if (!contextRoot.startsWith("/") && !contextRoot.isEmpty()) { contextRoot = "/" + contextRoot; } final Context context = (Context) host.findChild(contextRoot); if (context == null) { throw new IllegalArgumentException("Could not find web application context " + contextRoot + " in host " + host.getName()); } final Wrapper wrapper = (Wrapper) context.findChild(servletInfo.servletName); if (wrapper == null) { throw new IllegalArgumentException("Could not find servlet " + servletInfo.servletName + " in web application context " + context.getName()); } // for Pojo web services, we need to change the servlet class which is the service implementation // by the WsServler class wrapper.setServletClass(WsServlet.class.getName()); if (wrapper.getServlet() != null) { wrapper.unload(); // deallocate previous one wrapper.load(); // reload this one withuot unloading it to keep the instance - unload is called during stop() // boolean controlling this method call can't be set to false through API so let do it ourself wrapper.getServlet().init(StandardWrapper.class.cast(wrapper)); // or Reflections.set(wrapper, "instanceInitialized", false); } setWsContainer(context, wrapper, httpListener); // add service locations final List<String> addresses = new ArrayList<>(); for (final Connector connector : connectors) { for (final String mapping : wrapper.findMappings()) { final URI address = new URI(connector.getScheme(), null, host.getName(), connector.getPort(), (contextRoot.startsWith("/") ? "" : "/") + contextRoot + mapping, null, null); addresses.add(address.toString()); } } return addresses; }
Example 8
Source File: TomcatHessianRegistry.java From tomee with Apache License 2.0 | 4 votes |
@Override public String deploy(final ClassLoader loader, final HessianServer listener, final String hostname, final String app, final String authMethod, final String transportGuarantee, final String realmName, final String name) throws URISyntaxException { Container host = engine.findChild(hostname); if (host == null) { host = engine.findChild(engine.getDefaultHost()); if (host == null) { throw new IllegalArgumentException("Invalid virtual host '" + engine.getDefaultHost() + "'. Do you have a matchiing Host entry in the server.xml?"); } } final String contextRoot = contextName(app); Context context = Context.class.cast(host.findChild(contextRoot)); if (context == null) { Pair<Context, Integer> fakeContext = fakeContexts.get(contextRoot); if (fakeContext != null) { context = fakeContext.getLeft(); fakeContext.setValue(fakeContext.getValue() + 1); } else { context = Context.class.cast(host.findChild(contextRoot)); if (context == null) { fakeContext = fakeContexts.get(contextRoot); if (fakeContext == null) { context = createNewContext(loader, authMethod, transportGuarantee, realmName, app); fakeContext = new MutablePair<>(context, 1); fakeContexts.put(contextRoot, fakeContext); } else { context = fakeContext.getLeft(); fakeContext.setValue(fakeContext.getValue() + 1); } } } } final String servletMapping = generateServletPath(name); Wrapper wrapper = Wrapper.class.cast(context.findChild(servletMapping)); if (wrapper != null) { throw new IllegalArgumentException("Servlet " + servletMapping + " in web application context " + context.getName() + " already exists"); } wrapper = context.createWrapper(); wrapper.setName(HESSIAN.replace("/", "") + "_" + name); wrapper.setServlet(new OpenEJBHessianServlet(listener)); context.addChild(wrapper); context.addServletMappingDecoded(servletMapping, wrapper.getName()); if ("BASIC".equals(authMethod) && StandardContext.class.isInstance(context)) { final StandardContext standardContext = StandardContext.class.cast(context); boolean found = false; for (final Valve v : standardContext.getPipeline().getValves()) { if (LimitedBasicValve.class.isInstance(v) || BasicAuthenticator.class.isInstance(v)) { found = true; break; } } if (!found) { standardContext.addValve(new LimitedBasicValve()); } } final List<String> addresses = new ArrayList<>(); for (final Connector connector : connectors) { for (final String mapping : wrapper.findMappings()) { final URI address = new URI(connector.getScheme(), null, host.getName(), connector.getPort(), contextRoot + mapping, null, null); addresses.add(address.toString()); } } return HttpUtil.selectSingleAddress(addresses); }