3 Replies Latest reply: Apr 25, 2002 7:49 AM by Trevor Squires RSS

Differences about invoke and getAttribute() ?

Vad Newbie

Hi,

I try and port my app from jboss3 beta to jboss3 RC1. I get NoSuchMethodExceptions when invoking some methods which are indeed attributes. I changed the calls to
invoke(...,"getMyAttr",..,..) to getAttribute(...,"MyAttr") and now it works.

May you explain me the differences ?

TIA
Vad

  • 1. Re: Differences about invoke and getAttribute() ?
    Trevor Squires Novice

    Hmmm...

    I wrote a long explanation of this ages ago and now I can't find it...

    The difference is that just because you have an attribute called MyAttr you cannot assume that there is a getter method called getMyAttr. Nor can you even assume that there is a getter/setter method at all (because of ModelMBeans by the way).

    You should only call invoke() for operations listed in the MBeanInfo.

    HTH
    Trevor

  • 2. Re: Differences about invoke and getAttribute() ?
    Vad Newbie

    Thanks for your quick answer.

    > The difference is that just because you have an
    > attribute called MyAttr you cannot assume that there
    > is a getter method called getMyAttr. Nor can you
    > even assume that there is a getter/setter method at
    > all (because of ModelMBeans by the way)

    OK, but if I know they exist?...

    > You should only call invoke() for operations listed
    > in the MBeanInfo.

    My MBean are just basic ones, do you mean I should write (or maybe generate via some xdoclet stuff?) MBeanInfo classes for each of them?

    Vad

  • 3. Re: Differences about invoke and getAttribute() ?
    Trevor Squires Novice

    > OK, but if I know they exist?...

    You know the methods exist but you're relying on the StandardMBean naming conventions (right?) to convert your XXXMBean interface into MBeanInfo.

    You should consider that (as of the current spec) the MBeanServer can only act according to an MBean's MBeanInfo.

    > My MBean are just basic ones, do you mean I should
    > write (or maybe generate via some xdoclet stuff?)
    > MBeanInfo classes for each of them?

    Yes, if you want more control over what attributes and operations you want to expose then yes, you either write a DynamicMBean or you wrap your managed resource with a ModelMBean (XMBean using xdoclet as you say).

    Trev