>Thanks a lot!
>> Patch applied !
>Got the whole beat up now, though my public String sayHello() function gets
>invoked, but not displayed at the MX4J web console. Any chance to fire up
>the rmi-connector in order to test where the return is lost (e.g. via MC4J)
>- MX4J or the JMX facility?
>/peter
Hi Peter,
I noticed the method invoke results not showing up too. I think that may be due to a
stylesheet error in the default XSL stylesheet included with MX4J but I will look into
it further.
Here is a patch that adds some methods to the MBean for the test component in the
facility and enables the RMI adaptor to the MBean server in the test using a target
configuration override. The bundled .xconfig with the
MX4JComponentRegistrationManager component doesn't have the RMI Adaptor enabled by
default.
-Cameron
avalon-components/facilities/jmx/test/conf/block.xml:
Index: block.xml
===================================================================
RCS file: /home/cvspublic/avalon-components/facilities/jmx/test/conf/block.xml,v
retrieving revision 1.2
diff -u -r1.2 block.xml
--- block.xml 6 May 2004 19:42:15 -0000 1.2
+++ block.xml 7 May 2004 14:40:59 -0000
@@ -11,7 +11,18 @@
</classpath>
</classloader>
- <include name="mx4j" id="avalon-jmx:avalon-jmx-mx4j" version="1.0.dev-0"/>
+ <include name="mx4j" id="avalon-jmx:avalon-jmx-mx4j" version="1.0.dev-0">
+ <target path="registry">
+ <configuration>
+ <enable-rmi-adaptor>
+ true
+ </enable-rmi-adaptor>
+ <rmi-naming-factory>
+ com.sun.jndi.rmi.registry.RegistryContextFactory
+ </rmi-naming-factory>
+ </configuration>
+ </target>
+ </include>
<component name="test"
class="org.apache.avalon.playground.jmxtest.JMXTestComponent"/>
avalon-components/facilities/jmx/test/src/java/org/apache/avalon/playground/jmxtest/JMXTestComponentMBean.java:
Index: JMXTestComponentMBean.java
===================================================================
RCS file:
/home/cvspublic/avalon-components/facilities/jmx/test/src/java/org/apache/avalon/playground/jmxtest/JMXTestComponentMBean.java,v
retrieving revision 1.1
diff -u -r1.1 JMXTestComponentMBean.java
--- JMXTestComponentMBean.java 4 Apr 2004 15:00:58 -0000 1.1
+++ JMXTestComponentMBean.java 7 May 2004 14:40:23 -0000
@@ -23,4 +23,17 @@
public interface JMXTestComponentMBean
{
int getNumberOfServiceInvokes();
+ int getNumberOfJmxAttributeReads();
+ int getNumberOfJmxMethodInvokes();
+
+ int getMutableProperty();
+ void setMutableProperty(int mutableProperty);
+
+ String invokeMethodWithReturn();
+
+ void invokeMethodNoReturn();
+
+ void invokeMethodWithArgs(String arg1, int arg2);
+
+ String invokeMethodWithArgsAndReturn(String arg1, int arg2);
}
avalon-components/facilities/jmx/test/src/java/org/apache/avalon/playground/jmxtest/JMXTestComponent.java:
Index: JMXTestComponent.java
===================================================================
RCS file:
/home/cvspublic/avalon-components/facilities/jmx/test/src/java/org/apache/avalon/playground/jmxtest/JMXTestComponent.java,v
retrieving revision 1.2
diff -u -r1.2 JMXTestComponent.java
--- JMXTestComponent.java 8 Apr 2004 08:35:16 -0000 1.2
+++ JMXTestComponent.java 7 May 2004 14:40:00 -0000
@@ -26,12 +26,14 @@
*
* @avalon.component name="JMXTestComponent" lifestyle="singleton"
* @avalon.service type="org.apache.avalon.playground.jmxtest.JMXTestService"
- * @avalon.service type="org.apache.avalon.playground.jmxtest.JMXTestComponentMBean"
*/
public class JMXTestComponent extends AbstractLogEnabled implements JMXTestService,
Initializable,
Startable, JMXTestComponentMBean
{
private int numberOfServiceInvokes = 0;
+ private int numberOfJmxMethodInvokes = 0;
+ private int numberOfJmxAttributeReads = 0;
+ private int mutableProperty = 0;
public void initialize()
{
@@ -54,11 +56,80 @@
numberOfServiceInvokes++;
}
+ //JMXTestComponentMBean:
+
public int getNumberOfServiceInvokes()
{
getLogger().info( "getNumberOfServiceInvokes was invoked on instance: "
+ System.identityHashCode( this ) );
+ numberOfJmxAttributeReads++;
return numberOfServiceInvokes;
}
+ public int getNumberOfJmxAttributeReads()
+ {
+ getLogger().info( "getNumberOfJmxAttributeReads was invoked on instance: "
+ + System.identityHashCode( this ) );
+ numberOfJmxAttributeReads++;
+ return numberOfJmxAttributeReads;
+ }
+
+ public int getNumberOfJmxMethodInvokes()
+ {
+ numberOfJmxAttributeReads++;
+ return numberOfJmxMethodInvokes;
+ }
+
+ public int getMutableProperty()
+ {
+ getLogger().info( "getMutableProperty was invoked on instance: "
+ + System.identityHashCode( this ) );
+ numberOfJmxAttributeReads++;
+ return mutableProperty;
+ }
+
+ public void setMutableProperty(int mutableProperty)
+ {
+ getLogger().info( "setMutableProperty was invoked on instance: "
+ + System.identityHashCode( this ) );
+ this.mutableProperty = mutableProperty;
+ }
+
+ public String invokeMethodWithReturn()
+ {
+ final String message = "invokeMethodWithReturn was invoked on instance: "
+ + System.identityHashCode( this )
+ + " at: " + System.currentTimeMillis();
+ numberOfJmxMethodInvokes++;
+ getLogger().info( message );
+ return message;
+ }
+
+ public void invokeMethodNoReturn()
+ {
+ getLogger().info( "invokeMethodNoReturn was invoked on instance: "
+ + System.identityHashCode( this ) );
+ numberOfJmxMethodInvokes++;
+ }
+
+ public void invokeMethodWithArgs(String arg1, int arg2)
+ {
+ getLogger().info( "invokeMethodWithArgs was invoked on instance: "
+ + System.identityHashCode( this )
+ + " with arg1: " + arg1
+ + ", arg2: " + arg2 );
+ numberOfJmxMethodInvokes++;
+ }
+
+ public String invokeMethodWithArgsAndReturn(String arg1, int arg2)
+ {
+ final String message = "invokeMethodWithArgsAndReturn was invoked on
instance: "
+ + System.identityHashCode( this )
+ + " with arg1: " + arg1
+ + ", arg2: " + arg2
+ + " at: " + System.currentTimeMillis();
+ getLogger().info( message );
+ numberOfJmxMethodInvokes++;
+ return message;
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]