Skip to content

Commit

Permalink
AS7-4012 Handle expressions coming in post-boot as well; bump the sub…
Browse files Browse the repository at this point in the history
…system mgmt version
  • Loading branch information
bstansberry authored and stuartwdouglas committed Mar 9, 2012
1 parent 4acbbea commit 23e6102
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion xts/src/main/java/org/jboss/as/xts/XTSExtension.java
Expand Up @@ -59,7 +59,7 @@ public class XTSExtension implements Extension {

public void initialize(ExtensionContext context) {
XtsAsLogger.ROOT_LOGGER.debug("Initializing XTS Extension");
final SubsystemRegistration subsystem = context.registerSubsystem(SUBSYSTEM_NAME, 1, 0);
final SubsystemRegistration subsystem = context.registerSubsystem(SUBSYSTEM_NAME, 1, 1);
final ManagementResourceRegistration registration = subsystem.registerSubsystemModel(XTSSubsystemProviders.SUBSYSTEM);
registration.registerOperationHandler(ModelDescriptionConstants.ADD, XTSSubsystemAdd.INSTANCE, XTSSubsystemProviders.SUBSYSTEM_ADD, false);
registration.registerOperationHandler(ModelDescriptionConstants.REMOVE, XTSSubsystemRemove.INSTANCE, XTSSubsystemProviders.SUBSYSTEM_REMOVE, false);
Expand Down
20 changes: 18 additions & 2 deletions xts/src/main/java/org/jboss/as/xts/XTSSubsystemAdd.java
Expand Up @@ -28,14 +28,18 @@
import java.util.Map;

import org.jboss.as.controller.AbstractBoottimeAddStepHandler;
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.ServiceVerificationHandler;
import org.jboss.as.controller.SimpleAttributeDefinition;
import org.jboss.as.controller.SimpleAttributeDefinitionBuilder;
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
import org.jboss.as.txn.service.TxnServices;
import org.jboss.as.webservices.service.EndpointPublishService;
import org.jboss.as.webservices.util.WSServices;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.ModelType;
import org.jboss.jbossts.XTSService;
import org.jboss.msc.service.ServiceBuilder;
import org.jboss.msc.service.ServiceController;
Expand Down Expand Up @@ -130,6 +134,10 @@ static class ContextInfo {
*/
private static final String ENDPOINT_SERVICE_HOST_NAME = "default-host";

private static final SimpleAttributeDefinition ENVIRONMENT = new SimpleAttributeDefinition(CommonAttributes.XTS_ENVIRONMENT, ModelType.OBJECT, true);
private static final AttributeDefinition URL = SimpleAttributeDefinitionBuilder.create(ModelDescriptionConstants.URL, ModelType.STRING, true)
.setAllowExpression(true).build();

private XTSSubsystemAdd() {
}

Expand All @@ -139,8 +147,16 @@ static ContextInfo[] getContextDefinitions() {

@Override
protected void populateModel(ModelNode operation, ModelNode model) throws OperationFailedException {
model.get(CommonAttributes.XTS_ENVIRONMENT, ModelDescriptionConstants.URL).set(operation.get(CommonAttributes.XTS_ENVIRONMENT).require(ModelDescriptionConstants.URL));

ModelNode environmentNode = ENVIRONMENT.validateOperation(operation);
// URL.validateOperation will do a conversion to ModelType.EXPRESSION if necessary, same as what the parser does
// This is necessary to handle the case of the "add" operation being done by a mgmt client post-boot
ModelNode urlNode = environmentNode.isDefined() ? URL.validateOperation(environmentNode) : new ModelNode();
model.get(CommonAttributes.XTS_ENVIRONMENT, ModelDescriptionConstants.URL).set(urlNode);
// Brian Stansberry 2012/03/08: TODO get rid of this complex "XTS_ENVIRONMENT" attribute and for legacy
// compatibility only add a :read-attribute handler that can synthesize the attribute value from whatever
// resource structure replaces it. By "get rid of" I mean either make the "url" attribute a simple child of
// the subsystem, or, if there will need to be multiple structures to group sets of attributes together,
// create a properly addressable resource for each.
}


Expand Down

0 comments on commit 23e6102

Please sign in to comment.