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;
}
}
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);
}
}
}
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);
}
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);
}
}
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);
}
}
}
Aggregations