Package org.glassfish.embeddable.web

Examples of org.glassfish.embeddable.web.WebListener


    private void bind(Port port, WebListener webListener, String vsId) {

        String protocol = Port.HTTP_PROTOCOL;
        final int portNumber = port.getPortNumber();
        final String defaultVS = vsId;
        final WebListener listener = webListener;

        if (webListener == null) {
            listenerName = getListenerName();
            webListener = new HttpListener();
            webListener.setId(listenerName);
            webListener.setPort(portNumber);
        } else {
            listenerName = webListener.getId();
            protocol = webListener.getProtocol();
        }
        listeners.add(webListener);

        if (protocol.equals(Port.HTTP_PROTOCOL)) {
            securityEnabled = "false";
        } else if (protocol.equals(Port.HTTPS_PROTOCOL)) {
            securityEnabled = "true";
        }

        try {

            ConfigSupport.apply(new SingleConfigCode<Protocols>() {
                public Object run(Protocols param) throws TransactionFailure {
                    final Protocol protocol = param.createChild(Protocol.class);
                    protocol.setName(listenerName);
                    protocol.setSecurityEnabled(securityEnabled);
                    param.getProtocol().add(protocol);
                    final Http http = protocol.createChild(Http.class);
                    http.setDefaultVirtualServer(defaultVS);
                    http.setFileCache(http.createChild(FileCache.class));
                    protocol.setHttp(http);
                    return protocol;
                }
            }, networkConfig.getProtocols());

            ConfigSupport.apply(new ConfigCode() {
                public Object run(ConfigBeanProxy... params) throws TransactionFailure {
                    NetworkListeners nls = (NetworkListeners) params[0];
                    Transports transports = (Transports) params[1];
                    final NetworkListener listener = nls.createChild(NetworkListener.class);
                    listener.setName(listenerName);
                    listener.setPort(Integer.toString(portNumber));
                    listener.setProtocol(listenerName);
                    listener.setThreadPool("http-thread-pool");
                    if (listener.findThreadPool() == null) {
                        final ThreadPool pool = nls.createChild(ThreadPool.class);
                        pool.setName(listenerName);
                        listener.setThreadPool(listenerName);
                    }
                    listener.setTransport("tcp");
                    if (listener.findTransport() == null) {
                        final Transport transport = transports.createChild(Transport.class);
                        transport.setName(listenerName);
                        listener.setTransport(listenerName);
                    }
                    nls.getNetworkListener().add(listener);
                    return listener;
                }
            }, networkConfig.getNetworkListeners(), networkConfig.getTransports());
View Full Code Here


                vs = createVirtualServer(config.getVirtualServerId(), config.getDocRootDir());
                addVirtualServer(vs);

            }

            WebListener listener = getWebListener(config.getListenerName());
            if (listener == null) {
                listener = createWebListener(config.getListenerName(), HttpListener.class);
                listener.setPort(config.getPort());
                addWebListener(listener, config.getVirtualServerId());
            } else {
                if (listener.getPort() != config.getPort()) {
                    listener.setPort(config.getPort());
                }
            }

            EmbeddedWebArchivist archivist = habitat.getComponent(EmbeddedWebArchivist.class);
            archivist.setDefaultWebXml(config.getDefaultWebXml());
View Full Code Here

            EmbeddedWebArchivist archivist = habitat.getComponent(EmbeddedWebArchivist.class);
            archivist.setDefaultWebXml(config.getDefaultWebXml());

            embedded.setDirectoryListing(config.getListings());

            WebListener listener = getWebListener(config.getListenerName());
            if (listener == null) {
                listener = getWebListener(config.getPort());
                if (listener == null) {
                    boolean found = false;
                    for (Map.Entry entry : webContainer.getConnectorMap().entrySet()) {
                        if (((WebConnector)entry.getValue()).getPort() == config.getPort()) {
                            found = true;
                            log.info("Port "+config.getPort()+" is already configured");
                        }
                    }
                    if (!found) {
                        listener = createWebListener(config.getListenerName(), HttpListener.class);
                        listener.setPort(config.getPort());
                        addWebListener(listener, config.getVirtualServerId());
                    }
                }
            } else {
                if (listener.getPort() != config.getPort()) {
                    listener.setPort(config.getPort());
                }
            }

        }  catch (Exception ex) {
            ex.printStackTrace();
View Full Code Here

    private void bind(Port port, WebListener webListener, String vsId) {

        String protocol = Port.HTTP_PROTOCOL;
        final int portNumber = port.getPortNumber();
        final String defaultVS = vsId;
        final WebListener listener = webListener;

        if (webListener == null) {
            listenerName = getListenerName();
            webListener = new HttpListener();
            webListener.setId(listenerName);
            webListener.setPort(portNumber);
        } else {
            listenerName = webListener.getId();
            protocol = webListener.getProtocol();
        }
        listeners.add(webListener);

        if (protocol.equals(Port.HTTP_PROTOCOL)) {
            securityEnabled = "false";
        } else if (protocol.equals(Port.HTTPS_PROTOCOL)) {
            securityEnabled = "true";
        }

        try {

            ConfigSupport.apply(new SingleConfigCode<Protocols>() {
                public Object run(Protocols param) throws TransactionFailure {
                    final Protocol protocol = param.createChild(Protocol.class);
                    protocol.setName(listenerName);
                    protocol.setSecurityEnabled(securityEnabled);
                    param.getProtocol().add(protocol);
                    final Http http = protocol.createChild(Http.class);
                    http.setDefaultVirtualServer(defaultVS);
                    http.setFileCache(http.createChild(FileCache.class));
                    protocol.setHttp(http);
                    return protocol;
                }
            }, networkConfig.getProtocols());

            ConfigSupport.apply(new ConfigCode() {
                public Object run(ConfigBeanProxy... params) throws TransactionFailure {
                    NetworkListeners nls = (NetworkListeners) params[0];
                    Transports transports = (Transports) params[1];
                    final NetworkListener listener = nls.createChild(NetworkListener.class);
                    listener.setName(listenerName);
                    listener.setPort(Integer.toString(portNumber));
                    listener.setProtocol(listenerName);
                    listener.setThreadPool("http-thread-pool");
                    if (listener.findThreadPool() == null) {
                        final ThreadPool pool = nls.createChild(ThreadPool.class);
                        pool.setName(listenerName);
                        listener.setThreadPool(listenerName);
                    }
                    listener.setTransport("tcp");
                    if (listener.findTransport() == null) {
                        final Transport transport = transports.createChild(Transport.class);
                        transport.setName(listenerName);
                        listener.setTransport(listenerName);
                    }
                    nls.getNetworkListener().add(listener);
                    return listener;
                }
            }, networkConfig.getNetworkListeners(), networkConfig.getTransports());
View Full Code Here

    private void bind(Port port, WebListener webListener, String vsId) {

        String protocol = Port.HTTP_PROTOCOL;
        final int portNumber = port.getPortNumber();
        final String defaultVS = vsId;
        final WebListener listener = webListener;

        if (webListener == null) {
            listenerName = getListenerName();
            webListener = new HttpListener();
            webListener.setId(listenerName);
            webListener.setPort(portNumber);
        } else {
            listenerName = webListener.getId();
            protocol = webListener.getProtocol();
        }
        listeners.add(webListener);

        if (protocol.equals(Port.HTTP_PROTOCOL)) {
            securityEnabled = "false";
        } else if (protocol.equals(Port.HTTPS_PROTOCOL)) {
            securityEnabled = "true";
        }

        try {

            ConfigSupport.apply(new SingleConfigCode<Protocols>() {
                public Object run(Protocols param) throws TransactionFailure {
                    final Protocol protocol = param.createChild(Protocol.class);
                    protocol.setName(listenerName);
                    protocol.setSecurityEnabled(securityEnabled);
                    param.getProtocol().add(protocol);
                    final Http http = protocol.createChild(Http.class);
                    http.setDefaultVirtualServer(defaultVS);
                    http.setFileCache(http.createChild(FileCache.class));
                    protocol.setHttp(http);
                    return protocol;
                }
            }, networkConfig.getProtocols());

            ConfigSupport.apply(new ConfigCode() {
                public Object run(ConfigBeanProxy... params) throws TransactionFailure {
                    NetworkListeners nls = (NetworkListeners) params[0];
                    Transports transports = (Transports) params[1];
                    final NetworkListener listener = nls.createChild(NetworkListener.class);
                    listener.setName(listenerName);
                    listener.setPort(Integer.toString(portNumber));
                    listener.setProtocol(listenerName);
                    listener.setThreadPool("http-thread-pool");
                    if (listener.findThreadPool() == null) {
                        final ThreadPool pool = nls.createChild(ThreadPool.class);
                        pool.setName(listenerName);
                        listener.setThreadPool(listenerName);
                    }
                    listener.setTransport("tcp");
                    if (listener.findTransport() == null) {
                        final Transport transport = transports.createChild(Transport.class);
                        transport.setName(listenerName);
                        listener.setTransport(listenerName);
                    }
                    nls.getNetworkListener().add(listener);
                    return listener;
                }
            }, networkConfig.getNetworkListeners(), networkConfig.getTransports());
View Full Code Here

                vs = createVirtualServer(config.getVirtualServerId(), config.getDocRootDir());
                addVirtualServer(vs);

            }

            WebListener listener = getWebListener(config.getListenerName());
            if (listener == null) {
                listener = createWebListener(config.getListenerName(), HttpListener.class);
                listener.setPort(config.getPort());
                addWebListener(listener, config.getVirtualServerId());
            } else {
                if (listener.getPort() != config.getPort()) {
                    listener.setPort(config.getPort());
                }
            }

            EmbeddedWebArchivist archivist = habitat.getComponent(EmbeddedWebArchivist.class);
            archivist.setDefaultWebXml(config.getDefaultWebXml());
View Full Code Here

    private void bind(Port port, WebListener webListener, String vsId) {

        String protocol = Port.HTTP_PROTOCOL;
        final int portNumber = port.getPortNumber();
        final String defaultVS = vsId;
        final WebListener listener = webListener;

        if (webListener == null) {
            listenerName = getListenerName();
            webListener = new HttpListener();
            webListener.setId(listenerName);
            webListener.setPort(portNumber);
        } else {
            listenerName = webListener.getId();
            protocol = webListener.getProtocol();
        }
        listeners.add(webListener);

        if (protocol.equals(Port.HTTP_PROTOCOL)) {
            securityEnabled = "false";
        } else if (protocol.equals(Port.HTTPS_PROTOCOL)) {
            securityEnabled = "true";
        }

        try {

            ConfigSupport.apply(new SingleConfigCode<Protocols>() {
                public Object run(Protocols param) throws TransactionFailure {
                    final Protocol protocol = param.createChild(Protocol.class);
                    protocol.setName(listenerName);
                    protocol.setSecurityEnabled(securityEnabled);
                    param.getProtocol().add(protocol);
                    final Http http = protocol.createChild(Http.class);
                    http.setDefaultVirtualServer(defaultVS);
                    http.setFileCache(http.createChild(FileCache.class));
                    protocol.setHttp(http);
                    return protocol;
                }
            }, networkConfig.getProtocols());

            ConfigSupport.apply(new ConfigCode() {
                public Object run(ConfigBeanProxy... params) throws TransactionFailure {
                    NetworkListeners nls = (NetworkListeners) params[0];
                    Transports transports = (Transports) params[1];
                    final NetworkListener listener = nls.createChild(NetworkListener.class);
                    listener.setName(listenerName);
                    listener.setPort(Integer.toString(portNumber));
                    listener.setProtocol(listenerName);
                    listener.setThreadPool("http-thread-pool");
                    if (listener.findThreadPool() == null) {
                        final ThreadPool pool = nls.createChild(ThreadPool.class);
                        pool.setName(listenerName);
                        listener.setThreadPool(listenerName);
                    }
                    listener.setTransport("tcp");
                    if (listener.findTransport() == null) {
                        final Transport transport = transports.createChild(Transport.class);
                        transport.setName(listenerName);
                        listener.setTransport(listenerName);
                    }
                    nls.getNetworkListener().add(listener);
                    return listener;
                }
            }, networkConfig.getNetworkListeners(), networkConfig.getTransports());
View Full Code Here

            EmbeddedWebArchivist archivist = habitat.getComponent(EmbeddedWebArchivist.class);
            archivist.setDefaultWebXml(config.getDefaultWebXml());

            embedded.setDirectoryListing(config.getListings());

            WebListener listener = getWebListener(config.getListenerName());
            if (listener == null) {
                listener = getWebListener(config.getPort());
                if (listener == null) {
                    boolean found = false;
                    for (Map.Entry entry : webContainer.getConnectorMap().entrySet()) {
                        if (((WebConnector)entry.getValue()).getPort() == config.getPort()) {
                            found = true;
                            log.info("Port "+config.getPort()+" is already configured");
                        }
                    }
                    if (!found) {
                        listener = createWebListener(config.getListenerName(), HttpListener.class);
                        listener.setPort(config.getPort());
                        addWebListener(listener, config.getVirtualServerId());
                    }
                }
            } else {
                if (listener.getPort() != config.getPort()) {
                    listener.setPort(config.getPort());
                }
            }

        }  catch (Exception ex) {
            ex.printStackTrace();
View Full Code Here

    private void bind(Port port, WebListener webListener, String vsId) {

        String protocol = Port.HTTP_PROTOCOL;
        final int portNumber = port.getPortNumber();
        final String defaultVS = vsId;
        final WebListener listener = webListener;

        if (webListener == null) {
            listenerName = getListenerName();
            webListener = new HttpListener();
            webListener.setId(listenerName);
            webListener.setPort(portNumber);
        } else {
            listenerName = webListener.getId();
            protocol = webListener.getProtocol();
        }
        listeners.add(webListener);

        if (protocol.equals(Port.HTTP_PROTOCOL)) {
            securityEnabled = "false";
        } else if (protocol.equals(Port.HTTPS_PROTOCOL)) {
            securityEnabled = "true";
        }

        try {

            ConfigSupport.apply(new SingleConfigCode<Protocols>() {
                public Object run(Protocols param) throws TransactionFailure {
                    final Protocol protocol = param.createChild(Protocol.class);
                    protocol.setName(listenerName);
                    protocol.setSecurityEnabled(securityEnabled);
                    param.getProtocol().add(protocol);
                    final Http http = protocol.createChild(Http.class);
                    http.setDefaultVirtualServer(defaultVS);
                    http.setFileCache(http.createChild(FileCache.class));
                    protocol.setHttp(http);
                    return protocol;
                }
            }, networkConfig.getProtocols());

            ConfigSupport.apply(new ConfigCode() {
                public Object run(ConfigBeanProxy... params) throws TransactionFailure {
                    NetworkListeners nls = (NetworkListeners) params[0];
                    Transports transports = (Transports) params[1];
                    final NetworkListener listener = nls.createChild(NetworkListener.class);
                    listener.setName(listenerName);
                    listener.setPort(Integer.toString(portNumber));
                    listener.setProtocol(listenerName);
                    listener.setThreadPool("http-thread-pool");
                    if (listener.findThreadPool() == null) {
                        final ThreadPool pool = nls.createChild(ThreadPool.class);
                        pool.setName(listenerName);
                        listener.setThreadPool(listenerName);
                    }
                    listener.setTransport("tcp");
                    if (listener.findTransport() == null) {
                        final Transport transport = transports.createChild(Transport.class);
                        transport.setName(listenerName);
                        listener.setTransport(listenerName);
                    }
                    nls.getNetworkListener().add(listener);
                    return listener;
                }
            }, networkConfig.getNetworkListeners(), networkConfig.getTransports());
View Full Code Here

            EmbeddedWebArchivist archivist = habitat.<EmbeddedWebArchivist>getService(EmbeddedWebArchivist.class);
            archivist.setDefaultWebXml(config.getDefaultWebXml());

            embedded.setDirectoryListing(config.getListings());

            WebListener listener = getWebListener(config.getListenerName());
            if (listener == null) {
                listener = getWebListener(config.getPort());
                if (listener == null) {
                    boolean found = false;
                    for (Map.Entry entry : webContainer.getConnectorMap().entrySet()) {
                        if (((WebConnector)entry.getValue()).getPort() == config.getPort()) {
                            found = true;
                            log.info("Port "+config.getPort()+" is already configured");
                        }
                    }
                    if (!found) {
                        listener = createWebListener(config.getListenerName(), HttpListener.class);
                        listener.setPort(config.getPort());
                        addWebListener(listener, config.getVirtualServerId());
                    }
                }
            } else {
                if (listener.getPort() != config.getPort()) {
                    listener.setPort(config.getPort());
                }
            }

        }  catch (Exception ex) {
            ex.printStackTrace();
View Full Code Here

TOP

Related Classes of org.glassfish.embeddable.web.WebListener

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.