Search in sources :

Example 36 with NetworkListener

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

the class GetHostAndPortCommand method getHostAndPort.

private HostAndPort getHostAndPort(HttpService httpService, VirtualServer vs, boolean securityEnabled) {
    List<VirtualServer> virtualServerList = httpService.getVirtualServer();
    List<NetworkListener> httpListenerList = httpService.getParent(Config.class).getNetworkConfig().getNetworkListeners().getNetworkListener();
    for (VirtualServer virtualServer : virtualServerList) {
        if (!virtualServer.getId().equals(vs.getId())) {
            continue;
        }
        String vsHttpListeners = virtualServer.getNetworkListeners();
        if (vsHttpListeners == null) {
            continue;
        }
        List<String> vsHttpListenerList = StringUtils.parseStringList(vsHttpListeners, " ,");
        for (String vsHttpListener : vsHttpListenerList) {
            for (NetworkListener httpListener : httpListenerList) {
                if (!httpListener.getName().equals(vsHttpListener)) {
                    continue;
                }
                if (!Boolean.valueOf(httpListener.getEnabled())) {
                    continue;
                }
                final Protocol protocol = httpListener.findHttpProtocol();
                if (Boolean.valueOf(protocol.getSecurityEnabled()) == securityEnabled) {
                    String serverName = protocol.getHttp().getServerName();
                    if (serverName == null || serverName.trim().equals("")) {
                        serverName = DeploymentCommandUtils.getLocalHostName();
                    }
                    String portStr = httpListener.getPort();
                    String redirPort = protocol.getHttp().getRedirectPort();
                    if (redirPort != null && !redirPort.trim().equals("")) {
                        portStr = redirPort;
                    }
                    int port = Integer.parseInt(portStr);
                    return new HostAndPort(serverName, port, securityEnabled);
                }
            }
        }
    }
    return null;
}
Also used : HostAndPort(com.sun.enterprise.util.HostAndPort) Config(com.sun.enterprise.config.serverbeans.Config) Protocol(org.glassfish.grizzly.config.dom.Protocol) VirtualServer(com.sun.enterprise.config.serverbeans.VirtualServer) RestEndpoint(org.glassfish.api.admin.RestEndpoint) NetworkListener(org.glassfish.grizzly.config.dom.NetworkListener)

Example 37 with NetworkListener

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

the class GetHostAndPortCommand method getHostAndPort.

private HostAndPort getHostAndPort(HttpService httpService, boolean securityEnabled) {
    List<NetworkListener> httpListenerList = httpService.getParent(Config.class).getNetworkConfig().getNetworkListeners().getNetworkListener();
    for (NetworkListener httpListener : httpListenerList) {
        if (!Boolean.valueOf(httpListener.getEnabled())) {
            continue;
        }
        final Protocol protocol = httpListener.findHttpProtocol();
        final Http http = protocol.getHttp();
        if (http.getDefaultVirtualServer().equals("__asadmin")) {
            continue;
        }
        if (Boolean.valueOf(protocol.getSecurityEnabled()) == securityEnabled) {
            String serverName = http.getServerName();
            if (serverName == null || serverName.trim().equals("")) {
                serverName = DeploymentCommandUtils.getLocalHostName();
            }
            String portStr = httpListener.getPort();
            String redirPort = http.getRedirectPort();
            if (redirPort != null && !redirPort.trim().equals("")) {
                portStr = redirPort;
            }
            int port = Integer.parseInt(portStr);
            return new HostAndPort(serverName, port, securityEnabled);
        }
    }
    return null;
}
Also used : HostAndPort(com.sun.enterprise.util.HostAndPort) Config(com.sun.enterprise.config.serverbeans.Config) Http(org.glassfish.grizzly.config.dom.Http) Protocol(org.glassfish.grizzly.config.dom.Protocol) RestEndpoint(org.glassfish.api.admin.RestEndpoint) NetworkListener(org.glassfish.grizzly.config.dom.NetworkListener)

Example 38 with NetworkListener

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

the class SecureAdminConfigUpgrade method createAdminNetworkListener.

private NetworkListener createAdminNetworkListener(final Transaction t, final NetworkConfig nc, final String adminListenerProtocolName) throws TransactionFailure {
    final NetworkListeners nls_w = t.enroll(nc.getNetworkListeners());
    final NetworkListener nl_w = nls_w.createChild(NetworkListener.class);
    nls_w.getNetworkListener().add(nl_w);
    nl_w.setName(ADMIN_LISTENER_NAME);
    nl_w.setProtocol(adminListenerProtocolName);
    nl_w.setPort(ASADMIN_LISTENER_PORT);
    nl_w.setTransport(ASADMIN_LISTENER_TRANSPORT);
    nl_w.setThreadPool(ASADMIN_LISTENER_THREADPOOL);
    return nl_w;
}
Also used : NetworkListeners(org.glassfish.grizzly.config.dom.NetworkListeners) NetworkListener(org.glassfish.grizzly.config.dom.NetworkListener)

Example 39 with NetworkListener

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

the class SecureAdminConfigUpgrade method ensureConfigReady.

// private void prepareNonDASConfigs() throws TransactionFailure, PropertyVetoException {
// for (Config c : configs.getConfig()) {
// if (c.getName().equals(DAS_CONFIG_NAME)) {
// continue;
// }
// ensureConfigReady(c, SecureAdminCommand.PORT_UNIF_PROTOCOL_NAME);
// }
// }
private void ensureConfigReady(final Config c, final String adminListenerProtocol) throws TransactionFailure, PropertyVetoException {
    final NetworkConfig nc = c.getNetworkConfig();
    final NetworkListener nl = nc.getNetworkListener(SecureAdminCommand.ADMIN_LISTENER_NAME);
    if (nl != null) {
        return;
    }
    /*
         * Create an admin-listener for this configuration.
         */
    final Config config_w = writableConfig(c);
    createAdminNetworkListener(transaction(), nc, adminListenerProtocol);
    createAdminVirtualServer(transaction(), config_w);
}
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 40 with NetworkListener

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

the class DeleteThreadpool method preAuthorization.

@Override
public boolean preAuthorization(AdminCommandContext context) {
    final ActionReport report = context.getActionReport();
    config = CLIUtil.updateConfigIfNeeded(config, target, habitat);
    threadPools = config.getThreadPools();
    if (!isThreadPoolExists(threadPools)) {
        report.setMessage(localStrings.getLocalString("delete.threadpool.notexists", "Thread Pool named {0} does not exist.", threadpool_id));
        report.setActionExitCode(ExitCode.FAILURE);
        return false;
    }
    pool = null;
    for (ThreadPool tp : config.getThreadPools().getThreadPool()) {
        if (tp.getName().equals(threadpool_id)) {
            pool = tp;
        }
    }
    List<NetworkListener> nwlsnrList = pool.findNetworkListeners();
    for (NetworkListener nwlsnr : nwlsnrList) {
        if (pool.getName().equals(nwlsnr.getThreadPool())) {
            report.setMessage(localStrings.getLocalString("delete.threadpool.beingused", "{0} threadpool is being used in the network listener {1}", threadpool_id, nwlsnr.getName()));
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            return false;
        }
    }
    return true;
}
Also used : ThreadPool(org.glassfish.grizzly.config.dom.ThreadPool) ActionReport(org.glassfish.api.ActionReport) 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