3 Replies Latest reply on Oct 6, 2011 3:14 PM by lmcdasi

    module add listener for standalone xml changes

    lmcdasi

      How one could add a listener within a module in order to detect configuration changes ? The module extension has to implement the write element in order to perform the write to the xml file but I would like to know what would be the recommended way to "wire" that update with a module ?

        • 1. Re: module add listener for standalone xml changes
          lmcdasi

          The only way that I could figure out - which maybe very well wrong - is to have define a :

           

          modules.registerOperationHandler(ModelDescriptionConstants.ADD, ....)

           

          on a class where one needs to have implemented the execute method. In that method the service can be found and invoke a method from it. The key is to be carefull about the classloader when executing that method (need to set the thread classloader to the class classloader).

          At the same time the method shall be executing only id the service has been started .....

           

          if (context.getType() == OperationContext.Type.SERVER) {

                      context.addStep(new OperationStepHandler() {

                          @Override

                          public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {

                              String identifier = operation.get(ModelDescriptionConstants.OP_ADDR).asObject().get(CommonAttributes.MODULE).asString();

                             

                              ..... <YOUR CORE> ....

                                                

                              if (context.completeStep() == OperationContext.ResultAction.ROLLBACK) {

                                  stateService.removeModule(identifier);

                              }

                          }

                      }, OperationContext.Stage.RUNTIME);

          • 2. Re: module add listener for standalone xml changes
            jason.greene

            Did you get a chance to check out the example and archetype here:

            https://docs.jboss.org/author/display/AS7/Extending+JBoss+AS+7

            1 of 1 people found this helpful
            • 3. Re: module add listener for standalone xml changes
              lmcdasi

              A big while ago. The catch is that the service.setTick(tick) from the example will not run within the same classloader as when the service started.