[jboss-svn-commits] JBL Code SVN: r30576 - in labs/jbosstm/trunk: ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/common and 7 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu Dec 10 04:45:43 EST 2009


Author: mmusgrov
Date: 2009-12-10 04:45:42 -0500 (Thu, 10 Dec 2009)
New Revision: 30576

Added:
   labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/
   labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/annotation/
   labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/annotation/MXBeanDescription.java
   labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/annotation/MXBeanPropertyDescription.java
   labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/
   labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/BasicActionBean.java
   labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/BasicActionBeanMBean.java
   labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/ObjStoreBean.java
   labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/ObjStoreEntryBean.java
   labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/ObjStoreTypeBean.java
   labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/common/
   labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/common/AtomicActionBean.java
   labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/common/BasicBean.java
   labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/common/BasicBeanMBean.java
   labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/common/LogRecordBean.java
   labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/common/LogRecordBeanMBean.java
   labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/common/LogRecordListBean.java
   labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/common/LogRecordListBeanMBean.java
   labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/common/StateBean.java
   labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/common/StateBeanMBean.java
   labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/common/TransactionStatusManagerItemBean.java
   labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/common/TransactionStatusManagerItemBeanMBean.java
   labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/common/UidBean.java
   labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/common/UidBeanMBean.java
   labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/common/XAResourceRecordBeanMBean.java
   labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/util/
   labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/util/ActionWrapper.java
   labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/util/JMXServer.java
Modified:
   labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/ObjectStatus.java
   labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/ObjectType.java
   labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/common/ObjectStoreEnvironmentBean.java
   labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/common/ObjectStoreEnvironmentBeanMBean.java
   labs/jbosstm/trunk/atsintegration/transaction-jboss-beans.xml
   labs/jbosstm/trunk/atsintegration/transaction-jboss-beans.xml.jts
Log:
Add MBeans for instrumenting the Object Store.

JBTM-660


Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/ObjectStatus.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/ObjectStatus.java	2009-12-10 06:14:36 UTC (rev 30575)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/ObjectStatus.java	2009-12-10 09:45:42 UTC (rev 30576)
@@ -44,37 +44,34 @@
 
 public class ObjectStatus
 {
+    public static final int PASSIVE = 0;
+    public static final int PASSIVE_NEW = 1;
+    public static final int ACTIVE = 2;
+    public static final int ACTIVE_NEW = 3;
+    public static final int DESTROYED = 4;
+    public static final int UNKNOWN_STATUS = 5;
 
-public static final int PASSIVE = 0;
-public static final int PASSIVE_NEW = 1;
-public static final int ACTIVE = 2;
-public static final int ACTIVE_NEW = 3;
-public static final int DESTROYED = 4;
-public static final int UNKNOWN_STATUS = 5;
-    
-public static void print (PrintWriter strm, int os)
+    public static void print (PrintWriter strm, int os)
     {
-	switch (os)
-	{
-	case PASSIVE:
-	    strm.print("PASSIVE");
-	    break;
-	case PASSIVE_NEW:
-	    strm.print("PASSIVE_NEW");
-	    break;
-	case ACTIVE:
-	    strm.print("ACTIVE");
-	    break;
-	case ACTIVE_NEW:
-	    strm.print("ACTIVE_NEW");
-	    break;
-	case DESTROYED:
-	    strm.print("DESTROYED");
-	    break;
-	default:
-	    strm.print("UNKNOWN_STATUS");
-	    break;
-	}
+        strm.print(toString(os));
     }
-    
+
+    public static String toString(int os)
+    {
+        switch (os)
+        {
+            case PASSIVE:
+                return "PASSIVE";
+            case PASSIVE_NEW:
+                return "PASSIVE_NEW";
+            case ACTIVE:
+                return "ACTIVE";
+            case ACTIVE_NEW:
+                return "ACTIVE_NEW";
+            case DESTROYED:
+                return "DESTROYED";
+            default:
+                return "UNKNOWN_STATUS";
+        }
+    }
 }

Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/ObjectType.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/ObjectType.java	2009-12-10 06:14:36 UTC (rev 30575)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/ObjectType.java	2009-12-10 09:45:42 UTC (rev 30576)
@@ -35,7 +35,7 @@
 
 /**
  * The various types of StateManager object which can exist.
- * 
+ *
  * @author Mark Little (mark at arjuna.com)
  * @version $Id: ObjectType.java 2342 2006-03-30 13:06:17Z $
  * @since JTS 1.0.
@@ -58,21 +58,21 @@
 
     public static void print (PrintWriter strm, int ot)
     {
+        strm.print(toString(ot));
+    }
+
+    public static String toString(int ot)
+    {
         switch (ot)
         {
-        case RECOVERABLE:
-            strm.print("RECOVERABLE");
-            break;
-        case ANDPERSISTENT:
-            strm.print("ANDPERSISTENT");
-            break;
-        case NEITHER:
-            strm.print("NEITHER");
-            break;
-        default:
-            strm.print("UNKNOWN_TYPE");
-            break;
+            case RECOVERABLE:
+                return "RECOVERABLE";
+            case ANDPERSISTENT:
+                return"ANDPERSISTENT";
+            case NEITHER:
+                return"NEITHER";
+            default:
+                return"UNKNOWN_TYPE";
         }
     }
-
 }

Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/common/ObjectStoreEnvironmentBean.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/common/ObjectStoreEnvironmentBean.java	2009-12-10 06:14:36 UTC (rev 30575)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/common/ObjectStoreEnvironmentBean.java	2009-12-10 09:45:42 UTC (rev 30576)
@@ -72,6 +72,8 @@
     private volatile long txLogSize = 10 * 1024 * 1024;  // default maximum log txLogSize in bytes;
     @FullPropertyName(name = "com.arjuna.ats.arjuna.coordinator.transactionLog.purgeTime")
     private volatile long purgeTime = 100000; // in milliseconds
+    @FullPropertyName(name = "org.jboss.jbosstm.tools.jmx.osb.JMXEnabled")
+    private volatile boolean jmxEnabled = true;
 
 
     /**
@@ -613,4 +615,24 @@
     {
         this.purgeTime = purgeTime;
     }
+
+    /**
+     * Determines whether JMX instrumentation of the Object Store is enabled.
+     *
+     * @return true if JMX instrumentation is enabled
+     */
+    public boolean isJmxEnabled()
+	{
+		return jmxEnabled;
+	}
+
+    /**
+     * Enable or disable JMX instrumentation of the Object Store.
+     *
+     * @param enable set to true to enable.
+     */
+    public void setJmxEnabled(boolean enable)
+	{
+		jmxEnabled = enable;
+	}
 }

Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/common/ObjectStoreEnvironmentBeanMBean.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/common/ObjectStoreEnvironmentBeanMBean.java	2009-12-10 06:14:36 UTC (rev 30575)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/common/ObjectStoreEnvironmentBeanMBean.java	2009-12-10 09:45:42 UTC (rev 30576)
@@ -118,4 +118,9 @@
     long getPurgeTime();
 
     void setPurgeTime(long purgeTime);
+
+    boolean isJmxEnabled();
+
+    void setJmxEnabled(boolean enable);
+
 }

