User: slaboure
Date: 02/01/12 08:52:09
Modified: src/main/org/jboss/ha/framework/server
DistributedStateImpl.java
DistributedStateImplMBean.java
Log:
Provide a listContent and listXmlContent for debugging purposes (useful with
HTTP/JMX)
Revision Changes Path
1.8 +72 -7
jbossmx/src/main/org/jboss/ha/framework/server/DistributedStateImpl.java
Index: DistributedStateImpl.java
===================================================================
RCS file:
/cvsroot/jboss/jbossmx/src/main/org/jboss/ha/framework/server/DistributedStateImpl.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- DistributedStateImpl.java 2002/01/03 04:00:52 1.7
+++ DistributedStateImpl.java 2002/01/12 16:52:08 1.8
@@ -29,7 +29,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Sacha Labourey</a>.
* @author <a href="mailto:[EMAIL PROTECTED]">Bill Burke</a>.
- * @version $Revision: 1.7 $
+ * @version $Revision: 1.8 $
*
* <p><b>Revisions:</b><br>
* <p><b>2001/11/26: Sacha Labourey</b>
@@ -54,6 +54,7 @@
protected org.jboss.logging.Logger log = null;
protected MBeanServer mbeanServer = null;
+ protected String name = null;
// Static --------------------------------------------------------c
@@ -83,11 +84,11 @@
// we will need to redesign the way HAPartitions and its sub-protocols are
// registered with JMX. They will most probably be independant JMX services.
//
- String name = "jboss:service=" + SERVICE_NAME +
+ this.name = "jboss:service=" + SERVICE_NAME +
",partitionName=" + this.partition.getPartitionName();
- ObjectName jmxName = new ObjectName(name);
+ ObjectName jmxName = new ObjectName(this.name);
mbeanServer.registerMBean(this, jmxName);
- org.jboss.system.Registry.bind (name, this);
+ org.jboss.system.Registry.bind (this.name, this);
}
public void start () throws Exception
@@ -96,9 +97,73 @@
public void stop () throws Exception
{
- String name = "jboss:service=" + SERVICE_NAME +
- ",partitionName=" + this.partition.getPartitionName();
- org.jboss.system.Registry.unbind (name);
+ org.jboss.system.Registry.unbind (this.name);
+ ObjectName jmxName = new ObjectName(this.name);
+ mbeanServer.unregisterMBean (jmxName);
+ }
+
+ public String listContent () throws Exception
+ {
+ StringBuffer result = new StringBuffer ();
+ Collection cats = this.getAllCategories ();
+ java.util.Iterator catsIter = cats.iterator ();
+ while (catsIter.hasNext ())
+ {
+ String category = (String)catsIter.next ();
+ java.util.Iterator keysIter = this.getAllKeys(category).iterator ();
+
+ result.append ("-----------------------------------------------\n");
+ result.append ("Category : ").append (category).append ("\n\n");
+ result.append ("KEY\t:\tVALUE\n");
+
+ while (keysIter.hasNext ())
+ {
+ String key = (String)keysIter.next ();
+ String value = this.get (category, key).toString ();
+ result.append ("\"").append(key).append ("\"\t:\t\"").append
(value).append("\"\n");
+ }
+
+ result.append ("\n");
+
+ }
+
+ return result.toString ();
+ }
+
+ public String listXmlContent () throws Exception
+ {
+ StringBuffer result = new StringBuffer ();
+ Collection cats = this.getAllCategories ();
+ java.util.Iterator catsIter = cats.iterator ();
+
+ result.append ("<DistributedState>\n");
+
+ while (catsIter.hasNext ())
+ {
+ String category = (String)catsIter.next ();
+ java.util.Iterator keysIter = this.getAllKeys(category).iterator ();
+
+ result.append ("\t<Category>\n");
+ result.append ("\t\t<CategoryName>").append (category).append
("</CategoryName>\n");
+
+ while (keysIter.hasNext ())
+ {
+ String key = (String)keysIter.next ();
+ String value = this.get (category, key).toString ();
+ result.append ("\t\t<Entry>\n");
+ result.append ("\t\t\t<Key>").append (key).append ("</Key>\n");
+ result.append ("\t\t\t<Value>").append (value).append ("</Value>\n");
+ result.append ("\t\t</Entry>\n");
+ result.append ("\"").append(key).append ("\"\t:\t\"").append
(value).append("\"\n");
+ }
+
+ result.append ("\t</Category>\n");
+
+ }
+
+ result.append ("</DistributedState>\n");
+
+ return result.toString ();
}
// DistributedState implementation ----------------------------------------------
1.2 +3 -1
jbossmx/src/main/org/jboss/ha/framework/server/DistributedStateImplMBean.java
Index: DistributedStateImplMBean.java
===================================================================
RCS file:
/cvsroot/jboss/jbossmx/src/main/org/jboss/ha/framework/server/DistributedStateImplMBean.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DistributedStateImplMBean.java 2001/12/29 16:10:10 1.1
+++ DistributedStateImplMBean.java 2002/01/12 16:52:09 1.2
@@ -13,7 +13,7 @@
* @see <related>
*
* @author <a href="mailto:[EMAIL PROTECTED]">Sacha Labourey</a>.
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*
* <p><b>Revisions:</b>
*
@@ -25,5 +25,7 @@
public interface DistributedStateImplMBean extends
org.jboss.ha.framework.interfaces.DistributedState
{
+ public String listContent () throws Exception;
+ public String listXmlContent () throws Exception;
}
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development