Package org.apache.catalina.core

Examples of org.apache.catalina.core.StandardWrapper


        context.setManager(sessionMgr);
        context.getServletContext().setAttribute("_serverId", appInfo.server);
        context.getServletContext().setAttribute("componentName", appInfo.componentConfig.getComponentName());

        // create the Default Servlet instance to mount
        StandardWrapper defaultServlet = new StandardWrapper();
        defaultServlet.setServletClass("org.apache.catalina.servlets.DefaultServlet");
        defaultServlet.setServletName("default");
        defaultServlet.setLoadOnStartup(1);
        defaultServlet.addInitParameter("debug", "0");
        defaultServlet.addInitParameter("listing", "true");
        defaultServlet.addMapping("/");
        context.addChild(defaultServlet);
        context.addServletMapping("/", "default");

        // create the Jasper Servlet instance to mount
        StandardWrapper jspServlet = new StandardWrapper();
        jspServlet.setServletClass("org.apache.jasper.servlet.JspServlet");
        jspServlet.setServletName("jsp");
        jspServlet.setLoadOnStartup(1);
        jspServlet.addInitParameter("fork", "false");
        jspServlet.addInitParameter("xpoweredBy", "true");
        jspServlet.addMapping("*.jsp");
        jspServlet.addMapping("*.jspx");
        context.addChild(jspServlet);
        context.addServletMapping("*.jsp", "jsp");

        // default mime-type mappings
        configureMimeTypes(context);
