Announcement Announcement Module
Collapse
No announcement yet.
Creating a custom output in Mx4j/HttpAdapter for the result of a mbean operation Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Creating a custom output in Mx4j/HttpAdapter for the result of a mbean operation

    Hi,
    I have a mbean that has an operation which returns a map. How can I configure the mx4j to display the result as a table. I understood that I can customize the output from XSLTProcessor by creating a xsl template, but I don't know how to configure the XSLTProcessor or mx4j to use a special xsl template for displaying the result of an mbean operation.
    Can someone help me?

    Thanks & Regards

  • #2
    I will answer to my question.
    So the HttpAdaptor doesn't offer the possibility to create a custom web page for a return result from a bean operation. HttpAdaptor will display the string returned from toString() method of the return object.

    In order to create a customized output I've:
    1. insert some new classes called converters which conver the return object into xml code
    2. changed InvokeCommandProcessor class to call the converter for a specific type
    3. insert some new xsl templates to handle the new xml code for every type.

    Basically the idea is to move the logic of generating xml into the client side and here we can format as we want.

    Comment


    • #3
      Hi BlackEagle, Do you perhaps have sample code or diagrams depicting how you achieved this? I have a similar 'problem' whereby I need to customise the output of the admin pages for my Mbeans, and figured this would be the best approach.

      Comment


      • #4
        Hi,

        I will try this weekend to search the code for you, but since it pass more than one year, I can't promise you anything.

        Regards

        Comment


        • #5
          Hi,
          I finnaly had time to search the code. I have to say that it my be that you still have to implement something to work, but at least most of the job is done. Attached you will find the modified mx4j source code and next is a small explanation about what I have done and also some quidelines how to create a customized output.

          Basically there are 2 big steps that we have to make:

          1. Create a customized xml output from httpadaptor. The HttpAdaptor is not able to configure into a specific format the xml file for a class type. To have this I have modified and add the next classes: Modified: HttpAdaptor.java, HttpCommandProcessor.java, HttpCommandProcessorAdaptor.java, InvokeOperationCommandProcessor.java;
          Added: TypeConverter.java, DefaultElement.java.

          By doing this I have moved the logic of creating the XML output, for operation result, on the client side.

          2. Modify the xsl templates to interpret the new xml format. In order to interpret the new xml format I had to modify and add the new templates: Modified: invoke.xsl; Added: types.xsl. In order to have a customized output for a new type we have to insert a new template in types.xsl.

          Steps to create a new type:

          1. Create a your class that you want to be displayed
          2. Create a new class that will implement TypeConverter and will create the needed xml output.
          3. Register this new created converter to HttpAdaptor using addXmlBuilder method. Note: The key used here has to be the exact string that is returned from getClass().getName()
          4. Create a new template in types.xsl that will handle the html output format(There is already something as example there.(RCQueue)).

          An idea of improvment (among others) will be to modify types.xsl and invoke.xsl to handle automatically the templates.

          Fell free to modify whatever you want.
          Hope this helps. Sorry if is not very detailed, but is most than 1 year and I don't have time to make it better.

          Have fun
          Last edited by BlackEagle; Apr 22nd, 2011, 05:52 AM.

          Comment


          • #6
            Seems that I cannot attach bigger files. (File is ~1.2M) If you want the code give your email and I will send it .

            Comment


            • #8
              Your such a great help BlackEagle... Thank you so much for sharing this to us.

              Comment

              Working...
              X