Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

WFLY-1327 WFLY-901 #4490

Closed
wants to merge 2 commits into from

3 participants

 Brian Stansberry WildFly CI Kabir Khan
 Brian Stansberry
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

WildFly CI
Collaborator
Kabir Khan
Owner
kabir commented

Merged

Kabir Khan kabir closed this
 Brian Stansberry bstansberry deleted the branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 2 unique commits by 1 author.

May 10, 2013
 Brian Stansberry bstansberry AS7-1327 Add AttributeDefinition methods to resolve values outside a …
…Resource model / add operation structure
45f7c11
 Brian Stansberry bstansberry WFLY-901 Use the correct parameter name 89765d0
This page is out of date. Refresh to see the latest.
54 controller/src/main/java/org/jboss/as/controller/AttributeDefinition.java
@@ -231,7 +231,8 @@ public final void validateAndSet(ModelNode operationObject, final ModelNode mode
231 231
232 232 /**
233 233 * Finds a value in the given {@code model} whose key matches this attribute's {@link #getName() name},
234   - * resolves it and validates it using this attribute's {@link #getValidator() validator}. If the value is
  234 + * uses the given {@code context} to {@link OperationContext#resolveExpressions(org.jboss.dmr.ModelNode) resolve}
  235 + * it and validates it using this attribute's {@link #getValidator() validator}. If the value is
235 236 * undefined and a {@link #getDefaultValue() default value} is available, the default value is used.
236 237 *
237 238 * @param context the operation context
@@ -250,11 +251,62 @@ public ModelNode resolveExpressions(ModelNode node) throws OperationFailedExcept
250 251 }, model);
251 252 }
252 253
  254 + /**
  255 + * Finds a value in the given {@code model} whose key matches this attribute's {@link #getName() name},
  256 + * uses the given {@code resolver} to {@link ExpressionResolver#resolveExpressions(org.jboss.dmr.ModelNode)} resolve}
  257 + * it and validates it using this attribute's {@link #getValidator() validator}. If the value is
  258 + * undefined and a {@link #getDefaultValue() default value} is available, the default value is used.
  259 + *
  260 + * @param resolver the expression resolver
  261 + * @param model model node of type {@link ModelType#OBJECT}, typically representing a model resource
  262 + *
  263 + * @return the resolved value, possibly the default value if the model does not have a defined value matching
  264 + * this attribute's name
  265 + * @throws OperationFailedException if the value is not valid
  266 + */
253 267 public ModelNode resolveModelAttribute(final ExpressionResolver resolver, final ModelNode model) throws OperationFailedException {
254 268 final ModelNode node = new ModelNode();
255 269 if(model.has(name)) {
256 270 node.set(model.get(name));
257 271 }
  272 + return resolveValue(resolver, node);
  273 + }
  274 +
  275 + /**
  276 + * Takes the given {@code value}, resolves it using the given {@code context}
  277 + * and validates it using this attribute's {@link #getValidator() validator}. If the value is
  278 + * undefined and a {@link #getDefaultValue() default value} is available, the default value is used.
  279 + *
  280 + * @param context the context to use to {@link OperationContext#resolveExpressions(org.jboss.dmr.ModelNode) resolve} the value
  281 + * @param value a node that is expected to be a valid value for an attribute defined by this definition
  282 + *
  283 + * @return the resolved value, possibly the default value if {@code value} is not defined
  284 + *
  285 + * @throws OperationFailedException if the value is not valid
  286 + */
  287 + public ModelNode resolveValue(final OperationContext context, final ModelNode value) throws OperationFailedException {
  288 + return resolveValue(new ExpressionResolver() {
  289 + @Override
  290 + public ModelNode resolveExpressions(ModelNode node) throws OperationFailedException {
  291 + return context.resolveExpressions(node);
  292 + }
  293 + }, value);
  294 + }
  295 +
  296 + /**
  297 + * Takes the given {@code value}, resolves it using the given {@code resolver}
  298 + * and validates it using this attribute's {@link #getValidator() validator}. If the value is
  299 + * undefined and a {@link #getDefaultValue() default value} is available, the default value is used.
  300 + *
  301 + * @param resolver the expression resolver
  302 + * @param value a node that is expected to be a valid value for an attribute defined by this definition
  303 + *
  304 + * @return the resolved value, possibly the default value if {@code value} is not defined
  305 + *
  306 + * @throws OperationFailedException if the value is not valid
  307 + */
  308 + public ModelNode resolveValue(final ExpressionResolver resolver, final ModelNode value) throws OperationFailedException {
  309 + final ModelNode node = value.clone();
258 310 if (!node.isDefined() && defaultValue.isDefined()) {
259 311 node.set(defaultValue);
260 312 }
4 ejb3/src/main/java/org/jboss/as/ejb3/subsystem/deployment/AbstractEJBComponentRuntimeHandler.java
@@ -43,6 +43,7 @@
43 43 import org.jboss.msc.service.ServiceName;
44 44 import org.jboss.msc.service.ServiceRegistry;
45 45
  46 +import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.VALUE;
46 47 import static org.jboss.as.ejb3.EjbMessages.MESSAGES;
47 48 import static org.jboss.as.ejb3.subsystem.deployment.AbstractEJBComponentResourceDefinition.COMPONENT_CLASS_NAME;
48 49 import static org.jboss.as.ejb3.subsystem.deployment.AbstractEJBComponentResourceDefinition.DECLARED_ROLES;
@@ -54,6 +55,7 @@
54 55 import static org.jboss.as.ejb3.subsystem.deployment.AbstractEJBComponentResourceDefinition.POOL_REMOVE_COUNT;
55 56 import static org.jboss.as.ejb3.subsystem.deployment.AbstractEJBComponentResourceDefinition.RUN_AS_ROLE;
56 57 import static org.jboss.as.ejb3.subsystem.deployment.AbstractEJBComponentResourceDefinition.SECURITY_DOMAIN;
  58 +
57 59 /**
58 60 * Base class for operation handlers that provide runtime management for {@link EJBComponent}s.
59 61 *
@@ -174,7 +176,7 @@ protected void executeReadAttribute(final String attributeName, final OperationC
174 176 protected void executeWriteAttribute(String attributeName, OperationContext context, ModelNode operation, T component,
175 177 PathAddress address) throws OperationFailedException {
176 178 if (componentType.hasPool() && POOL_MAX_SIZE.getName().equals(attributeName)) {
177   - int newSize = POOL_MAX_SIZE.resolveModelAttribute(context, operation).asInt();
  179 + int newSize = POOL_MAX_SIZE.resolveValue(context, operation.get(VALUE)).asInt();
178 180 final Pool<?> pool = componentType.getPool(component);
179 181 final int oldSize = pool.getMaxSize();
180 182 componentType.getPool(component).setMaxSize(newSize);

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.