use of org.jvnet.hk2.config.ConfigBeanProxy in project Payara by payara.
the class InstallerThread method install.
/**
* <p> Install the admingui.war file.</p>
*/
private void install() throws Exception {
if (domain.getSystemApplicationReferencedFrom(env.getInstanceName(), AdminConsoleAdapter.ADMIN_APP_NAME) != null) {
// Application is already installed
adapter.setStateMsg(AdapterState.APPLICATION_INSTALLED_BUT_NOT_LOADED);
return;
}
// Set the adapter state
adapter.setStateMsg(AdapterState.INSTALLING);
if (log.isLoggable(Level.FINE)) {
log.log(Level.FINE, "Installing the Admin Console Application...");
}
// create the application entry in domain.xml
ConfigCode code = new ConfigCode() {
@Override
public Object run(ConfigBeanProxy... proxies) throws PropertyVetoException, TransactionFailure {
SystemApplications sa = (SystemApplications) proxies[0];
Application app = sa.createChild(Application.class);
sa.getModules().add(app);
app.setName(AdminConsoleAdapter.ADMIN_APP_NAME);
app.setEnabled(Boolean.TRUE.toString());
// TODO
app.setObjectType("system-admin");
app.setDirectoryDeployed("true");
app.setContextRoot(contextRoot);
try {
app.setLocation("${com.sun.aas.installRootURI}/lib/install/applications/" + AdminConsoleAdapter.ADMIN_APP_NAME);
} catch (Exception me) {
// can't do anything
throw new RuntimeException(me);
}
Module singleModule = app.createChild(Module.class);
app.getModule().add(singleModule);
singleModule.setName(app.getName());
Engine webe = singleModule.createChild(Engine.class);
webe.setSniffer("web");
Engine sece = singleModule.createChild(Engine.class);
sece.setSniffer("security");
singleModule.getEngines().add(webe);
singleModule.getEngines().add(sece);
Server s = (Server) proxies[1];
List<ApplicationRef> arefs = s.getApplicationRef();
ApplicationRef aref = s.createChild(ApplicationRef.class);
aref.setRef(app.getName());
aref.setEnabled(Boolean.TRUE.toString());
// TODO
aref.setVirtualServers(getVirtualServerList());
arefs.add(aref);
return true;
}
};
Server server = domain.getServerNamed(env.getInstanceName());
ConfigSupport.apply(code, domain.getSystemApplications(), server);
// Set the adapter state
adapter.setStateMsg(AdapterState.APPLICATION_INSTALLED_BUT_NOT_LOADED);
if (log.isLoggable(Level.FINE)) {
log.log(Level.FINE, "Admin Console Application Installed.");
}
}
use of org.jvnet.hk2.config.ConfigBeanProxy in project Payara by payara.
the class ConfigModularityUtils method applyCustomTokens.
public synchronized <T extends ConfigBeanProxy> void applyCustomTokens(final ConfigBeanDefaultValue configBeanDefaultValue, T finalConfigBean, ConfigBeanProxy parent) throws TransactionFailure, PropertyVetoException {
// then that is the freaking parent, get it and set the SystemProperty :D
if (parent instanceof SystemPropertyBag) {
addSystemPropertyForToken(configBeanDefaultValue.getCustomizationTokens(), (SystemPropertyBag) parent);
} else {
ConfigBeanProxy curParent = finalConfigBean;
while (!(curParent instanceof SystemPropertyBag)) {
curParent = curParent.getParent();
}
if (configBeanDefaultValue.getCustomizationTokens().size() != 0) {
final boolean oldIP = isIgnorePersisting();
try {
setIgnorePersisting(true);
final SystemPropertyBag bag = (SystemPropertyBag) curParent;
final List<ConfigCustomizationToken> tokens = configBeanDefaultValue.getCustomizationTokens();
ConfigSupport.apply(new SingleConfigCode<SystemPropertyBag>() {
public Object run(SystemPropertyBag param) throws PropertyVetoException, TransactionFailure {
addSystemPropertyForToken(tokens, bag);
return param;
}
}, bag);
} finally {
setIgnorePersisting(oldIP);
}
}
}
}
use of org.jvnet.hk2.config.ConfigBeanProxy in project Payara by payara.
the class ConfigModularityUtils method deleteConfigurationForConfigBean.
public boolean deleteConfigurationForConfigBean(ConfigBeanProxy configBean, Collection col, ConfigBeanDefaultValue defaultValue) {
String name;
ConfigBeanProxy itemToRemove;
try {
Class configBeanClass = getClassForFullName(defaultValue.getConfigBeanClassName());
name = getNameForConfigBean(configBean, configBeanClass);
itemToRemove = getNamedConfigBeanFromCollection(col, name, configBeanClass);
if (itemToRemove != null) {
col.remove(itemToRemove);
return true;
}
if (name == null) {
col.remove(configBean);
return true;
}
} catch (Exception ex) {
return false;
}
return false;
}
use of org.jvnet.hk2.config.ConfigBeanProxy in project Payara by payara.
the class ConfigModularityUtils method replacePropertiesWithCurrentValue.
public String replacePropertiesWithCurrentValue(String xmlConfiguration, ConfigBeanDefaultValue value) throws InvocationTargetException, IllegalAccessException {
for (ConfigCustomizationToken token : value.getCustomizationTokens()) {
String toReplace = "${" + token.getName() + "}";
ConfigBeanProxy current = getCurrentConfigBeanForDefaultValue(value);
String propertyValue = getPropertyValue(token, current);
if (propertyValue != null) {
xmlConfiguration = xmlConfiguration.replace(toReplace, propertyValue);
}
}
return xmlConfiguration;
}
use of org.jvnet.hk2.config.ConfigBeanProxy in project Payara by payara.
the class DeleteModuleConfigCommand method deleteDependentConfigElement.
private void deleteDependentConfigElement(final ConfigBeanDefaultValue defaultValue) {
Class parentClass = configModularityUtils.getOwningClassForLocation(defaultValue.getLocation());
final Class configBeanClass = configModularityUtils.getClassForFullName(defaultValue.getConfigBeanClassName());
final Method m = configModularityUtils.findSuitableCollectionGetter(parentClass, configBeanClass);
if (m != null) {
try {
final ConfigBeanProxy parent = configModularityUtils.getOwningObject(defaultValue.getLocation());
ConfigSupport.apply(new SingleConfigCode<ConfigBeanProxy>() {
@Override
public Object run(ConfigBeanProxy param) throws PropertyVetoException, TransactionFailure {
List col = null;
ConfigBeanProxy configBean = null;
try {
col = (List) m.invoke(param);
if (col != null) {
configBean = configModularityUtils.getCurrentConfigBeanForDefaultValue(defaultValue);
}
} catch (Exception e) {
String message = localStrings.getLocalString("delete.module.config.failed.deleting.dependant", "Failed to remove all configuration elements related to your service form domain.xml. You can use create-module-config --dryRun with your module name to see all relevant configurations and try removing the config elements ");
report.setMessage(message);
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
LOG.log(Level.INFO, DELETE_MODULE_CONFIG_FAILED_DELETING_DEPENDENT, e);
}
if (configBean != null) {
boolean deleted = configModularityUtils.deleteConfigurationForConfigBean(configBean, col, defaultValue);
if (!deleted) {
for (int i = 0; i < col.size(); i++) {
if (configBeanClass.isAssignableFrom(col.get(i).getClass())) {
col.remove(col.get(i));
removeCustomTokens(defaultValue, configBean, parent);
return param;
}
}
}
}
return param;
}
}, parent);
} catch (Exception e) {
String message = localStrings.getLocalString("delete.module.config.failed.deleting.dependant", "Failed to remove all configuration elements related to your service form domain.xml. You can use create-module-config --dryRun with your module name to see all relevant configurations and try removing the config elements ");
report.setMessage(message);
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
LOG.log(Level.INFO, DELETE_MODULE_CONFIG_FAILED_DELETING_DEPENDENT, e);
}
} else {
report.setMessage(localStrings.getLocalString("delete.module.config.failed.deleting.dependant", "Failed to remove all configuration elements related to your service form domain.xml. You can use create-module-config --dryRun with your module name to see all relevant configurations and try removing the config elements "));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
}
}
Aggregations