This content has been marked as final.
Show 2 replies
-
1. Re: my first JMX
dikar Aug 14, 2008 12:29 PM (in response to anand_anan2k)There is a simple example for you (in windows OS)
By the way ,you must add the jboss-system-x.x.x.jar and jboss-jmx-x.x.x.jar in your lib path(or eclipse build path),these jar in JBoss lib dir.############################################## package JMX; import org.jboss.system.ServiceMBean; public interface HelloWorldServiceMBean extends ServiceMBean { public String getMessage(); public void setMessage(String message); } /***********************************************************/ package JMX; import org.jboss.system.ServiceMBeanSupport; public class HelloWorldService extends ServiceMBeanSupport implements HelloWorldServiceMBean { private String message; public HelloWorldService() { super(); // TODO Auto-generated constructor stub } public String getMessage() { System.out.println("getMessage()=" + message); return message; } public void setMessage(String message) { System.out.println("setMessage(" + message + ")"); this.message = message; } }/***********************************************************/ jboss-service.xml ----------------------------------------------------------------------------------- <?xml version="1.0" encoding="UTF-8"?> <server> <mbean code="JMX.HelloWorldService" name="JBoss:service=HelloWorldService"> <attribute name="Message">Hello World</attribute> </mbean> </server>----------------------------------------------------------
In your JBOSS deploy dir ,for example:"jboss-4.2.2.GA\server\default\deploy" ,you create a dir named "Hello.sar" and new create 2 files in "Hello.sar" ,one named "JMX" and other named "META-INF".Then put the HelloWorldService.class and HelloWorldServiceMBean.class in your "JMX" dir. and new a XML file named jboss-service.xml write the content like above red XML.
ok you can run your JBOSS and access the http://127.0.0.1:8080/jmx-console/
find the "service=HelloWorldService " in JBoss domain.
Note: I'm very sorry that my English not well. -
2. Re: my first JMX
dikar Aug 15, 2008 1:08 AM (in response to anand_anan2k)I'm very sorry that I forget to tell you that put the jboss-service.xml in your "META-INF" dir.
this is the structure of hello.sar dir
hello.sar
-------META-INF
--------------jboss-service.xml
-------JMX
--------------HelloWorldService.claa
--------------HelloWorldServiceMBean.claa