Package org.eclipse.jetty.server

Examples of org.eclipse.jetty.server.Connector


        String connectorKey = getConnectorKey(endpoint);

        synchronized (CONNECTORS) {
            ConnectorRef connectorRef = CONNECTORS.get(connectorKey);
            if (connectorRef == null) {
                Connector connector;
                if ("https".equals(endpoint.getProtocol())) {
                    connector = getSslSocketConnector(endpoint);
                } else {
                    connector = getSocketConnector(endpoint.getPort());
                }
                connector.setPort(endpoint.getPort());
                connector.setHost(endpoint.getHttpUri().getHost());
                if ("localhost".equalsIgnoreCase(endpoint.getHttpUri().getHost())) {
                    LOG.warn("You use localhost interface! It means that no external connections will be available."
                            + " Don't you want to use 0.0.0.0 instead (all network interfaces)? " + endpoint);
                }
                Server server = createServer();
View Full Code Here


        String connectorKey = getConnectorKey(endpoint);

        synchronized (CONNECTORS) {
            ConnectorRef connectorRef = CONNECTORS.get(connectorKey);
            if (connectorRef == null) {
                Connector connector;
                if (endpoint.getSslContextParameters() != null) {
                    connector = getSslSocketConnector(endpoint.getSslContextParameters());
                } else {
                    connector = new SelectChannelConnector();
                }

                LOG.trace("Jetty Connector added: {}", connector.getName());

                if (endpoint.getPort() != null) {
                    connector.setPort(endpoint.getPort());
                } else {
                    connector.setPort(port);
                }

                if (endpoint.getHost() != null) {
                    connector.setHost(endpoint.getHost());
                } else {
                    connector.setHost(host);
                }

                // Create Server and add connector
                server = createServer();
                if (endpoint.isEnableJmx()) {
                    enableJmx(server);
                }
                server.addConnector(connector);

                // Create ServletContextHandler
                ServletContextHandler context = createContext(server, connector, endpoint.getHandlers());
                // setup the WebSocketComponentServlet initial parameters
                setWebSocketComponentServletInitialParameter(context, endpoint);
                server.setHandler(context);

                // Apply CORS (http://www.w3.org/TR/cors/)
                applyCrossOriginFiltering(endpoint, context);

                // Create Static resources
                if (endpoint.getStaticResources() != null) {
                    server = createStaticResourcesServer(server, context, endpoint.getStaticResources());
                }

                // Don't provide a Servlet object as Producer/Consumer will create them later on
                connectorRef = new ConnectorRef(server, connector, null);

                // must enable session before we start
                if (endpoint.isSessionSupport()) {
                    enableSessionSupport(connectorRef.server, connectorKey);
                }
                LOG.info("Jetty Server starting on host: {}:{}", connector.getHost(), connector.getPort());
                connectorRef.server.start();

                CONNECTORS.put(connectorKey, connectorRef);

            } else {
View Full Code Here

        return server;
    }

    protected Server createStaticResourcesServer(ServletContextHandler context, String host, int port, String home) throws Exception {
        Server server = new Server();
        Connector connector = new SelectChannelConnector();
        connector.setHost(host);
        connector.setPort(port);
        server.addConnector(connector);
        return createStaticResourcesServer(server, context, home);
    }
View Full Code Here

            LOG.info("Starting static resources server {}:{} with static resource: {}", new Object[]{host, port, staticResources});
            ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
            staticResourcesServer = createStaticResourcesServer(context, host, port, staticResources);
            staticResourcesServer.start();
            Connector connector = staticResourcesServer.getConnectors()[0];

            // must add static resource server to CONNECTORS in case the websocket producers/consumers
            // uses the same port number, and therefore we must be part of this
            ConnectorRef ref = new ConnectorRef(staticResourcesServer, connector, null);
            String key = "websocket:" + host + ":" + port;
View Full Code Here

        String connectorKey = getConnectorKey(endpoint);

        synchronized (CONNECTORS) {
            ConnectorRef connectorRef = CONNECTORS.get(connectorKey);
            if (connectorRef == null) {
                Connector connector;
                if (endpoint.getSslContextParameters() != null) {
                    connector = getSslSocketConnector(endpoint.getSslContextParameters());
                } else {
                    connector = new SelectChannelConnector();
                }

                LOG.trace("Jetty Connector added: {}", connector.getName());

                if (endpoint.getPort() != null) {
                    connector.setPort(endpoint.getPort());
                } else {
                    connector.setPort(port);
                }

                if (endpoint.getHost() != null) {
                    connector.setHost(endpoint.getHost());
                } else {
                    connector.setHost(host);
                }

                // Create Server and add connector
                server = createServer();
                if (endpoint.isEnableJmx()) {
                    enableJmx(server);
                }
                server.addConnector(connector);

                // Create ServletContextHandler
                ServletContextHandler context = createContext(server, connector, endpoint.getHandlers());
                // setup the WebSocketComponentServlet initial parameters
                setWebSocketComponentServletInitialParameter(context, endpoint);
                server.setHandler(context);

                // Apply CORS (http://www.w3.org/TR/cors/)
                applyCrossOriginFiltering(endpoint, context);

                // Create Static resources
                if (endpoint.getStaticResources() != null) {
                    server = createStaticResourcesServer(server, context, endpoint.getStaticResources());
                }

                // Don't provide a Servlet object as Producer/Consumer will create them later on
                connectorRef = new ConnectorRef(server, connector, null);

                // must enable session before we start
                if (endpoint.isSessionSupport()) {
                    enableSessionSupport(connectorRef.server, connectorKey);
                }
                LOG.info("Jetty Server starting on host: {}:{}", connector.getHost(), connector.getPort());
                connectorRef.server.start();

                CONNECTORS.put(connectorKey, connectorRef);

            } else {
View Full Code Here

        return server;
    }

    protected Server createStaticResourcesServer(ServletContextHandler context, String host, int port, String home) throws Exception {
        Server server = new Server();
        Connector connector = new SelectChannelConnector();
        connector.setHost(host);
        connector.setPort(port);
        server.addConnector(connector);
        return createStaticResourcesServer(server, context, home);
    }
View Full Code Here

            LOG.info("Starting static resources server {}:{} with static resource: {}", new Object[]{host, port, staticResources});
            ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
            staticResourcesServer = createStaticResourcesServer(context, host, port, staticResources);
            staticResourcesServer.start();
            Connector connector = staticResourcesServer.getConnectors()[0];

            // must add static resource server to CONNECTORS in case the websocket producers/consumers
            // uses the same port number, and therefore we must be part of this
            ConnectorRef ref = new ConnectorRef(staticResourcesServer, connector, null);
            String key = "websocket:" + host + ":" + port;
View Full Code Here

        String connectorKey = getConnectorKey(endpoint);

        synchronized (CONNECTORS) {
            ConnectorRef connectorRef = CONNECTORS.get(connectorKey);
            if (connectorRef == null) {
                Connector connector;
                if ("https".equals(endpoint.getProtocol())) {
                    connector = getSslSocketConnector(endpoint);
                } else {
                    connector = getSocketConnector(endpoint.getPort());
                }
                connector.setPort(endpoint.getPort());
                connector.setHost(endpoint.getHttpUri().getHost());
                if ("localhost".equalsIgnoreCase(endpoint.getHttpUri().getHost())) {
                    LOG.warn("You use localhost interface! It means that no external connections will be available."
                            + " Don't you want to use 0.0.0.0 instead (all network interfaces)? " + endpoint);
                }
                Server server = createServer();
View Full Code Here

    public String getKeystore() {
        return sslKeystore;
    }

    protected Connector getSslSocketConnector(JettyHttpEndpoint endpoint) throws Exception {
        Connector answer = null;
        if (sslSocketConnectors != null) {
            answer = sslSocketConnectors.get(endpoint.getPort());
        }
        if (answer == null) {
            answer = createSslSocketConnector(endpoint);
View Full Code Here

    public void setSslSocketConnectors(Map <Integer, SslSelectChannelConnector> connectors) {
        sslSocketConnectors = connectors;
    }

    public Connector getSocketConnector(int port) throws Exception {
        Connector answer = null;
        if (socketConnectors != null) {
            answer = socketConnectors.get(port);
        }
        if (answer == null) {
            answer = createSocketConnector();
View Full Code Here

TOP

Related Classes of org.eclipse.jetty.server.Connector

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.