Permalink
Browse files

Changed "enableResource" to execute after all resources.

If adding xa-datasource-properties, an exception was generated because
the xa-datasource was enabled before any of the
xa-datasource-properties had been added.  This changes the
enableResource to execute after all resources have been added.  I
believe this is an imperfect solution.  I will discuss this with the
other developers.
  • Loading branch information...
jbrownfield committed Jan 29, 2012
1 parent 4d34ed9 commit 9dbfea5954a2e6876d65060e022c578146de4ef1
Showing with 12 additions and 1 deletion.
  1. +12 −1 src/main/java/org/jboss/as/plugin/deployment/resource/AddResource.java
@@ -126,6 +126,8 @@ public void execute() throws MojoExecutionException, MojoFailureException {
}
private void processResources(final ModelControllerClient client, final Resource... resources) throws IOException {
+ ModelNode finalOP = null;
+
for (Resource resource : resources) {
final String address;
if (this.address == null) {
@@ -148,11 +150,20 @@ private void processResources(final ModelControllerClient client, final Resource
op.get(ClientConstants.ROLLBACK_ON_RUNTIME_FAILURE).set(true);
op.get(ClientConstants.STEPS).add(buildAddOperation(address, resource.getProperties()));
if (resource.isEnableResource()) {
- op.get(ClientConstants.STEPS).add(buildEnableOperation(address));
+ if (finalOP != null) {
+ throw new RuntimeException("Only one resouce can have 'enableResource' set to 'true'");
+ }
+ finalOP = buildEnableOperation(address);
+ //op.get(ClientConstants.STEPS).add(buildEnableOperation(address));
}
ModelNode r = client.execute(OperationBuilder.create(op).build());
reportFailure(r);
}
+
+ if (finalOP != null) {
+ ModelNode r = client.execute(OperationBuilder.create(finalOP).build());
+ reportFailure(r);
+ }
}
/**

0 comments on commit 9dbfea5

Please sign in to comment.