Java Code Examples for org.apache.catalina.Wrapper#getName()

The following examples show how to use org.apache.catalina.Wrapper#getName() . 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 vote down vote up
/**
 * 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 vote down vote up
/**
 * 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 vote down vote up
/**
 * 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 vote down vote up
/**
 * 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 vote down vote up
/**
 * 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 vote down vote up
/**
 * 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 5 votes vote down vote up
private void setWsContainer(final Context context, final Wrapper wrapper, final HttpListener wsContainer) {
    // Make up an ID for the WebServiceContainer
    // put a reference the ID in the init-params
    // put the WebServiceContainer in the webapp context keyed by its ID
    final String webServicecontainerID = wrapper.getName() + WsServlet.WEBSERVICE_CONTAINER + wsContainer.hashCode();
    context.getServletContext().setAttribute(webServicecontainerID, wsContainer);
    wrapper.addInitParameter(WsServlet.WEBSERVICE_CONTAINER, webServicecontainerID);
}
 
Example 8
Source File: ApplicationContext.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
private ServletRegistration.Dynamic addServlet(String servletName, String servletClass,
        Servlet servlet, Map<String,String> initParams) throws IllegalStateException {

    if (servletName == null || servletName.equals("")) {
        throw new IllegalArgumentException(sm.getString(
                "applicationContext.invalidServletName", servletName));
    }

    if (!context.getState().equals(LifecycleState.STARTING_PREP)) {
        //TODO Spec breaking enhancement to ignore this restriction
        throw new IllegalStateException(
                sm.getString("applicationContext.addServlet.ise",
                        getContextPath()));
    }

    Wrapper wrapper = (Wrapper) context.findChild(servletName);

    // Assume a 'complete' ServletRegistration is one that has a class and
    // a name
    if (wrapper == null) {
        wrapper = context.createWrapper();
        wrapper.setName(servletName);
        context.addChild(wrapper);
    } else {
        if (wrapper.getName() != null &&
                wrapper.getServletClass() != null) {
            if (wrapper.isOverridable()) {
                wrapper.setOverridable(false);
            } else {
                return null;
            }
        }
    }

    ServletSecurity annotation = null;
    if (servlet == null) {
        wrapper.setServletClass(servletClass);
        Class<?> clazz = Introspection.loadClass(context, servletClass);
        if (clazz != null) {
            annotation = clazz.getAnnotation(ServletSecurity.class);
        }
    } else {
        wrapper.setServletClass(servlet.getClass().getName());
        wrapper.setServlet(servlet);
        if (context.wasCreatedDynamicServlet(servlet)) {
            annotation = servlet.getClass().getAnnotation(ServletSecurity.class);
        }
    }

    if (initParams != null) {
        for (Map.Entry<String, String> initParam: initParams.entrySet()) {
            wrapper.addInitParameter(initParam.getKey(), initParam.getValue());
        }
    }

    ServletRegistration.Dynamic registration =
            new ApplicationServletRegistration(wrapper, context);
    if (annotation != null) {
        registration.setServletSecurity(new ServletSecurityElement(annotation));
    }
    return registration;
}
 
Example 9
Source File: ApplicationContext.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
private ServletRegistration.Dynamic addServlet(String servletName,
        String servletClass, Servlet servlet) throws IllegalStateException {

    if (servletName == null || servletName.equals("")) {
        throw new IllegalArgumentException(sm.getString(
                "applicationContext.invalidServletName", servletName));
    }

    if (!context.getState().equals(LifecycleState.STARTING_PREP)) {
        //TODO Spec breaking enhancement to ignore this restriction
        throw new IllegalStateException(
                sm.getString("applicationContext.addServlet.ise",
                        getContextPath()));
    }

    Wrapper wrapper = (Wrapper) context.findChild(servletName);

    // Assume a 'complete' ServletRegistration is one that has a class and
    // a name
    if (wrapper == null) {
        wrapper = context.createWrapper();
        wrapper.setName(servletName);
        context.addChild(wrapper);
    } else {
        if (wrapper.getName() != null &&
                wrapper.getServletClass() != null) {
            if (wrapper.isOverridable()) {
                wrapper.setOverridable(false);
            } else {
                return null;
            }
        }
    }

    if (servlet == null) {
        wrapper.setServletClass(servletClass);
    } else {
        wrapper.setServletClass(servlet.getClass().getName());
        wrapper.setServlet(servlet);
    }

    return context.dynamicServletAdded(wrapper);
}
 
Example 10
Source File: ApplicationContext.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
private ServletRegistration.Dynamic addServlet(String servletName,
        String servletClass, Servlet servlet) throws IllegalStateException {

    if (servletName == null || servletName.equals("")) {
        throw new IllegalArgumentException(sm.getString(
                "applicationContext.invalidServletName", servletName));
    }

    if (!context.getState().equals(LifecycleState.STARTING_PREP)) {
        //TODO Spec breaking enhancement to ignore this restriction
        throw new IllegalStateException(
                sm.getString("applicationContext.addServlet.ise",
                        getContextPath()));
    }

    Wrapper wrapper = (Wrapper) context.findChild(servletName);

    // Assume a 'complete' ServletRegistration is one that has a class and
    // a name
    if (wrapper == null) {
        wrapper = context.createWrapper();
        wrapper.setName(servletName);
        context.addChild(wrapper);
    } else {
        if (wrapper.getName() != null &&
                wrapper.getServletClass() != null) {
            if (wrapper.isOverridable()) {
                wrapper.setOverridable(false);
            } else {
                return null;
            }
        }
    }

    if (servlet == null) {
        wrapper.setServletClass(servletClass);
    } else {
        wrapper.setServletClass(servlet.getClass().getName());
        wrapper.setServlet(servlet);
    }

    return context.dynamicServletAdded(wrapper);
}
 
Example 11
Source File: TomcatWsRegistry.java    From tomee with Apache License 2.0 4 votes vote down vote up
private void addServlet(final Container host, final Context context, final String mapping, final HttpListener httpListener, final String path,
                        final List<String> addresses, final boolean fakeDeployment, final String moduleId) {
    // build the servlet
    final Wrapper wrapper = context.createWrapper();
    wrapper.setName("webservice" + path.substring(1));
    wrapper.setServletClass(WsServlet.class.getName());

    // add servlet to context
    context.addChild(wrapper);
    context.addServletMappingDecoded(mapping, wrapper.getName());

    final String webServicecontainerID = wrapper.getName() + WsServlet.WEBSERVICE_CONTAINER + httpListener.hashCode();
    wrapper.addInitParameter(WsServlet.WEBSERVICE_CONTAINER, webServicecontainerID);

    setWsContainer(context, wrapper, httpListener);

    webserviceContexts.put(new Key(path, moduleId), context);

    // register wsdl locations for service-ref resolution
    for (final Connector connector : connectors) {
        final StringBuilder fullContextpath;
        if (!WEBSERVICE_OLDCONTEXT_ACTIVE && !fakeDeployment) {
            String contextPath = context.getPath();
            if (contextPath == null ||  !contextPath.isEmpty()) {
                if (contextPath != null && !contextPath.startsWith("/")) {
                    contextPath = "/" + contextPath;
                } else if (contextPath == null) {
                    contextPath = "/";
                }
            }

            fullContextpath = new StringBuilder(contextPath);
            if (!WEBSERVICE_SUB_CONTEXT.equals("/")) {
                fullContextpath.append(WEBSERVICE_SUB_CONTEXT);
            }
            fullContextpath.append(path);
        } else {
            fullContextpath = new StringBuilder(context.getPath()).append(path);
        }

        try {
            final URI address = new URI(connector.getScheme(), null, host.getName(), connector.getPort(), fullContextpath.toString(), null, null);
            addresses.add(address.toString());
        } catch (final URISyntaxException ignored) {
            // no-op
        }
    }
}