Search in sources :

Example 11 with SystemProperty

use of com.sun.enterprise.config.serverbeans.SystemProperty in project Payara by payara.

the class InstanceRegisterInstanceCommand method execute.

@Override
public void execute(AdminCommandContext ctxt) {
    final ActionReport report = ctxt.getActionReport();
    try {
        // create node if it doesn't exist
        Node n = domain.getNodes().getNode(node);
        if (n == null) {
            ConfigSupport.apply(new SingleConfigCode<Nodes>() {

                @Override
                public Object run(Nodes param) throws PropertyVetoException, TransactionFailure {
                    Node newNode = param.createChild(Node.class);
                    newNode.setName(node);
                    if (installdir != null && !"".equals(installdir))
                        newNode.setInstallDir(installdir);
                    if (nodedir != null && !"".equals(nodedir))
                        newNode.setNodeDir(nodedir);
                    if (nodehost != null && !"".equals(nodehost))
                        newNode.setNodeHost(nodehost);
                    newNode.setType(type);
                    // comment out - not needed
                    /*if (type.equals("SSH")) {
                            SshConnector sshC = param.createChild(SshConnector.class);
                            if (sshHost != null && sshHost != "") {
                                sshC.setSshHost(sshHost);

                            }
                            if (sshPort != "-1" && sshPort != "") {
                                sshC.setSshPort(sshPort);

                            }
                            if (sshuser != null || sshkeyfile != null || sshpassword != null
                                    || sshkeypassphrase != null) {
                                SshAuth sshA = sshC.createChild(SshAuth.class);
                                if (sshuser != null && sshuser != "") {
                                    sshA.setUserName(sshuser);
                                }
                                if (sshkeyfile != null && sshkeyfile != "") {
                                    sshA.setKeyfile(sshkeyfile);
                                }
                                if (sshpassword != null && sshpassword != "") {
                                    sshA.setPassword(sshpassword);
                                }
                                if (sshkeypassphrase != null && sshkeypassphrase != "") {
                                    sshA.setKeyPassphrase(sshkeypassphrase);
                                }
                                sshC.setSshAuth(sshA);
                            }
                            if (sshC != null) {
                                newNode.setSshConnector(sshC);
                            }
                        }*/
                    param.getNode().add(newNode);
                    return newNode;
                }
            }, domain.getNodes());
        }
        // create server if it doesn't exist
        Server s = domain.getServers().getServer(instanceName);
        if (s == null) {
            ConfigSupport.apply(new SingleConfigCode<Servers>() {

                public Object run(Servers param) throws PropertyVetoException, TransactionFailure {
                    Server newServer = param.createChild(Server.class);
                    newServer.setConfigRef(config);
                    // newServer.setLbWeight(lbWeight);
                    newServer.setName(instanceName);
                    newServer.setNodeRef(node);
                    if (systemProperties != null) {
                        for (final Map.Entry<Object, Object> entry : systemProperties.entrySet()) {
                            final String propName = (String) entry.getKey();
                            final String propValue = (String) entry.getValue();
                            SystemProperty newSP = newServer.createChild(SystemProperty.class);
                            // newSP.setDescription(sp.getDescription());
                            newSP.setName(propName);
                            newSP.setValue(propValue);
                            newServer.getSystemProperty().add(newSP);
                        }
                    }
                    param.getServer().add(newServer);
                    return newServer;
                }
            }, domain.getServers());
            // create server-ref on cluster
            Cluster thisCluster = domain.getClusterNamed(clusterName);
            if (thisCluster != null) {
                ConfigSupport.apply(new SingleConfigCode<Cluster>() {

                    public Object run(Cluster param) throws PropertyVetoException, TransactionFailure {
                        ServerRef newServerRef = param.createChild(ServerRef.class);
                        newServerRef.setRef(instanceName);
                        newServerRef.setLbEnabled(lbEnabled);
                        param.getServerRef().add(newServerRef);
                        return param;
                    }
                }, thisCluster);
            }
        }
        report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
    } catch (TransactionFailure tfe) {
        report.setMessage(localStrings.getLocalString("register.instance.failed", "Instance {0} registration failed on {1}", instanceName, server.getName()));
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        report.setFailureCause(tfe);
        return;
    } catch (Exception e) {
        report.setMessage(localStrings.getLocalString("register.instance.failed", "Instance {0} registration failed on {1}", instanceName, server.getName()));
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        report.setFailureCause(e);
        return;
    }
}
Also used : TransactionFailure(org.jvnet.hk2.config.TransactionFailure) Server(com.sun.enterprise.config.serverbeans.Server) Node(com.sun.enterprise.config.serverbeans.Node) Cluster(com.sun.enterprise.config.serverbeans.Cluster) ActionReport(org.glassfish.api.ActionReport) Servers(com.sun.enterprise.config.serverbeans.Servers) SystemProperty(com.sun.enterprise.config.serverbeans.SystemProperty) Nodes(com.sun.enterprise.config.serverbeans.Nodes) PropertyVetoException(java.beans.PropertyVetoException) PropertyVetoException(java.beans.PropertyVetoException) ServerRef(com.sun.enterprise.config.serverbeans.ServerRef)

Example 12 with SystemProperty

