Package org.eclipse.jetty.server

Examples of org.eclipse.jetty.server.Server


  void stop() {
    if (server == null) {
      throw new RuntimeException("Server is already stopped");
    } else {
      try {
        final Server server1 = server;
        port = -1;
        server = null;
        server1.stop();
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
  }
View Full Code Here


            sslContextFactory.setTrustStorePath(truststoreFile);
        }
        if (truststorePassword != null) {
            sslContextFactory.setTrustStorePassword(truststorePassword);
        }
        return new ServerConnector(new Server(), sslContextFactory);
    }
View Full Code Here

     * Creates an ordinary, non-secured Jetty server connector.
     *
     * @return - a server connector
     */
    private static ServerConnector createSocketConnector() {
        return new ServerConnector(new Server());
    }
View Full Code Here

   *
   * @throws Exception
   */
  public void start() throws Exception {
   
    server = new Server(port);
   
    WebAppContext context = new WebAppContext();
    context.setContextPath("/");
   
    File file = new File(basePath, "webapp");
View Full Code Here

    public static void main(String[] args) throws Exception {
        COUNTER_1.inc();
        COUNTER_2.inc();

        final ThreadPool threadPool = new InstrumentedQueuedThreadPool(REGISTRY);
        final Server server = new Server(threadPool);

        final Connector connector = new ServerConnector(server,
                                                        new InstrumentedConnectionFactory(new HttpConnectionFactory(),
                                                                                          REGISTRY.timer("http.connection")));
        server.addConnector(connector);

        final ServletContextHandler context = new ServletContextHandler();
        context.setContextPath("/initial");
        context.setAttribute(MetricsServlet.METRICS_REGISTRY, REGISTRY);
        context.setAttribute(HealthCheckServlet.HEALTH_CHECK_REGISTRY, new HealthCheckRegistry());

        final ServletHolder holder = new ServletHolder(new AdminServlet());
        context.addServlet(holder, "/dingo/*");

        final InstrumentedHandler handler = new InstrumentedHandler(REGISTRY);
        handler.setHandler(context);
        server.setHandler(handler);
       
        server.start();
        server.join();
    }
View Full Code Here

        return new Console(DatabaseInfo.expose(database));
    }

    public void start(int port) throws Exception {
        LOG.warn("Port used: " + port + " location " + WEBAPP_LOCATION + " " + databaseInfo.toString());
        server = new Server(port);
        WebAppContext root = new WebAppContext();
        root.setContextPath("/");
        root.setDescriptor(WEBAPP_LOCATION + "/WEB-INF/web.xml");
        root.setResourceBase(WEBAPP_LOCATION);
        root.setParentLoaderPriority(true);
View Full Code Here

{
  final static Logger log = LoggerFactory.getLogger(Runner.class);

  public static void main(String[] args) throws Exception
  {
    Server server = new Server();

    Connector connector = new SelectChannelConnector();

        connector.setPort(8080);

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

    WebAppContext context = new WebAppContext();
    context.setContextPath("/");
        context.setResourceBase(System.getProperty("user.dir"));
    context.setInitParameter(SessionManager.__CheckRemoteSessionEncoding, "true"); // Stops Jetty from adding 'jsessionid' URL rewriting into non-local URLs (e.g. Google OpenId redirects)

    server.setHandler(context);

    server.addLifeCycleListener(new AbstractLifeCycle.AbstractLifeCycleListener()
    {
      @Override
      public void lifeCycleStarted(LifeCycle event)
      {
        log.warn("Jetty ready to accept requests...");
      }
    });

    server.start();

    server.join();
  }
View Full Code Here

        throw new IllegalArgumentException(
            String.format("%1$s#%2$s cannot be %3$s",
                Actor.class.getName(), ActorType.ID.getKey(),
                actorExtractor.extract().getId()));
      }
      server = new Server();
      server.addLifeCycleListener(new LifeCycle.Listener() {
        @Override
        public void lifeCycleStopping(final LifeCycle lifeCycle) {
          UGateKeeper.DEFAULT.notifyListeners(new UGateEvent<>(
              WebServer.this, Type.WEB_DISCONNECTING, false));
View Full Code Here

public class Start
{

  public static void main(String[] args) throws Exception
  {
    Server server = new Server();
    SocketConnector connector = new SocketConnector();

    // Set some timeout options to make debugging easier.
    connector.setMaxIdleTime(1000 * 60 * 60);
    connector.setSoLingerTime(-1);
    connector.setPort(8080);
    server.setConnectors(new Connector[] { connector });

    WebAppContext bb = new WebAppContext();
    bb.setServer(server);
    bb.setContextPath("/");
    bb.setWar("src/main/webapp");

    server.setHandler(bb);

    try
    {
      System.out.println(">>> STARTING EMBEDDED JETTY SERVER, PRESS ANY KEY TO STOP");
      server.start();
      System.in.read();
      System.out.println(">>> STOPPING EMBEDDED JETTY SERVER");
      // while (System.in.available() == 0) {
      // Thread.sleep(5000);
      // }
      server.stop();
      server.join();
    }
    catch (Exception e)
    {
      e.printStackTrace();
      System.exit(100);
View Full Code Here

        SelectChannelConnector connector = new SelectChannelConnector();
        connector.setHost("127.0.0.1");
        connector.setPort(HTTP_SERVER_PORT);
        connector.setName("admin");

        server = new Server(HTTP_SERVER_PORT);
        server.setHandler(requestHandler);
        server.setConnectors(new Connector[] { connector });
        server.setStopAtShutdown(true);
        server.start();
    }
View Full Code Here

TOP

Related Classes of org.eclipse.jetty.server.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.