3 Replies Latest reply on Nov 12, 2012 3:12 PM by Alex B

    Adding Optimistic locking programmatically

    Alex B Newbie

      I am trying to programatically add the following to my JBoss 7 configuration:

       

      {code:xml}

      <entity-bean>

         

      <optimistic-locking enabled="true" />

       

      </entity-bean>

       

      {code:xml}

       

       

      Trying to use the following code,but it doesn't work, checking with jboss-cli I can't even find entity-bean in ejb3 subsystem

       

      {code}

          public static void setOptimisticLocking(ModelControllerClient client,boolean value) throws IOException {

              ModelNode request = new ModelNode();

              request.get(ClientConstants.OP).set(ClientConstants.ADD);

              request.get(ClientConstants.OP_ADDR).add("subsystem",

                      "ejb3");

       

       

              request.get(ClientConstants.OP_ADDR).add("entity-bean","default");

              request.get("name").set("optimistic-locking");

              request.get("value").set(value);

              ModelNode result = client.execute(new OperationBuilder(request).build());

       

       

              String outcome = result.get(ClientConstants.OUTCOME).asString();

              String description = "";

              if (outcome.equalsIgnoreCase("failed")) {

                  description += " ,Reason: " + result.get(ClientConstants.FAILURE_DESCRIPTION).asString();

              }

              System.out.println("Setting Optimistic locking: Result: " + outcome + description);

          }

       

      {code}