Package org.mortbay.jetty.handler

Examples of org.mortbay.jetty.handler.ContextHandler


                if ((q=uriInContext.indexOf(';'))>0)
                    uriInContext=uriInContext.substring(0,q);

                String pathInContext=URIUtil.canonicalPath(URIUtil.decodePath(uriInContext));
                String uri=URIUtil.addPaths(getContextPath(), uriInContext);
                ContextHandler context=org.mortbay.jetty.servlet.Context.this;
                return new Dispatcher(context,uri, pathInContext, query);
            }
            catch(Exception e)
            {
                Log.ignore(e);
View Full Code Here


        ContextHandlerCollection contexts = (ContextHandlerCollection) handlerCollection.getHandlers()[0];
        Handler[] handlers = contexts.getHandlers();
        if (handlers != null) {
            for (int i = 0; i < handlers.length; i++) {
                if (handlers[i] instanceof ContextHandler) {
                    ContextHandler h = (ContextHandler) handlers[i];
                    String handlerPath = h.getContextPath() + "/";
                    if (handlerPath.startsWith(pathSlash) || pathSlash.startsWith(handlerPath)) {
                        throw new Exception("The requested context for path '" + path
                                        + "' overlaps with an existing context for path: '" + h.getContextPath() + "'");
                    }
                }
            }
        }
        // Create context
        ContextHandler context = new ContextHandler();
        context.setContextPath(path);
        ServletHolder holder = new ServletHolder();
        holder.setName("jbiServlet");
        holder.setClassName(HttpBridgeServlet.class.getName());
        ServletHandler handler = new ServletHandler();
        handler.setServlets(new ServletHolder[] {holder});
        ServletMapping mapping = new ServletMapping();
        mapping.setServletName("jbiServlet");
        mapping.setPathSpec("/*");
        handler.setServletMappings(new ServletMapping[] {mapping});
        if (processor.getAuthMethod() != null) {
            SecurityHandler secHandler = new SecurityHandler();
            ConstraintMapping constraintMapping = new ConstraintMapping();
            Constraint constraint = new Constraint();
            constraint.setAuthenticate(true);
            constraint.setRoles(new String[] {"*"});
            constraintMapping.setConstraint(constraint);
            constraintMapping.setPathSpec("/");
            secHandler.setConstraintMappings(new ConstraintMapping[] {constraintMapping});
            secHandler.setHandler(handler);
            secHandler.setAuthMethod(processor.getAuthMethod());
            JaasUserRealm realm = new JaasUserRealm();
            if (configuration.getAuthenticationService() != null) {
                realm.setAuthenticationService(configuration.getAuthenticationService());
            }
            secHandler.setUserRealm(realm);
            context.setHandler(secHandler);
        } else {
            context.setHandler(handler);
        }
        context.setAttribute("processor", processor);
        // add context
        contexts.addHandler(context);
        handler.initialize();
        context.start();
        return context;
    }
View Full Code Here

                Handler[] handlers = server.getChildHandlersByClass(ContextHandler.class);
                for (int i = 0; handlers != null && i < handlers.length; i++) {
                    if (!(handlers[i] instanceof ContextHandler)) {
                        continue;
                    }
                    ContextHandler context = (ContextHandler) handlers[i];
                    StringBuffer sb = new StringBuffer();
                    sb.append(serverUri);
                    if (!context.getContextPath().startsWith("/")) {
                        sb.append("/");
                    }
                    sb.append(context.getContextPath());
                    if (!context.getContextPath().endsWith("/")) {
                        sb.append("/");
                    }
                    if (context.isStarted()) {
                        writer.write("<li><a href=\"");
                        writer.write(sb.toString());
                        writer.write("?wsdl\">");
                        writer.write(sb.toString());
                        writer.write("</a></li>\n");
View Full Code Here

    public void init() {
        super.init();

        final HandlerList handlers = createHandlers();

        final ContextHandler contextHandler = createContextHandler(handlers);

        startServer(contextHandler);
    }
View Full Code Here

            servletHandler.addFilterMapping(filterMapping);
        }
    }

    private ContextHandler createContextHandler(final HandlerList handlers) {
        final ContextHandler contextHandler = buildContextHandler(handlers);
        addContextParams(contextHandler);
        addServletContextListeners(contextHandler);
        setWelcomeFiles(contextHandler);
        return contextHandler;
    }
