...
To use your custom granularity the META-INF/aop.xml file will look like the following. Note that we are using the ResponseTimeAspect twice, once with default granularity and once with average granularity, and thus we specify an aspect "name".
| Code Block |
|---|
|
<!DOCTYPE aspectwerkz PUBLIC |
...
"-//AspectWerkz//DTD//EN" |
...
"http://aspectwerkz.codehaus.org/dtd/aspectwerkz.dtd"> |
...
<aspectwerkz>
<system id="aware-jmx"> |
...
<!-- make use of defaults granularity and server --> |
...
<aspect class="org.codehaus.aware.jmx.ResponseTimeAspect"> |
...
<advice name="monitor" type="around" |
...
bind-to="execution(!static * test.jmx.ResponseTimeObject.*(..)) AND !execution(* *..*.freeze(..))"/> |
...
...
<!-- make use of custom granularity --> |
...
<aspect class="org.codehaus.aware.jmx.ResponseTimeAspect" name="MyAverageResponseTimeAspect"> |
...
<param name="granularity" value="org.codehaus.aware.jmx.ResponseTimeAspect$AverageGranularity"/> |
...
<advice name="monitor" type="around" |
...
bind-to="execution(!static * test.jmx.ResponseTimeObject.*(..)) AND !execution(* *..*.freeze(..))"/> |
...
...
Using a specific JMX mbean server
The default AWare implementation is using the default JMX API to retrieve the local JMX server and register the mbeans:
| Code Block |
|---|
|
public class JMXHelper {
/**
* Default driver interface using javax.management.MBeanServerFactory.
* See MX4JAspect if using it with MX4J jmx server.
*
*/
public static class StandardMBeanServerDriver implements IMBeanServerDriver {
public MBeanServer findMBeanServer() throws Throwable {
return javax.management.MBeanServerFactory.createMBeanServer();
}
}
}
|
This might not be convenient in your environment. For example in BEA WebLogic, you have several JMX server available when you are running in a cluster or in a managed server environment.
AWare allows you to use the mbean server you like.
For such use the aspect parameter "mbeanServer" and specify a class that implements the org.codehaus.aware.jmx.JMXHelper.IMBeanServerDriver interface:
| Code Block |
|---|
|
public interface IMBeanServerDriver {
public MBeanServer findMBeanServer() throws Throwable;
}
|
AWare provides a BEA Weblogic implementation of it thru org.codehaus.aware.jmx.JMXHelper.WebLogicMBeanServerDriver.
To use it, the META-INF/aop.xml will looks like:
| Code Block |
|---|
|
<aspectwerkz>
<system id="aware-jmx">
<!-- make use of defaults granularity and use WebLogic mbean server custom lookup -->
<aspect class="org.codehaus.aware.jmx.ResponseTimeAspect">
<param name="mbeanServer" value="org.codehaus.aware.jmx.JMXHelper$WebLogicMBeanServerDriver"/>
<advice name="monitor" type="around"
bind-to="execution(!static * test.jmx.ResponseTimeObject.*(..)) AND !execution(* *..*.freeze(..))"/>
</aspect>
</system>
</aspectwerkz>
|