use of com.sun.enterprise.config.serverbeans.Configs in project Payara by payara.
the class SystemTasksImpl method getConfigSystemProperties.
private List<SystemProperty> getConfigSystemProperties() {
try {
String configName = server.getConfigRef();
Configs configs = domain.getConfigs();
List<Config> configsList = configs.getConfig();
Config config = null;
for (Config c : configsList) {
if (c.getName().equals(configName)) {
config = c;
break;
}
}
return (List<SystemProperty>) (config != null ? config.getSystemProperty() : Collections.emptyList());
} catch (Exception e) {
// possible NPE if domain.xml has issues!
return Collections.emptyList();
}
}
use of com.sun.enterprise.config.serverbeans.Configs in project Payara by payara.
the class IiopFolbGmsClient method getConfigForServer.
private Config getConfigForServer(Server server) {
fineLog("getConfigForServer: server {0}", server);
String configRef = server.getConfigRef();
fineLog("getConfigForServer: configRef {0}", configRef);
Configs configs = services.getService(Configs.class);
fineLog("getConfigForServer: configs {0}", configs);
Config config = configs.getConfigByName(configRef);
fineLog("getConfigForServer: config {0}", config);
return config;
}
use of com.sun.enterprise.config.serverbeans.Configs in project Payara by payara.
the class ConfigRefValidator method isValid.
@Override
public boolean isValid(final Named bean, final ConstraintValidatorContext constraintValidatorContext) {
if (bean == null)
return true;
Server server = null;
Cluster mycluster = null;
String configRef = null;
String serverName = null;
if (bean instanceof Server) {
server = (Server) bean;
configRef = server.getConfigRef();
serverName = server.getName();
} else if (bean instanceof Cluster) {
mycluster = (Cluster) bean;
configRef = mycluster.getConfigRef();
serverName = mycluster.getName();
}
// skip validation @NotNull is already on getConfigRef
if (configRef == null)
return true;
// cannot use default-config
if (configRef.equals(SystemPropertyConstants.TEMPLATE_CONFIG_NAME)) {
logger.warning(ConfigApiLoggerInfo.configRefDefaultconfig);
return false;
}
// cannot change config-ref of DAS
if (server != null) {
if (server.isDas() && !configRef.equals(SystemPropertyConstants.DAS_SERVER_CONFIG)) {
logger.warning(ConfigApiLoggerInfo.configRefDASconfig);
return false;
}
// cannot use server-config if not DAS
if (!server.isDas() && configRef.equals(SystemPropertyConstants.DAS_SERVER_CONFIG)) {
logger.warning(ConfigApiLoggerInfo.configRefServerconfig);
return false;
}
final Servers servers = server.getParent(Servers.class);
final Domain domain = servers.getParent(Domain.class);
final Configs configs = domain.getConfigs();
if (servers.getServer(serverName) != null) {
// validate for set, not _register-instance
// cannot change config ref of a clustered instance
Cluster cluster = domain.getClusterForInstance(serverName);
if (cluster != null) {
// cluster is not null during create-local-instance --cluster c1 i1
if (!cluster.getConfigRef().equals(configRef)) {
// During set when trying to change config-ref of a clustered instance,
// the value of desired config-ref will be different than the current config-ref.
// During _register-instance, (create-local-instance --cluster c1 i1)
// cluster.getConfigRef().equals(configRef) will be true and not come here.
logger.warning(ConfigApiLoggerInfo.configRefClusteredInstance);
return false;
}
}
// cannot use a non-existent config (Only used by set. _register-instance will fail earlier)
if (configs == null || configs.getConfigByName(configRef) == null) {
logger.warning(ConfigApiLoggerInfo.configRefNonexistent);
return false;
}
}
}
return true;
}
use of com.sun.enterprise.config.serverbeans.Configs in project Payara by payara.
the class DeepCopyTest method configCopy.
@Test
public void configCopy() throws Exception {
final Config config = getHabitat().getService(Config.class);
Assert.assertNotNull(config);
String configName = config.getName();
final Config newConfig = (Config) ConfigSupport.apply(new SingleConfigCode<ConfigBeanProxy>() {
@Override
public Object run(ConfigBeanProxy parent) throws PropertyVetoException, TransactionFailure {
return config.deepCopy(parent);
}
}, config.getParent());
Assert.assertNotNull(newConfig);
try {
newConfig.setName("some-config");
} catch (Exception e) {
// I was expecting this...
}
ConfigSupport.apply(new SingleConfigCode<Config>() {
@Override
public Object run(Config wConfig) throws PropertyVetoException, TransactionFailure {
wConfig.setName("some-config");
return null;
}
}, newConfig);
Assert.assertEquals(newConfig.getName(), "some-config");
Assert.assertEquals(config.getName(), configName);
// add it the parent
ConfigSupport.apply(new SingleConfigCode<Configs>() {
@Override
public Object run(Configs wConfigs) throws PropertyVetoException, TransactionFailure {
wConfigs.getConfig().add(newConfig);
return null;
}
}, getHabitat().<Configs>getService(Configs.class));
String resultingXML = save(document).toString();
Assert.assertTrue("Expecting some-config, got " + resultingXML, resultingXML.contains("some-config"));
}
Aggregations