View Full Code Here

        setWelcomeFiles(contextHandler);
        return contextHandler;
    }

    private ContextHandler buildContextHandler(final HandlerList handlers) {
        final ContextHandler contextHandler = new ContextHandler("/");
        contextHandler.setClassLoader(Thread.currentThread().getContextClassLoader());
        contextHandler.setHandler(handlers);
        return contextHandler;
    }
View Full Code Here

            server.stop();
        }
    }

    public void test() throws Exception {
        ContextHandler context = new ContextHandler();
        context.setContextPath("/test");
        context.setEventListeners(new EventListener[] {new ContextLoaderListener()});
        Map initParams = new HashMap();
        initParams.put("contextConfigLocation", "classpath:org/apache/servicemix/http/spring-web.xml");
        initParams.put("contextClass", XmlWebApplicationContext.class.getName());
        context.setInitParams(initParams);
        ServletHolder holder = new ServletHolder();
        holder.setName("jbiServlet");
        holder.setClassName(HttpManagedServlet.class.getName());
        ServletHandler handler = new ServletHandler();
        handler.setServlets(new ServletHolder[] {holder});
        ServletMapping mapping = new ServletMapping();
        mapping.setServletName("jbiServlet");
        mapping.setPathSpec("/*");
        handler.setServletMappings(new ServletMapping[] {mapping});
        context.setHandler(handler);

        ContextHandlerCollection contexts = new ContextHandlerCollection();
        HandlerCollection handlers = new HandlerCollection();
        handlers.setHandlers(new Handler[] {contexts});
        contexts.addHandler(context);
View Full Code Here

     *
     * @throws JBIException
     */
    public void start() throws JBIException {
        server.setConnectors(new Connector[] { listener });
        ContextHandler context = new ContextHandler();
        context.setContextPath("/");
        ServletHolder holder = new ServletHolder();
        holder.setName("jbiServlet");
        holder.setClassName(BindingServlet.class.getName());
        ServletHandler handler = new ServletHandler();
        handler.setServlets(new ServletHolder[] { holder });
        ServletMapping mapping = new ServletMapping();
        mapping.setServletName("jbiServlet");
        mapping.setPathSpec("/*");
        handler.setServletMappings(new ServletMapping[] { mapping });
        context.setHandler(handler);
        server.setHandler(context);
        context.setAttribute("binding", this);
        try {
            server.start();
        }
        catch (Exception e) {
          log.warn(e.toString());
View Full Code Here

   *
   * @throws JBIException
   */
  public void start() throws JBIException {
        server.setConnectors(new Connector[] { listener });
        ContextHandler context = new ContextHandler();
        context.setContextPath("/");
        ServletHolder holder = new ServletHolder();
        holder.setName("jbiServlet");
        holder.setClassName(BindingServlet.class.getName());
        ServletHandler handler = new ServletHandler();
        handler.setServlets(new ServletHolder[] { holder });
        ServletMapping mapping = new ServletMapping();
        mapping.setServletName("jbiServlet");
        mapping.setPathSpec("/*");
        handler.setServletMappings(new ServletMapping[] { mapping });
        context.setHandler(handler);
        server.setHandler(context);
        context.setAttribute("binding", this);
        try {
            server.start();
        }
        catch (Exception e) {
          log.warn(e.toString());
View Full Code Here

                    SelectChannelConnector selectConnector = new SelectChannelConnector();
                    selectConnector.setPort(portNumber);
                    server.setConnectors(new Connector[] {selectConnector});
                }
   
                ContextHandler contextHandler = new ContextHandler();
                //contextHandler.setContextPath(contextPath);
                contextHandler.setContextPath("/");
                server.setHandler(contextHandler);
   
                SessionHandler sessionHandler = new SessionHandler();
                ServletHandler servletHandler = new ServletHandler();
                sessionHandler.addHandler(servletHandler);
   
                contextHandler.setHandler(sessionHandler);
   
                server.setStopAtShutdown(true);
                server.setSendServerVersion(sendServerVersion);
                server.start();
               
View Full Code Here

TOP

Related Classes of org.mortbay.jetty.handler.ContextHandler

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.