Search in sources :

Example 6 with NetworkListeners

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

the class GrizzlyConfigSchemaMigrator method migrateThreadPools.

private void migrateThreadPools(ThreadPools threadPools) throws TransactionFailure {
    final Config config = threadPools.getParent(Config.class);
    final NetworkListeners networkListeners = config.getNetworkConfig().getNetworkListeners();
    threadPools.getThreadPool().addAll(networkListeners.getThreadPool());
    ConfigSupport.apply(new SingleConfigCode<NetworkListeners>() {

        public Object run(NetworkListeners param) {
            param.getThreadPool().clear();
            return null;
        }
    }, networkListeners);
}
Also used : JavaConfig(com.sun.enterprise.config.serverbeans.JavaConfig) Config(com.sun.enterprise.config.serverbeans.Config) NetworkConfig(org.glassfish.grizzly.config.dom.NetworkConfig) NetworkListeners(org.glassfish.grizzly.config.dom.NetworkListeners)

Example 7 with NetworkListeners

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

the class DirectRemovalTest method doTest.

public void doTest() throws TransactionFailure {
    NetworkListeners listeners = habitat.getService(NetworkListeners.class);
    ConfigBean serviceBean = (ConfigBean) ConfigBean.unwrap(listeners);
    for (NetworkListener listener : listeners.getNetworkListener()) {
        if (listener.getName().endsWith("http-listener-1")) {
            ConfigSupport.deleteChild(serviceBean, (ConfigBean) ConfigBean.unwrap(listener));
            break;
        }
    }
}
Also used : NetworkListeners(org.glassfish.grizzly.config.dom.NetworkListeners) ConfigBean(org.jvnet.hk2.config.ConfigBean) NetworkListener(org.glassfish.grizzly.config.dom.NetworkListener)

Example 8 with NetworkListeners

use of org.glassfish.grizzly.config.dom.NetworkListeners 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 9 with NetworkListeners

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

the class DeleteNetworkListener method execute.

/**
 * Executes the command with the command parameters passed as Properties where the keys are the paramter names and
 * the values the parameter values
 *
 * @param context information
 */
public void execute(AdminCommandContext context) {
    Target targetUtil = services.getService(Target.class);
    Config newConfig = targetUtil.getConfig(target);
    if (newConfig != null) {
        config = newConfig;
    }
    ActionReport report = context.getActionReport();
    NetworkListeners networkListeners = config.getNetworkConfig().getNetworkListeners();
    try {
        if (findListener(networkListeners, report)) {
            final Protocol httpProtocol = listenerToBeRemoved.findHttpProtocol();
            final VirtualServer virtualServer = config.getHttpService().getVirtualServerByName(httpProtocol.getHttp().getDefaultVirtualServer());
            ConfigSupport.apply(new ConfigCode() {

                public Object run(ConfigBeanProxy... params) throws PropertyVetoException {
                    final NetworkListeners listeners = (NetworkListeners) params[0];
                    final VirtualServer server = (VirtualServer) params[1];
                    listeners.getNetworkListener().remove(listenerToBeRemoved);
                    server.removeNetworkListener(listenerToBeRemoved.getName());
                    return listenerToBeRemoved;
                }
            }, networkListeners, virtualServer);
        }
        report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
    } catch (TransactionFailure e) {
        report.setMessage(MessageFormat.format(rb.getString(LogFacade.DELETE_NETWORK_LISTENER_FAIL), networkListenerName));
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        report.setFailureCause(e);
    }
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) TransactionFailure(org.jvnet.hk2.config.TransactionFailure) Target(org.glassfish.internal.api.Target) CommandTarget(org.glassfish.config.support.CommandTarget) ConfigBeanProxy(org.jvnet.hk2.config.ConfigBeanProxy) ConfigCode(org.jvnet.hk2.config.ConfigCode) Config(com.sun.enterprise.config.serverbeans.Config) NetworkListeners(org.glassfish.grizzly.config.dom.NetworkListeners) ActionReport(org.glassfish.api.ActionReport) Protocol(org.glassfish.grizzly.config.dom.Protocol) VirtualServer(com.sun.enterprise.config.serverbeans.VirtualServer)

Example 10 with NetworkListeners

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

the class InstanceReaderImpl method getListeners.

/**
 * Enlists both http and https listeners of this server instance
 * It will be form "http:<hostname>:<port> https:<hostname>:<port>"
 *
 * @return String   Listener(s) info.
 */
@Override
public String getListeners() throws LbReaderException {
    StringBuffer listenerStr = new StringBuffer();
    Config config = _domain.getConfigNamed(_server.getConfigRef());
    NetworkConfig networkConfig = config.getNetworkConfig();
    Protocols protocols = networkConfig.getProtocols();
    NetworkListeners nls = networkConfig.getNetworkListeners();
    Iterator<NetworkListener> listenerIter = nls.getNetworkListener().iterator();
    int i = 0;
    PropertyResolver resolver = new PropertyResolver(_domain, _server.getName());
    while (listenerIter.hasNext()) {
        NetworkListener listener = listenerIter.next();
        NetworkListener rawListener = GlassFishConfigBean.getRawView(listener);
        if (rawListener.getName().equals(ADMIN_LISTENER)) {
            continue;
        }
        String prot = rawListener.getProtocol();
        Protocol protocol = protocols.findProtocol(prot);
        if (i > 0) {
            // space between listener names
            listenerStr.append(' ');
        }
        i++;
        if (Boolean.valueOf(protocol.getHttp().getJkEnabled())) {
            listenerStr.append(AJP_PROTO);
        } else {
            if (Boolean.valueOf(protocol.getSecurityEnabled()).booleanValue()) {
                listenerStr.append(HTTPS_PROTO);
            } else {
                listenerStr.append(HTTP_PROTO);
            }
        }
        String hostName = getResolvedHostName(rawListener.getAddress());
        listenerStr.append(hostName);
        listenerStr.append(':');
        // resolve the port name
        String port = rawListener.getPort();
        // If it is system variable, resolve it
        if ((port != null) && (port.length() > 1) && (port.charAt(0) == '$') && (port.charAt(1) == '{') && (port.charAt(port.length() - 1) == '}')) {
            String portVar = port.substring(2, port.length() - 1);
            port = resolver.getPropertyValue(portVar);
            if (port == null) {
                throw new LbReaderException(LbLogUtil.getStringManager().getString("UnableToResolveSystemProperty", portVar, _server.getName()));
            }
        }
        listenerStr.append(port);
    }
    return listenerStr.toString();
}
Also used : Protocols(org.glassfish.grizzly.config.dom.Protocols) Config(com.sun.enterprise.config.serverbeans.Config) NetworkConfig(org.glassfish.grizzly.config.dom.NetworkConfig) NetworkConfig(org.glassfish.grizzly.config.dom.NetworkConfig) NetworkListeners(org.glassfish.grizzly.config.dom.NetworkListeners) PropertyResolver(org.glassfish.config.support.PropertyResolver) Protocol(org.glassfish.grizzly.config.dom.Protocol) LbReaderException(org.glassfish.loadbalancer.admin.cli.reader.api.LbReaderException) 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