Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

WFLY-1327 WFLY-901 #4490

Closed
wants to merge 2 commits into from

3 participants

@bstansberry
Owner

WFLY-1327 Make it easier to use AttributeDefinition in a runtime-only write-attribute handler

WFLY-901 use WFLY-1327 solution in fix for bug where write-attribute handler was using the wrong parameter name

Supersedes #4378.

@wildfly-ci
Collaborator

Triggering build using a merge of 89765d0 on branch master:
Private: http://lightning.mw.lab.eng.bos.redhat.com/jenkins/job/wildfly-param-pull/

@wildfly-ci
Collaborator

Build 7036 is now running using a merge of 89765d0 on branch master:
Private: http://lightning.mw.lab.eng.bos.redhat.com/jenkins/job/wildfly-param-pull/7036

@kabir
Owner

Merged

@kabir kabir closed this
@bstansberry bstansberry deleted the branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 10, 2013
  1. @bstansberry

    AS7-1327 Add AttributeDefinition methods to resolve values outside a …

    bstansberry authored
    …Resource model / add operation structure
  2. @bstansberry
This page is out of date. Refresh to see the latest.
View
54 controller/src/main/java/org/jboss/as/controller/AttributeDefinition.java
@@ -231,7 +231,8 @@ public final void validateAndSet(ModelNode operationObject, final ModelNode mode
/**
* Finds a value in the given {@code model} whose key matches this attribute's {@link #getName() name},
- * resolves it and validates it using this attribute's {@link #getValidator() validator}. If the value is
+ * uses the given {@code context} to {@link OperationContext#resolveExpressions(org.jboss.dmr.ModelNode) resolve}
+ * it and validates it using this attribute's {@link #getValidator() validator}. If the value is
* undefined and a {@link #getDefaultValue() default value} is available, the default value is used.
*
* @param context the operation context
@@ -250,11 +251,62 @@ public ModelNode resolveExpressions(ModelNode node) throws OperationFailedExcept
}, model);
}
+ /**
+ * Finds a value in the given {@code model} whose key matches this attribute's {@link #getName() name},
+ * uses the given {@code resolver} to {@link ExpressionResolver#resolveExpressions(org.jboss.dmr.ModelNode)} resolve}
+ * it and validates it using this attribute's {@link #getValidator() validator}. If the value is
+ * undefined and a {@link #getDefaultValue() default value} is available, the default value is used.
+ *
+ * @param resolver the expression resolver
+ * @param model model node of type {@link ModelType#OBJECT}, typically representing a model resource
+ *
+ * @return the resolved value, possibly the default value if the model does not have a defined value matching
+ * this attribute's name
+ * @throws OperationFailedException if the value is not valid
+ */
public ModelNode resolveModelAttribute(final ExpressionResolver resolver, final ModelNode model) throws OperationFailedException {
final ModelNode node = new ModelNode();
if(model.has(name)) {
node.set(model.get(name));
}
+ return resolveValue(resolver, node);
+ }
+
+ /**
+ * Takes the given {@code value}, resolves it using the given {@code context}
+ * and validates it using this attribute's {@link #getValidator() validator}. If the value is
+ * undefined and a {@link #getDefaultValue() default value} is available, the default value is used.
+ *
+ * @param context the context to use to {@link OperationContext#resolveExpressions(org.jboss.dmr.ModelNode) resolve} the value
+ * @param value a node that is expected to be a valid value for an attribute defined by this definition
+ *
+ * @return the resolved value, possibly the default value if {@code value} is not defined
+ *
+ * @throws OperationFailedException if the value is not valid
+ */
+ public ModelNode resolveValue(final OperationContext context, final ModelNode value) throws OperationFailedException {
+ return resolveValue(new ExpressionResolver() {
+ @Override
+ public ModelNode resolveExpressions(ModelNode node) throws OperationFailedException {
+ return context.resolveExpressions(node);
+ }
+ }, value);
+ }
+
+ /**
+ * Takes the given {@code value}, resolves it using the given {@code resolver}
+ * and validates it using this attribute's {@link #getValidator() validator}. If the value is
+ * undefined and a {@link #getDefaultValue() default value} is available, the default value is used.
+ *
+ * @param resolver the expression resolver
+ * @param value a node that is expected to be a valid value for an attribute defined by this definition
+ *
+ * @return the resolved value, possibly the default value if {@code value} is not defined
+ *
+ * @throws OperationFailedException if the value is not valid
+ */
+ public ModelNode resolveValue(final ExpressionResolver resolver, final ModelNode value) throws OperationFailedException {
+ final ModelNode node = value.clone();
if (!node.isDefined() && defaultValue.isDefined()) {
node.set(defaultValue);
}
View
4 ejb3/src/main/java/org/jboss/as/ejb3/subsystem/deployment/AbstractEJBComponentRuntimeHandler.java
@@ -43,6 +43,7 @@
import org.jboss.msc.service.ServiceName;
import org.jboss.msc.service.ServiceRegistry;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.VALUE;
import static org.jboss.as.ejb3.EjbMessages.MESSAGES;
import static org.jboss.as.ejb3.subsystem.deployment.AbstractEJBComponentResourceDefinition.COMPONENT_CLASS_NAME;
import static org.jboss.as.ejb3.subsystem.deployment.AbstractEJBComponentResourceDefinition.DECLARED_ROLES;
@@ -54,6 +55,7 @@
import static org.jboss.as.ejb3.subsystem.deployment.AbstractEJBComponentResourceDefinition.POOL_REMOVE_COUNT;
import static org.jboss.as.ejb3.subsystem.deployment.AbstractEJBComponentResourceDefinition.RUN_AS_ROLE;
import static org.jboss.as.ejb3.subsystem.deployment.AbstractEJBComponentResourceDefinition.SECURITY_DOMAIN;
+
/**
* Base class for operation handlers that provide runtime management for {@link EJBComponent}s.
*
@@ -174,7 +176,7 @@ protected void executeReadAttribute(final String attributeName, final OperationC
protected void executeWriteAttribute(String attributeName, OperationContext context, ModelNode operation, T component,
PathAddress address) throws OperationFailedException {
if (componentType.hasPool() && POOL_MAX_SIZE.getName().equals(attributeName)) {
- int newSize = POOL_MAX_SIZE.resolveModelAttribute(context, operation).asInt();
+ int newSize = POOL_MAX_SIZE.resolveValue(context, operation.get(VALUE)).asInt();
final Pool<?> pool = componentType.getPool(component);
final int oldSize = pool.getMaxSize();
componentType.getPool(component).setMaxSize(newSize);
Something went wrong with that request. Please try again.