use of org.jboss.dmr.Property in project wildfly by wildfly.
the class RemoteActiveMQProviderJMSOperations method executeOperation.
private void executeOperation(final ModelNode address, final String opName, ModelNode attributes) {
final ModelNode operation = new ModelNode();
operation.get(OP).set(opName);
operation.get(OP_ADDR).set(address);
if (attributes != null) {
for (Property property : attributes.asPropertyList()) {
operation.get(property.getName()).set(property.getValue());
}
}
try {
execute(client, operation);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of org.jboss.dmr.Property in project wildfly by wildfly.
the class ServletContainerAdd method installRuntimeServices.
void installRuntimeServices(OperationContext context, ModelNode model, String name) throws OperationFailedException {
final ModelNode fullModel = Resource.Tools.readModel(context.readResource(PathAddress.EMPTY_ADDRESS), 2);
final SessionCookieConfig config = SessionCookieDefinition.INSTANCE.getConfig(context, fullModel.get(SessionCookieDefinition.INSTANCE.getPathElement().getKeyValuePair()));
final CrawlerSessionManagerConfig crawlerSessionManagerConfig = CrawlerSessionManagementDefinition.INSTANCE.getConfig(context, fullModel.get(CrawlerSessionManagementDefinition.INSTANCE.getPathElement().getKeyValuePair()));
final boolean persistentSessions = PersistentSessionsDefinition.isEnabled(context, fullModel.get(PersistentSessionsDefinition.INSTANCE.getPathElement().getKeyValuePair()));
final boolean allowNonStandardWrappers = ServletContainerDefinition.ALLOW_NON_STANDARD_WRAPPERS.resolveModelAttribute(context, model).asBoolean();
final boolean proactiveAuth = ServletContainerDefinition.PROACTIVE_AUTHENTICATION.resolveModelAttribute(context, model).asBoolean();
final String bufferCache = ServletContainerDefinition.DEFAULT_BUFFER_CACHE.resolveModelAttribute(context, model).asString();
final boolean disableFileWatchService = ServletContainerDefinition.DISABLE_FILE_WATCH_SERVICE.resolveModelAttribute(context, model).asBoolean();
final boolean disableSessionIdReususe = ServletContainerDefinition.DISABLE_SESSION_ID_REUSE.resolveModelAttribute(context, model).asBoolean();
JSPConfig jspConfig = JspDefinition.INSTANCE.getConfig(context, fullModel.get(JspDefinition.INSTANCE.getPathElement().getKeyValuePair()));
final String stackTracesString = ServletContainerDefinition.STACK_TRACE_ON_ERROR.resolveModelAttribute(context, model).asString();
final ModelNode defaultEncodingValue = ServletContainerDefinition.DEFAULT_ENCODING.resolveModelAttribute(context, model);
final String defaultEncoding = defaultEncodingValue.isDefined() ? defaultEncodingValue.asString() : null;
final boolean useListenerEncoding = ServletContainerDefinition.USE_LISTENER_ENCODING.resolveModelAttribute(context, model).asBoolean();
final boolean ignoreFlush = ServletContainerDefinition.IGNORE_FLUSH.resolveModelAttribute(context, model).asBoolean();
final boolean eagerFilterInit = ServletContainerDefinition.EAGER_FILTER_INIT.resolveModelAttribute(context, model).asBoolean();
final boolean disableCachingForSecuredPages = ServletContainerDefinition.DISABLE_CACHING_FOR_SECURED_PAGES.resolveModelAttribute(context, model).asBoolean();
final int sessionIdLength = ServletContainerDefinition.SESSION_ID_LENGTH.resolveModelAttribute(context, model).asInt();
final int fileCacheMetadataSize = ServletContainerDefinition.FILE_CACHE_METADATA_SIZE.resolveModelAttribute(context, model).asInt();
final int fileCacheMaxFileSize = ServletContainerDefinition.FILE_CACHE_MAX_FILE_SIZE.resolveModelAttribute(context, model).asInt();
final ModelNode fileCacheTtlNode = ServletContainerDefinition.FILE_CACHE_TIME_TO_LIVE.resolveModelAttribute(context, model);
final Integer fileCacheTimeToLive = fileCacheTtlNode.isDefined() ? fileCacheTtlNode.asInt() : null;
final int defaultCookieVersion = ServletContainerDefinition.DEFAULT_COOKIE_VERSION.resolveModelAttribute(context, model).asInt();
final boolean preservePathOnForward = ServletContainerDefinition.PRESERVE_PATH_ON_FORWARD.resolveModelAttribute(context, model).asBoolean();
Boolean directoryListingEnabled = null;
if (model.hasDefined(Constants.DIRECTORY_LISTING)) {
directoryListingEnabled = ServletContainerDefinition.DIRECTORY_LISTING.resolveModelAttribute(context, model).asBoolean();
}
Integer maxSessions = null;
if (model.hasDefined(Constants.MAX_SESSIONS)) {
maxSessions = ServletContainerDefinition.MAX_SESSIONS.resolveModelAttribute(context, model).asInt();
}
final int sessionTimeout = ServletContainerDefinition.DEFAULT_SESSION_TIMEOUT.resolveModelAttribute(context, model).asInt();
WebsocketsDefinition.WebSocketInfo webSocketInfo = WebsocketsDefinition.INSTANCE.getConfig(context, fullModel.get(WebsocketsDefinition.INSTANCE.getPathElement().getKeyValuePair()));
final Map<String, String> mimeMappings = new HashMap<>();
if (fullModel.hasDefined(Constants.MIME_MAPPING)) {
for (final Property mapping : fullModel.get(Constants.MIME_MAPPING).asPropertyList()) {
mimeMappings.put(mapping.getName(), MimeMappingDefinition.VALUE.resolveModelAttribute(context, mapping.getValue()).asString());
}
}
List<String> welcomeFiles = new ArrayList<>();
if (fullModel.hasDefined(Constants.WELCOME_FILE)) {
for (final Property welcome : fullModel.get(Constants.WELCOME_FILE).asPropertyList()) {
welcomeFiles.add(welcome.getName());
}
}
final CapabilityServiceBuilder<?> sb = context.getCapabilityServiceTarget().addCapability(ServletContainerDefinition.SERVLET_CONTAINER_CAPABILITY);
final Consumer<ServletContainerService> sConsumer = sb.provides(ServletContainerDefinition.SERVLET_CONTAINER_CAPABILITY, UndertowService.SERVLET_CONTAINER.append(name));
final Supplier<SessionPersistenceManager> spmSupplier = persistentSessions ? sb.requires(AbstractPersistentSessionManager.SERVICE_NAME) : null;
final Supplier<DirectBufferCache> bcSupplier = bufferCache != null ? sb.requires(BufferCacheService.SERVICE_NAME.append(bufferCache)) : null;
final Supplier<ByteBufferPool> bbpSupplier = webSocketInfo != null ? sb.requiresCapability(Capabilities.CAPABILITY_BYTE_BUFFER_POOL, ByteBufferPool.class, webSocketInfo.getBufferPool()) : null;
final Supplier<XnioWorker> xwSupplier = webSocketInfo != null ? sb.requiresCapability(Capabilities.REF_IO_WORKER, XnioWorker.class, webSocketInfo.getWorker()) : null;
final ServletContainerService container = new ServletContainerService(sConsumer, spmSupplier, bcSupplier, bbpSupplier, xwSupplier, allowNonStandardWrappers, ServletStackTraces.valueOf(stackTracesString.toUpperCase().replace('-', '_')), config, jspConfig, defaultEncoding, useListenerEncoding, ignoreFlush, eagerFilterInit, sessionTimeout, disableCachingForSecuredPages, webSocketInfo != null, webSocketInfo != null && webSocketInfo.isDispatchToWorker(), webSocketInfo != null && webSocketInfo.isPerMessageDeflate(), webSocketInfo == null ? -1 : webSocketInfo.getDeflaterLevel(), mimeMappings, welcomeFiles, directoryListingEnabled, proactiveAuth, sessionIdLength, maxSessions, crawlerSessionManagerConfig, disableFileWatchService, disableSessionIdReususe, fileCacheMetadataSize, fileCacheMaxFileSize, fileCacheTimeToLive, defaultCookieVersion, preservePathOnForward);
sb.setInstance(container);
sb.setInitialMode(ServiceController.Mode.ON_DEMAND);
sb.install();
}
use of org.jboss.dmr.Property in project eap-additional-testsuite by jboss-set.
the class ExpressionSupportSmokeTestCase method handleSimpleCollection.
private void handleSimpleCollection(PathAddress address, String attrName, ModelNode attrValue, ModelType valueType, Map<String, ModelNode> expressionAttrs, Map<String, ModelNode> otherAttrs, Map<String, ModelNode> expectedAttrs) {
if (COMPLEX_TYPES.contains(valueType)) {
// Too complicated
noSimpleCollection++;
logNoExpressions(address, attrName);
otherAttrs.put(attrName, attrValue);
} else {
boolean hasExpression = false;
ModelNode updated = new ModelNode();
ModelNode expected = new ModelNode();
for (ModelNode item : attrValue.asList()) {
ModelType itemType = item.getType();
if (itemType == ModelType.PROPERTY) {
Property prop = item.asProperty();
ModelNode propVal = prop.getValue();
ModelType propValType = propVal.getType();
if (propVal.isDefined() && propValType != ModelType.EXPRESSION) {
// Convert property value to expression
if (propValType == ModelType.STRING) {
checkForUnconvertedExpression(address, attrName, propVal);
}
String expression = "${exp.test:" + propVal.asString() + "}";
updated.get(prop.getName()).set(expression);
expected.get(prop.getName()).set(new ModelNode().set(new ValueExpression(expression)));
hasExpression = true;
} else {
updated.get(prop.getName()).set(propVal);
expected.get(prop.getName()).set(propVal);
}
} else if (item.isDefined() && itemType != ModelType.EXPRESSION) {
// Convert item to expression
if (itemType == ModelType.STRING) {
checkForUnconvertedExpression(address, attrName, item);
}
String expression = "${exp.test:" + item.asString() + "}";
updated.add(expression);
expected.add(new ModelNode().set(new ValueExpression(expression)));
hasExpression = true;
} else {
updated.add(item);
expected.add(item);
}
}
if (hasExpression) {
simpleCollection++;
logHandling("Added expression to SIMPLE " + attrValue.getType() + " attribute " + attrName + " at " + address.toModelNode().asString());
expressionAttrs.put(attrName, updated);
expectedAttrs.put(attrName, expected);
} else {
// We didn't change anything
noSimpleCollection++;
logNoExpressions(address, attrName);
otherAttrs.put(attrName, attrValue);
expectedAttrs.put(attrName, attrValue);
}
}
}
use of org.jboss.dmr.Property in project eap-additional-testsuite by jboss-set.
the class ExpressionSupportSmokeTestCase method organizeAttributes.
private void organizeAttributes(PathAddress address, ModelNode description, ModelNode resource, ModelNode resourceNoDefaults, Map<String, ModelNode> expressionAttrs, Map<String, ModelNode> otherAttrs, Map<String, ModelNode> expectedAttrs) {
ModelNode attributeDescriptions = description.get(ATTRIBUTES);
for (Property descProp : attributeDescriptions.asPropertyList()) {
String attrName = descProp.getName();
ModelNode attrDesc = descProp.getValue();
if (isAttributeExcluded(address, attrName, attrDesc, resourceNoDefaults)) {
continue;
}
ModelNode noDefaultValue = resourceNoDefaults.get(attrName);
if (!noDefaultValue.isDefined()) {
// We need to see if it's legal to set this attribute, or whether it's undefined
// because an alternative attribute is defined
Set<String> base = new HashSet<String>();
base.add(attrName);
if (attrDesc.hasDefined(REQUIRES)) {
for (ModelNode node : attrDesc.get(REQUIRES).asList()) {
base.add(node.asString());
}
}
boolean conflict = false;
for (String baseAttr : base) {
if (!resource.hasDefined(baseAttr)) {
conflict = true;
break;
}
ModelNode baseAttrAlts = attributeDescriptions.get(baseAttr, ALTERNATIVES);
if (baseAttrAlts.isDefined()) {
for (ModelNode alt : baseAttrAlts.asList()) {
String altName = alt.asString();
if (resourceNoDefaults.hasDefined(alt.asString()) || expressionAttrs.containsKey(altName) || otherAttrs.containsKey(altName)) {
conflict = true;
break;
}
}
}
}
if (conflict) {
conflicts++;
logHandling("Skipping conflicted attribute " + attrName + " at " + address.toModelNode().asString());
continue;
}
}
ModelNode attrValue = resource.get(attrName);
ModelType attrType = attrValue.getType();
if (attrDesc.get(EXPRESSIONS_ALLOWED).asBoolean(false)) {
// If it's defined and not an expression, use the current value to create an expression
if (attrType != ModelType.UNDEFINED && attrType != ModelType.EXPRESSION) {
// Deal with complex types specially
if (COMPLEX_TYPES.contains(attrType)) {
ModelNode valueType = attrDesc.get(VALUE_TYPE);
if (valueType.getType() == ModelType.TYPE) {
// Simple collection whose elements support expressions
handleSimpleCollection(address, attrName, attrValue, valueType.asType(), expressionAttrs, otherAttrs, expectedAttrs);
} else if (valueType.isDefined()) {
handleComplexCollection(address, attrName, attrValue, attrType, valueType, expressionAttrs, otherAttrs, expectedAttrs);
} else {
noSimple++;
logNoExpressions(address, attrName);
otherAttrs.put(attrName, attrValue);
expectedAttrs.put(attrName, attrValue);
}
} else {
if (attrType == ModelType.STRING) {
checkForUnconvertedExpression(address, attrName, attrValue);
}
String expression = "${exp.test:" + attrValue.asString() + "}";
expressionAttrs.put(attrName, new ModelNode(expression));
expectedAttrs.put(attrName, new ModelNode().set(new ValueExpression(expression)));
simple++;
logHandling("Added expression to simple attribute " + attrName + " at " + address.toModelNode().asString());
}
} else {
if (attrType != ModelType.EXPRESSION) {
supportedUndefined++;
logHandling("Expression supported but value undefined on simple attribute " + attrName + " at " + address.toModelNode().asString());
} else {
simple++;
logHandling("Already found an expression on simple attribute " + attrName + " at " + address.toModelNode().asString());
}
otherAttrs.put(attrName, attrValue);
expectedAttrs.put(attrName, attrValue);
}
} else if (COMPLEX_TYPES.contains(attrType) && attrDesc.get(VALUE_TYPE).getType() != ModelType.TYPE && attrDesc.get(VALUE_TYPE).isDefined()) {
handleComplexCollection(address, attrName, attrValue, attrType, attrDesc.get(VALUE_TYPE), expressionAttrs, otherAttrs, expectedAttrs);
} else /*if (!attrDesc.hasDefined(DEPRECATED))*/
{
noSimple++;
logNoExpressions(address, attrName);
otherAttrs.put(attrName, attrValue);
expectedAttrs.put(attrName, attrValue);
}
}
}
use of org.jboss.dmr.Property in project eap-additional-testsuite by jboss-set.
the class LoggingDeploymentResourceTestCase method testEarDeploymentConfigurationResource.
@OperateOnDeployment(EAR_DEPLOYMENT_NAME)
@Test
public void testEarDeploymentConfigurationResource() throws Exception {
ModelNode loggingConfiguration = readDeploymentResource(EAR_DEPLOYMENT_NAME, EAR_DEPLOYMENT_NAME + "/META-INF/logging.properties");
// The address should have logging.properties
Deque<Property> resultAddress = new ArrayDeque<>(Operations.getOperationAddress(loggingConfiguration).asPropertyList());
Assert.assertTrue("The configuration path did not include logging.properties", resultAddress.getLast().getValue().asString().contains("logging.properties"));
ModelNode handler = loggingConfiguration.get("handler", "FILE");
Assert.assertTrue("The FILE handler was not found effective configuration", handler.isDefined());
Assert.assertTrue(handler.hasDefined("properties"));
String fileName = null;
// Find the fileName property
for (Property property : handler.get("properties").asPropertyList()) {
if ("fileName".equals(property.getName())) {
fileName = property.getValue().asString();
break;
}
}
Assert.assertNotNull("fileName property not found", fileName);
Assert.assertTrue(fileName.endsWith("test-logging-ear.log"));
// Check the WAR which should inherit the EAR's logging.properties
loggingConfiguration = readSubDeploymentResource(EAR_DEPLOYMENT_NAME, EAR_WAR_DEPLOYMENT_NAME, EAR_DEPLOYMENT_NAME + "/META-INF/logging.properties");
// The address should have logging.properties
resultAddress = new ArrayDeque<>(Operations.getOperationAddress(loggingConfiguration).asPropertyList());
Assert.assertTrue("The configuration path did not include logging.properties", resultAddress.getLast().getValue().asString().contains("logging.properties"));
handler = loggingConfiguration.get("handler", "FILE");
Assert.assertTrue("The FILE handler was not found effective configuration", handler.isDefined());
Assert.assertTrue(handler.hasDefined("properties"));
fileName = null;
// Find the fileName property
for (Property property : handler.get("properties").asPropertyList()) {
if ("fileName".equals(property.getName())) {
fileName = property.getValue().asString();
break;
}
}
Assert.assertNotNull("fileName property not found", fileName);
Assert.assertTrue(fileName.endsWith("test-logging-ear.log"));
}
Aggregations