Announcement Announcement Module
Collapse
No announcement yet.
JMX Support, commons-attributes Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • JMX Support, commons-attributes

    Hi,
    I have been using the JMX support in the sandbox and have encountered the following:

    When I annotate my class thus,
    Code:
        /**
         * This type represents some object which will be exposed and managed via JMX.
         * <br>
         *
         * @@org.springframework.jmx.metadata.support.ManagedResource&#40;objectName="com.domain&#58;name=Service"&#41;
         */
    
        public class ManagedService
        &#123;
            ...
        &#125;
    the commons-attributes 'pre-compilation' step does not generate the objectName (_attr.setObjectName( ) value correctly
    Code:
        ...
        private void initClassAttributes &#40;&#41; &#123;
            &#123;
            org.springframework.jmx.metadata.support.ManagedResource _attr =
                new org.springframework.jmx.metadata.support.ManagedResource&#40;
                    // edited by SB
                &#41;;
            _attr.setObjectName&#40;
                "com.domain.name=Service"
            &#41;;
            Object _oattr = _attr; // Need to erase type information
            if &#40;_oattr instanceof org.apache.commons.attributes.Sealable&#41; &#123;
                &#40;&#40;org.apache.commons.attributes.Sealable&#41; _oattr&#41;.seal &#40;&#41;;
            &#125;
            classAttributes.add &#40; _attr &#41;;
            &#125;
        &#125;
        ...
    i.e.
    the "com.domain:name=Service" becomes "com.domain.name=Service" the : (colon) becomes . (a period).

    _attr.setObjectName(
    "com.domain.name=Service"
    );


    This is an error in the commons-attributes which I have been unable locate.

    Can anyone help with a fix ?

    Plus it looks as if the class definition structure is significant if the 'pre-compilation' step is to work.
    Specifically the "package" and "import" statements _must_ come before the class comment otherwise the #initClassAttributes() is generated as a no-op (empty) method.

    PS. I have posted here because there was no "sandbox/jmx/" section.

  • #2
    The solution to this error seems to be to introduce spaces around the <objectName> assignment:

    Code:
    @@org.springframework.jmx.metadata.support.ManagedResource&#40;objectName = "com.domain&#58;name=Service"&#41;
    Don't know why this works ... but it does.

    Comment

    Working...
    X