Package org.mortbay.jetty

Examples of org.mortbay.jetty.Server


    }

    private Server createServer() throws Exception {
        setCamelServlet(new CamelServlet());

        Server server = new Server();
        Context context = new Context(Context.NO_SECURITY | Context.NO_SESSIONS);

        context.setContextPath("/");
        ServletHolder holder = new ServletHolder();
        holder.setServlet(getCamelServlet());
        context.addServlet(holder, "/*");
        server.setHandler(context);

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


        }
        try {
            Set<Entry<Integer, Port>> entries = new HashSet<Entry<Integer, Port>>(ports.entrySet());
            for (Entry<Integer, Port> entry : entries) {
                Port port = entry.getValue();
                Server server = port.getServer();
                server.stop();
                server.setStopAtShutdown(false);
                ports.remove(entry.getKey());
            }
        } catch (Exception e) {
            throw new ServletMappingException(e);
        } finally {
View Full Code Here

        Port port = ports.get(portNumber);
        if (port == null) {

            // Create and start a new server
            try {
                Server server = new Server();
                server.setThreadPool(new WorkSchedulerThreadPool());
                if ("https".equals(scheme)) {
                    //                    Connector httpConnector = new SelectChannelConnector();
                    //                    httpConnector.setPort(portNumber);
                    SslSocketConnector sslConnector = new SslSocketConnector();
                    sslConnector.setPort(portNumber);
                    // FIXME: [rfeng] We should set the host to be bound but binding-ws-axis2 is passing
                    // in an absolute URI with host set to one of the ip addresses
                    sslConnector.setHost(host);
                    configureSSL(sslConnector, securityContext);
                    server.setConnectors(new Connector[] {sslConnector});
                } else {
                    SelectChannelConnector selectConnector = new SelectChannelConnector();
                    selectConnector.setPort(portNumber);
                    // FIXME: [rfeng] We should set the host to be bound but binding-ws-axis2 is passing
                    // in an absolute URI with host set to one of the ip addresses
                    selectConnector.setHost(host);
                    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();

                // Keep track of the new server and Servlet handler
                port = new Port(server, servletHandler);
                ports.put(portNumber, port);
View Full Code Here

            servletHandler.setServletMappings(mappings.toArray(new ServletMapping[mappings.size()]));

            // Stop the port if there are no servlet mappings on it anymore
            if (mappings.size() == 0) {
                try {
                    Server server = port.getServer();
                    server.stop();
                    server.setStopAtShutdown(false);
                } catch (Exception e) {
                    throw new IllegalStateException(e);
                }
                ports.remove(portNumber);
            }
View Full Code Here

    }
    shPojoMap.setInitParameter(JSONConfiguration.FEATURE_POJO_MAPPING, "true");

    // set up Jetty and run the embedded server

    Server server = new Server();

    Connector connector = new SelectChannelConnector();
    if(conf.getBoolean(REST_SSL_ENABLED, false)) {
      SslSelectChannelConnector sslConnector = new SslSelectChannelConnector();
      String keystore = conf.get(REST_SSL_KEYSTORE_STORE);
      String password = conf.get(REST_SSL_KEYSTORE_PASSWORD);
      String keyPassword = conf.get(REST_SSL_KEYSTORE_KEYPASSWORD, password);
      sslConnector.setKeystore(keystore);
      sslConnector.setPassword(password);
      sslConnector.setKeyPassword(keyPassword);
      connector = sslConnector;
    }
    connector.setPort(servlet.getConfiguration().getInt("hbase.rest.port", 8080));
    connector.setHost(servlet.getConfiguration().get("hbase.rest.host", "0.0.0.0"));

    server.addConnector(connector);

    // Set the default max thread number to 100 to limit
    // the number of concurrent requests so that REST server doesn't OOM easily.
    // Jetty set the default max thread number to 250, if we don't set it.
    //
    // Our default min thread number 2 is the same as that used by Jetty.
    int maxThreads = servlet.getConfiguration().getInt("hbase.rest.threads.max", 100);
    int minThreads = servlet.getConfiguration().getInt("hbase.rest.threads.min", 2);
    QueuedThreadPool threadPool = new QueuedThreadPool(maxThreads);
    threadPool.setMinThreads(minThreads);
    server.setThreadPool(threadPool);

    server.setSendServerVersion(false);
    server.setSendDateHeader(false);
    server.setStopAtShutdown(true);
      // set up context
    Context context = new Context(server, "/", Context.SESSIONS);
    context.addServlet(shPojoMap, "/status/cluster");
    context.addServlet(sh, "/*");
    if (authFilter != null) {
      context.addFilter(authFilter, "/*", 1);
    }

    // Load filters from configuration.
    String[] filterClasses = servlet.getConfiguration().getStrings(FILTER_CLASSES,
      ArrayUtils.EMPTY_STRING_ARRAY);
    for (String filter : filterClasses) {
      filter = filter.trim();
      context.addFilter(Class.forName(filter), "/*", 0);
    }

    // Put up info server.
    int port = conf.getInt("hbase.rest.info.port", 8085);
    if (port >= 0) {
      conf.setLong("startcode", System.currentTimeMillis());
      String a = conf.get("hbase.rest.info.bindAddress", "0.0.0.0");
      InfoServer infoServer = new InfoServer("rest", a, port, false, conf);
      infoServer.setAttribute("hbase.conf", conf);
      infoServer.start();
    }

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

   */
  private Server createServer(int port) throws Exception {
    System.setProperty("shindig.port", String.valueOf(port));
    System.setProperty("jetty.port", String.valueOf(port));

    Server newServer = new Server(port);

    // Attach the test resources in /endtoend as static content for the test
    ResourceHandler resources = new ResourceHandler();
    URL resource = EndToEndTest.class.getResource("/endtoend");
    resources.setBaseResource(Resource.newResource(resource));
    newServer.addHandler(resources);

    Context context = new Context(newServer, "/", Context.SESSIONS);
    context.addEventListener(new GuiceServletContextListener());

    Map<String, String> initParams = Maps.newHashMap();
View Full Code Here

* Basic jetty launcher
*/
public class JettyLauncher {

    public static void main(String[] args) throws Exception {
        Server server = new Server();
        FileInputStream jettyConfFile = new FileInputStream(args[0]);
        XmlConfiguration configuration = new XmlConfiguration(jettyConfFile);
        jettyConfFile.close();
        configuration.configure(server);
        server.start();
        server.join();
    }
View Full Code Here

        assertFalse(orginal.exists());
    }

    @Test
    public void testHelloWorldExternalBindingFile() throws Exception {
        Server server = new Server(8585);

        ResourceHandler reshandler = new ResourceHandler();
        reshandler.setResourceBase(getLocation("/wsdl2java_wsdl/"));
        server.addHandler(reshandler);
        server.start();
        env.put(ToolConstants.CFG_WSDLURL, "http://localhost:8585/hello_world.wsdl");
        env.put(ToolConstants.CFG_BINDING, "http://localhost:8585/remote-hello_world_binding.xsd");
        processor.setContext(env);
        processor.execute();
        try {
            reshandler.stop();
        } finally {
            server.stop();
            server.destroy();
        }

    }
View Full Code Here

    }
    shPojoMap.setInitParameter(JSONConfiguration.FEATURE_POJO_MAPPING, "true");

    // set up Jetty and run the embedded server

    Server server = new Server();

    Connector connector = new SelectChannelConnector();
    connector.setPort(servlet.getConfiguration().getInt("hbase.rest.port", 8080));
    connector.setHost(servlet.getConfiguration().get("hbase.rest.host", "0.0.0.0"));

    server.addConnector(connector);

    // Set the default max thread number to 100 to limit
    // the number of concurrent requests so that REST server doesn't OOM easily.
    // Jetty set the default max thread number to 250, if we don't set it.
    //
    // Our default min thread number 2 is the same as that used by Jetty.
    int maxThreads = servlet.getConfiguration().getInt("hbase.rest.threads.max", 100);
    int minThreads = servlet.getConfiguration().getInt("hbase.rest.threads.min", 2);
    QueuedThreadPool threadPool = new QueuedThreadPool(maxThreads);
    threadPool.setMinThreads(minThreads);
    server.setThreadPool(threadPool);

    server.setSendServerVersion(false);
    server.setSendDateHeader(false);
    server.setStopAtShutdown(true);

    // set up context
    Context context = new Context(server, "/", Context.SESSIONS);
    context.addServlet(shPojoMap, "/status/cluster");
    context.addServlet(sh, "/*");
    context.addFilter(GzipFilter.class, "/*", 0);
    HttpServerUtil.constrainHttpMethods(context);

    // Put up info server.
    int port = conf.getInt("hbase.rest.info.port", 8085);
    if (port >= 0) {
      conf.setLong("startcode", System.currentTimeMillis());
      String a = conf.get("hbase.rest.info.bindAddress", "0.0.0.0");
      InfoServer infoServer = new InfoServer("rest", a, port, false, conf);
      infoServer.setAttribute("hbase.conf", conf);
      infoServer.start();
    }

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

    jettyConnector.setLowResourcesConnections(HTTP_SERVER_THREADS - 10);
    jettyConnector.setLowResourceMaxIdleTime(1500);
    jettyConnector.setPort(portNum);

    // Set up jetty server, using connector
    jettyServer = new Server(portNum);
    jettyServer.setConnectors(new org.mortbay.jetty.Connector[] { jettyConnector });
    BoundedThreadPool pool = new BoundedThreadPool();
    pool.setMaxThreads(HTTP_SERVER_THREADS);
    jettyServer.setThreadPool(pool);
View Full Code Here

TOP

Related Classes of org.mortbay.jetty.Server

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.