Added: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/annotation/MXBeanDescription.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/annotation/MXBeanDescription.java	                        (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/annotation/MXBeanDescription.java	2009-12-10 09:45:42 UTC (rev 30576)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ * (C) 2009
+ * @author Red Hat Middleware LLC.
+ */
+package com.arjuna.ats.arjuna.tools.osb.annotation;
+
+import javax.management.DescriptorKey;
+import java.lang.annotation.*;
+
+/**
+ * Annotation for adding a description to the MBeanInfo of an MBean
+ */
+ at Documented
+ at Target(ElementType.TYPE)
+ at Retention(RetentionPolicy.RUNTIME)
+public @interface MXBeanDescription
+{
+    @DescriptorKey("description")
+    String value();
+}

Added: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/annotation/MXBeanPropertyDescription.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/annotation/MXBeanPropertyDescription.java	                        (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/annotation/MXBeanPropertyDescription.java	2009-12-10 09:45:42 UTC (rev 30576)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ * (C) 2009
+ * @author Red Hat Middleware LLC.
+ */
+package com.arjuna.ats.arjuna.tools.osb.annotation;
+
+import javax.management.DescriptorKey;
+import java.lang.annotation.*;
+
+/**
+ * Annotation for adding a description to the MBeanInfo of an MBean property
+ */
+ at Documented
+ at Target(ElementType.METHOD)
+ at Retention(RetentionPolicy.RUNTIME)
+public @interface MXBeanPropertyDescription
+{
+    @DescriptorKey("description")
+    String value();
+}

Added: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/BasicActionBean.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/BasicActionBean.java	                        (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/BasicActionBean.java	2009-12-10 09:45:42 UTC (rev 30576)
@@ -0,0 +1,218 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ * (C) 2009
+ * @author Red Hat Middleware LLC.
+ */
+package com.arjuna.ats.arjuna.tools.osb.mbean;
+
+import com.arjuna.ats.arjuna.coordinator.RecordList;
+import com.arjuna.ats.arjuna.coordinator.AbstractRecord;
+import com.arjuna.ats.arjuna.common.Uid;
+import com.arjuna.ats.arjuna.exceptions.ObjectStoreException;
+import com.arjuna.ats.arjuna.tools.osb.mbean.common.LogRecordListBean;
+import com.arjuna.ats.arjuna.tools.osb.mbean.common.LogRecordBean;
+import com.arjuna.ats.arjuna.tools.osb.util.ActionWrapper;
+
+import javax.management.ObjectInstance;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Collection;
+import java.util.Iterator;
+
+/**
+ * @see BasicActionBeanMBean
+ */
+public class BasicActionBean extends ObjStoreEntryBean implements BasicActionBeanMBean
+{
+    protected ActionWrapper action_;
+    protected Map<String, LogRecordListBean> lists = new HashMap<String, LogRecordListBean>();
+    private boolean activated;
+
+    public BasicActionBean(ObjStoreTypeBean parent, Uid uid)
+    {
+        super(parent, uid);
+    }
+
+    public ObjectInstance register()
+    {
+        if (activated)
+            remove();
+
+        if (action_ == null)
+            action_ = new BasicActionWrapper(uid);
+
+        try {
+            action_.getAction().activate();
+        } catch (Exception e) {
+            addError(e.getMessage());
+        }
+
+        action_.populateLists(lists, this);
+
+        for (LogRecordListBean listBean : lists.values())
+            listBean.register();
+
+        activated = true;
+
+        return super.register();
+    }
+
+    public void remove()
+    {
+
+        if (action_ == null)
+            return;
+
+        action_.getAction().deactivate();
+        activated = false;
+
+        try {
+            action_.remove();
+        } catch (ObjectStoreException e) {
+            throw new RuntimeException(e);
+        }
+
+        action_ = null;
+
+        // record successfuly remove the mbean
+        unregister();
+    }
+
+    public int getFailedCount()
+    {
+        return getListSize("Failed");
+    }
+    public int getHeuristicCount()
+    {
+        return getListSize("Heuristic");
+    }
+    public int getPendingCount()
+    {
+        return getListSize("Pending");
+    }
+    public int getPreparedCount()
+    {
+        return getListSize("Prepared");
+    }
+    public int getReadOnlyCount()
+    {
+        return getListSize("ReadOnly");
+    }
+
+    private int getListSize(String type) {
+        LogRecordListBean lb = lists.get(type);
+
+        return (lb == null ? 0 : lb.getSize());
+    }
+
+    public String[] getFailedList()
+    {
+        return toStringArray(lists.get("Failed"));
+    }
+
+    public String[] getHeuristicList()
+    {
+        return toStringArray(lists.get("Heuristic"));
+    }
+
+    public String[] getPendingList()
+    {
+        return toStringArray(lists.get("Pending"));
+    }
+
+    public String[] getPreparedList()
+    {
+        return toStringArray(lists.get("Prepared"));
+    }
+
+    public String[] getReadOnlyList()
+    {
+        return toStringArray(lists.get("Readonly"));
+    }
+
+    public static String[] toStringArray(LogRecordListBean listBean)
+    {
+        Collection<LogRecordBean> beans = listBean.getRegisteredMBeans();
+
+        if (beans != null) {
+            String[] res = new String[beans.size()];
+            int i = 0;
+
+            for (LogRecordBean bean : beans)
+                res[i++] = bean.getObjectName();
+
+            return res;
+        }
+
+        return new String[0];
+    }
+
+    public static String[] toStringArray(RecordList rl)
+    {
+        String[] res = new String[rl.size()];
+        AbstractRecord rec = rl.peekFront();
+        int i = 0;
+
+        while (rec != null)
+        {
+            res[i++] = rec.getTypeOfObject();
+            rec = rl.peekNext(rec);
+        }
+
+        return res;
+    }
+
+    public boolean unregister()
+    {
+        for (Iterator<Map.Entry<String, LogRecordListBean>> i = lists.entrySet().iterator(); i.hasNext();)
+        {
+            Map.Entry<String, LogRecordListBean> entry = i.next();
+            if (entry.getValue().unregister())
+                i.remove();
+        }
+
+        return (lists.size() == 0 && super.unregister());
+    }
+
+    public class BasicActionWrapper extends com.arjuna.ats.arjuna.coordinator.BasicAction implements ActionWrapper
+    {
+        public BasicActionWrapper (Uid objUid)
+        {
+            super(objUid);
+        }
+
+        public com.arjuna.ats.arjuna.coordinator.BasicAction getAction() {
+            return this;
+        }
+
+        public void populateLists(Map<String, LogRecordListBean> lists, BasicActionBean bean)
+        {
+            lists.put("Heuristic", new LogRecordListBean(bean, heuristicList, "Heuristic List"));
+            lists.put("Failed", new LogRecordListBean(bean, failedList, "Failed List"));
+            lists.put("Readonly", new LogRecordListBean(bean, readonlyList, "Readonly List"));
+            lists.put("Pending", new LogRecordListBean(bean, pendingList, "Pending List"));
+            lists.put("Prepared", new LogRecordListBean(bean, preparedList, "Prepared List"));
+        }
+
+        public void remove() throws ObjectStoreException
+        {
+            if (!getStore().remove_committed(getSavingUid(), type()))
+                throw new ObjectStoreException();
+        }
+    }
+}

Added: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/BasicActionBeanMBean.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/BasicActionBeanMBean.java	                        (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/BasicActionBeanMBean.java	2009-12-10 09:45:42 UTC (rev 30576)
@@ -0,0 +1,62 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ * (C) 2009
+ * @author Red Hat Middleware LLC.
+ */
+package com.arjuna.ats.arjuna.tools.osb.mbean;
+
+import com.arjuna.ats.arjuna.tools.osb.annotation.MXBeanDescription;
+import com.arjuna.ats.arjuna.tools.osb.annotation.MXBeanPropertyDescription;
+import com.arjuna.ats.arjuna.tools.osb.mbean.common.StateBeanMBean;
+
+/**
+ * MBean representation of an ObjectStore BasicAction providing a summary of the number
+ * of records in each of the various lists
+ *
+ * @see com.arjuna.ats.arjuna.coordinator.BasicAction
+ */
+
+ at MXBeanDescription("A representation of the state of each participant involved in an action")
+public interface BasicActionBeanMBean extends StateBeanMBean
+{
+//	@MXBeanPropertyDescription("Permanently remove this mxbean")
+//    public void remove();
+/*  TODO array types don't seem to work with the JMX agent inside the JBoss AS
+    @MXBeanPropertyDescription("Participants that failed during phase 2 (of a two phase commit protocol)")
+    String[] getFailedList();
+    @MXBeanPropertyDescription("Particpants that returned a heuristic out come during phase 2 (of a two phase commit protocol)")
+    String[] getHeuristicList();
+    @MXBeanPropertyDescription("Participants that have not had phase 1 (of a two phase commit protocol) called on them")
+    String[] getPendingList();
+    @MXBeanPropertyDescription("Particpants that have successfully completed phase 1 (of a two phase commit protocol)")
+    String[] getPreparedList();
+    @MXBeanPropertyDescription("Particpants that indicated no chages were made when asked to complete phase 1 (of a two phase commit protocol)")
+    String[] getReadOnlyList();
+*/
+
+    @MXBeanPropertyDescription("Number of participants that failed during phase 2 (of a two phase commit protocol)")    
+    int getFailedCount();
+    @MXBeanPropertyDescription("Number of particpants that returned a heuristic out come during phase 2 (of a two phase commit protocol)")
+    int getHeuristicCount();
+    @MXBeanPropertyDescription("Number of particpants that have successfully completed phase 1 (of a two phase commit protocol)")
+    int getPendingCount();
+    @MXBeanPropertyDescription("Number of particpants that indicated no chages were made when asked to complete phase 1 (of a two phase commit protocol)")
+    int getPreparedCount();
+    @MXBeanPropertyDescription("Number of particpants that indicated no chages were made when asked to complete phase 1 (of a two phase commit protocol)")
+    int getReadOnlyCount();
+}

Added: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/ObjStoreBean.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/ObjStoreBean.java	                        (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/ObjStoreBean.java	2009-12-10 09:45:42 UTC (rev 30576)
@@ -0,0 +1,229 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ * (C) 2009
+ * @author Red Hat Middleware LLC.
+ */
+package com.arjuna.ats.arjuna.tools.osb.mbean;
+
+import javax.management.ObjectInstance;
+import javax.management.OperationsException;
+import javax.management.MBeanException;
+
+import com.arjuna.ats.arjuna.objectstore.ObjectStore;
+import com.arjuna.ats.arjuna.state.InputObjectState;
+import com.arjuna.ats.arjuna.exceptions.ObjectStoreException;
+import com.arjuna.ats.arjuna.common.arjPropertyManager;
+import com.arjuna.ats.arjuna.logging.tsLogger;
+import com.arjuna.ats.arjuna.tools.osb.util.JMXServer;
+
+import java.util.Collection;
+import java.util.Arrays;
+import java.util.ArrayList;
+import java.util.List;
+import java.io.IOException;
+import java.io.File;
+import java.io.FilenameFilter;
+
+/**
+ * MBean representation of an Object Store.
+ * An Object Store contains a type hierarchy for storing different kinds of record.
+ * The hierarchy is reflected in the set of keys of the corresponding MBeans, ie a containing type will
+ * have a set of keys that are a strict superset of each of the types further up the hierarchy.
+ *
+ * @see com.arjuna.ats.arjuna.objectstore.ObjectStore
+ *
+ * @message com.arjuna.ats.arjuna.tools.osb.mbean.ObjStoreBean.m_1
+ *		  [com.arjuna.ats.arjuna.tools.osb.mbean.ObjStoreBean.m_1] - new store for location: {0}.
+ * @message com.arjuna.ats.arjuna.tools.osb.mbean.ObjStoreBean.m_2
+ *		  [com.arjuna.ats.arjuna.tools.osb.mbean.ObjStoreBean.m_2] - Error creating object store root: {0}.
+ * @message com.arjuna.ats.arjuna.tools.osb.mbean.ObjStoreBean.m_3
+ *		  [com.arjuna.ats.arjuna.tools.osb.mbean.ObjStoreBean.m_3] - Error creating object store root: {0}.
+ * @message com.arjuna.ats.arjuna.tools.osb.mbean.ObjStoreBean.m_4
+ *		  [com.arjuna.ats.arjuna.tools.osb.mbean.ObjStoreBean.m_4] - parsing store type: {0}
+ * @message com.arjuna.ats.arjuna.tools.osb.mbean.ObjStoreBean.m_5
+ *		  [com.arjuna.ats.arjuna.tools.osb.mbean.ObjStoreBean.m_5] - Browsing store {0} location: {1}
+ *
+ */
+public class ObjStoreBean extends ObjStoreTypeBean
+{
+    private ObjectStore store;
+    private int id;
+
+    private static ObjStoreBean localStore;
+    
+    public static ObjStoreTypeBean getObjectStoreBrowserBean()
+            throws OperationsException, MBeanException, InterruptedException, IOException
+    {
+        if (localStore == null)
+            localStore = (ObjStoreBean) getObjectStoreBrowserBean(0, arjPropertyManager.getObjectStoreEnvironmentBean().getObjectStoreDir());
+
+        return localStore;
+    }
+
+    public static ObjStoreTypeBean getObjectStoreBrowserBean(int id, String storeDir)
+            throws OperationsException, MBeanException, InterruptedException, IOException
+    {
+        ObjStoreBean sbean = new ObjStoreBean(id, storeDir);
+
+        sbean.register();
+
+        return sbean;
+    }
+
+    public ObjStoreBean()
+    {
+        super();
+    }
+
+    private List<String> getStoreNames()
+    {
+        File osf = new File(store.storeDir());
+        List<String> storeNames = new ArrayList<String>();
+
+        if (osf.exists())
+            storeNames = Arrays.asList(osf.list(new FilenameFilter() {
+                public boolean accept(File dir, String name) {
+                    return new File(dir, name).isDirectory();
+                }
+            }));
+
+        return storeNames;
+    }
+
+    // TODO dont restrict the mbean to filesystem based stores
+    public ObjStoreBean(int id, String storeLocation)
+    {
+        super(null, "/", "root");
+        this.id = id;
+
+        if (tsLogger.arjLoggerI18N.isDebugEnabled())
+            tsLogger.arjLoggerI18N.debug("com.arjuna.ats.arjuna.tools.osb.mbean.ObjStoreBean.m_1",
+                    new Object[] { storeLocation });
+
+        store = getObjectStore(storeLocation, null);
+    }
+
+    public String getObjectName()
+    {
+        // return a unique name for this object store
+        return "jboss.jta:type=ObjectStore,id=" + id;
+    }
+
+    public ObjectStore getStore()
+    {
+        return store;
+    }
+
+    public ObjectInstance register()
+    {
+        if (arjPropertyManager.getObjectStoreEnvironmentBean().isJmxEnabled()) {
+            Collection<ObjStoreTypeBean> beans = new ArrayList<ObjStoreTypeBean> ();
+            ObjectInstance oi = JMXServer.getAgent().registerMBean(this);
+
+            if (tsLogger.arjLoggerI18N.isDebugEnabled())
+                tsLogger.arjLoggerI18N.debug("com.arjuna.ats.arjuna.tools.osb.mbean.ObjStoreBean.m_4",
+                        new Object[] { arjPropertyManager.getCoordinatorEnvironmentBean().getActionStore() });
+
+            for (String storeName : getStoreNames()) {
+                allTypes(this, storeName, beans);
+
+                if (tsLogger.arjLoggerI18N.isDebugEnabled())
+                    tsLogger.arjLoggerI18N.debug("com.arjuna.ats.arjuna.tools.osb.mbean.ObjStoreBean.m_5",
+                            new Object[] { storeName, store.storeDir() });
+
+                for(ObjStoreTypeBean bean : beans)
+                    bean.register();
+
+                registeredBeans.addAll(beans);
+
+                beans.clear();
+            }
+
+            super.register();
+
+            return oi;
+        }
+
+        return null;
+    }
+
+    public boolean unregister()
+    {
+        return super.unregister();
+    }
+
+    public ObjectStore getObjectStore(String storeDir, String storeName)
+    {
+        arjPropertyManager.getObjectStoreEnvironmentBean().setObjectStoreDir(storeDir);
+        String storeImple = arjPropertyManager.getCoordinatorEnvironmentBean().getActionStore();
+        arjPropertyManager.getObjectStoreEnvironmentBean().setLocalOSRoot(storeName);
+
+        try {
+            Class osImple = Class.forName(storeImple);
+
+            return (ObjectStore) osImple.newInstance();
+        } catch (Exception e) {
+            if (tsLogger.arjLoggerI18N.isWarnEnabled())
+                tsLogger.arjLoggerI18N.warn("com.arjuna.ats.arjuna.tools.osb.mbean.ObjStoreBean.m_2",
+                        new Object[] { e });
+        }
+
+        return null;
+    }
+
+    public void allTypes(ObjStoreTypeBean parent, String storeName, Collection<ObjStoreTypeBean> names)
+    {
+        InputObjectState types = new InputObjectState();
+
+        try {
+            if (getObjectStore(store.storeDir(), storeName).allTypes(types)) {
+                while (true) {
+                    try {
+                        String theName = types.unpackString();
+
+                        if (theName.length() == 0)
+                            break;
+                        else
+                            names.add(new ObjStoreTypeBean(parent, storeName, theName));
+                    } catch (IOException e) {
+                        break; // end of list
+                    }
+                }
+            }
+        } catch (ObjectStoreException e) {
+            if (tsLogger.arjLoggerI18N.isWarnEnabled())
+                tsLogger.arjLoggerI18N.warn("com.arjuna.ats.arjuna.tools.osb.mbean.ObjStoreBean.m_3",
+                        new Object[] { e });
+        }
+    }
+
+    public static void main(String[] args) throws OperationsException, MBeanException, InterruptedException, IOException {
+        String[] storeLocations = {
+                "/home/mmusgrov/source/as/trunk/build/output/jboss-6.0.0-SNAPSHOT/server/all/data/tx-object-store",
+//                "../../logs/os.2",
+        };
+        ObjStoreBean[] browsers = new ObjStoreBean[storeLocations.length];
+
+        for (int i = 0; i < storeLocations.length; i++) {
+            browsers[i] = new ObjStoreBean(i, storeLocations[i]);
+            browsers[i].register();
+        }
+
+        Thread.sleep(24000000);
+    }
+}

Added: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/ObjStoreEntryBean.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/ObjStoreEntryBean.java	                        (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/ObjStoreEntryBean.java	2009-12-10 09:45:42 UTC (rev 30576)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ * (C) 2009
+ * @author Red Hat Middleware LLC.
+ */
+package com.arjuna.ats.arjuna.tools.osb.mbean;
+
+import com.arjuna.ats.arjuna.common.Uid;
+import com.arjuna.ats.arjuna.objectstore.ObjectStore;
+import com.arjuna.ats.arjuna.tools.osb.mbean.common.StateBean;
+
+/**
+ * Super class for MBean representations of Object Store records
+ *
+ * @see com.arjuna.ats.arjuna.tools.osb.mbean.common.StateBeanMBean
+ */
+public class ObjStoreEntryBean extends StateBean
+{
+	public ObjStoreEntryBean(ObjStoreTypeBean parent, Uid uid)
+    {
+        super(parent, parent.getStore(), uid);
+    }
+
+    public ObjectStore getStore()
+    {
+        return ((ObjStoreTypeBean) parent).getStore();
+    }
+}

Added: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/ObjStoreTypeBean.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/ObjStoreTypeBean.java	                        (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/ObjStoreTypeBean.java	2009-12-10 09:45:42 UTC (rev 30576)
@@ -0,0 +1,267 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ * (C) 2009
+ * @author Red Hat Middleware LLC.
+ */
+package com.arjuna.ats.arjuna.tools.osb.mbean;
+
+import java.util.*;
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+
+import com.arjuna.ats.arjuna.objectstore.ObjectStore;
+import com.arjuna.ats.arjuna.common.Uid;
+import com.arjuna.ats.arjuna.exceptions.ObjectStoreException;
+import com.arjuna.ats.arjuna.state.InputObjectState;
+import com.arjuna.ats.arjuna.tools.osb.mbean.common.BasicBean;
+import com.arjuna.ats.arjuna.logging.tsLogger;
+import com.arjuna.ats.internal.arjuna.common.UidHelper;
+
+import javax.management.ObjectInstance;
+
+/**
+ * MBean corresponding to an Object Store type.
+ * An Ojbect Store type correspond to the type of record that can be stored in a given store location.
+ *
+ * @see com.arjuna.ats.arjuna.objectstore.ObjectStore
+ *
+ * @message com.arjuna.ats.arjuna.tools.osb.mbean.ObjStoreTypeBean.m_1
+ *		  [com.arjuna.ats.arjuna.tools.osb.mbean.ObjStoreTypeBean.m_1] - new type: {0} store name: {0}.
+ * @message com.arjuna.ats.arjuna.tools.osb.mbean.ObjStoreTypeBean.m_2
+ *		  [com.arjuna.ats.arjuna.tools.osb.mbean.ObjStoreTypeBean.m_2] - error unpacking uids for type: {0}, : {1}.
+ * @message com.arjuna.ats.arjuna.tools.osb.mbean.ObjStoreTypeBean.m_3
+ *		  [com.arjuna.ats.arjuna.tools.osb.mbean.ObjStoreTypeBean.m_3] - Error unpacking uids for type: {0} : {1}.
+ * @message com.arjuna.ats.arjuna.tools.osb.mbean.ObjStoreTypeBean.m_4
+ *		  [com.arjuna.ats.arjuna.tools.osb.mbean.ObjStoreTypeBean.m_4] - registering bean: {0}.
+ * @message com.arjuna.ats.arjuna.tools.osb.mbean.ObjStoreTypeBean.m_5
+ *		  [com.arjuna.ats.arjuna.tools.osb.mbean.ObjStoreTypeBean.m_5] - Warning: no viewer for object store type {0}.
+ * @message com.arjuna.ats.arjuna.tools.osb.mbean.ObjStoreTypeBean.m_6
+ *		  [com.arjuna.ats.arjuna.tools.osb.mbean.ObjStoreTypeBean.m_6] - Error registering bean for class {0} : {1}.
+ * @message com.arjuna.ats.arjuna.tools.osb.mbean.ObjStoreTypeBean.m_7
+ *		  [com.arjuna.ats.arjuna.tools.osb.mbean.ObjStoreTypeBean.m_7] - Warning: error {0} creating viewer for object store type {1}.
+ */
+public class ObjStoreTypeBean extends BasicBean
+{
+    /*
+     * A map for associating Object Store record type names with Java types that know how to represent
+     * them as JMX beans.
+     * 
+     * TODO move this map to an external file to make it easy to add new handlers
+     */
+    private static final Map<String, String[]> typeHandlers = new HashMap<String, String[]> () {{
+        put("StateManager/BasicAction/TwoPhaseCoordinator/AtomicAction", new String[] {
+                "com.arjuna.ats.arjuna.tools.osb.mbean.common.AtomicActionBean",
+                "com.arjuna.ats.arjuna.tools.osb.mbean.BasicActionBean"});
+        put("Recovery/TransactionStatusManager", new String[] {
+                "com.arjuna.ats.arjuna.tools.osb.mbean.common.TransactionStatusManagerItemBean" });
+
+        // JTS record type handlers
+        put("StateManager/BasicAction/TwoPhaseCoordinator/ArjunaTransactionImple", new String[] {
+                "com.arjuna.ats.internal.jta.tools.osb.mbean.jts.ArjunaTransactionImpleBean",
+                "com.arjuna.ats.arjuna.tools.osb.mbean.BasicActionBean" });
+        put("RecoveryCoordinator", new String[] {
+                "com.arjuna.ats.internal.jta.tools.osb.mbean.jts.RecoveryCoordinatorBean",
+                "com.arjuna.ats.arjuna.tools.osb.mbean.common.UidBean" });
+        put("CosTransactions/XAResourceRecord", new String[] {
+                "com.arjuna.ats.internal.jta.tools.osb.mbean.jts.JTSXAResourceRecordBean",
+                "com.arjuna.ats.arjuna.tools.osb.mbean.common.UidBean" });
+//		put("StateManager/AbstractRecord/XAResourceRecord", "org.jboss.jbosstm.tools.jmx.osb.mbeanimpl.JTAXAResourceRecordBean");
+    }};
+
+    private String type;
+    private String storeName;
+    protected List<BasicBean> registeredBeans = new ArrayList<BasicBean> ();
+
+    public ObjStoreTypeBean()
+    {
+        super();
+    }
+
+    public ObjStoreTypeBean(ObjStoreTypeBean parent, String storeName, String type)
+    {
+        super(parent, type);
+        this.parent = parent;
+        this.type = type;
+        this.storeName = storeName;
+
+        if (tsLogger.arjLoggerI18N.isDebugEnabled())
+            tsLogger.arjLoggerI18N.debug("com.arjuna.ats.arjuna.tools.osb.mbean.ObjStoreTypeBean.m_1",
+                    new Object[] { type, storeName });
+    }
+
+    public ObjectStore getStore()
+    {
+        return ((ObjStoreTypeBean) parent).getStore();
+    }
+
+    public String getObjectName()
+    {
+        return toObjectName(storeName, type).toString();
+    }
+
+    protected StringBuilder toObjectName(String storeName, String type)
+    {
+        StringBuilder on = new StringBuilder();
+        String[] nc = type.split("/");
+
+        on.append(parent.getObjectName()).append(',');
+        on.append("name=").append(storeName);
+
+        for (int i = 0; i < nc.length; i++) {
+            on.append(',').append('L').append(i + 1).append("=").append(nc[i]);
+        }
+
+        return on;
+    }
+
+    private void allUids(Collection<Uid> uis)
+    {
+        InputObjectState uids = new InputObjectState();
+
+        try {
+            if (getStore().allObjUids(type, uids)) {
+                try {
+                    boolean endOfUids = false;
+
+                    while (!endOfUids) {
+                        Uid theUid = UidHelper.unpackFrom(uids);
+
+                        if (theUid.equals(Uid.nullUid()))
+                            endOfUids = true;
+                        else
+                            uis.add(new Uid(theUid));
+                    }
+                } catch (IOException e) {
+                    if (tsLogger.arjLoggerI18N.isWarnEnabled())
+                        tsLogger.arjLoggerI18N.warn("com.arjuna.ats.arjuna.tools.osb.mbean.ObjStoreTypeBean.m_2",
+                                new Object[] { type, e });
+
+                }
+            }
+        } catch (ObjectStoreException e) {
+            if (tsLogger.arjLoggerI18N.isWarnEnabled())
+                tsLogger.arjLoggerI18N.warn("com.arjuna.ats.arjuna.tools.osb.mbean.ObjStoreTypeBean.m_3",
+                        new Object[] { type, e });
+
+        }
+    }
+
+    @Override
+    public void refresh()
+    {
+        clearErrors();
+        unregisterDependents(true);
+        register();
+        Iterator<BasicBean> i = registeredBeans.iterator();
+
+        while (i.hasNext()) {
+            BasicBean bb = i.next();
+
+            if (!bb.isMarked()) {
+                i.remove();
+                bb.unregister();
+            }
+        }
+    }
+
+    public ObjectInstance register()
+    {
+        Collection<Uid> uids = new ArrayList<Uid>();
+        ObjectInstance oi;
+        BasicBean bean;
+
+        if (tsLogger.arjLoggerI18N.isDebugEnabled())
+            tsLogger.arjLoggerI18N.debug("com.arjuna.ats.arjuna.tools.osb.mbean.ObjStoreTypeBean.m_4",
+                    new Object[] { getObjectName() });
+
+        allUids(uids);
+        oi = super.register(); // register this
+
+        if (!uids.isEmpty()) {
+//            oi = super.register(); // register this
+
+            for (Uid uid : uids) {
+                if ((bean = createBean(uid)) != null)
+                    registeredBeans.add(bean);
+            }
+        }
+
+        return oi;
+    }
+
+    public boolean unregister()
+    {
+        return super.unregister();
+    }
+
+    public void unregisterDependents(boolean markOnly)
+    {
+        for (BasicBean osBean : registeredBeans) {
+            if (markOnly)
+                osBean.mark();
+            else
+                osBean.unregister();
+        }
+
+        if (!markOnly)
+            registeredBeans.clear();
+    }
+
+    private BasicBean createBean(Uid uid)
+    {
+        String[] cnames = typeHandlers.get(type);
+
+        if (cnames == null) {
+            if (tsLogger.arjLoggerI18N.isWarnEnabled())
+                tsLogger.arjLoggerI18N.debug("com.arjuna.ats.arjuna.tools.osb.mbean.ObjStoreTypeBean.m_5",
+                        new Object[] { type });
+
+            cnames = new String[] { "com.arjuna.ats.tools.osb.mbean.ObjStoreEntryBean" };
+        }
+
+        for (String cname : cnames) {
+            try {
+                Class<BasicBean> cl = (Class<BasicBean>) Class.forName(cname);
+                Constructor<BasicBean> ccon = cl.getConstructor(ObjStoreTypeBean.class, Uid.class);
+                BasicBean action = ccon.newInstance(this, uid);
+
+                for (BasicBean registeredBean : registeredBeans) {
+                    if (registeredBean == action) {
+                        registeredBean.mark();
+                        return null;
+                    }
+                }
+
+                // TODO make sure all the parent beans are registered
+                action.register();
+
+                return action;
+            } catch (Exception e) {
+                if (tsLogger.arjLoggerI18N.isDebugEnabled())
+                    tsLogger.arjLoggerI18N.debug("com.arjuna.ats.arjuna.tools.osb.mbean.ObjStoreTypeBean.m_7",
+                            new Object[] { e.getMessage(), type });                
+            }
+        }
+
+        if (tsLogger.arjLoggerI18N.isWarnEnabled())
+            tsLogger.arjLoggerI18N.warn("com.arjuna.ats.arjuna.tools.osb.mbean.ObjStoreTypeBean.m_6",
+                    new Object[] { type, "No suitable handler" });
+
+        return null;
+    }
+}

Added: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/common/AtomicActionBean.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/common/AtomicActionBean.java	                        (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/common/AtomicActionBean.java	2009-12-10 09:45:42 UTC (rev 30576)
@@ -0,0 +1,82 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ * (C) 2009
+ * @author JBoss Inc.
+ */
+package com.arjuna.ats.arjuna.tools.osb.mbean.common;
+
+import com.arjuna.ats.arjuna.common.Uid;
+import com.arjuna.ats.arjuna.tools.osb.mbean.BasicActionBean;
+import com.arjuna.ats.arjuna.tools.osb.mbean.ObjStoreTypeBean;
+import com.arjuna.ats.arjuna.tools.osb.util.ActionWrapper;
+import com.arjuna.ats.arjuna.AtomicAction;
+import com.arjuna.ats.arjuna.exceptions.ObjectStoreException;
+
+import javax.management.ObjectInstance;
+import java.util.Map;
+
+/**
+ * MBean representation of an AtomicAction
+ * The AtomicActionWrapper inner class exposes the itentions lists of
+ * the actual atomic action
+ *
+ * @see com.arjuna.ats.arjuna.tools.osb.mbean.BasicActionBean
+ */
+public class AtomicActionBean extends BasicActionBean
+{
+    public AtomicActionBean(ObjStoreTypeBean parent, Uid uid) {
+        super(parent, uid);
+    }
+
+    public ObjectInstance register()
+    {
+        if (action_ == null)
+            action_ = new AtomicActionWrapper(uid);
+
+        return super.register();
+    }
+
+    public class AtomicActionWrapper extends AtomicAction implements ActionWrapper
+    {
+        public AtomicActionWrapper(Uid objUid)
+        {
+            super(objUid);
+        }
+
+        public com.arjuna.ats.arjuna.coordinator.BasicAction getAction()
+        {
+            return this;
+        }
+
+        public void populateLists(Map<String, LogRecordListBean> lists, BasicActionBean bean)
+        {
+            lists.put("Heuristic", new LogRecordListBean(bean, heuristicList, "Heuristic List"));
+            lists.put("Failed", new LogRecordListBean(bean, failedList, "Failed List"));
+            lists.put("Readonly", new LogRecordListBean(bean, readonlyList, "Readonly List"));
+            lists.put("Pending", new LogRecordListBean(bean, pendingList, "Pending List"));
+            lists.put("Prepared", new LogRecordListBean(bean, preparedList, "Prepared List"));
+        }
+
+        public void remove() throws ObjectStoreException
+        {
+            if (!getStore().remove_committed(getSavingUid(), type()))
+                throw new ObjectStoreException();
+        }
+    }
+}
+

Added: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/common/BasicBean.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/common/BasicBean.java	                        (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/common/BasicBean.java	2009-12-10 09:45:42 UTC (rev 30576)
@@ -0,0 +1,138 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ * (C) 2009
+ * @author Red Hat Middleware LLC.
+ */
+package com.arjuna.ats.arjuna.tools.osb.mbean.common;
+
+import javax.management.ObjectInstance;
+
+import com.arjuna.ats.arjuna.tools.osb.util.JMXServer;
+import com.arjuna.ats.arjuna.tools.osb.annotation.MXBeanPropertyDescription;
+
+/**
+ * Base class for all Object Store instrumentation types
+ *
+ * @see com.arjuna.ats.arjuna.tools.osb.mbean.common.BasicBeanMBean
+ */
+public class BasicBean implements BasicBeanMBean
+{
+    protected String type;
+    protected BasicBean parent;
+    protected boolean marked = true;
+    protected StringBuilder errorMessages = new StringBuilder();
+
+    public BasicBean()
+    {
+        super();
+    }
+
+    public BasicBean(BasicBean parent, String type)
+    {
+		this.type = type;
+        this.parent = parent;
+    }
+
+    public String getDescription() {
+        return "";
+    }
+    public String getObjectName() {
+        throw new RuntimeException("ObjectName is not implemented");
+    }
+
+    public BasicBean getParent()
+    {
+        return parent;
+    }
+
+    @MXBeanPropertyDescription("Record of any errors whilst populating mbean properties")
+    public String getMessages()
+    {
+        return errorMessages.toString();
+    }
+
+    protected void clearErrors()
+    {
+        errorMessages.delete(0, errorMessages.length());
+    }
+
+    protected void addError(String message)
+    {
+        errorMessages.append(message).append(System.getProperty("line.separator", "\n"));
+    }
+
+    public String getType()
+    {
+        return type;
+    }
+
+    public void refresh()
+    {
+        clearErrors();
+        unregisterDependents(true);
+        register();
+    }
+
+    public  ObjectInstance register()
+    {
+        return JMXServer.getAgent().registerMBean(this);
+    }
+
+    public boolean unregister()
+    {
+        return JMXServer.getAgent().unregisterMBean(getObjectName());
+    }
+
+    public void unregisterDependents(boolean markOnly)
+    {
+    }
+
+    @Override
+    public boolean equals(Object obj)
+    {
+        if (obj instanceof BasicBean) {
+            BasicBean bb = (BasicBean) obj;
+            return getObjectName().equals(bb.getObjectName());
+        }
+        
+        return false;
+    }
+
+    @Override
+    public int hashCode()
+    {
+        return getObjectName().hashCode();
+    }
+
+    @Override
+    public String toString()
+    {
+        return getObjectName();
+    }
+
+    public boolean isMarked()
+    {
+        return marked;
+    }
+
+    public void mark()
+    {
+        marked = true;
+    }
+
+}

Added: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/common/BasicBeanMBean.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/common/BasicBeanMBean.java	                        (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/common/BasicBeanMBean.java	2009-12-10 09:45:42 UTC (rev 30576)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ * (C) 2009
+ * @author Red Hat Middleware LLC.
+ */
+package com.arjuna.ats.arjuna.tools.osb.mbean.common;
+
+import com.arjuna.ats.arjuna.tools.osb.annotation.MXBeanDescription;
+import com.arjuna.ats.arjuna.tools.osb.annotation.MXBeanPropertyDescription;
+
+/**
+ * Base interface for all Object Store instrumentation.
+ *
+ * The MBean hierarchy corresponding to an Object Store is created once when the JVM
+ * is created and therefore, for performance reasons, the user must manually update
+ * using the refresh method:
+ */
+ at MXBeanDescription("Properties and behavior shared by all Object Store MXBeans")
+public interface BasicBeanMBean
+{
+    @MXBeanPropertyDescription("Record of any errors whilst populating mbean properties")
+	public String getMessages();
+
+    @MXBeanPropertyDescription("The object store type of this record")
+	public String getType();
+    @MXBeanPropertyDescription("See if any new MBeans have been created or if any MBeans no longer exist")
+    public void refresh();
+}

Added: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/common/LogRecordBean.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/common/LogRecordBean.java	                        (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/common/LogRecordBean.java	2009-12-10 09:45:42 UTC (rev 30576)
@@ -0,0 +1,62 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ * (C) 2009
+ * @author Red Hat Middleware LLC.
+ */
+package com.arjuna.ats.arjuna.tools.osb.mbean.common;
+
+import com.arjuna.ats.arjuna.coordinator.AbstractRecord;
+import com.arjuna.ats.arjuna.coordinator.RecordType;
+import com.arjuna.ats.arjuna.tools.osb.mbean.BasicActionBean;
+
+/**
+ * MBean implementation of records that extend StateManager
+ *
+ * @see com.arjuna.ats.arjuna.tools.osb.mbean.common.StateBeanMBean
+ *
+ */
+public class LogRecordBean extends StateBean // implements LogRecordMXBean
+{
+    private AbstractRecord record;
+    BasicActionBean owner;
+
+    public LogRecordBean(BasicBean parent, BasicActionBean owner, AbstractRecord record)
+    {
+        super(parent, record.type(), owner.getStore(), record.order());
+        this.record = record;
+        this.owner = owner;
+    }
+
+    public String getRecordType()
+    {
+        Class recordClass = RecordType.typeToClass(record.typeIs());
+        
+        return recordClass.getCanonicalName();
+    }
+
+    // MXBean method overrides
+    // log records inherit their header from Object Store entry
+    @Override public String getCreationTime()
+    { 
+        return owner.getCreationTime();
+    }
+    @Override public long getAgeInSeconds()
+    {
+        return owner.getAgeInSeconds();
+    }
+}

Added: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/common/LogRecordBeanMBean.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/common/LogRecordBeanMBean.java	                        (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/common/LogRecordBeanMBean.java	2009-12-10 09:45:42 UTC (rev 30576)
@@ -0,0 +1,31 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ * (C) 2009
+ * @author Red Hat Middleware LLC.
+ */
+package com.arjuna.ats.arjuna.tools.osb.mbean.common;
+
+import com.arjuna.ats.arjuna.tools.osb.annotation.MXBeanDescription;
+import com.arjuna.ats.arjuna.tools.osb.annotation.MXBeanPropertyDescription;
+
+ at MXBeanDescription("Generic representation of a participant")
+public interface LogRecordBeanMBean extends BasicBeanMBean
+{
+    @MXBeanPropertyDescription("The class name of the object that implements this record")
+    int getRecordType();
+}

Added: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/common/LogRecordListBean.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/common/LogRecordListBean.java	                        (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/common/LogRecordListBean.java	2009-12-10 09:45:42 UTC (rev 30576)
@@ -0,0 +1,116 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ * (C) 2009
+ * @author Red Hat Middleware LLC.
+ */
+package com.arjuna.ats.arjuna.tools.osb.mbean.common;
+
+import com.arjuna.ats.arjuna.coordinator.RecordList;
+import com.arjuna.ats.arjuna.coordinator.AbstractRecord;
+import com.arjuna.ats.arjuna.tools.osb.mbean.BasicActionBean;
+
+import javax.management.ObjectInstance;
+import java.util.Iterator;
+import java.util.Collection;
+import java.util.ArrayList;
+
+/**
+ * MBean implementation of ObjectStore records that contain other records.
+ *
+ * @see com.arjuna.ats.arjuna.tools.osb.mbean.common.LogRecordListBeanMBean
+ */
+public class LogRecordListBean extends BasicBean implements LogRecordListBeanMBean
+{
+    private Collection<LogRecordBean> registeredBeans = new ArrayList<LogRecordBean>();
+    private RecordList records;
+    private String name;
+
+    public LogRecordListBean(BasicActionBean parent, RecordList records, String name)
+    {
+        super(parent, parent.getType());
+
+        this.records = records;
+        this.name = name;
+    }
+
+    public int getSize()
+    {
+		return (records == null ? 0 : records.size());
+	}
+
+	public String getObjectName()
+	{
+		return parent.getObjectName() + "T1=" + name;
+	}
+
+    public BasicActionBean getParent()
+    {
+        return (BasicActionBean) parent;
+    }
+
+    public String getName()
+    {
+		return name;
+	}
+
+    public Collection<LogRecordBean> getRegisteredMBeans()
+    {
+		return registeredBeans;
+	}
+
+    public ObjectInstance register()
+    {
+        ObjectInstance oi = null;
+
+        if (getSize() != 0) {
+            super.register();
+            
+            for (AbstractRecord rec = records.peekFront(); rec != null; rec = records.peekNext(rec)) {
+                LogRecordBean bean = new LogRecordBean(this, (BasicActionBean) parent, rec);
+
+                if (bean.register() != null)
+					registeredBeans.add(bean);
+			}
+		}
+
+        return oi;
+    }
+
+    public void unregisterDependents(boolean markOnly)
+    {
+        for (LogRecordBean mbean : registeredBeans) {
+            if (markOnly)
+                mbean.marked = true;
+            else
+                mbean.unregister();
+        }
+
+        if (!markOnly)
+            registeredBeans.clear();
+    }
+
+    public boolean unregister()
+    {
+		for (Iterator<LogRecordBean> i = registeredBeans.iterator(); i.hasNext(); ) {
+			if (i.next().unregister())
+				i.remove();
+		}
+
+		return (getSize() == 0 && super.unregister());
+	}  
+}

Added: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/common/LogRecordListBeanMBean.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/common/LogRecordListBeanMBean.java	                        (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/common/LogRecordListBeanMBean.java	2009-12-10 09:45:42 UTC (rev 30576)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ * (C) 2009
+ * @author Red Hat Middleware LLC.
+ */
+package com.arjuna.ats.arjuna.tools.osb.mbean.common;
+
+import com.arjuna.ats.arjuna.tools.osb.annotation.MXBeanDescription;
+import com.arjuna.ats.arjuna.tools.osb.annotation.MXBeanPropertyDescription;
+
+/**
+ * MBean corresponding to records that contain lists of other records
+ *
+ * @see com.arjuna.ats.arjuna.coordinator.BasicAction
+ */
+ at MXBeanDescription("Encapsulates all participants in a particular state (prepared, pending, etc)")
+public interface LogRecordListBeanMBean extends BasicBeanMBean
+{
+    @MXBeanPropertyDescription("The type of the list (failed, heuristic, etc)")
+    public String getName();
+    @MXBeanPropertyDescription("The number of records stored in the list")
+    public int getSize();
+}

Added: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/common/StateBean.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/common/StateBean.java	                        (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/common/StateBean.java	2009-12-10 09:45:42 UTC (rev 30576)
@@ -0,0 +1,143 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ * (C) 2009
+ * @author Red Hat Middleware LLC.
+ */
+package com.arjuna.ats.arjuna.tools.osb.mbean.common;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.io.IOException;
+
+import com.arjuna.ats.arjuna.common.Uid;
+import com.arjuna.ats.arjuna.StateManager;
+import com.arjuna.ats.arjuna.ObjectStatus;
+import com.arjuna.ats.arjuna.ObjectType;
+import com.arjuna.ats.arjuna.logging.tsLogger;
+import com.arjuna.ats.arjuna.state.InputObjectState;
+import com.arjuna.ats.arjuna.exceptions.ObjectStoreException;
+import com.arjuna.ats.arjuna.objectstore.ObjectStore;
+
+/**
+ * @see StateBeanMBean
+ *
+ * @message org.jboss.jbosstm.tools.jmx.osb.MbState.m_1
+ *          [org.jboss.jbosstm.tools.jmx.osb.MbState.m_1] - Failed to unpack header: {0}.
+ */
+public class StateBean extends UidBean implements StateBeanMBean
+{
+    public static final DateFormat formatter = new SimpleDateFormat("E, dd MMM yyyy HH:mm:ss Z");
+
+    protected StateManagerInfo info;
+
+    // package private since info is not initialized
+    StateBean(BasicBean parent, Uid uid)
+    {
+        super(parent, uid);
+    }
+
+    public StateBean(BasicBean parent, ObjectStore store, Uid uid)
+    {
+        this(parent, parent.getType(), store, uid);
+    }
+
+    public StateBean(BasicBean parent, String type, ObjectStore store, Uid uid)
+    {
+        super(parent, type, uid);
+        this.info = new StateManagerInfo(store, uid, type);
+    }
+
+    // MXBean methods
+    public String getCreationTime()
+    {
+        return info.birthDate < 0 ? "" : formatter.format(new Date(info.birthDate));
+    }
+
+    public long getAgeInSeconds()
+    {
+        return (info.birthDate < 0 ? -1 : ((System.currentTimeMillis()) - info.birthDate) / 1000L);
+    }
+
+    public String getUid()
+    {
+        return uid.stringForm();
+    }
+
+    public String getStoreRoot()
+    {
+        return info.getStoreRoot();
+    }
+
+    public String getType()
+    {
+        return type;
+    }
+
+    public String getStatus()
+    {
+        return ObjectStatus.toString(info.status());
+    }
+
+    public String getObjectType()
+    {
+        return ObjectType.toString(info.ObjectType());
+    }
+
+    class StateManagerInfo extends StateManager
+    {
+        String state;
+        Uid txId = Uid.nullUid();
+        Uid processUid = Uid.nullUid();
+        long birthDate = -1;
+
+        protected StateManagerInfo(ObjectStore os, Uid uid, String type) {
+            super(uid);
+            try {
+                unpackHeader(os.read_committed(uid, type));
+            } catch (IOException e) {
+                if (tsLogger.arjLoggerI18N.isInfoEnabled())
+                    tsLogger.arjLoggerI18N.info("org.jboss.jbosstm.tools.jmx.osb.MbState.m_1",
+                            new Object[] { e.getMessage() });
+            } catch (ObjectStoreException e) {
+                if (tsLogger.arjLoggerI18N.isInfoEnabled())
+                    tsLogger.arjLoggerI18N.info("org.jboss.jbosstm.tools.jmx.osb.MbState.m_1",
+                            new Object[] { e.getMessage() });
+            }
+        }
+
+        void unpackHeader(InputObjectState os) throws IOException
+        {
+            if (os != null) {
+                state = os.unpackString();
+                byte[] txIdBytes = os.unpackBytes();
+                txId = new Uid(txIdBytes);
+
+                if (state.equals("#ARJUNA#")) {
+                    if (!txId.equals(Uid.nullUid())) {
+                        byte[] pUidBytes = os.unpackBytes();
+                        processUid = new Uid(pUidBytes);
+                    }
+
+                    birthDate = os.unpackLong();
+                }
+            }
+        }
+
+    }
+}

Added: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/common/StateBeanMBean.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/common/StateBeanMBean.java	                        (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/common/StateBeanMBean.java	2009-12-10 09:45:42 UTC (rev 30576)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ * (C) 2009
+ * @author Red Hat Middleware LLC.
+ */
+package com.arjuna.ats.arjuna.tools.osb.mbean.common;
+
+import com.arjuna.ats.arjuna.tools.osb.annotation.MXBeanDescription;
+import com.arjuna.ats.arjuna.tools.osb.annotation.MXBeanPropertyDescription;
+
+/**
+ * JMX instrumentation of Object Store log records that extend State Manager
+ *
+ * @see com.arjuna.ats.arjuna.StateManager
+ */
+ at MXBeanDescription("Generic representation of log record state")
+public interface StateBeanMBean extends UidBeanMBean
+{
+    @MXBeanPropertyDescription("The time that this record was last written to the log.")
+    String getCreationTime();
+    @MXBeanPropertyDescription("The number of seconds that have elapsed since this record was last saved")
+    long getAgeInSeconds();
+    @MXBeanPropertyDescription("The current status of this record (active, passive, ...)")
+	String getStatus();	// status
+    @MXBeanPropertyDescription("The type of the object (persistent, recoverable, ...)")
+	String getObjectType();	// ObjectType
+}

Added: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/common/TransactionStatusManagerItemBean.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/common/TransactionStatusManagerItemBean.java	                        (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/common/TransactionStatusManagerItemBean.java	2009-12-10 09:45:42 UTC (rev 30576)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ * (C) 2009
+ * @author Red Hat Middleware LLC.
+ */
+package com.arjuna.ats.arjuna.tools.osb.mbean.common;
+
+import com.arjuna.ats.arjuna.common.Uid;
+import com.arjuna.ats.arjuna.tools.osb.mbean.ObjStoreTypeBean;
+
+import java.util.Date;
+
+/**
+ * @see com.arjuna.ats.arjuna.tools.osb.mbean.common.TransactionStatusManagerItemBeanMBean
+ */
+public class TransactionStatusManagerItemBean extends UidBean implements TransactionStatusManagerItemBeanMBean
+{
+    private com.arjuna.ats.internal.arjuna.recovery.TransactionStatusManagerItem txStatusMgrItem;
+
+    public TransactionStatusManagerItemBean(ObjStoreTypeBean parent, Uid uid)
+    {
+        super(parent, parent.getType(), uid);
+
+        txStatusMgrItem = com.arjuna.ats.internal.arjuna.recovery.TransactionStatusManagerItem.recreate(uid);
+    }
+
+    public String getHost()
+    {
+        return txStatusMgrItem.host();
+    }
+
+    public int getPort()
+    {
+        return txStatusMgrItem.port();
+    }
+
+    public String getDeadTime()
+    {
+        Date d = txStatusMgrItem.getDeadTime();
+
+        return (d == null ? "Still live" : StateBean.formatter.format(d));
+    }
+}

Added: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/common/TransactionStatusManagerItemBeanMBean.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/common/TransactionStatusManagerItemBeanMBean.java	                        (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/common/TransactionStatusManagerItemBeanMBean.java	2009-12-10 09:45:42 UTC (rev 30576)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ * (C) 2009
+ * @author Red Hat Middleware LLC.
+ */
+package com.arjuna.ats.arjuna.tools.osb.mbean.common;
+
+import com.arjuna.ats.arjuna.tools.osb.annotation.MXBeanDescription;
+import com.arjuna.ats.arjuna.tools.osb.annotation.MXBeanPropertyDescription;
+
+/**
+ * MBean representation of an object that the recovery subsystem uses to obtain the status of transactions
+ *
+ * @see com.arjuna.ats.arjuna.recovery.TransactionStatusManager
+ * @see com.arjuna.ats.internal.arjuna.recovery.TransactionStatusManagerItem
+ */
+ at MXBeanDescription("Represents an object that the recovery subsystem uses to obtain the status of transactions")
+public interface TransactionStatusManagerItemBeanMBean extends UidBeanMBean
+{
+    @MXBeanPropertyDescription("The host where the TransactionStatusManager is running")
+    String getHost();
+    @MXBeanPropertyDescription("The port on which the TransactionStatusManager is listening")
+    int getPort();
+    @MXBeanPropertyDescription("The time at which the process was determined to be no longer existing")
+    String getDeadTime();
+}

Added: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/common/UidBean.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/common/UidBean.java	                        (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/common/UidBean.java	2009-12-10 09:45:42 UTC (rev 30576)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ * (C) 2009
+ * @author Red Hat Middleware LLC.
+ */
+package com.arjuna.ats.arjuna.tools.osb.mbean.common;
+
+import com.arjuna.ats.arjuna.common.Uid;
+
+/**
+ * @see com.arjuna.ats.arjuna.tools.osb.mbean.common.UidBeanMBean
+ */
+public class UidBean extends BasicBean implements UidBeanMBean
+{
+    protected Uid uid;
+
+    public UidBean(BasicBean parent, String type, Uid uid)
+    {
+        super(parent, type);
+        this.uid = uid;
+    }
+
+    public UidBean(BasicBean parent, Uid uid)
+    {
+        this(parent, parent.getType(), uid);
+    }
+
+    public String getObjectName()
+    {
+		String pon = parent.getObjectName();
+		String key = (pon.indexOf(",uid=") == -1 ? ",uid=" : ",suid=");
+
+        return parent.getObjectName() + key + "\"" + uid.toString() + "\"";
+    }
+
+    public String getUid()
+    {
+        return uid.toString();
+    }
+}

Added: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/common/UidBeanMBean.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/common/UidBeanMBean.java	                        (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/common/UidBeanMBean.java	2009-12-10 09:45:42 UTC (rev 30576)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ * (C) 2009
+ * @author Red Hat Middleware LLC.
+ */
+package com.arjuna.ats.arjuna.tools.osb.mbean.common;
+
+import com.arjuna.ats.arjuna.tools.osb.annotation.MXBeanDescription;
+import com.arjuna.ats.arjuna.tools.osb.annotation.MXBeanPropertyDescription;
+
+/**
+ * MBean representation of records that have unique ids
+ *
+ * @see com.arjuna.ats.arjuna.common.Uid
+ */
+ at MXBeanDescription("Common properties of records that have unique ids")
+public interface UidBeanMBean extends BasicBeanMBean
+{
+    @MXBeanPropertyDescription("A unique id for this record")
+    String getUid();
+    @MXBeanPropertyDescription("The object store type of the record")
+	String getType();
+}

Added: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/common/XAResourceRecordBeanMBean.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/common/XAResourceRecordBeanMBean.java	                        (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/common/XAResourceRecordBeanMBean.java	2009-12-10 09:45:42 UTC (rev 30576)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ * (C) 2009
+ * @author Red Hat Middleware LLC.
+ */
+package com.arjuna.ats.arjuna.tools.osb.mbean.common;
+
+import com.arjuna.ats.arjuna.tools.osb.annotation.MXBeanDescription;
+import com.arjuna.ats.arjuna.tools.osb.annotation.MXBeanPropertyDescription;
+import com.arjuna.ats.arjuna.tools.osb.mbean.common.UidBeanMBean;
+
+/**
+ * MBean representation of an XA ResourceManager
+ */
+ at MXBeanDescription("Log Record for distributed XA Resources")
+public interface XAResourceRecordBeanMBean extends UidBeanMBean
+{
+    @MXBeanPropertyDescription("The java type that implements this XAResource")
+    String getClassName();
+    @MXBeanPropertyDescription("JNDI name of the JCA resource")
+    String getEisProductName();
+    @MXBeanPropertyDescription("JCA product version")
+    String getEisProductVersion();
+    @MXBeanPropertyDescription("XA xid for the transaction branch")
+    String getXid();
+    @MXBeanPropertyDescription("The number of seconds before the resource can rollback the branch")
+    int getTimeout();
+}

Added: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/util/ActionWrapper.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/util/ActionWrapper.java	                        (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/util/ActionWrapper.java	2009-12-10 09:45:42 UTC (rev 30576)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ * (C) 2009
+ * @author Red Hat Middleware LLC.
+ */
+package com.arjuna.ats.arjuna.tools.osb.util;
+
+import com.arjuna.ats.arjuna.exceptions.ObjectStoreException;
+import com.arjuna.ats.arjuna.tools.osb.mbean.BasicActionBean;
+import com.arjuna.ats.arjuna.tools.osb.mbean.common.LogRecordListBean;
+
+import java.util.Map;
+
+/**
+ * An interface that abstracts the differences between the JTS and JTA  versions of actions
+ */
+public interface ActionWrapper
+{
+    void populateLists(Map<String, LogRecordListBean> lists, BasicActionBean bean);
+    void remove() throws ObjectStoreException;
+    com.arjuna.ats.arjuna.coordinator.BasicAction getAction();
+}

Added: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/util/JMXServer.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/util/JMXServer.java	                        (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/util/JMXServer.java	2009-12-10 09:45:42 UTC (rev 30576)
@@ -0,0 +1,161 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ * (C) 2009,
+ * @author Red Hat Middleware LLC.
+ */
+package com.arjuna.ats.arjuna.tools.osb.util;
+
+import com.arjuna.ats.arjuna.tools.osb.mbean.common.BasicBean;
+import com.arjuna.ats.arjuna.logging.tsLogger;
+
+import javax.management.*;
+import java.lang.management.ManagementFactory;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+/**
+ * Simple wrapper for accessing the JMX server
+ *
+ * @message com.arjuna.ats.arjuna.tools.osb.util.JMXServer.m_1
+ *          [com.arjuna.ats.arjuna.tools.osb.util.JMXServer.m_1] - registering bean {0}.
+ * @message com.arjuna.ats.arjuna.tools.osb.util.JMXServer.m_2
+ *          [com.arjuna.ats.arjuna.tools.osb.util.JMXServer.m_2] - Instance already exists: {0}.
+ * @message com.arjuna.ats.arjuna.tools.osb.util.JMXServer.m_3
+ *          [com.arjuna.ats.arjuna.tools.osb.util.JMXServer.m_3] - Error registrating {0} - {1}.
+ * @message com.arjuna.ats.arjuna.tools.osb.util.JMXServer.m_4
+ *          [com.arjuna.ats.arjuna.tools.osb.util.JMXServer.m_4] - Try to unregister mbean with invalid name {0}.
+ * @message com.arjuna.ats.arjuna.tools.osb.util.JMXServer.m_5]
+ *          [com.arjuna.ats.arjuna.tools.osb.util.JMXServer.m_5] - Unable to unregister bean {0} error: {1}.
+ * @message com.arjuna.ats.arjuna.tools.osb.util.JMXServer.m_6
+ *          [com.arjuna.ats.arjuna.tools.osb.util.JMXServer.m_6] - Unable to unregister bean {0} error: {1}.
+ */
+
+public class JMXServer
+{
+    private static MBeanServer server;
+    private static JMXServer agent = new JMXServer();
+
+    public static JMXServer getAgent() { return agent; }
+
+    private List<BasicBean> registeredBeans = new ArrayList<BasicBean>();
+
+    public JMXServer()
+    {
+        Class<?> c1;
+        Class<?> c2;
+
+        try {
+            c1 = Class.forName("com.arjuna.ats.internal.jta.Implementations");
+            c1.getMethod("initialise").invoke(null);
+        } catch (Exception e) {
+        }
+
+        try {
+            c1 = Class.forName("com.arjuna.ats.internal.jts.Implementations");
+            c2 = Class.forName("com.arjuna.ats.internal.jta.Implementationsx"); // needed for XAResourceRecord
+
+            c1.getMethod("initialise").invoke(null);
+            c2.getMethod("initialise").invoke(null);
+        } catch (Exception e) {
+        }
+    }
+
+    public MBeanServer getServer()
+    {
+        if (server == null)
+        {
+            List<MBeanServer> servers = MBeanServerFactory.findMBeanServer(null);
+
+            if (servers != null && servers.size() > 0)
+                server = servers.get(0);
+            else
+                server = ManagementFactory.getPlatformMBeanServer();
+
+            if (server == null)
+                server = MBeanServerFactory.createMBeanServer();
+        }
+
+        return server;
+    }
+
+    public ObjectInstance registerMBean(BasicBean bean)
+    {
+        ObjectInstance oi = null;
+
+        try {
+            if (tsLogger.arjLoggerI18N.isInfoEnabled())
+                tsLogger.arjLoggerI18N.debug("com.arjuna.ats.arjuna.tools.osb.util.JMXServer.m_1",
+                        new Object[] { bean.getObjectName() });
+            oi = getServer().registerMBean(bean, new ObjectName(bean.getObjectName()));
+            registeredBeans.add(bean);
+        } catch (InstanceAlreadyExistsException e) {
+            if (tsLogger.arjLoggerI18N.isInfoEnabled())
+                tsLogger.arjLoggerI18N.debug("com.arjuna.ats.arjuna.tools.osb.util.JMXServer.m_2",
+                        new Object[] { bean.getObjectName() });
+        } catch (javax.management.JMException e) {
+            if (tsLogger.arjLoggerI18N.isWarnEnabled())
+                tsLogger.arjLoggerI18N.warn("com.arjuna.ats.arjuna.tools.osb.util.JMXServer.m_3",
+                        new Object[] { bean.getObjectName(), e.getMessage() });
+        }
+
+		return oi;
+    }
+
+    public boolean unregisterMBean(String objectName)
+	{
+        boolean unregistered = false;
+        try {
+			unregistered = unregisterMBean(new ObjectName(objectName));
+            Iterator<BasicBean> i = registeredBeans.iterator();
+
+            while (i.hasNext()) {
+                BasicBean bb = i.next();
+
+                if (objectName.equals(bb.getObjectName())) {
+                    i.remove();
+                    break;
+                }
+            }
+        } catch (MalformedObjectNameException e) {
+            if (tsLogger.arjLoggerI18N.isWarnEnabled())
+                tsLogger.arjLoggerI18N.warn("com.arjuna.ats.arjuna.tools.osb.util.JMXServer.m_4",
+                        new Object[] { e.getMessage() });
+		}
+
+        return unregistered;
+    }
+
+    public boolean unregisterMBean(ObjectName objectName)
+    {
+        try {
+            getServer().unregisterMBean(objectName);
+        	return true;
+        } catch (InstanceNotFoundException e) {
+            if (tsLogger.arjLoggerI18N.isWarnEnabled())
+                tsLogger.arjLoggerI18N.warn("com.arjuna.ats.arjuna.tools.osb.util.JMXServer.m_5",
+                        new Object[] { objectName, e.getMessage() });
+        } catch (MBeanRegistrationException e) {
+            if (tsLogger.arjLoggerI18N.isWarnEnabled())
+                tsLogger.arjLoggerI18N.warn("com.arjuna.ats.arjuna.tools.osb.util.JMXServer.m_6",
+                        new Object[] { objectName, e.getMessage() });
+        }
+
+        return false;
+    }
+}

Modified: labs/jbosstm/trunk/atsintegration/transaction-jboss-beans.xml
===================================================================
--- labs/jbosstm/trunk/atsintegration/transaction-jboss-beans.xml	2009-12-10 06:14:36 UTC (rev 30575)
+++ labs/jbosstm/trunk/atsintegration/transaction-jboss-beans.xml	2009-12-10 09:45:42 UTC (rev 30576)
@@ -118,6 +118,12 @@
         <property name="objectStoreDir">${jboss.server.data.dir}/tx-object-store</property>
     </bean>
 
+    <bean name="ObjectStoreBrowserBean" class="com.arjuna.ats.arjuna.tools.osb.mbean.ObjStoreBean">
+       <constructor factoryClass="com.arjuna.ats.arjuna.tools.osb.mbean.ObjStoreBean" factoryMethod="getObjectStoreBrowserBean"/>
+
+       <demand state="Create">ObjectStoreEnvironmentBean</demand>
+    </bean>
+
     <bean name="JTAEnvironmentBean" class="com.arjuna.ats.jta.common.JTAEnvironmentBean">
 
         <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.jta:name=JTAEnvironmentBean", exposedInterface=com.arjuna.ats.jta.common.JTAEnvironmentBeanMBean.class, registerDirectly=true)</annotation>

Modified: labs/jbosstm/trunk/atsintegration/transaction-jboss-beans.xml.jts
===================================================================
--- labs/jbosstm/trunk/atsintegration/transaction-jboss-beans.xml.jts	2009-12-10 06:14:36 UTC (rev 30575)
+++ labs/jbosstm/trunk/atsintegration/transaction-jboss-beans.xml.jts	2009-12-10 09:45:42 UTC (rev 30576)
@@ -111,7 +111,7 @@
 
         <constructor factoryClass="com.arjuna.ats.arjuna.common.arjPropertyManager" factoryMethod="getCoordinatorEnvironmentBean"/>
 
-        <property name="enableStatistics">false</property>
+        <property name="enableStatistics">true</property>
         <property name="defaultTimeout">300</property>
     </bean>
 
@@ -124,6 +124,11 @@
         <property name="objectStoreDir">${jboss.server.data.dir}/tx-object-store</property>
     </bean>
 
+    <bean name="ObjectStoreBrowserBean" class="com.arjuna.ats.arjuna.tools.osb.mbean.ObjStoreBean">
+        <constructor factoryClass="com.arjuna.ats.arjuna.tools.osb.mbean.ObjStoreBean" factoryMethod="getObjectStoreBrowserBean"/>
+        <demand state="Create">ObjectStoreEnvironmentBean</demand>
+    </bean>
+
     <bean name="JTAEnvironmentBean" class="com.arjuna.ats.jta.common.JTAEnvironmentBean">
 
         <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.jta:name=JTAEnvironmentBean", exposedInterface=com.arjuna.ats.jta.common.JTAEnvironmentBeanMBean.class, registerDirectly=true)</annotation>



More information about the jboss-svn-commits mailing list