use of com.sun.enterprise.config.serverbeans.Config in project Payara by payara.
the class ConfigModularityUtils method getOwner.
public ConfigBeanProxy getOwner(ConfigBeanProxy parent, String parentElement, String childElement) throws InvocationTargetException, IllegalAccessException {
if (childElement.contains("CURRENT_INSTANCE_CONFIG_NAME")) {
return serviceLocator.<Config>getService(Config.class, ServerEnvironment.DEFAULT_INSTANCE_NAME);
}
if (childElement.contains("CURRENT_INSTANCE_SERVER_NAME")) {
return serviceLocator.<Server>getService(Server.class, ServerEnvironment.DEFAULT_INSTANCE_NAME);
}
if (childElement.endsWith("]")) {
String componentName;
String elementName;
elementName = childElement.substring(childElement.lastIndexOf("/") + 1, childElement.indexOf("["));
componentName = childElement.substring(childElement.lastIndexOf("[") + 1, childElement.indexOf("]"));
Class childClass = getClassFor(elementName);
Class parentClass = getClassFor(parentElement);
Method m = findSuitableCollectionGetter(parentClass, childClass);
if (m != null) {
try {
Collection col = (Collection) m.invoke(parent);
componentName = resolveExpression(componentName);
return getNamedConfigBeanFromCollection(col, componentName, childClass);
} catch (Exception e) {
LogHelper.log(LOG, Level.INFO, invalidPath, e, childElement, componentName);
}
}
return null;
} else {
Class clz = getClassFor(childElement);
if (parent == null)
return null;
Method m = getMatchingGetterMethod(parent.getClass(), clz);
if (m != null) {
return (ConfigBeanProxy) m.invoke(parent);
} else {
try {
m = parent.getClass().getMethod("getExtensionByType", java.lang.Class.class);
} catch (NoSuchMethodException e) {
if (LOG.isLoggable(Level.FINE)) {
LOG.log(Level.FINE, "Cannot find getExtensionByType", e);
}
}
if (m != null) {
return (ConfigBeanProxy) m.invoke(parent, clz);
}
return null;
}
}
}
use of com.sun.enterprise.config.serverbeans.Config in project Payara by payara.
the class CreateModuleConfigCommand method preAuthorization.
@Override
public boolean preAuthorization(AdminCommandContext context) {
report = context.getActionReport();
if (target != null) {
Config newConfig = getConfigForName(target, serviceLocator, domain);
if (newConfig != null) {
config = newConfig;
}
if (config == null) {
report.setMessage(localStrings.getLocalString("create.module.config.target.name.invalid", "The target name specified is invalid. Please double check the target name and try again"));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return false;
}
}
if (isAll && (serviceName != null)) {
report.setMessage(localStrings.getLocalString("create.module.config.service.name.ignored", "One of the --all service name parameters can be used at a time. These two options can not be used together."));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return false;
}
return true;
}
use of com.sun.enterprise.config.serverbeans.Config in project Payara by payara.
the class DeleteModuleConfigCommand method execute.
@Override
public void execute(AdminCommandContext context) {
report = context.getActionReport();
if (target != null) {
Config newConfig = getConfigForName(target, serviceLocator, domain);
if (newConfig != null) {
config = newConfig;
}
if (config == null) {
report.setMessage(localStrings.getLocalString("delete.module.config.target.name.invalid", "The target name specified is invalid. Please double check the target name and try again."));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
}
if (serviceName == null) {
report.setMessage(localStrings.getLocalString("delete.module.config.service.name.is.required", "The service name is required, please specify which service you want to delete its default configuration."));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
final String className = configModularityUtils.convertConfigElementNameToClassName(serviceName);
Class configBeanType = configModularityUtils.getClassFor(serviceName);
if (configBeanType == null) {
String msg = localStrings.getLocalString("delete.module.config.not.such.a.service.found", "Your service name does not match any service installed on this domain.");
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setMessage(msg);
return;
}
if (configModularityUtils.hasCustomConfig(configBeanType)) {
List<ConfigBeanDefaultValue> defaults = configModularityUtils.getDefaultConfigurations(configBeanType, configModularityUtils.getRuntimeTypePrefix(serverenv.getStartupContext()));
deleteDependentConfigElements(defaults);
} else {
deleteTopLevelExtensionByType(config, className, configBeanType);
}
}
use of com.sun.enterprise.config.serverbeans.Config in project Payara by payara.
the class SynchronizeRealmFromConfig method execute.
@Override
public void execute(AdminCommandContext context) {
Config realConfig = null;
try {
realConfig = configs.getConfigByName(target);
} catch (Exception ex) {
}
if (realConfig == null) {
Server targetServer = domain.getServerNamed(target);
if (targetServer != null) {
realConfig = domain.getConfigNamed(targetServer.getConfigRef());
}
com.sun.enterprise.config.serverbeans.Cluster cluster = domain.getClusterNamed(target);
if (cluster != null) {
realConfig = domain.getConfigNamed(cluster.getConfigRef());
}
}
ActionReport report = context.getActionReport();
try {
// TODO: can i use realConfig.equals(config) instead
if (realConfig.getName().equals(config.getName())) {
this.setRestartRequired(report);
return;
}
// this is not an active config so try and update the backend
// directly
Realm r = realmsManager.getFromLoadedRealms(realConfig.getName(), realmName);
if (r == null) {
// realm is not loaded yet
report.setMessage(_localStrings.getLocalString("REALM_SYNCH_SUCCESSFUL", "Synchronization of Realm {0} from Configuration Successful.", new Object[] { realmName }));
report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
return;
}
// now we really need to update the realm in the backend from the config.
realmsManager.removeFromLoadedRealms(realConfig.getName(), realmName);
boolean done = this.instantiateRealm(realConfig, realmName);
if (done) {
report.setMessage(_localStrings.getLocalString("REALM_SYNCH_SUCCESSFUL", "Synchronization of Realm {0} from Configuration Successful.", new Object[] { realmName }));
report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
return;
}
} catch (BadRealmException ex) {
// throw new RuntimeException(ex);
report.setFailureCause(ex);
report.setActionExitCode(ExitCode.FAILURE);
} catch (NoSuchRealmException ex) {
// throw new RuntimeException(ex);
report.setFailureCause(ex);
report.setActionExitCode(ExitCode.FAILURE);
} catch (Exception ex) {
report.setFailureCause(ex);
report.setActionExitCode(ExitCode.FAILURE);
}
}
use of com.sun.enterprise.config.serverbeans.Config in project Payara by payara.
the class SecureAdminConfigUpgrade method writableConfig.
private Config writableConfig(final Config c) throws TransactionFailure {
Config result = writableConfigs.get(c.getName());
if (result == null) {
result = transaction().enroll(c);
writableConfigs.put(c.getName(), result);
}
return result;
}
Aggregations