Package com.sun.enterprise.web.connector.coyote

Examples of com.sun.enterprise.web.connector.coyote.PECoyoteConnector


        _logger.log(Level.FINE,"Creating connector for address='" +
                  ((address == null) ? "ALL" : address) +
                  "' port='" + port + "' protocol='" + protocol + "'");

        PECoyoteConnector connector = new PECoyoteConnector();

        if (address != null) {
            connector.setAddress(address);
        }

        connector.setPort(port);

        if (protocol.equals("ajp")) {
            connector.setProtocolHandlerClassName(
                 "org.apache.jk.server.JkCoyoteHandler");
        } else if (protocol.equals("memory")) {
            connector.setProtocolHandlerClassName(
                 "org.apache.coyote.memory.MemoryProtocolHandler");
        } else if (protocol.equals("https")) {
            connector.setScheme("https");
            connector.setSecure(true);
        }

        return (connector);

    }
View Full Code Here


     */      
    public PECoyoteConnector createConnector(HttpListener httpListener,
                                             HttpService httpService){
                                
        int port = 8080;
        PECoyoteConnector connector;
       
        checkHostnameUniqueness(httpListener.getId(), httpService);

        try {
            port = Integer.parseInt(httpListener.getPort());
        } catch (NumberFormatException nfe) {
            String msg = _rb.getString("pewebcontainer.http_listener.invalid_port");
            msg = MessageFormat.format(msg,
                                       new Object[] {httpListener.getPort(),
                                       httpListener.getId() });
            throw new IllegalArgumentException(msg);
        }

        /*
         * Create Connector. Connector is SSL-enabled if
         * 'security-enabled' attribute in <http-listener>
         * element is set to TRUE.
         */
        boolean isSecure = httpListener.isSecurityEnabled();
        if (isSecure && defaultRedirectPort == -1) {
            defaultRedirectPort = port;
        }
        String address = httpListener.getAddress();
        if ("any".equals(address) || "ANY".equals(address)
                || "INADDR_ANY".equals(address)) {
            address = null;
            /*
             * Setting 'address' to NULL will cause Tomcat to pass a
             * NULL InetAddress argument to the java.net.ServerSocket
             * constructor, meaning that the server socket will accept
             * connections on any/all local addresses.
             */
        }

        connector =
            (PECoyoteConnector)_embedded.createConnector(address,port,
                                                         isSecure);
        connector.setName(httpListener.getId());

        configureConnector(connector,httpListener,isSecure,httpService);

        if ( _logger.isLoggable(Level.FINE)){
            _logger.log(Level.FINE, "create.listenerport",
                new Object[] {Integer.valueOf(port), connector});
        }

        _embedded.addConnector(connector);

        connectorMap.put(httpListener.getId(), connector);      

        // If we already know the redirect port, then set it now
        // This situation will occurs when dynamic reconfiguration occurs
        if ( defaultRedirectPort != -1 ){
            connector.setRedirectPort(defaultRedirectPort);
        }

        return connector;
    }
