use of com.sun.enterprise.config.serverbeans.Application in project Payara by payara.
the class ModuleConfigSource method deleteValue.
public boolean deleteValue(String propertyName) throws TransactionFailure {
boolean result = false;
Application app = domainConfiguration.getApplications().getApplication(configurationName);
if (app != null) {
Module m = app.getModule(moduleName);
for (Property object : m.getProperty()) {
if ((PROPERTY_PREFIX + propertyName).equals(object.getName())) {
ConfigSupport.deleteChild((ConfigBean) ConfigBean.unwrap(m), (ConfigBean) ConfigBean.unwrap(object));
result = true;
}
}
}
return result;
}
use of com.sun.enterprise.config.serverbeans.Application in project Payara by payara.
the class ModuleConfigSource method getProperties.
@Override
public Map<String, String> getProperties() {
Application config = domainConfiguration.getApplications().getApplication(configurationName);
HashMap<String, String> result = new HashMap<>();
if (config != null) {
Module module = config.getModule(moduleName);
if (module != null) {
List<Property> properties = module.getProperty();
for (Property property : properties) {
if (property.getName().startsWith(PROPERTY_PREFIX)) {
result.put(property.getName().substring(PROPERTY_PREFIX.length()), property.getValue());
}
}
}
}
return result;
}
use of com.sun.enterprise.config.serverbeans.Application in project Payara by payara.
the class ModuleConfigSource method setValue.
public boolean setValue(final String propertyName, final String propertyValue) throws TransactionFailure {
boolean result = false;
Application app = domainConfiguration.getApplications().getApplication(configurationName);
if (app != null) {
Module m = app.getModule(moduleName);
if (m != null) {
Property p = m.getProperty(PROPERTY_PREFIX + propertyName);
if (p == null) {
ConfigSupport.apply(new SingleConfigCode<Module>() {
@Override
public Object run(Module config) throws TransactionFailure, PropertyVetoException {
Property prop = config.createChild(Property.class);
prop.setName(PROPERTY_PREFIX + propertyName);
prop.setValue(propertyValue);
config.getProperty().add(prop);
return null;
}
}, m);
} else {
ConfigSupport.apply(new SingleConfigCode<Property>() {
@Override
public Object run(Property config) throws TransactionFailure, PropertyVetoException {
config.setValue(propertyValue);
return null;
}
}, p);
}
result = true;
}
}
return result;
}
use of com.sun.enterprise.config.serverbeans.Application in project Payara by payara.
the class ModuleConfigSource method getValue.
@Override
public String getValue(String propertyName) {
String result = null;
Application app = domainConfiguration.getApplications().getApplication(configurationName);
if (app != null) {
Module m = app.getModule(moduleName);
if (m != null) {
result = m.getPropertyValue(PROPERTY_PREFIX + propertyName);
}
}
return result;
}
use of com.sun.enterprise.config.serverbeans.Application in project Payara by payara.
the class ApplicationConfigListener method transactionCommited.
public void transactionCommited(final List<PropertyChangeEvent> changes) {
boolean isUpdatingAttribute = true;
for (PropertyChangeEvent event : changes) {
Object oldValue = event.getOldValue();
Object newValue = event.getNewValue();
if (event.getSource() instanceof Applications) {
if (event.getPropertyName().equals(ServerTags.APPLICATION)) {
if (oldValue == null || newValue == null) {
// we are adding/removing application element here
// and updating existing attribute
isUpdatingAttribute = false;
break;
}
}
} else if (event.getSource() instanceof Server || event.getSource() instanceof Cluster) {
if (event.getPropertyName().equals(ServerTags.APPLICATION_REF)) {
if (oldValue == null || newValue == null) {
// we are adding/removing application-ref element here
// and updating existing attribute
isUpdatingAttribute = false;
break;
}
}
}
}
if (!isUpdatingAttribute) {
// skip the config listener
return;
}
for (PropertyChangeEvent event : changes) {
if (event.getSource() instanceof Application || event.getSource() instanceof ApplicationRef || event.getSource() instanceof Property) {
Object oldValue = event.getOldValue();
Object newValue = event.getNewValue();
String propertyName = null;
if (oldValue != null && newValue != null && oldValue instanceof String && newValue instanceof String && !((String) oldValue).equals((String) newValue)) {
// if it's an attribute change of the application
// element or application-ref element
Object parent = event.getSource();
String appName = null;
if (parent instanceof Application) {
appName = ((Application) parent).getName();
propertyName = event.getPropertyName();
} else if (parent instanceof ApplicationRef) {
appName = ((ApplicationRef) parent).getRef();
propertyName = event.getPropertyName();
} else if (parent instanceof Property) {
appName = ((Property) parent).getParent(Application.class).getName();
propertyName = ((Property) parent).getName();
}
// anything
if (applications.getApplication(appName) == null) {
return;
}
if (ServerTags.ENABLED.equals(propertyName)) {
// enable or disable application accordingly
handleAppEnableChange(event.getSource(), appName, Boolean.valueOf((String) newValue));
} else if (ServerTags.CONTEXT_ROOT.equals(propertyName) || ServerTags.VIRTUAL_SERVERS.equals(propertyName) || ServerTags.AVAILABILITY_ENABLED.equals(propertyName) || ServerTags.CDI_DEV_MODE_ENABLED_PROP.equals(propertyName)) {
// for other changes, reload the application
handleOtherAppConfigChanges(event.getSource(), appName);
}
}
}
}
}
Aggregations