Show TOC Start of Content Area

Procedure documentation Instrumenting the Application  Locate the document in its SAP Library structure

Procedure

You have already learned how to use the methods provided by the JMX standard and how to work with the different xml files you need to supply your application with. The following steps will help you to summarize what you have learned until now in one single procedure for instrumenting your application with monitoring:

...

       1.      In the monitoring XML file, describe the monitoring tree nodes to be installed:

             ….

<text-monitor name="Bank name" configuration-group="Name">

    <monitored-resource name="BankMBean" type="APPLICATION"/>

    <text-attribute-mapping>

        <text-attribute>

            <observed-resource-attribute name="BankName"/>

        </text-attribute>

    </text-attribute-mapping>

</text-monitor>

 

       2.      In the web.xml, declare a security role and let the Servlet run with this role:

<servlet>

   <servlet-name></servlet-name>

   <servlet-class></servlet-class>

   <run-as>

      <role-name>MBeanCreator</role-name>

   </run-as>

</servlet>

     

 

     

<security-role>

   <description>Role for accessing MBean server</description>

   <role-name>MBeanCreator</role-name>

</security-role>

 

       3.      In the web-j2ee-engine.xml, map the security role declared in the web.xml to the administrators group in the AS Java:

<web-j2ee-engine>

    <security-role-map>

      <role-name>

        MBeanCreator

      </role-name>

      <server-role-name>

        administrators

      </server-role-name>

    </security-role-map>

</web-j2ee-engine>

 

       4.      In the init() method of the Servlet, put the following coding:

InitialContext initialCtx = new InitialContext();

MBeanServer mbs = (MBeanServer) initialCtx.lookup("jmx");

ObjectName monitoringObjectName = ObjectNameFactory.getNameForApplicationResourcePerNode("BankMBean", RuntimeProperties.get(RuntimeProperties.PROPERTY_APPLICATION), ObjectNameFactory.EMPTY_VALUE, ObjectNameFactory.EMPTY_VALUE);

mbs.registerMBean(mBeanObject, monitoringObjectName);

 

 

End of Content Area