Package org.apache.sling.api.servlets

Examples of org.apache.sling.api.servlets.ServletResolver


        // record the request for the web console display
        RequestHistoryConsolePlugin.recordRequest(request);

        try {
            final ServletResolver sr = this.servletResolver;

            // check that we have all required services
            if (resourceResolver == null) {
                throw new UnavailableException("ResourceResolver");
            } else if (sr == null) {
View Full Code Here


    @Override
    public int doEndTag() throws JspException {
        final SlingBindings bindings = (SlingBindings) pageContext.getRequest().getAttribute(
                SlingBindings.class.getName());
        final SlingScriptHelper scriptHelper = bindings.getSling();
        final ServletResolver servletResolver = scriptHelper.getService(ServletResolver.class);

        final RequestProgressTracker tracker = TagUtil.getRequest(pageContext).getRequestProgressTracker();
        String servletName = null;

        final Servlet servlet;
        if (!ignoreComponentHierarchy) {
            final Resource resource = bindings.getResource();
            servlet = servletResolver.resolveServlet(resource, this.script);

            if (servlet != null) {
                servletName = RequestUtil.getServletName(servlet);
                tracker.log("Including script {0} for path={1}, type={2}: {3}", script, resource.getPath(),
                        resource.getResourceType(), servletName);
            }

        } else {
            final ResourceResolver resolver = bindings.getRequest().getResourceResolver();
            final String scriptPath;
            if (!script.startsWith("/")) {

                // resolve relative script
                String parentPath = ResourceUtil.getParent(scriptHelper.getScript().getScriptResource().getPath());
                // check if parent resides on search path
                for (String sp : resolver.getSearchPath()) {
                    if (parentPath.startsWith(sp)) {
                        parentPath = parentPath.substring(sp.length());
                        break;
                    }
                }
                scriptPath = parentPath + "/" + script;

            } else {

                scriptPath = this.script;
            }
            servlet = servletResolver.resolveServlet(resolver, scriptPath);

            if (servlet != null) {
                servletName = RequestUtil.getServletName(servlet);
                tracker.log("Including script {0} (ignoring component hierarchy): {1}", script, servletName);
            }
View Full Code Here

        log.debug("EvalTagHandler doEndTag");

        final SlingBindings bindings = (SlingBindings) pageContext.getRequest().getAttribute(
                SlingBindings.class.getName());
        final SlingScriptHelper scriptHelper = bindings.getSling();
        final ServletResolver servletResolver = scriptHelper.getService(ServletResolver.class);

        final Servlet servlet;
        if ( !this.ignoreResourceTypeHierarchy ) {
            // detecte resource
            final Resource resource;
            if ( this.resource != null ) {
                resource = this.resource;
            } else if ( this.resourceType != null ) {
                resource = new SyntheticResource(bindings.getRequest().getResourceResolver(),
                        bindings.getResource().getPath(), this.resourceType);
            } else {
                resource = bindings.getResource();
            }
            servlet = servletResolver.resolveServlet(resource, this.script);
        } else {
            final ResourceResolver rr = bindings.getRequest().getResourceResolver();
            final String scriptPath;
            if (!script.startsWith("/")) {

                // resolve relative script
                String parentPath = ResourceUtil.getParent(scriptHelper.getScript().getScriptResource().getPath());
                // check if parent resides on search path
                for (String sp: rr.getSearchPath()) {
                    if (parentPath.startsWith(sp)) {
                        parentPath = parentPath.substring(sp.length());
                        break;
                    }
                }
                scriptPath = parentPath + '/' + script;

            } else {

                scriptPath = this.script;
            }
            servlet = servletResolver.resolveServlet(rr, scriptPath);
        }

        if (servlet == null) {
            throw new JspException("Could not find script '" + script + "' referenced in jsp " + scriptHelper.getScript().getScriptResource().getPath());
        }
View Full Code Here

        RequestPathInfo requestPathInfo = new SlingRequestPathInfo(resource,
            getServletRequest().getPathInfo());
        ContentData contentData = pushContent(resource, requestPathInfo);

        // finally resolve the servlet for the resource
        ServletResolver sr = slingMainServlet.getServletResolver();
        if (sr != null) {
            requestProgressTracker.startTimer("ServletResolution");
            Servlet servlet = sr.resolveServlet(slingRequest);
            requestProgressTracker.logTimer("ServletResolution",
                "URI={0} handled by Servlet={1}",
                getServletRequest().getRequestURI(), servlet.getServletInfo());
            contentData.setServlet(servlet);
        } else {
View Full Code Here

        ContentData contentData = pushContent(resource, requestPathInfo);

      requestProgressTracker.log("Resource Path Info: {0}", requestPathInfo);

        // finally resolve the servlet for the resource
        ServletResolver sr = slingMainServlet.getServletResolver();
        if (sr != null) {
            requestProgressTracker.startTimer("ServletResolution");
            Servlet servlet = sr.resolveServlet(slingRequest);
            requestProgressTracker.logTimer("ServletResolution",
                "URI={0} handled by Servlet={1}",
                getServletRequest().getRequestURI(), RequestUtil.getServletName(servlet));
            contentData.setServlet(servlet);
        } else {
View Full Code Here

TOP

Related Classes of org.apache.sling.api.servlets.ServletResolver

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.