01: /*
02: * All content copyright (c) 2003-2007 Terracotta, Inc., except as may otherwise be noted in a separate copyright
03: * notice. All rights reserved.
04: */
05: package com.tctest.webapp.servlets;
06:
07: import org.apache.commons.logging.Log;
08: import org.apache.commons.logging.LogFactory;
09: import org.jboss.mx.util.MBeanProxyExt;
10: import org.jboss.mx.util.MBeanServerLocator;
11:
12: import com.tctest.service.DirectoryMonitorMBean;
13:
14: import java.io.IOException;
15: import java.util.ArrayList;
16: import java.util.List;
17:
18: import javax.management.MBeanServer;
19: import javax.servlet.ServletException;
20: import javax.servlet.http.HttpServlet;
21: import javax.servlet.http.HttpServletRequest;
22: import javax.servlet.http.HttpServletResponse;
23:
24: public class JBossSarServlet extends HttpServlet {
25: private List list = new ArrayList();
26: private static Log log = LogFactory.getLog(JBossSarServlet.class);
27:
28: protected void doGet(HttpServletRequest req,
29: HttpServletResponse resp) throws ServletException,
30: IOException {
31: try {
32: synchronized (list) {
33: while (list.size() < 2) {
34: list.wait();
35: }
36: }
37: log.debug("shared list: " + list);
38: MBeanServer server = MBeanServerLocator.locateJBoss();
39: DirectoryMonitorMBean dmm = (DirectoryMonitorMBean) MBeanProxyExt
40: .create(
41: DirectoryMonitorMBean.class,
42: "service.directory.monitor:service=Monitor",
43: server);
44: resp.getWriter().println(
45: "OK: " + list + ", " + dmm.getExtensionList());
46: } catch (Exception e) {
47: throw new ServletException(e);
48: }
49: }
50: }
|