2 Replies Latest reply on Dec 10, 2004 3:16 AM by p_nevilleuk

    Flaws in XMBean example

    gunterze

      The XMBean version(s) of the JNDIMap MBean example contains some misleading flaws:

      The XMBean descriptor specifies default values for attributes with associated getMethods. But default values only applies to attributes stored in the MMB meta data and has no effect for attributes retrieved from the managed resource.

      jboss-service.xml specifies
      inmemory/maps/MapTest
      also in the examples, which demonstrates MMB persistence. Hence JndiName is always initialized with the specified value at restart, independent which value was stored in the serialized MMB instance.

      It took me several hours, to figure out, that it is not possible to specify first start default values for attributes backed by the resource: specifing it in the MMB descriptor has no effect and specifying it in jboss-service.xml rattens persistence of changed values.

        • 1. Re: Flaws in XMBean example
          starksm64

          Correct: Use of the jboss-service.xml attribute elements conflicts with the use of XMBean persistence. I have pointed this out in the next edition.

          Correct: The default element does not actually affect the value of an attribute as seen by the underlying XMBean if it has a setter. Its only used when there is no accessor and no value element. This has been claried in the next edition.

          Incorect: You cannot set an initial attribute value from the XMBean descriptor. You need to use the value element:


          The location in JNDI where the Map we manage will be bound
          JndiName
          java.lang.String





          On startup this value is set on the XMBean before any peristent value is loaded. The version 2 XMBean example now uses this mechanism to bootstrap the JndiName attribute.

          • 2. Re: Flaws in XMBean example
            p_nevilleuk

            I have been trying to provide a default value for an XMBean (using the xml config files) if a persisted value is not available, but cannot achieve this. If I set the attribute in jboss-service.xml, it overwrites the persisted value on startup. The default value in xmbean.xml is not suitable as it is only for attibutes with no accessor.

            This topic seems related, but can you confirm that this is the case please and if so, what do you mean by 'the next edition'?

            I am using jboss 4.0.0.