Package org.mortbay.jetty.servlet

Examples of org.mortbay.jetty.servlet.ServletHolder


   */
  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("/*");
 
View Full Code Here


                connector.setPort(Integer.getInteger("litmus.port", 0));

                Server server = new Server();
                server.addConnector(connector);

                ServletHolder holder = new ServletHolder(
                        new SimpleWebdavServlet() {
                            @Override
                            public Repository getRepository() {
                                return repository;
                            }
                        });
                holder.setInitParameter("resource-config", "/config.xml");

                Context context = new Context(server, "/");
                context.setResourceBase("src/test/resources");
                context.addServlet(holder, "/*");
                server.addHandler(context);
View Full Code Here

            }
        }

        // Register the servlet mapping
        ServletHandler servletHandler = port.getServletHandler();
        ServletHolder holder;
        if (servlet instanceof DefaultResourceServlet) {
           
            // Optimize the handling of resource requests, use the Jetty default servlet
            // instead of our default resource servlet
            String servletPath = uri.getPath();
            if (servletPath.endsWith("*")) {
                servletPath = servletPath.substring(0, servletPath.length()-1);
            }
            if (servletPath.endsWith("/")) {
                servletPath = servletPath.substring(0, servletPath.length()-1);
            }         
            if (!servletPath.startsWith("/")) {
                servletPath = '/' + servletPath;
            }    
      
            DefaultResourceServlet resourceServlet = (DefaultResourceServlet)servlet;
            DefaultServlet defaultServlet = new JettyDefaultServlet(servletPath, resourceServlet.getDocumentRoot());
            holder = new ServletHolder(defaultServlet);
           
        } else {
            holder = new ServletHolder(servlet);
        }
        servletHandler.addServlet(holder);
       
        ServletMapping mapping = new ServletMapping();
        mapping.setServletName(holder.getName());
        String path = uri.getPath();
       
        if (!path.startsWith("/")) {
            path = '/' + path;
        }
View Full Code Here

   * @deprecated this is a temporary method
   */
  @Deprecated
  public void addInternalServlet(String name, String pathSpec,
      Class<? extends HttpServlet> clazz) {
    ServletHolder holder = new ServletHolder(clazz);
    if (name != null) {
      holder.setName(name);
    }
    webAppContext.addServlet(holder, pathSpec);
  }
View Full Code Here

    public static void main(String[] args)
        throws Exception
    {
        Server server = new Server(8080);
        Context context = new Context(server,"/",Context.SESSIONS);
        context.addServlet(new ServletHolder(new HelloServlet()), "/*");
       
        server.start();
        server.join();
    }
View Full Code Here

            _connector.setPort(_PORT);
        }

        _server.addConnector(_connector);
        Context context = new Context(_server,"",Context.NO_SECURITY | Context.NO_SESSIONS);
        ServletHolder h = new ServletHolder(new HttpServlet()
        {
            private static final long serialVersionUID = 1L;

            @Override
            protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException
View Full Code Here

        Context context = new Context(_server,"/");
        context.setBaseResource(Resource.newResource("./src/test"));

        // Cometd servlet
        _cometd=new ContinuationCometdServlet();
        ServletHolder cometd_holder = new ServletHolder(_cometd);
        cometd_holder.setInitParameter("timeout","10000");
        cometd_holder.setInitParameter("interval","100");
        cometd_holder.setInitParameter("maxInterval","10000");
        cometd_holder.setInitParameter("multiFrameInterval","2000");
        cometd_holder.setInitParameter("logLevel","0");

        context.addServlet(cometd_holder, "/cometd/*");
        context.addServlet(DefaultServlet.class,"/");

        _server.start();
View Full Code Here

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

        ServletHandler handler = new ServletHandler();
        TestServlet servlet = new TestServlet();
        handler.addServletWithMapping(new ServletHolder(servlet),"/test");
        server.addHandler(handler);
       
        try
        {
            SSLContext context = SSLContext.getInstance("SSL");
View Full Code Here

            Resource.newResource(base+"/../demo/src/main/webapp/"),
            Resource.newResource(base+"/../demo/target/cometd-demo-"+version+"/"),
        }));
       
        // Cometd servlet
        ServletHolder cometd_holder = new ServletHolder(ContinuationCometdServlet.class);
        cometd_holder.setInitParameter("timeout","200000");
        cometd_holder.setInitParameter("interval","100");
        cometd_holder.setInitParameter("maxInterval","100000");
        cometd_holder.setInitParameter("multiFrameInterval","1500");
        cometd_holder.setInitParameter("directDeliver","true");
        cometd_holder.setInitParameter("logLevel","1");
        cometd_holder.setInitOrder(1);
        context.addServlet(cometd_holder, "/cometd/*");
       
        ServletHolder oort_holder = new ServletHolder(OortServlet.class);
        oort_holder.setInitParameter(Oort.OORT_URL,"http://localhost:"+port+"/cometd");
        oort_holder.setInitParameter(Oort.OORT_CHANNELS,"/chat/**");
        oort_holder.setInitParameter(Oort.OORT_CLOUD,(port==8080)?"http://localhost:"+8081+"/cometd":"http://localhost:"+8080+"/cometd");
        oort_holder.setInitOrder(2);
        context.addServlet(oort_holder, "/oort/*");

        ServletHolder seti_holder = new ServletHolder(SetiServlet.class);
        seti_holder.setInitParameter(Seti.SETI_SHARD,"S"+(port%2));
        seti_holder.setInitOrder(2);
        context.addServlet(seti_holder, "/seti/*");

        ServletHolder demo_holder = new ServletHolder(OortDemoServlet.class);
        demo_holder.setInitOrder(3);
        context.getServletHandler().addServlet(demo_holder);
       
        context.addServlet("org.mortbay.jetty.servlet.DefaultServlet", "/");
       
        server.start();
View Full Code Here

        ContextHandlerCollection contexts = new ContextHandlerCollection();
        server.setHandler(contexts);

        Context root = new Context(contexts,"/",Context.SESSIONS);
        root.addServlet(new ServletHolder(new HelloServlet("Ciao")), "/*");

        Context other = new Context(contexts,"/other",Context.SESSIONS);
        other.addServlet("org.mortbay.jetty.example.ManyServletContexts$HelloServlet", "/*");

        StatisticsHandler stats = new StatisticsHandler();
        contexts.addHandler(stats);
        Context yetanother =new Context(stats,"/yo",Context.SESSIONS);
        yetanother.addServlet(new ServletHolder(new HelloServlet("YO!")), "/*");

        server.start();
        server.join();
    }
View Full Code Here

TOP

Related Classes of org.mortbay.jetty.servlet.ServletHolder

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.