View Full Code Here


     *
     * @return The generated ad-hoc servlet wrapper
     */
    private Wrapper createAdHocWrapper(AdHocServletInfo servletInfo) {

        Wrapper adHocWrapper = new StandardWrapper();
        adHocWrapper.setServletClass(servletInfo.getServletClass().getName());
        adHocWrapper.setName(servletInfo.getServletName());
        Map<String,String> initParams = servletInfo.getServletInitParams();
        if (initParams != null && !initParams.isEmpty()) {
            Iterator<String> iter = initParams.keySet().iterator();
            while (iter.hasNext()) {
                String paramName = iter.next();
                adHocWrapper.addInitParameter(
                    paramName,
                    initParams.get(paramName));
            }             
        }

View Full Code Here

     */
    protected static void configureStandardContext(WebModule webModule,
                                                   WebBundleDescriptor wmd) {
   
       Set set = wmd.getWebComponentDescriptorsSet();
       StandardWrapper wrapper;   
       WebComponentDescriptor webComponentDesc;
       Enumeration enumeration;
       SecurityRoleReference securityRoleReference;
      
       Set set2;
       Iterator iterator2;
      
       if ( !set.isEmpty() ){
           Iterator iterator = set.iterator();

           while (iterator.hasNext()) {

                webComponentDesc = (WebComponentDescriptor)iterator.next();

                wrapper = (StandardWrapper)webModule.createWrapper();
                wrapper.setName(webComponentDesc.getCanonicalName());
                webModule.addChild(wrapper);

                enumeration = webComponentDesc.getInitializationParameters();
                InitializationParameter initP = null;
                while (enumeration.hasMoreElements()){
                    initP = (InitializationParameter)enumeration.nextElement();
                    wrapper.addInitParameter(initP.getName(), initP.getValue());
                }

                if (webComponentDesc.isServlet()){
                        wrapper.setServletClass(
                                webComponentDesc.getWebComponentImplementation());
                } else {
                    wrapper.setJspFile(webComponentDesc.
                                                 getWebComponentImplementation());               
                }

                wrapper.setLoadOnStartup(webComponentDesc.getLoadOnStartUp());
                if (webComponentDesc.getRunAsIdentity() != null)
                    wrapper.setRunAs(webComponentDesc.getRunAsIdentity().getRoleName());


                set2 = webComponentDesc.getUrlPatternsSet();
                iterator2 = set2.iterator();
                while (iterator2.hasNext()){
                    webModule.addServletMapping((String)iterator2.next(),
                                                webComponentDesc.getCanonicalName());
                }

                enumeration = webComponentDesc.getSecurityRoleReferences();
                while (enumeration.hasMoreElements()){
                    securityRoleReference =
                                (SecurityRoleReference)enumeration.nextElement();
                    wrapper.
                        addSecurityReference(securityRoleReference.getRolename(),
                             securityRoleReference.getSecurityRoleLink().getName());
                }
            }
        }
View Full Code Here

     * Register wrapper.
     */
    public void registerWrapper(ObjectName objectName)
        throws Exception {

        StandardWrapper wrapper = (StandardWrapper)
            mBeanServer.invoke(objectName, "findMappingObject", null, null);
        if (wrapper == null) {
            throw new Exception("No wrapper registered for " + objectName);
        }
   
        // If the domain is the same with ours or the engine
        // name attribute is the same... - then it's ours
        String targetDomain=objectName.getDomain();
        if( ! domain.equals( targetDomain )) {
            targetDomain= wrapper.getEngineName();
            if( ! domain.equals( targetDomain )) {
                // not ours
                return;
            }
           
        }

        String wrapperName = objectName.getKeyProperty("name");
        String name = objectName.getKeyProperty("WebModule");

        String hostName = null;
        String contextName = null;
        if (name.startsWith("//")) {
            name = name.substring(2);
        }
        int slash = name.indexOf("/");
        if (slash != -1) {
            hostName = name.substring(0, slash);
            contextName = name.substring(slash);
            contextName = RequestUtil.URLDecode(contextName , "UTF-8");
        } else {
            return;
        }
        // Special case for the root context
        if (contextName.equals("/")) {
            contextName = "";
        }

        if (log.isDebugEnabled()) {
            log.debug(sm.getString("mapperListener.registerWrapper",
                                   wrapperName, contextName));
        }

        String[] mappings = wrapper.findMappings();

        for (int i = 0; i < mappings.length; i++) {
            boolean jspWildCard = (wrapperName.equals("jsp")
                                   && mappings[i].endsWith("/*"));
            mapper.addWrapper(hostName, contextName, mappings[i], wrapper,
View Full Code Here

        context.setManager(sessionMgr);
        context.getServletContext().setAttribute("_serverId", appInfo.server);
        context.getServletContext().setAttribute("componentName", appInfo.componentConfig.getComponentName());

        // create the Default Servlet instance to mount
        StandardWrapper defaultServlet = new StandardWrapper();
        defaultServlet.setServletClass("org.apache.catalina.servlets.DefaultServlet");
        defaultServlet.setServletName("default");
        defaultServlet.setLoadOnStartup(1);
        defaultServlet.addInitParameter("debug", "0");
        defaultServlet.addInitParameter("listing", "true");
        defaultServlet.addMapping("/");
        context.addChild(defaultServlet);
        context.addServletMapping("/", "default");

        // create the Jasper Servlet instance to mount
        StandardWrapper jspServlet = new StandardWrapper();
        jspServlet.setServletClass("org.apache.jasper.servlet.JspServlet");
        jspServlet.setServletName("jsp");
        jspServlet.setLoadOnStartup(1);
        jspServlet.addInitParameter("fork", "false");
        jspServlet.addInitParameter("xpoweredBy", "true");
        jspServlet.addMapping("*.jsp");
        jspServlet.addMapping("*.jspx");
        context.addChild(jspServlet);
        context.addServletMapping("*.jsp", "jsp");

        // default mime-type mappings
        configureMimeTypes(context);
View Full Code Here

            for (final Container c : children) {
                if (!(c instanceof StandardWrapper)) {
                    continue;
                }

                final StandardWrapper wrapper = (StandardWrapper) c;

                final String appSpec = wrapper.getInitParameter("javax.ws.rs.Application");
                if (appSpec != null) {
                    mappedChildren.put(appSpec, c);
                } else {
                    final String app = wrapper.getInitParameter(Application.class.getName());
                    if (app != null) {
                        mappedChildren.put(app, c);
                    } else if (wrapper.getServletClass() == null) {
                        try {
                            if (Application.class.isAssignableFrom(
                                    context.getLoader().getClassLoader().loadClass(wrapper.getServletName()))) {
                                context.removeChild(c); // remove directly since it is not in restApplications
                            }
                        } catch (final Exception e) {
                            // no-op
                        }
View Full Code Here

        String dispatchPath = (String) request.getAttribute(Globals.DISPATCHER_REQUEST_PATH_ATTR);
        mb.setString(webContext.getName() + dispatchPath);

        try {
            mapper.map(mb, mappingData);
            StandardWrapper wrapper = (StandardWrapper) mappingData.wrapper;
            return wrapper.getName();
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }

        return null;
View Full Code Here

            } catch (Throwable t) {
                getLogger().error("createWrapper", t);
                return (null);
            }
        } else {
            wrapper = new StandardWrapper();
        }

        synchronized (instanceListenersLock) {
            for (String instanceListener: findInstanceListeners()) {
                try {
View Full Code Here

        context.setName(name);
        return context;
    }

    private Wrapper createWrapper(String name) {
        Wrapper wrapper = new StandardWrapper();
        wrapper.setName(name);
        return wrapper;
    }
View Full Code Here

     * Process the annotations for the servlets.
     */
    protected static void loadApplicationServletAnnotations(Context context) {
       
        ClassLoader classLoader = context.getLoader().getClassLoader();
        StandardWrapper wrapper = null;
        Class classClass = null;
       
        Container[] children = context.findChildren();
        for (int i = 0; i < children.length; i++) {
            if (children[i] instanceof StandardWrapper) {
               
                wrapper = (StandardWrapper) children[i];
                if (wrapper.getServletClass() == null) {
                    continue;
                }
               
                try {
                    classClass = classLoader.loadClass(wrapper.getServletClass());
                } catch (ClassNotFoundException e) {
                    // We do nothing
                } catch (NoClassDefFoundError e) {
                    // We do nothing
                }
               
                if (classClass == null) {
                    continue;
                }
               
                loadClassAnnotation(context, wrapper.getServletClass());
                /* Process RunAs annotation which can be only on servlets.
                 * Ref JSR 250, equivalent to the run-as element in
                 * the deployment descriptor
                 */
                if (classClass.isAnnotationPresent(RunAs.class)) {
                    RunAs annotation = (RunAs)
                        classClass.getAnnotation(RunAs.class);
                    wrapper.setRunAs(annotation.value());
                }
            }
        }
       
       
View Full Code Here

TOP

Related Classes of org.apache.catalina.core.StandardWrapper

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.