Package org.mortbay.jetty

Examples of org.mortbay.jetty.Server


        this(port, 30, 10);
    }

    public TerracottaJettyServer(int port, int maxInactivePeriod, int scavengePeriod)
    {
        this.server = new Server(port);
        this.maxInactivePeriod = maxInactivePeriod;
        this.scavengePeriod = scavengePeriod;
        this.contexts = new ContextHandlerCollection();
        this.sessionIdManager = new TerracottaSessionIdManager(server);
    }
View Full Code Here


import org.mortbay.jetty.webapp.WebAppContext;

public class JettyLauncher {
    public static void main(String[] args) {

        Server server = new Server(8080);
        server.addHandler(new WebAppContext("./src/main/webapp", "/ultimate-roundtrip"));
        try {
            server.start();
            Thread.sleep(100000); //Makes sure the server doesn't die
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
View Full Code Here

        {
            throw new Error( "Cannot start HTTP client: " + e );
        }

        // Create server
        server = new Server();
        SelectChannelConnector connector = new SelectChannelConnector();
        connector.setHost( host );
        connector.setPort( 0 );
        server.setConnectors( new Connector[] { connector } );
        server.setHandler( new AbstractHandler()
View Full Code Here

            server.stop();
            server = null;
        }
       
        // Create a Jetty server with a simple servlet that returns immediately
        server = new Server();
        SocketConnector connector = new SocketConnector();
        connector.setHost("127.0.0.1");
      
        if (_PORT == 0)
        {
View Full Code Here

        }
    }

    protected void newServer() throws Exception
    {
        _server=new Server();
        _server.setGracefulShutdown(500);
        _connector=new SelectChannelConnector();

        _connector.setPort(0);
        _server.setConnectors(new Connector[] { _connector });
View Full Code Here

     *
     * @throws Exception
     */
    public void testRequest1_jetty_https() throws Exception
    {
        Server server=new Server();
        SslSelectChannelConnector connector=new SslSelectChannelConnector();

        String keystore = System.getProperty("user.dir")+File.separator+"src"+File.separator+"test"+File.separator+"resources"+File.separator+"keystore";
       
        connector.setPort(0);
        connector.setKeystore(keystore);
        connector.setPassword("storepwd");
        connector.setKeyPassword("keypwd");

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

        final int numConns=200;
        Socket[] client=new Socket[numConns];

        SSLContext ctx=SSLContext.getInstance("SSLv3");
        ctx.init(null,s_dummyTrustManagers,new java.security.SecureRandom());

        int port=connector.getLocalPort();

        try
        {
            for (int i=0; i<numConns; ++i)
            {
                // System.err.println("write:"+i);
                client[i]=ctx.getSocketFactory().createSocket("localhost",port);
                OutputStream os=client[i].getOutputStream();

                os.write(REQUEST0.getBytes());
                os.write(REQUEST0.getBytes());
                os.flush();
            }

            for (int i=0; i<numConns; ++i)
            {
                // System.err.println("flush:"+i);
                OutputStream os=client[i].getOutputStream();
                os.write(REQUEST1.getBytes());
                os.flush();
            }

            for (int i=0; i<numConns; ++i)
            {
                // System.err.println("read:"+i);
                // Read the response.
                String responses=readResponse(client[i]);
                // Check the response
                assertEquals(String.format("responses %d",i),RESPONSE0+RESPONSE0+RESPONSE1,responses);
            }
        }
        finally
        {
            for (int i=0; i<numConns; ++i)
            {
                if (client[i]!=null)
                {
                    client[i].close();
                }
            }
            server.stop();
        }
    }
View Full Code Here

            port = Integer.parseInt(_port);
        }

        // Set the location and server
        this.location = "http://" + servername + ":" + port;
        this.server = new Server(port);

        final Context context = new Context(this.server, "/", Context.SESSIONS);
        final DwrServlet servlet = new DwrServlet();
        final ServletHolder servletholder = new ServletHolder(servlet);
View Full Code Here


    public static void main(String[] args)
        throws Exception
    {
        Server proxy = new Server();
        //SelectChannelConnector connector = new SelectChannelConnector();
        Connector connector = new SocketConnector();
        connector.setPort(8888);
        proxy.addConnector(connector);
        Context context = new Context(proxy,"/",0);
        context.addServlet(new ServletHolder(new AsyncProxyServlet.Transparent("","www.google.com",80)), "/");

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

   *          metrics object for using.
   * @throws IOException
   */
  public HttpJettyServer(int bindPort, int port, int baseControllerPort, int baseShardPort, int baseGuiControllerPort,
      int baseGuiShardPort, String base) throws IOException {
    server = new Server(port);

    String logDir = System.getProperty("blur.logs.dir");
    String logFile = System.getProperty("blur.log.file");
    String blurLogFile = logDir + "/" + logFile;
    System.setProperty("blur.gui.servicing.port", bindPort + "");
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

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.