Package org.mortbay.jetty

Examples of org.mortbay.jetty.Server


        InetAddress.getLocalHost().getCanonicalHostName()),
      port);

    // set up Jetty and run the embedded server

    Server server = new Server(port);
    server.setSendServerVersion(false);
    server.setSendDateHeader(false);
    server.setStopAtShutdown(true);
      // set up context
    Context context = new Context(server, "/", Context.SESSIONS);
    context.addServlet(sh, "/*");

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


    protected void run() {
        // setup the system properties
        String busFactory = System.getProperty(BusFactory.BUS_FACTORY_PROPERTY_NAME);
        System.setProperty(BusFactory.BUS_FACTORY_PROPERTY_NAME, "org.apache.cxf.bus.CXFBusFactory");
        try {
            httpServer = new Server(Integer.parseInt(PORT));
            ContextHandlerCollection contexts = new ContextHandlerCollection();
            httpServer.setHandler(contexts);

            Context root = new Context(contexts, "/", Context.SESSIONS);
View Full Code Here

            LOG.info( "configuring jetty http server from the configuration file {}", confFile );

            try
            {
                jetty = new Server();
                jettyConf.configure( jetty );
                configured = true;
            }
            catch ( Exception e )
            {
View Full Code Here

     */
    private void configureServerThroughCode()
    {
        try
        {
            jetty = new Server();

            if ( httpTransport != null )
            {
                SelectChannelConnector httpConnector = new SelectChannelConnector();
                httpConnector.setPort( httpTransport.getPort() );
View Full Code Here

    public void setUp()
        throws Exception
    {
        System.setProperty( "org.mortbay.xml.XmlParser.NotValidating", "true" );

        server = new Server();
        String testPort = ":18080";
        server.addListener( testPort );
        server.addWebApplication( "127.0.0.1", "/webapp", "target/webapp" );

        server.start();
View Full Code Here

      "jetty");

    LOG.info("configured " + ServletContainer.class.getName());
   
    // set up Jetty and run the embedded server
    server = new Server(0);
    server.setSendServerVersion(false);
    server.setSendDateHeader(false);
      // set up context
    Context context = new Context(server, "/", Context.SESSIONS);
    context.addServlet(sh, "/*");
 
View Full Code Here

    public void init(Properties props) throws Exception {
        port = Options.getInt(props, "port", 8080);
       
        // Create all the Jetty objects but dont' start them
        server = new Server();
        Connector connector = new SelectChannelConnector();
        connector.setPort(port);
        server.setConnectors(new Connector[]{connector});

        ContextHandler context = new ContextHandler();
View Full Code Here

                for (ComponentConfig.WebappInfo webappInfo : component.getWebappInfos()) {

                    List<String> virtualHosts = webappInfo.getVirtualHosts();
                    Map<String, String> initParameters = webappInfo.getInitParameters();

                    Server server = servers.get(webappInfo.server);

                    if (server == null) {
                        Debug.logWarning("Server with name [" + webappInfo.server + "] not found; not mounting [" + webappInfo.name + "]", module);
                    } else {

                        // set the root location (make sure we set the paths correctly)
                        String location = component.getRootLocation() + webappInfo.location;
                        location = location.replace('\\', '/');
                        if (location.endsWith("/")) {
                            location = location.substring(0, location.lastIndexOf("/"));
                        }

                        // load the application
                        String mountPoint = webappInfo.mountPoint;
                        if (mountPoint.endsWith("/*")) {
                            mountPoint = mountPoint.substring(0, mountPoint.lastIndexOf("/"));
                        }

                        WebAppContext context = new WebAppContext(location, mountPoint);
                        context.setAttribute("_serverId", webappInfo.server);
                        context.setLogUrlOnStart(true);

                         // set the session manager
                        HashSessionManager sm = new HashSessionManager();
                        context.setSessionHandler(new SessionHandler(sm));

                        // set the virtual hosts
                        if (virtualHosts != null && !virtualHosts.isEmpty()) {
                            context.setVirtualHosts((String[]) virtualHosts.toArray());
                        }

                        // set the init parameters
                        if (initParameters != null && !initParameters.isEmpty()) {
                            context.setInitParams(initParameters);
                        }

                        server.addHandler(context);
                    }
                }
            }
        }
    }
View Full Code Here

        }
    }

    private Server createServer(ContainerConfig.Container.Property serverConfig) throws ContainerException {

        Server server = new Server();

        // configure the connectors / loggers
        for (ContainerConfig.Container.Property props : serverConfig.properties.values()) {

            if ("send-server-version".equals(props.name)) {
                if ("false".equalsIgnoreCase(props.value)) {
                    server.setSendServerVersion(false);
                }
            } else if ("connector".equals(props.value)) {

                if ("http".equals(props.getProperty("type").value)) {

                    AbstractConnector connector = new SocketConnector();
                    setConnectorOptions(connector, props);
                    server.addConnector(connector);

                } else if ("https".equals(props.getProperty("type").value)) {

                    SslSocketConnector connector = new SslSocketConnector();
                    setConnectorOptions(connector, props);

                    if (props.getProperty("keystore") != null) {
                        connector.setKeystore(props.getProperty("keystore").value);
                    }
                    if (props.getProperty("password") != null) {
                        connector.setPassword(props.getProperty("password").value);
                    }
                    if (props.getProperty("key-password") != null) {
                        connector.setKeyPassword(props.getProperty("key-password").value);
                    }
                    if (props.getProperty("client-auth") != null) {
                        if ("need".equals(props.getProperty("client-auth").value)) {
                            connector.setNeedClientAuth(true);
                        } else if ("want".equals(props.getProperty("client-auth").value)) {
                            connector.setWantClientAuth(true);
                        }
                    }

                    server.addConnector(connector);

                } else if ("nio-http".equals(props.getProperty("type").value)) {

                    AbstractConnector connector = new SelectChannelConnector();
                    setConnectorOptions(connector, props);
                    server.addConnector(connector);

                } else if ("nio-https".equals(props.getProperty("type").value)) {

                    SslSelectChannelConnector connector = new SslSelectChannelConnector();
                    setConnectorOptions(connector, props);

                    if (props.getProperty("keystore") != null) {
                        connector.setKeystore(props.getProperty("keystore").value);
                    }
                    if (props.getProperty("password") != null) {
                        connector.setPassword(props.getProperty("password").value);
                    }
                    if (props.getProperty("key-password") != null) {
                        connector.setKeyPassword(props.getProperty("key-password").value);
                    }
                    if (props.getProperty("need-client-auth") != null) {
                        boolean needClientAuth = "true".equalsIgnoreCase(props.getProperty("need-client-auth").value);
                        connector.setNeedClientAuth(needClientAuth);
                    }

                    server.addConnector(connector);

                } else if ("ajp13".equals(props.getProperty("type").value)) {

                    AbstractConnector connector = new Ajp13SocketConnector();
                    setConnectorOptions(connector, props);
                    server.addConnector(connector);
                }

            } else if ("request-log".equals(props.value)) {

                RequestLogHandler requestLogHandler = new RequestLogHandler();

                NCSARequestLog requestLog = new NCSARequestLog();

                if (props.getProperty("filename") != null) {
                    requestLog.setFilename(props.getProperty("filename").value);
                }

                if (props.getProperty("append") != null) {
                    requestLog.setAppend("true".equalsIgnoreCase(props.getProperty("append").value));
                }

                if (props.getProperty("extended") != null) {
                    requestLog.setExtended("true".equalsIgnoreCase(props.getProperty("extended").value));
                }

                if (props.getProperty("timezone") != null) {
                    requestLog.setLogTimeZone(props.getProperty("timezone").value);
                }

                if (props.getProperty("date-format") != null) {
                    requestLog.setLogDateFormat(props.getProperty("date-format").value);
                }

                if (props.getProperty("retain-days") != null) {
                    int days = 90;
                    try {
                        days = Integer.parseInt(props.getProperty("retain-days").value);
                    } catch (NumberFormatException e) {
                        days = 90;
                    }
                    requestLog.setRetainDays(days);
                }

                requestLogHandler.setRequestLog(requestLog);
                server.addHandler(requestLogHandler);
            }
        }

        return server;
    }
View Full Code Here

    private final Server server;

    public ServerTestFixture( final int port )
        throws Exception
    {
        server = new Server();

        Connector connector = new SelectChannelConnector();
        connector.setPort( port );

        server.setConnectors( new Connector[]{ connector } );
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.