Search in sources :

Example 56 with NetworkListener

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

the class GrizzlyConfig method setupNetwork.

public void setupNetwork() throws IOException {
    validateConfig(config);
    synchronized (listeners) {
        for (final NetworkListener listener : config.getNetworkListeners().getNetworkListener()) {
            final GenericGrizzlyListener grizzlyListener = new GenericGrizzlyListener();
            grizzlyListener.configure(serviceLocator, listener);
            listeners.add(grizzlyListener);
            try {
                grizzlyListener.start();
            } catch (IOException e) {
                LOGGER.log(Level.SEVERE, e.getMessage(), e);
            }
        }
    }
}
Also used : IOException(java.io.IOException) NetworkListener(org.glassfish.grizzly.config.dom.NetworkListener)

Example 57 with NetworkListener

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

the class SSLConfigurator method logEmptyWarning.

protected void logEmptyWarning(Ssl ssl, final String msg) {
    final StringBuilder name = new StringBuilder();
    for (NetworkListener listener : ((Protocol) ssl.getParent()).findNetworkListeners()) {
        if (name.length() != 0) {
            name.append(", ");
        }
        name.append(listener.getName());
    }
    LOGGER.log(Level.FINE, msg, name.toString());
}
Also used : Protocol(org.glassfish.grizzly.config.dom.Protocol) NetworkListener(org.glassfish.grizzly.config.dom.NetworkListener)

Example 58 with NetworkListener

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

the class SecureAdminConfigUpgrade method prepareDASConfig.

private void prepareDASConfig() throws TransactionFailure, PropertyVetoException {
    final Config dasConfig = writableConfig(configs.getConfigByName(DAS_CONFIG_NAME));
    final NetworkConfig nc = dasConfig.getNetworkConfig();
    final NetworkListener nl_w = transaction().enroll(nc.getNetworkListener(SecureAdminCommand.ADMIN_LISTENER_NAME));
    nl_w.setProtocol(SecureAdminCommand.ADMIN_LISTENER_NAME);
}
Also used : Config(com.sun.enterprise.config.serverbeans.Config) NetworkConfig(org.glassfish.grizzly.config.dom.NetworkConfig) NetworkConfig(org.glassfish.grizzly.config.dom.NetworkConfig) NetworkListener(org.glassfish.grizzly.config.dom.NetworkListener)

Example 59 with NetworkListener

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

the class GrizzlyConfigTest method references.

@Test
public void references() throws IOException {
    GrizzlyConfig grizzlyConfig = null;
    try {
        grizzlyConfig = new GrizzlyConfig("grizzly-config.xml");
        final List<NetworkListener> list = grizzlyConfig.getConfig().getNetworkListeners().getNetworkListener();
        final NetworkListener listener = list.get(0);
        boolean found = false;
        for (NetworkListener ref : listener.findProtocol().findNetworkListeners()) {
            found |= ref.getName().equals(listener.getName());
        }
        assertTrue("Should find the NetworkListener in the list of references from Protocol", found);
        found = false;
        for (NetworkListener ref : listener.findTransport().findNetworkListeners()) {
            found |= ref.getName().equals(listener.getName());
        }
        assertTrue("Should find the NetworkListener in the list of references from Transport", found);
        found = false;
        for (NetworkListener ref : listener.findThreadPool().findNetworkListeners()) {
            found |= ref.getName().equals(listener.getName());
        }
        assertTrue("Should find the NetworkListener in the list of references from ThreadPool", found);
    } finally {
        if (grizzlyConfig != null) {
            grizzlyConfig.shutdown();
        }
    }
}
Also used : NetworkListener(org.glassfish.grizzly.config.dom.NetworkListener) Test(org.junit.Test)

Example 60 with NetworkListener

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

the class MetroContainer method getHttpPort.

/**
 * Get the http/https port number for the default virtual server of this server instance.
 * <p/>
 * If the 'secure' parameter is true, then return the secure http listener port, otherwise
 * return the non-secure http listener port.
 *
 * @param secure true if you want the secure port, false if you want the non-secure port
 * @return the port or null if there was an error retrieving it.
 */
private String getHttpPort(boolean secure, String serverName, Config config) {
    try {
        final String networkListeners = config.getHttpService().getVirtualServerByName(serverName).getNetworkListeners();
        if (networkListeners == null || networkListeners.isEmpty()) {
            return null;
        }
        final String[] networkListenerNames = networkListeners.split(",");
        for (String listenerName : networkListenerNames) {
            if (listenerName == null || listenerName.isEmpty()) {
                continue;
            }
            NetworkListener listener = config.getNetworkConfig().getNetworkListener(listenerName.trim());
            if (secure == Boolean.valueOf(listener.findHttpProtocol().getSecurityEnabled())) {
                return listener.getPort();
            }
        }
    } catch (Throwable t) {
        // error condition handled in wsit code
        if (logger.isLoggable(Level.FINEST)) {
            logger.log(Level.FINEST, LogUtils.WSTX_SERVICE_PORT_CONFIGURATION_EXCEPTION, t);
        }
    }
    return null;
}
Also used : NetworkListener(org.glassfish.grizzly.config.dom.NetworkListener)

Aggregations

NetworkListener (org.glassfish.grizzly.config.dom.NetworkListener)74 NetworkConfig (org.glassfish.grizzly.config.dom.NetworkConfig)21 Protocol (org.glassfish.grizzly.config.dom.Protocol)18 Config (com.sun.enterprise.config.serverbeans.Config)17 NetworkListeners (org.glassfish.grizzly.config.dom.NetworkListeners)14 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)12 Test (org.junit.Test)11 ActionReport (org.glassfish.api.ActionReport)10 CommandTarget (org.glassfish.config.support.CommandTarget)9 Target (org.glassfish.internal.api.Target)9 VirtualServer (com.sun.enterprise.config.serverbeans.VirtualServer)8 HttpService (com.sun.enterprise.config.serverbeans.HttpService)7 ArrayList (java.util.ArrayList)7 Protocols (org.glassfish.grizzly.config.dom.Protocols)7 ObservableBean (org.jvnet.hk2.config.ObservableBean)7 Transactions (org.jvnet.hk2.config.Transactions)7 IOException (java.io.IOException)6 Http (org.glassfish.grizzly.config.dom.Http)6 PropertyVetoException (java.beans.PropertyVetoException)5 ThreadPool (org.glassfish.grizzly.config.dom.ThreadPool)5