Java Reference
In-Depth Information
Creating your resource watches using the detyped API
Now that you have learned the basics of the detyped management API, we will illus-
trate a concrete example; our goal will be monitoring a server resource (the number
of active JDBC connections for a datasource) using an EJB. You can use this pattern
to create your own server watches, which can be integrated with your application en-
vironment:
import java.io.IOException;
import java.net.*;
import java.util.logging.Logger;
import javax.annotation.Resource;
import javax.ejb.*;
import
org.jboss.as.controller.client.ModelControllerClient;
import org.jboss.dmr.ModelNode;
@Stateless
public class WatchMyDB
{
private final static Logger logger =
Logger.getLogger(WatchMyDB.class.getName()
);());
@Resource
private TimerService timerService;
@Schedule(dayOfWeek = "*", hour = "*", minute
= "*", second = "*/30",year="*", persistent =
false)
public void backgroundProcessing()
{
ModelControllerClient client=null;
try {
client =
Search WWH ::




Custom Search