Package org.mortbay.jetty.handler

Examples of org.mortbay.jetty.handler.ContextHandler


        Server server = new Server();
        Connector connector=new SelectChannelConnector();
        connector.setPort(8080);
        server.setConnectors(new Connector[]{connector});
       
        ContextHandler context0 = new ContextHandler();
        context0.setContextPath("/zero");
        Handler handler0=new HelloHandler();
        context0.setHandler(handler0);

        ContextHandler context1 = new ContextHandler();
        context1.setContextPath("/one");
        Handler handler1=new HelloHandler();
        context1.setHandler(handler1);  
       
        ContextHandlerCollection contexts = new ContextHandlerCollection();
        contexts.setHandlers(new Handler[]{context0,context1});
       
        HandlerCollection handlers = new HandlerCollection();
View Full Code Here


        Server server = new Server();
        Connector connector=new SelectChannelConnector();
        connector.setPort(8080);
        server.setConnectors(new Connector[]{connector});
       
        ContextHandler context = new ContextHandler();
        context.setContextPath("/");
        context.setResourceBase(".");
        context.setClassLoader(Thread.currentThread().getContextClassLoader());
        server.setHandler(context);
       
        Handler handler=new HelloHandler();
        context.setHandler(handler);
       
        server.start();
        server.join();
    }
View Full Code Here

    Server server = new Server();
   
    protected void setUp() throws Exception
    {
        sessionManager.setIdManager(idManager);
        ContextHandler context=new ContextHandler();
        sessionManager.setSessionHandler(handler);
        server.setHandler(context);
        context.setHandler(handler);
        server.start();
    }
View Full Code Here

    public static ContextHandler getCurrentWebAppContext()
    {
        ContextHandler.SContext context=ContextHandler.getCurrentContext();
        if (context!=null)
        {
            ContextHandler handler = context.getContextHandler();
            if (handler instanceof WebAppContext)
                return (ContextHandler)handler;
        }
        return null;  
    }
View Full Code Here

            }
            server.setConnectors(new Connector[]{connector});
           
            if (args.length<3)
            {
                ContextHandler context = new ContextHandler();
                context.setContextPath(URIUtil.SLASH);
                context.setResourceBase(args.length==1?".":args[1]);
                ServletHandler servlet = new ServletHandler();
                servlet.addServletWithMapping("org.mortbay.jetty.servlet.DefaultServlet", URIUtil.SLASH);
                context.setHandler(servlet);
                contexts.addHandler(context);
            }
            else if ("-webapps".equals(args[1]))
            {
                WebAppContext.addWebApplications(server, args[2], WebAppContext.WEB_DEFAULTS_XML, true, true);
View Full Code Here

    /* ------------------------------------------------------------ */
    public String getObjectNameBasis()
    {
        if (_managed!=null && _managed instanceof ContextHandler)
        {
            ContextHandler context = (ContextHandler)_managed;
            String name = context.getDisplayName();
            if (name!=null)
                return name;
           
            if (context.getBaseResource()!=null && context.getBaseResource().getName().length()>1)
                return context.getBaseResource().getName();
        }
        return super.getObjectNameBasis();
    }
View Full Code Here

    {

        HttpConnection connection = new HttpConnection(connector,connector._endp,connector._server);
        Request request = connection.getRequest();
        Response response = connection.getResponse();
        ContextHandler context = new ContextHandler();
        context.addLocaleEncoding(Locale.ENGLISH.toString(),"ISO-8859-1");
        context.addLocaleEncoding(Locale.ITALIAN.toString(),"ISO-8859-2");
        request.setContext(context.getServletContext());

        response.setLocale(java.util.Locale.ITALIAN);
        assertEquals(null,response.getContentType());
        response.setContentType("text/plain");
        assertEquals("text/plain; charset=ISO-8859-2",response.getContentType());
View Full Code Here

    {
        super(arg0);
        server.setConnectors(new Connector[]
        { connector });

        ContextHandler vcontext=new ContextHandler();
        vcontext.setContextPath("/");
        vcontext.setVirtualHosts(new String[]
        { "VirtualHost" });
        vcontext.setHandler(new DumpHandler("Virtual Dump"));

        ContextHandler context=new ContextHandler();
        context.setContextPath("/");
        context.setHandler(new DumpHandler());

        HandlerCollection collection=new HandlerCollection();
        collection.setHandlers(new Handler[]
        { vcontext, context });
View Full Code Here

    private void checkIfContextIsFree(String path)
    {
        Handler[] handlers = _contextCollection.getChildHandlersByClass(ContextHandler.class);
        for (int i = 0; handlers!= null && i < handlers.length; i++)
        {
            ContextHandler ctx = (ContextHandler) handlers[i];
            if (ctx.getContextPath().equals(path))
                throw new IllegalArgumentException("another context already bound to path " + path)
        }
    }
View Full Code Here

    {
        Handler handler = null;
        Handler[] handlers = _contextCollection.getChildHandlersByClass(ContextHandler.class);
        for (int i = 0; handlers!= null && i < handlers.length && handler == null; i++)
        {
            ContextHandler ctx = (ContextHandler) handlers[i];
            if (ctx.getContextPath().equals(path))
                handler = ctx;
        }
        if (handler != null)
            _contextCollection.removeHandler(handler);
    }
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.