3 Replies Latest reply on Mar 31, 2015 10:56 AM by zhfeng

    How to persist the attribute value change when setting in the subsystem

    zhfeng

      Hi all,

       

      I'm working on the WFLY-1119 and it needs to generate the node identifier if it is not defined in the configuration. I had made the changes

      Comparing wildfly:master...zhfeng:WFLY-1119 · wildfly/wildfly · GitHub

      Now it works fine with changing the node value at the run time but it also needs to persist this new value in the configuration xml.

      Can anyone help me to get this work ?

       

      Thanks a lot,

      Amos

        • 1. Re: How to persist the attribute value change when setting in the subsystem
          ctomc

          What is idea behind this? you want to calculate unique id only once if not changed and save that value?

          Or would it be fine if you would just calculate the new unique id every boot?

          • 2. Re: How to persist the attribute value change when setting in the subsystem
            zhfeng

            I just want to calculate the node id when it's not defined in the standalone.xml and save the value. It does not need to calculate it every boot.

            currently the default value of node id is "1" and I have to remove the default value in my changes

            public static final SimpleAttributeDefinition NODE_IDENTIFIER = new SimpleAttributeDefinitionBuilder(CommonAttributes.NODE_IDENTIFIER, ModelType.STRING, true)

            -            .setDefaultValue(new ModelNode().set("1"))

            now the problem is how to persist and  save the new calculate value in the configuration file. I tried the following codes

            ModelNode node = model.get(TransactionSubsystemRootResourceDefinition.NODE_IDENTIFIER.getName());
            if (!node.isDefined()) {
                UUID uuid  =  UUID.randomUUID();
                node.set(new ModelNode().set(uuid.toString().substring(0, 23)));
            }
            

             

            It works fine to change the value at the run time but the new value does not persist in the configuration file.

             

            Thanks,

            Amos

            • 3. Re: How to persist the attribute value change when setting in the subsystem
              zhfeng

              if I just copy a war to the deployment directory, the new node identifier value will be persisted in the standalone.xml after shutdown the server.