Search in sources :

Example 11 with Target

use of org.glassfish.internal.api.Target in project Payara by payara.

the class DeleteProtocol 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();
    NetworkConfig networkConfig = config.getNetworkConfig();
    Protocols protocols = networkConfig.getProtocols();
    try {
        protocol = protocols.findProtocol(protocolName);
        if (protocol == null) {
            report.setMessage(MessageFormat.format(rb.getString(LogFacade.DELETE_PROTOCOL_NOT_EXISTS), protocolName));
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            return;
        }
        // check if the protocol to be deleted is being used by
        // any network listener
        List<NetworkListener> nwlsnrList = protocol.findNetworkListeners();
        for (NetworkListener nwlsnr : nwlsnrList) {
            if (protocol.getName().equals(nwlsnr.getProtocol())) {
                report.setMessage(MessageFormat.format(rb.getString(LogFacade.DELETE_PROTOCOL_BEING_USED), protocolName, nwlsnr.getName()));
                report.setActionExitCode(ActionReport.ExitCode.FAILURE);
                return;
            }
        }
        ConfigSupport.apply(new SingleConfigCode<Protocols>() {

            public Object run(Protocols param) {
                param.getProtocol().remove(protocol);
                return protocol;
            }
        }, protocols);
    } catch (TransactionFailure e) {
        report.setMessage(MessageFormat.format(rb.getString(LogFacade.DELETE_PROTOCOL_FAIL), protocolName) + e.getLocalizedMessage());
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        report.setFailureCause(e);
        return;
    }
    report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
}
Also used : TransactionFailure(org.jvnet.hk2.config.TransactionFailure) Target(org.glassfish.internal.api.Target) CommandTarget(org.glassfish.config.support.CommandTarget) 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) ActionReport(org.glassfish.api.ActionReport) NetworkListener(org.glassfish.grizzly.config.dom.NetworkListener)

Example 12 with Target

use of org.glassfish.internal.api.Target in project Payara by payara.

the class ListProtocolFilters method execute.

public void execute(AdminCommandContext context) {
    Target targetUtil = services.getService(Target.class);
    Config newConfig = targetUtil.getConfig(target);
    if (newConfig != null) {
        config = newConfig;
    }
    final ActionReport report = context.getActionReport();
    Protocol protocol = config.getNetworkConfig().getProtocols().findProtocol(protocolName);
    if (protocol != null && protocol.getProtocolChainInstanceHandler() != null) {
        final ProtocolChain chain = protocol.getProtocolChainInstanceHandler().getProtocolChain();
        if (chain != null) {
            for (ProtocolFilter filter : chain.getProtocolFilter()) {
                report.getTopMessagePart().addChild().setMessage(filter.getName());
            }
        }
    }
    report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
}
Also used : Target(org.glassfish.internal.api.Target) CommandTarget(org.glassfish.config.support.CommandTarget) Config(com.sun.enterprise.config.serverbeans.Config) ProtocolChain(org.glassfish.grizzly.config.dom.ProtocolChain) ActionReport(org.glassfish.api.ActionReport) Protocol(org.glassfish.grizzly.config.dom.Protocol) ProtocolFilter(org.glassfish.grizzly.config.dom.ProtocolFilter)

Example 13 with Target

use of org.glassfish.internal.api.Target in project Payara by payara.

the class ListVirtualServers 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();
    List<VirtualServer> list = config.getHttpService().getVirtualServer();
    for (VirtualServer virtualServer : list) {
        report.getTopMessagePart().addChild().setMessage(virtualServer.getId());
    }
    report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
}
Also used : Target(org.glassfish.internal.api.Target) Config(com.sun.enterprise.config.serverbeans.Config) ActionReport(org.glassfish.api.ActionReport) VirtualServer(com.sun.enterprise.config.serverbeans.VirtualServer)

Example 14 with Target

use of org.glassfish.internal.api.Target in project Payara by payara.

the class ListNetworkListeners method execute.

/**
 * Executes the command with the command parameters passed as Properties where the keys are the parameter 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;
    }
    final ActionReport report = context.getActionReport();
    List<NetworkListener> list = config.getNetworkConfig().getNetworkListeners().getNetworkListener();
    for (NetworkListener networkListener : list) {
        report.getTopMessagePart().addChild().setMessage(networkListener.getName());
    }
    report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
}
Also used : Target(org.glassfish.internal.api.Target) CommandTarget(org.glassfish.config.support.CommandTarget) Config(com.sun.enterprise.config.serverbeans.Config) ActionReport(org.glassfish.api.ActionReport) NetworkListener(org.glassfish.grizzly.config.dom.NetworkListener)

Example 15 with Target

use of org.glassfish.internal.api.Target in project Payara by payara.

the class ListProtocolFinders method execute.

public void execute(AdminCommandContext context) {
    Target targetUtil = services.getService(Target.class);
    Config newConfig = targetUtil.getConfig(target);
    if (newConfig != null) {
        config = newConfig;
    }
    final ActionReport report = context.getActionReport();
    Protocol protocol = config.getNetworkConfig().getProtocols().findProtocol(protocolName);
    if (protocol != null) {
        final PortUnification pu = protocol.getPortUnification();
        if (pu != null) {
            for (ProtocolFinder finder : pu.getProtocolFinder()) {
                report.getTopMessagePart().addChild().setMessage(finder.getName());
            }
        }
    }
    report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
}
Also used : Target(org.glassfish.internal.api.Target) CommandTarget(org.glassfish.config.support.CommandTarget) PortUnification(org.glassfish.grizzly.config.dom.PortUnification) Config(com.sun.enterprise.config.serverbeans.Config) ActionReport(org.glassfish.api.ActionReport) Protocol(org.glassfish.grizzly.config.dom.Protocol) ProtocolFinder(org.glassfish.grizzly.config.dom.ProtocolFinder)

Aggregations

Target (org.glassfish.internal.api.Target)39 CommandTarget (org.glassfish.config.support.CommandTarget)35 Config (com.sun.enterprise.config.serverbeans.Config)32 ActionReport (org.glassfish.api.ActionReport)32 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)22 Protocol (org.glassfish.grizzly.config.dom.Protocol)15 PropertyVetoException (java.beans.PropertyVetoException)11 NetworkConfig (org.glassfish.grizzly.config.dom.NetworkConfig)11 Protocols (org.glassfish.grizzly.config.dom.Protocols)10 NetworkListener (org.glassfish.grizzly.config.dom.NetworkListener)9 List (java.util.List)8 VirtualServer (com.sun.enterprise.config.serverbeans.VirtualServer)5 HttpService (com.sun.enterprise.config.serverbeans.HttpService)4 SystemPropertyConstants (com.sun.enterprise.util.SystemPropertyConstants)3 ArrayList (java.util.ArrayList)3 Properties (java.util.Properties)3 Logger (java.util.logging.Logger)3 Inject (javax.inject.Inject)3 I18n (org.glassfish.api.I18n)3 Param (org.glassfish.api.Param)3