View Full Code Here

        ArrayList<Integer> portsList = new ArrayList();
      
        for (int i=0; i < httpListeners.length; i++){
            if (httpListeners[i].isEnabled()){
                PECoyoteConnector conn = connectorMap.get(
                    httpListeners[i].getId());
                if (conn != null) {
                    portsList.add(Integer.valueOf(conn.getPort()));
                }
            } else {
                if ((vs.getName().equalsIgnoreCase(VirtualServer.ADMIN_VS))) {
                    String msg = _rb.getString(
                        "pewebcontainer.httpListener.mustNotDisable");
View Full Code Here

            }
            if (!found) {
                // http listener was removed
                Connector[] connectors = _embedded.findConnectors();
                for (int k=0; k<connectors.length; k++) {
                    PECoyoteConnector conn = (PECoyoteConnector)
                        connectors[k];
                    if (oldPorts[i] == conn.getPort()) {
                        try {
                            conn.getMapperListener().unregisterHost(
                                virtualServer.getJmxName());
                        } catch (Exception e) {
                            throw new LifecycleException(e);
                        }
                    }
                }
            }
        }

        // Associate the virtual server with all http listeners that
        // have been added to its "http-listeners" attribute, or, in case
        // the virtual server's "hosts" attribute has changed, with all
        // listeners specified in its "http-listeners" attribute.
        for (int i=0; i<newPorts.length; i++) {
            boolean found = false;
            for (int j=0; j<oldPorts.length; j++) {
                if (newPorts[i] == oldPorts[j]) {
                    found = true;
                }
            }
            if (!found || doAliasesDiffer) {
                // http listener was added, or "hosts" attribute has changed
                Connector[] connectors = _embedded.findConnectors();
                for (int k=0; k<connectors.length; k++) {
                    PECoyoteConnector conn = (PECoyoteConnector)
                        connectors[k];
                    if (newPorts[i] == conn.getPort()) {
                        if (!conn.isAvailable()){
                            conn.start();
                            enableHttpListenerMonitoring(
                                virtualServer,
                                conn.getPort(),
                                conn.getName());
                        }
                        if (found) {
                            // Unregister virtual server from old
                            // http-listener (since its "hosts" attribute has
                            // changed), before registering it again to have
                            // its new "hosts" attribute reflected
                            try {
                                conn.getMapperListener().unregisterHost(
                                    virtualServer.getJmxName());
                            } catch (Exception e) {
                                throw new LifecycleException(e);
                            }
                        }
                        virtualServer.registerWith(conn.getMapperListener());
                    }
                }
            }
        }
View Full Code Here

    public void updateConnectorProperty(HttpListener httpListener,
                                        String propName,
                                        String propValue)
        throws LifecycleException{
      
        PECoyoteConnector connector = connectorMap.get(httpListener.getId());
        if (connector != null) {
            configureHttpListenerProperty(propName,propValue,connector);
        }
    }
View Full Code Here

        if (httpListener.getDefaultVirtualServer()
                                    .equals(VirtualServer.ADMIN_VS)){
            return;
        }
       
        PECoyoteConnector connector = connectorMap.get(httpListener.getId());
        if (connector != null) {
            _embedded.removeConnector(connector);
            connectorMap.remove(httpListener.getId());
        }

        if (!httpListener.isEnabled()) {
            return;
        }

        connector = createConnector(httpListener, httpService);

        // Update the list of ports of all associated virtual servers with
        // the listener's new port number, so that the associated virtual
        // servers will be registered with the listener's request mapper when
        // the listener is started
        ArrayList<VirtualServer> virtualServers =
            getVirtualServersForHttpListenerId(httpService,
                                               httpListener.getId());
        if (virtualServers != null) {
            Mapper mapper = connector.getMapper();

            Server serverBean = null;
            try {
                serverBean = ServerBeansFactory.getServerBean(configContext);
            } catch (ConfigException e) {
                _logger.log(Level.SEVERE, "webcontainer.configError", e);
            }      

            for (Iterator<VirtualServer> it = virtualServers.iterator();
                                                    it.hasNext(); ) {
                VirtualServer vs = it.next();
                boolean found = false;
                int[] ports = vs.getPorts();
                for (int i=0; i<ports.length; i++) {
                    if (ports[i] == connector.getPort()) {
                        found = true;
                        break;
                    }
                }
                if (!found) {
                    int[] newPorts = new int[ports.length + 1];
                    System.arraycopy(ports, 0, newPorts, 0, ports.length);
                    newPorts[ports.length] = connector.getPort();
                    vs.setPorts(newPorts);
                }

                // Check if virtual server has default-web-module configured,
                // and if so, configure the http listener's mapper with this
                // information
                String defaultWebModulePath = vs.getDefaultContextPath(serverBean);
                if (defaultWebModulePath != null) {
                    try {
                        mapper.setDefaultContextPath(vs.getName(),
                                                     defaultWebModulePath);
                        vs.setDefaultContextPath(defaultWebModulePath);
                    } catch (Exception e) {
                        throw new LifecycleException(e);
                    }
                }
            }       
        }

        connector.start();
    }
View Full Code Here

            defaultContextPath = "/" + defaultContextPath;
        }

        Connector[] connectors = _embedded.findConnectors();
        for (int i=0; i<connectors.length; i++) {
            PECoyoteConnector conn = (PECoyoteConnector) connectors[i];
            int port = conn.getPort();
            for (int j=0; j<ports.length; j++) {
                if (port == ports[j]) {
                    Mapper mapper = conn.getMapper();
                    try {
                        mapper.setDefaultContextPath(virtualServer.getName(),
                                                     defaultContextPath);
                        virtualServer.setDefaultContextPath(defaultContextPath);
                    } catch (Exception e) {
View Full Code Here

            wmInfo.getDescriptor().setContextRoot(defaultContextPath);
        }

        Connector[] connectors = _embedded.findConnectors();
        for (Connector connector : connectors) {
            PECoyoteConnector conn = (PECoyoteConnector) connector;
            String name = conn.getName();
            for (String listenerName : listenerNames) {
                if (name.equals(listenerName)) {
                    Mapper mapper = conn.getMapper();
                    try {
                        mapper.setDefaultContextPath(virtualServer.getName(),
                                defaultContextPath);
                        for (String alias : virtualServer.findAliases()) {
                            mapper.setDefaultContextPath(alias,
View Full Code Here

            wmInfo.getDescriptor().setContextRoot(defaultContextPath);
        }

        Connector[] connectors = _embedded.findConnectors();
        for (Connector connector : connectors) {
            PECoyoteConnector conn = (PECoyoteConnector) connector;
            String name = conn.getName();
            for (String listenerName : listenerNames) {
                if (name.equals(listenerName)) {
                    Mapper mapper = conn.getMapper();
                    try {
                        mapper.setDefaultContextPath(virtualServer.getName(),
                                defaultContextPath);
                        for (String alias : virtualServer.findAliases()) {
                            mapper.setDefaultContextPath(alias,
View Full Code Here

            wmInfo.getDescriptor().setContextRoot(defaultContextPath);
        }

        Connector[] connectors = _embedded.findConnectors();
        for (Connector connector : connectors) {
            PECoyoteConnector conn = (PECoyoteConnector) connector;
            String name = conn.getName();
            for (String listenerName : listenerNames) {
                if (name.equals(listenerName)) {
                    Mapper mapper = conn.getMapper();
                    try {
                        mapper.setDefaultContextPath(virtualServer.getName(),
                                defaultContextPath);
                        for (String alias : virtualServer.findAliases()) {
                            mapper.setDefaultContextPath(alias,
View Full Code Here

TOP

Related Classes of com.sun.enterprise.web.connector.coyote.PECoyoteConnector

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.