Java Reference
In-Depth Information
Creating your resource watches using the detyped API
Now that you have learned the basics of the detypedmanagement API , we will illustrate
a concrete example; our goal will be to monitor a server resource (the number of active
JDBC connections for a data source) using an EJB. You can use this pattern to create your
own server watches that can be integrated with your application environment. This is
shown in the following code snippet:
package com.packtpub.wflydevelopment.chapter9;
import org.jboss.as.controller.client.ModelControllerClient;
import org.jboss.dmr.ModelNode;
import javax.ejb.Schedule;
import javax.ejb.Stateless;
import java.io.Closeable;
import java.net.InetAddress;
import java.util.logging.Level;
import java.util.logging.Logger;
@Stateless
public class WatchMyDB {
private final static Logger logger =
Logger.getLogger(WatchMyDB.class.getName());
@Schedule(dayOfWeek = "*", hour = "*", minute = "*",
second =
"*/30", year = "*", persistent = false)
public void backgroundProcessing() {
ModelControllerClient client = null;
try {
client =
ModelControllerClient.Factory.create(InetAddress.getByName("localhost"),
9990);
final ModelNode operation = new ModelNode();
operation.get("operation").set("read-resource");
operation.get("include-runtime").set(true);
final ModelNode address =
Search WWH ::




Custom Search