use of org.jvnet.hk2.config.ConfigModel.Property in project Payara by payara.
the class DefaultConfigUpgrade method createProviderConfigProperty.
private void createProviderConfigProperty(ProviderConfig pc) throws PropertyVetoException {
while (!(parser.getEventType() == END_ELEMENT && parser.getLocalName().equals("provider-config"))) {
try {
if (parser.next() == START_ELEMENT) {
if (parser.getLocalName().equals("property") && pc != null) {
Property p = pc.createChild(Property.class);
pc.getProperty().add(p);
createProperty(p);
}
}
} catch (TransactionFailure ex) {
logger.log(Level.SEVERE, createProviderConfigPropertyFailed, ex);
} catch (XMLStreamException ex) {
logger.log(Level.SEVERE, problemParsingProviderConfigProp, ex);
}
}
}
use of org.jvnet.hk2.config.ConfigModel.Property in project Payara by payara.
the class DefaultConfigUpgrade method createAdminServiceProperty.
/* <property value="${com.sun.aas.installRoot}/lib/install/applications/admingui.war"
* name="adminConsoleDownloadLocation"/>
*/
private void createAdminServiceProperty(AdminService as) throws PropertyVetoException {
while (true) {
try {
if (parser.next() == START_ELEMENT) {
if (parser.getLocalName().equals("property")) {
Property p = as.createChild(Property.class);
as.getProperty().add(p);
createProperty(p);
break;
}
}
} catch (TransactionFailure ex) {
logger.log(Level.SEVERE, failedToCreateAdminService, ex);
} catch (XMLStreamException ex) {
logger.log(Level.SEVERE, problemParsingAdminService, ex);
}
}
}
use of org.jvnet.hk2.config.ConfigModel.Property in project Payara by payara.
the class GrizzlyConfigSchemaMigrator method promoteVirtualServerProperties.
private void promoteVirtualServerProperties(HttpService service) throws TransactionFailure {
for (VirtualServer virtualServer : service.getVirtualServer()) {
ConfigSupport.apply(new SingleConfigCode<VirtualServer>() {
@Override
public Object run(VirtualServer param) throws PropertyVetoException {
if (param.getHttpListeners() != null && !"".equals(param.getHttpListeners())) {
param.setNetworkListeners(param.getHttpListeners());
}
param.setHttpListeners(null);
final List<Property> propertyList = new ArrayList<Property>(param.getProperty());
final Iterator<Property> it = propertyList.iterator();
while (it.hasNext()) {
final Property property = it.next();
if ("docroot".equals(property.getName())) {
param.setDocroot(property.getValue());
it.remove();
} else if ("accesslog".equals(property.getName())) {
param.setAccessLog(property.getValue());
it.remove();
} else if ("sso-enabled".equals(property.getName())) {
param.setSsoEnabled(property.getValue());
it.remove();
}
}
param.getProperty().clear();
param.getProperty().addAll(propertyList);
return null;
}
}, virtualServer);
}
}
use of org.jvnet.hk2.config.ConfigModel.Property in project Payara by payara.
the class TargetBasedResolver method getTarget.
private <T extends ConfigBeanProxy> T getTarget(Class<? extends ConfigBeanProxy> targetType, Class<T> type) throws ClassNotFoundException {
// when using the target based parameter, we look first for a configuration of that name,
// then we look for a cluster of that name and finally we look for a subelement of the right type
final String name = getName();
ConfigBeanProxy config = habitat.getService(targetType, target);
if (config != null) {
try {
return type.cast(config);
} catch (ClassCastException e) {
// ok we need to do more work to find which object is really requested.
}
Dom parentDom = Dom.unwrap(config);
String elementName = GenericCrudCommand.elementName(parentDom.document, targetType, type);
if (elementName == null) {
return null;
}
ConfigModel.Property property = parentDom.model.getElement(elementName);
if (property.isCollection()) {
Collection<Dom> collection;
synchronized (parentDom) {
collection = parentDom.nodeElements(elementName);
}
if (collection == null) {
return null;
}
for (Dom child : collection) {
if (name.equals(child.attribute("ref"))) {
return type.cast(child.<ConfigBeanProxy>createProxy());
}
}
}
}
return null;
}
use of org.jvnet.hk2.config.ConfigModel.Property in project Payara by payara.
the class DuplicateKeyedElementTest method identicalKeyTest.
@Test(expected = TransactionFailure.class)
public void identicalKeyTest() throws TransactionFailure {
HttpService httpService = getHabitat().getService(HttpService.class);
assertNotNull(httpService);
// let's find a acceptable target.
VirtualServer target = null;
for (VirtualServer vs : httpService.getVirtualServer()) {
if (!vs.getProperty().isEmpty()) {
target = vs;
break;
}
}
assertNotNull(target);
Property newProp = (Property) ConfigSupport.apply(new SingleConfigCode<VirtualServer>() {
public Object run(VirtualServer param) throws PropertyVetoException, TransactionFailure {
// first one is fine...
Property firstProp = param.createChild(Property.class);
firstProp.setName("foo");
firstProp.setValue("bar");
param.getProperty().add(firstProp);
// this should fail...
Property secondProp = param.createChild(Property.class);
secondProp.setName("foo");
secondProp.setValue("bar");
param.getProperty().add(secondProp);
return secondProp;
}
}, target);
// if we arrive here, this is an error, we succeeded adding a property with
// the same key name.
assertTrue(false);
}
Aggregations