Added some JMX support.
[jsvc.git] / src / dolda / jsvc / jmx / Context.java
diff --git a/src/dolda/jsvc/jmx/Context.java b/src/dolda/jsvc/jmx/Context.java
new file mode 100644 (file)
index 0000000..2f062f6
--- /dev/null
@@ -0,0 +1,30 @@
+package dolda.jsvc.jmx;
+
+import javax.management.*;
+import java.util.*;
+import dolda.jsvc.*;
+
+public class Context implements ContextMBean {
+    public final ObjectName name;
+    private final ThreadContext b;
+    
+    public Context(ThreadContext ctx) {
+       this.b = ctx;
+       Hashtable<String, String> info = new Hashtable<String, String>();
+       info.put("type", "Context");
+       info.put("name", getname());
+       try {
+           name = new ObjectName("dolda.jsvc", info);
+       } catch(MalformedObjectNameException e) {
+           throw(new RuntimeException(e));
+       }
+    }
+    
+    public long getrequests() {
+       return(b.requests());
+    }
+    
+    public String getname() {
+       return(b.server().name());
+    }
+}