4 Replies Latest reply on Dec 16, 2013 1:17 PM by amyw

    How does an agent plugin know when a connection setting has changed?

    amyw

      I am working on an agent plugin where users are able to connect to a JMX MBean server either remotely or via local attach.  Is there some sort of ConnectionSettingsListener that allows me to be notified if the user makes a change in the connection settings page?  I want to ensure that if the user decides to switch from local to remote, the agent plugin will switch how it is connecting to the MBean server.

       

      Also, is there a way to update my resource's version number after it has been discovered?  I have timing issue where sometimes my agent is unable to determine version number during discovery but it is able to determine some time after the Component has been created.  Is there a way for the agent to update the version number later?

       

      Thanks

        • 1. Re: How does an agent plugin know when a connection setting has changed?
          genman

          As for the version issue, the only way to set version is through the discovery component. Unfortunately, the component itself can't tell discovery the version number: https://bugzilla.redhat.com/show_bug.cgi?id=1000637

           

          I think one hack would be to use some sort of static Map. Once the component is created and starts, it simply keeps in a static variable the version tied to a key. E.g. static Map<String, String> keyToVersionMap. You can then fetch the version in discovery. Note: Possible memory leak here.

          1 of 1 people found this helpful
          • 2. Re: How does an agent plugin know when a connection setting has changed?
            amyw

            Thanks for the bug reference.  It actually describes a similar issue I am facing regarding partially discovering a resource and requiring user input before fully "discovering" the resource.

            • 3. Re: How does an agent plugin know when a connection setting has changed?
              lkrejci

              Amy Wu wrote:

               

              I am working on an agent plugin where users are able to connect to a JMX MBean server either remotely or via local attach.  Is there some sort of ConnectionSettingsListener that allows me to be notified if the user makes a change in the connection settings page?  I want to ensure that if the user decides to switch from local to remote, the agent plugin will switch how it is connecting to the MBean server.

               

               

              This should be automatic. As soon as you change your plugin configuration (aka connection properties, which IMHO better describes its intended purpose), your resource component on the agent is stopped and started anew with the updated plugin configuration.

              • 4. Re: How does an agent plugin know when a connection setting has changed?
                amyw

                Okay, thanks, this is good to know that the resource component will always be stopped and started again whenever there is an update to the connection properties.  So then we can store how we are connecting to the server currently and whenever our component is stopped and started again, we can check if the current connection settings have changed from what we have stored in our member variable.