A Hello World Service
package com.acme;
import org.jboss.system.ServiceMBean;
public interface HelloWorldServiceMBean extends ServiceMBean
{
// Configure getters and setters for the message attribute
String getMessage();
void setMessage(String message);
// The print message operation
void printMessage();
}
package com.acme;
import org.jboss.system.ServiceMBeanSupport;
public class HelloWorldService extends ServiceMBeanSupport implements HelloWorldServiceMBean
{
// Our message attribute
private String message = "Sorry no message today";
// Getters and Setters
public String getMessage()
{
return message;
}
public void setMessage(String message)
{
this.message = message;
}
// The printMessage operation
public void printMessage()
{
log.info(message);
}
// The lifecycle
protected void startService() throws Exception
{
log.info("Starting with message=" + message);
}
protected void stopService() throws Exception
{
log.info("Stopping with message=" + message);
}
}
jboss-service.xml
<?xml?>
<server>
<mbean code="com.acme.HelloWorldService" name="acme.com:service=HelloWorld">
<attribute name="Message">Hello World</attribute>
</mbean>
</server>
Sar File directory structure
hello-world.sar
hello-world.sar/META-INF/jboss-service.xml
hello-world.sar/com/acme/HelloWorldService.class
hello-world.sar/com/acme/HelloWorldServiceMBean.class
your blog posts are google. If you are interested can I publish your content in my website JavaBeat. also provide backlink to your blog. contact me at krishna.sa [at] gmail.com
ReplyDelete