Search in sources :

Example 16 with NetworkListeners

use of org.glassfish.grizzly.config.dom.NetworkListeners in project Payara by payara.

the class WebContainerImpl method removeListener.

private void removeListener(String name) {
    try {
        NetworkListeners networkListeners = networkConfig.getNetworkListeners();
        final NetworkListener listenerToBeRemoved = networkConfig.getNetworkListener(name);
        final Protocols protocols = networkConfig.getProtocols();
        final Protocol protocol = networkConfig.findProtocol(name);
        if (listenerToBeRemoved == null) {
            log.severe("Network Listener " + name + " doesn't exist");
        } else {
            final com.sun.enterprise.config.serverbeans.VirtualServer virtualServer = httpService.getVirtualServerByName(listenerToBeRemoved.findHttpProtocol().getHttp().getDefaultVirtualServer());
            ConfigSupport.apply(new ConfigCode() {

                public Object run(ConfigBeanProxy... params) throws PropertyVetoException {
                    final NetworkListeners listeners = (NetworkListeners) params[0];
                    final com.sun.enterprise.config.serverbeans.VirtualServer server = (com.sun.enterprise.config.serverbeans.VirtualServer) params[1];
                    listeners.getNetworkListener().remove(listenerToBeRemoved);
                    server.removeNetworkListener(listenerToBeRemoved.getName());
                    return listenerToBeRemoved;
                }
            }, networkListeners, virtualServer);
            ConfigSupport.apply(new ConfigCode() {

                public Object run(ConfigBeanProxy... params) throws PropertyVetoException {
                    final Protocols protocols = (Protocols) params[0];
                    final Protocol protocol = (Protocol) params[1];
                    protocols.getProtocol().remove(protocol);
                    return protocol;
                }
            }, protocols, protocol);
        }
    } catch (TransactionFailure e) {
        log.severe("Remove listener " + name + " failed " + e.getMessage());
    }
}
Also used : Protocols(org.glassfish.grizzly.config.dom.Protocols) VirtualServer(org.glassfish.embeddable.web.VirtualServer) PropertyVetoException(java.beans.PropertyVetoException) NetworkListeners(org.glassfish.grizzly.config.dom.NetworkListeners) Protocol(org.glassfish.grizzly.config.dom.Protocol) org.jvnet.hk2.config(org.jvnet.hk2.config) NetworkListener(org.glassfish.grizzly.config.dom.NetworkListener)

Aggregations

NetworkListeners (org.glassfish.grizzly.config.dom.NetworkListeners)16 NetworkListener (org.glassfish.grizzly.config.dom.NetworkListener)12 NetworkConfig (org.glassfish.grizzly.config.dom.NetworkConfig)5 Protocol (org.glassfish.grizzly.config.dom.Protocol)5 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)5 Config (com.sun.enterprise.config.serverbeans.Config)4 PropertyVetoException (java.beans.PropertyVetoException)4 Protocols (org.glassfish.grizzly.config.dom.Protocols)3 Test (org.junit.Test)3 ConfigBeanProxy (org.jvnet.hk2.config.ConfigBeanProxy)3 ObservableBean (org.jvnet.hk2.config.ObservableBean)3 ActionReport (org.glassfish.api.ActionReport)2 CommandTarget (org.glassfish.config.support.CommandTarget)2 VirtualServer (org.glassfish.embeddable.web.VirtualServer)2 ThreadPool (org.glassfish.grizzly.config.dom.ThreadPool)2 Transport (org.glassfish.grizzly.config.dom.Transport)2 Target (org.glassfish.internal.api.Target)2 org.jvnet.hk2.config (org.jvnet.hk2.config)2 ConfigBean (org.jvnet.hk2.config.ConfigBean)2 ConfigCode (org.jvnet.hk2.config.ConfigCode)2