use of com.sun.enterprise.config.serverbeans.SystemProperty in project Payara by payara.

the class SystemTasksImpl method setSystemProperties.

private void setSystemProperties(List<SystemProperty> spList) {
    for (SystemProperty sp : spList) {
        String name = sp.getName();
        String value = sp.getValue();
        if (ok(name)) {
            setSystemProperty(name, value);
        }
    }
}
Also used : SystemProperty(com.sun.enterprise.config.serverbeans.SystemProperty)

Example 13 with SystemProperty

use of com.sun.enterprise.config.serverbeans.SystemProperty in project Payara by payara.

the class SystemTasksImpl method setSystemPropertiesFromDomainXml.

private void setSystemPropertiesFromDomainXml() {
    // precedence order from high to low
    // 0. server
    // 1. cluster
    // 2. <server>-config or <cluster>-config
    // 3. domain
    // so we need to add System Properties in *reverse order* to get the
    // right precedence.
    List<SystemProperty> domainSPList = domain.getSystemProperty();
    List<SystemProperty> configSPList = getConfigSystemProperties();
    Cluster cluster = server.getCluster();
    List<SystemProperty> clusterSPList = null;
    if (cluster != null) {
        clusterSPList = cluster.getSystemProperty();
    }
    List<SystemProperty> serverSPList = server.getSystemProperty();
    setSystemProperties(domainSPList);
    setSystemProperties(configSPList);
    if (clusterSPList != null) {
        setSystemProperties(clusterSPList);
    }
    setSystemProperties(serverSPList);
}
Also used : Cluster(com.sun.enterprise.config.serverbeans.Cluster) SystemProperty(com.sun.enterprise.config.serverbeans.SystemProperty)

Example 14 with SystemProperty

use of com.sun.enterprise.config.serverbeans.SystemProperty in project Payara by payara.

the class ListSystemProperties 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
 */
@Override
public void execute(AdminCommandContext context) {
    final ActionReport report = context.getActionReport();
    try {
        List<SystemProperty> sysProps = spb.getSystemProperty();
        int length = 0;
        if (sysProps.isEmpty()) {
            final ActionReport.MessagePart part = report.getTopMessagePart().addChild();
            part.setMessage(localStrings.getLocalString("NothingToList", "Nothing to List."));
        } else {
            for (SystemProperty prop : sysProps) {
                final ActionReport.MessagePart part = report.getTopMessagePart().addChild();
                part.setMessage(prop.getName() + "=" + prop.getValue());
                length++;
            }
            report.setMessage(localStrings.getLocalString("list.ok", "The target {0} contains following {1} system properties", target, length));
        }
        report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
    } catch (Exception e) {
        report.setMessage(localStrings.getLocalString("list.system.properties.failed", "list-system-properties failed"));
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        report.setFailureCause(e);
    }
}
Also used : ActionReport(org.glassfish.api.ActionReport) SystemProperty(com.sun.enterprise.config.serverbeans.SystemProperty)

Example 15 with SystemProperty

use of com.sun.enterprise.config.serverbeans.SystemProperty in project Payara by payara.

the class ConfigModularityUtils method addSystemPropertyForToken.

public void addSystemPropertyForToken(List<ConfigCustomizationToken> tokens, SystemPropertyBag bag) throws TransactionFailure, PropertyVetoException {
    for (ConfigCustomizationToken token : tokens) {
        if (!bag.containsProperty(token.getName())) {
            SystemProperty prop = bag.createChild(SystemProperty.class);
            prop.setName(token.getName());
            prop.setDescription(token.getDescription());
            prop.setValue(token.getValue());
            bag.getSystemProperty().add(prop);
        }
    }
}
Also used : ConfigCustomizationToken(com.sun.enterprise.config.modularity.customization.ConfigCustomizationToken) SystemProperty(com.sun.enterprise.config.serverbeans.SystemProperty)

Aggregations

SystemProperty (com.sun.enterprise.config.serverbeans.SystemProperty)18 PropertyVetoException (java.beans.PropertyVetoException)5 Domain (com.sun.enterprise.config.serverbeans.Domain)4 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)4 Cluster (com.sun.enterprise.config.serverbeans.Cluster)3 Server (com.sun.enterprise.config.serverbeans.Server)3 ActionReport (org.glassfish.api.ActionReport)3 Config (com.sun.enterprise.config.serverbeans.Config)2 JavaConfig (com.sun.enterprise.config.serverbeans.JavaConfig)2 Node (com.sun.enterprise.config.serverbeans.Node)2 VirtualServer (com.sun.enterprise.config.serverbeans.VirtualServer)2 ConfigApiTest (com.sun.enterprise.configapi.tests.ConfigApiTest)2 ArrayList (java.util.ArrayList)2 NetworkListener (org.glassfish.grizzly.config.dom.NetworkListener)2 Test (org.junit.Test)2 Changed (org.jvnet.hk2.config.Changed)2 ConfigBeanProxy (org.jvnet.hk2.config.ConfigBeanProxy)2 NotProcessed (org.jvnet.hk2.config.NotProcessed)2 Property (org.jvnet.hk2.config.types.Property)2 ConfigCustomizationToken (com.sun.enterprise.config.modularity.customization.ConfigCustomizationToken)1