8 Replies Latest reply on Sep 10, 2002 2:45 PM by jhaynie

    getXXX methods on MBean interface don't work

    jhaynie

      If you have a getXXX method on an MBean using the latest JBoss 3.0.2 codebase, they fail with:

      Cause: java.lang.NoSuchMethodException: Unable to locate method for: getFoo()]

      example interface:

      interface BarMBean extends ServiceMBean
      {
      public void getFoo ();
      }

      if i change it to this interface, it works....

      interface BarMBean extends ServiceMBean
      {
      public void foo ();
      }

      Looks like it assumes that anything with is/get/set is assumed to be an attribute only.

        • 1. Re: getXXX methods on MBean interface don't work

          True

          Regards,
          Adrian

          • 2. Re: getXXX methods on MBean interface don't work
            jhaynie

            OK, I re-looked at the spec and I guess that makes sense. If I switch to call getAttribute() instead it will work.

            According to the spec, however, it does say that "an implementation may also choose to allow the getAttributeName and setAttributeName methods, described in 'Lexical Design Patterns' on page 38, to be invoked as operations."

            I'm not sure exactly ... but it seems to read that i should be able to call foo as an attribute, and also getFoo as an operation. ?? Spec vagueness

            • 3. Re: getXXX methods on MBean interface don't work
              sgturner

              In these cases, I use:

              findFoo()
              updateFoo (Foo f)

              • 4. Re: getXXX methods on MBean interface don't work

                > According to the spec, however, it does say that "an
                > implementation may also choose to allow the
                > getAttributeName and setAttributeName methods,
                > described in 'Lexical Design Patterns' on page 38, to
                > be invoked as operations."

                This seems to be a new addition to the JMX 1.1 spec. The earlier 1.0 spec did not allow for this. However, at least Sun's RI had a bug in it where it was possible to invoke the attribute accessor methods as operations. So it seems that rather than fixing their implementation, they decided to "fix" the spec.

                We do not allow for this in our current implementation, and haven't so far seen a need to implement this bug either, even though the spec now seems to say it's ok.


                > I'm not sure exactly ... but it seems to read that i
                > should be able to call foo as an attribute, and also
                > getFoo as an operation. ?? Spec vagueness

                Notice it says the implementation may choose to allow this. We haven't allowed it.

                -- Juha

                • 5. Re: getXXX methods on MBean interface don't work
                  cepage

                  Hmmm... this doesn't seem to be extremely consistent. Running on 3.0.2, my entity beans have an exposed operation called getCacheSize().

                  It seems to work just fine.

                  However, I think cacheSize should be an attribute anyway.

                  Corby

                  • 6. Re: getXXX methods on MBean interface don't work
                    jhaynie

                    It would seem that it would be fine to first check to see if it was an attribute (is/get/set) and then if an attribute was not found, then try seeing if it maps to an operation and if so, invoke the operation if the signature matched.

                    It would be very useful, since we have MBean's that map to interfaces that have operations such as getXXX - that can't be expressed as attributes - for example, we have a method sig:

                    String [] getDialogLanguageVersion(String language);

                    This is impossible in JBossMX to invoke - since an attribute can't have parameters, and since it starts with "get" - I can't invoke it as an operation. Invoking this method fails.

                    Is there some working around, besides breaking the interface?

                    • 7. Re: getXXX methods on MBean interface don't work

                      getter with args will be invokable as operations

                      • 8. Re: getXXX methods on MBean interface don't work
                        jhaynie

                        hmmm.. this doesn't seem to work then. I tried getXXXX(args) and it fails. will check into it more.