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

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Wed Dec 1 17:22:13 EST 2010


Author: mmusgrov
Date: 2010-12-01 17:22:12 -0500 (Wed, 01 Dec 2010)
New Revision: 36152

Added:
   labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/api/
   labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/api/mbeans/
   labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/api/mbeans/BaseStoreBean.java
   labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/api/mbeans/BaseStoreMBean.java
   labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/api/mbeans/ObjectStateWrapper.java
   labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/api/mbeans/OutputObjectStateWrapper.java
   labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/api/mbeans/ParticipantStoreBean.java
   labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/api/mbeans/ParticipantStoreBeanMBean.java
   labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/api/mbeans/RecoveryStoreBean.java
   labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/api/mbeans/RecoveryStoreBeanMBean.java
   labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/api/mbeans/TxLogBean.java
   labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/api/mbeans/TxLogBeanMBean.java
   labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/api/proxy/
   labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/api/proxy/ParticipantStoreProxy.java
   labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/api/proxy/RecoveryStoreProxy.java
   labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/api/proxy/StoreManagerProxy.java
   labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/api/proxy/TxLogProxy.java
   labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/tools/ObjectStoreAPIJMXTest.java
   labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/tools/OtherObjectStoreAPIJMXTest.java
Modified:
   labs/jbosstm/trunk/ArjunaCore/arjuna/build.xml
   labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/exceptions/ObjectStoreException.java
Log:
[JBQA-3927] Add a JMX proxy for the RecoveryStore and ParticipantStore

Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/build.xml
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/build.xml	2010-12-01 17:15:49 UTC (rev 36151)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/build.xml	2010-12-01 22:22:12 UTC (rev 36152)
@@ -41,6 +41,23 @@
         </compile-tests.macro>
     </target>
     
+	<!--
+		run tests that match a given pattern, for example
+		ant testone -DONECLASS="**/*ObjectStoreAPIJMXTest.java"
+		To run under the debugger pass the following to the run.tests.macro macro:
+            <additional.jvmargs>
+                <jvmarg value="-Xdebug"/>
+                <jvmarg value="-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"/>
+            </additional.jvmargs>
+	-->
+    <target name="testone">
+        <run.tests.macro>
+            <tests>
+                <fileset dir="tests/classes" includes="${ONECLASS}"/>
+            </tests>
+        </run.tests.macro>
+    </target>
+
     <target name="run.tests">
         <run.tests.macro>
             <tests>

Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/exceptions/ObjectStoreException.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/exceptions/ObjectStoreException.java	2010-12-01 17:15:49 UTC (rev 36151)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/exceptions/ObjectStoreException.java	2010-12-01 22:22:12 UTC (rev 36152)
@@ -32,6 +32,7 @@
 package com.arjuna.ats.arjuna.exceptions;
 
 import java.lang.Exception;
+import java.io.Serializable;
 
 /**
  * Exception that can be thrown when attempting to access
@@ -42,7 +43,7 @@
  * @since JTS 1.0.
  */
 
-public class ObjectStoreException extends Exception
+public class ObjectStoreException extends Exception implements Serializable
 {
     static final long serialVersionUID = -1228565199285342890L;
 

Added: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/api/mbeans/BaseStoreBean.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/api/mbeans/BaseStoreBean.java	                        (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/api/mbeans/BaseStoreBean.java	2010-12-01 22:22:12 UTC (rev 36152)
@@ -0,0 +1,65 @@
+package com.arjuna.ats.arjuna.tools.osb.api.mbeans;
+
+import com.arjuna.ats.arjuna.objectstore.BaseStore;
+import com.arjuna.ats.arjuna.tools.osb.api.proxy.StoreManagerProxy;
+
+import javax.management.*;
+
+/**
+ * abstract MBean implementation of a BaseStore MBean
+ */
+public abstract class BaseStoreBean extends NotificationBroadcasterSupport implements BaseStoreMBean {
+	private BaseStore store;
+
+	public BaseStoreBean(BaseStore store) {
+		this.store = store;
+	}
+
+    protected BaseStore getStore() {
+        return store;
+    }
+
+    /**
+     * The object name that the MBean will be registered with the MBean Server
+     * @return the MBeans object name
+     */
+    protected abstract ObjectName getMBeanName();
+
+    // implementation of methods in the BaseStore interface
+
+	public String getStoreName () {
+		return store.getStoreName ();
+	}
+
+    /**
+     * life cycle method for registering the MBean
+     */
+    public void start() {
+        StoreManagerProxy.registerBean(getMBeanName(), this, true);
+		generateNotification("Registering ObjectStore MBean");
+//		store.start ();        
+	}
+
+    /**
+     * life cycle method for un-registering the MBean
+     */
+    public void stop() {
+//		store.stop ();
+		generateNotification("Unregistering ObjectStore MBean");
+        StoreManagerProxy.registerBean(getMBeanName(), this, false);
+	}
+
+	private void generateNotification(String message) {
+		AttributeChangeNotification acn = new AttributeChangeNotification(this, 0, 0, message,
+			"storeName", "String", "oldValue", "newValue");
+		sendNotification(acn);
+	}
+
+	public MBeanNotificationInfo[] getNotificationInfo() {
+		return new MBeanNotificationInfo[] {new MBeanNotificationInfo(
+			new String[] { AttributeChangeNotification.ATTRIBUTE_CHANGE },
+			AttributeChangeNotification.class.getName(),
+			"Generated when the ObjectStore MBean is registered and destroyed")
+		};
+	}
+}

Added: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/api/mbeans/BaseStoreMBean.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/api/mbeans/BaseStoreMBean.java	                        (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/api/mbeans/BaseStoreMBean.java	2010-12-01 22:22:12 UTC (rev 36152)
@@ -0,0 +1,9 @@
+package com.arjuna.ats.arjuna.tools.osb.api.mbeans;
+
+// MBean interface corresponding to com.arjuna.ats.arjuna.objectstore.BaseStore
+public interface BaseStoreMBean
+{
+    public String getStoreName ();
+    public void start();
+    public void stop();
+}

Added: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/api/mbeans/ObjectStateWrapper.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/api/mbeans/ObjectStateWrapper.java	                        (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/api/mbeans/ObjectStateWrapper.java	2010-12-01 22:22:12 UTC (rev 36152)
@@ -0,0 +1,88 @@
+package com.arjuna.ats.arjuna.tools.osb.api.mbeans;
+
+import com.arjuna.ats.arjuna.common.Uid;
+import com.arjuna.ats.arjuna.state.InputObjectState;
+import com.arjuna.ats.arjuna.state.OutputObjectState;
+
+import java.io.Serializable;
+
+/**
+ * Wrapper for ObjectInputState and ObjectOutputState to facilitate use in JMX invocations
+ */
+public class ObjectStateWrapper implements Serializable {
+    private static final long serialVersionUID = 323923953274907077L;
+
+    private Uid newUid;
+    private String tName;
+    private byte[] buff;
+    private boolean valid = true;
+
+    public ObjectStateWrapper(OutputObjectState oos) {
+        this();
+
+        if (oos != null)
+            init(oos.stateUid(), oos.type(), oos.buffer());
+    }
+
+    public ObjectStateWrapper(InputObjectState ios) {
+        this();
+
+        if (ios != null)
+            init(ios.stateUid(), ios.type(), ios.buffer());
+    }
+
+    public ObjectStateWrapper(InputObjectState ios, boolean ok) {
+        this(ios);
+        setValid(ok);
+    }
+
+    public ObjectStateWrapper() {
+        init(Uid.nullUid(), "", new byte[0]);
+    }
+
+    private void init(Uid u, String t, byte[] b) {
+        this.newUid = u;
+        this.tName = t;
+        this.buff = b;
+    }
+
+    public boolean isValid() {
+        return valid;
+    }
+
+    public void setValid(boolean valid) {
+        this.valid = valid;
+    }
+
+    public InputObjectState getIOS() {
+        if (getBuff() == null || getBuff().length == 0)
+            return null;
+
+        Uid u = getNewUid() == null ? Uid.nullUid() : getNewUid();
+        String t = gettName() == null ? "" : gettName();
+        byte[] b = getBuff() == null ? new byte[0] : getBuff();
+        return new InputObjectState(u, t, b);
+    }
+    
+    public OutputObjectState getOOS() {
+        if (getBuff() == null || getBuff().length == 0)
+            return null;
+
+        Uid u = getNewUid() == null ? Uid.nullUid() : getNewUid();
+        String t = gettName() == null ? "" : gettName();
+        byte[] b = getBuff() == null ? new byte[0] : getBuff();
+        return new OutputObjectState(u, t, b);
+    }
+
+    public Uid getNewUid() {
+        return newUid;
+    }
+
+    public String gettName() {
+        return tName;
+    }
+
+    public byte[] getBuff() {
+        return buff;
+    }
+}

Added: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/api/mbeans/OutputObjectStateWrapper.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/api/mbeans/OutputObjectStateWrapper.java	                        (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/api/mbeans/OutputObjectStateWrapper.java	2010-12-01 22:22:12 UTC (rev 36152)
@@ -0,0 +1,12 @@
+package com.arjuna.ats.arjuna.tools.osb.api.mbeans;
+
+import com.arjuna.ats.arjuna.state.OutputObjectState;
+
+/**
+ * Wrapper for ObjectOutputState to facilitate use in JMX invocations
+ */
+public class OutputObjectStateWrapper extends ObjectStateWrapper {
+    public OutputObjectStateWrapper(OutputObjectState oos) {
+        super(oos);
+    }
+}
\ No newline at end of file

Added: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/api/mbeans/ParticipantStoreBean.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/api/mbeans/ParticipantStoreBean.java	                        (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/api/mbeans/ParticipantStoreBean.java	2010-12-01 22:22:12 UTC (rev 36152)
@@ -0,0 +1,74 @@
+package com.arjuna.ats.arjuna.tools.osb.api.mbeans;
+
+import com.arjuna.ats.arjuna.common.Uid;
+import com.arjuna.ats.arjuna.exceptions.ObjectStoreException;
+import com.arjuna.ats.arjuna.objectstore.ParticipantStore;
+import com.arjuna.ats.arjuna.objectstore.StoreManager;
+import com.arjuna.ats.arjuna.state.InputObjectState;
+import com.arjuna.ats.arjuna.tools.osb.api.proxy.StoreManagerProxy;
+
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+
+/**
+ * implementation of the JMX interface to the JBossTS participant store
+ */
+public class ParticipantStoreBean extends TxLogBean implements ParticipantStoreBeanMBean {
+
+	private ParticipantStore ps;
+
+    /**
+     * Construct an MBean corresponding to the default participant store in this JVM
+     */
+	public ParticipantStoreBean() {
+        super(StoreManager.getParticipantStore());
+        ps = (ParticipantStore) getStore();
+	}
+
+    /**
+     * Construct an MBean corresponding to the given store
+     * @param ps the ParticipantStore that is wrapped by this MBean
+     */
+    public ParticipantStoreBean(ParticipantStore ps) {
+        super(ps);
+        this.ps = ps;
+    }
+
+    @Override
+    protected ObjectName getMBeanName() {
+        try {
+            return new ObjectName(StoreManagerProxy.PARTICIPANT_BEAN_NAME);
+        } catch (MalformedObjectNameException e) {
+            System.out.println("Error creating object name: " + e.getMessage());
+            return null;
+        }
+    }
+
+	// ParticipantStore interface implementation
+
+	public boolean commit_state (Uid u, String tn) throws ObjectStoreException {
+		return ps.commit_state (u, tn);
+	}
+    
+	public ObjectStateWrapper read_committed (Uid u, String tn) throws ObjectStoreException {
+		InputObjectState ios = ps.read_committed (u, tn);
+        return new ObjectStateWrapper(ios);
+	}
+
+	public ObjectStateWrapper read_uncommitted (Uid u, String tn) throws ObjectStoreException {
+		InputObjectState ios = ps.read_uncommitted (u, tn);
+        return new ObjectStateWrapper(ios);
+	}
+
+	public boolean remove_uncommitted (Uid u, String tn) throws ObjectStoreException {
+		return ps.remove_uncommitted (u, tn);
+	}
+
+	public boolean write_uncommitted (Uid u, String tn, OutputObjectStateWrapper buff) throws ObjectStoreException {
+		return ps.write_uncommitted (u, tn, buff.getOOS());
+	}
+
+	public boolean fullCommitNeeded () {
+		return ps.fullCommitNeeded ();
+	}
+}

Added: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/api/mbeans/ParticipantStoreBeanMBean.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/api/mbeans/ParticipantStoreBeanMBean.java	                        (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/api/mbeans/ParticipantStoreBeanMBean.java	2010-12-01 22:22:12 UTC (rev 36152)
@@ -0,0 +1,24 @@
+package com.arjuna.ats.arjuna.tools.osb.api.mbeans;
+
+import com.arjuna.ats.arjuna.common.Uid;
+import com.arjuna.ats.arjuna.exceptions.ObjectStoreException;
+
+/**
+ * JMX interface to the JBossTS participant store
+ *
+ * OutputObjectState and InputObjectState are wrapped since they are not convertible to
+ * open MBean types.
+ *
+ * @see com.arjuna.ats.arjuna.tools.osb.api.proxy.ParticipantStoreProxy
+ * for the actual remote RecoveryStore proxy
+ *
+ * @see com.arjuna.ats.arjuna.objectstore.ParticipantStore for the interface it implements
+ */
+public interface ParticipantStoreBeanMBean extends TxLogBeanMBean {
+    public boolean commit_state (Uid u, String tn) throws ObjectStoreException;
+    public ObjectStateWrapper read_committed (Uid u, String tn) throws ObjectStoreException;
+    public ObjectStateWrapper read_uncommitted (Uid u, String tn) throws ObjectStoreException;
+    public boolean remove_uncommitted (Uid u, String tn) throws ObjectStoreException;
+    public boolean write_uncommitted (Uid u, String tn, OutputObjectStateWrapper buff) throws ObjectStoreException;
+    public boolean fullCommitNeeded ();
+}

Added: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/api/mbeans/RecoveryStoreBean.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/api/mbeans/RecoveryStoreBean.java	                        (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/api/mbeans/RecoveryStoreBean.java	2010-12-01 22:22:12 UTC (rev 36152)
@@ -0,0 +1,85 @@
+package com.arjuna.ats.arjuna.tools.osb.api.mbeans;
+
+import com.arjuna.ats.arjuna.common.Uid;
+import com.arjuna.ats.arjuna.exceptions.ObjectStoreException;
+import com.arjuna.ats.arjuna.objectstore.RecoveryStore;
+import com.arjuna.ats.arjuna.objectstore.StoreManager;
+import com.arjuna.ats.arjuna.state.InputObjectState;
+import com.arjuna.ats.arjuna.tools.osb.api.proxy.StoreManagerProxy;
+
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+
+/**
+ * implementation of the JMX interface to the JBossTS recovery store
+ */
+public class RecoveryStoreBean extends TxLogBean implements RecoveryStoreBeanMBean {
+	private RecoveryStore rs;
+
+    /**
+     * Construct an MBean corresponding to the default recovery store in this JVM
+     */
+	public RecoveryStoreBean() {
+        super(StoreManager.getRecoveryStore());
+		rs = (RecoveryStore) getStore();
+	}
+    /**
+     * Construct an MBean corresponding to the given store
+     * @param rs the RecoveryStore that is wrapped by this MBean
+     */
+    public RecoveryStoreBean(RecoveryStore rs) {
+        super(rs);
+        this.rs = rs;
+    }
+
+    @Override
+    protected ObjectName getMBeanName() {
+        try {
+            return new ObjectName(StoreManagerProxy.RECOVERY_BEAN_NAME);
+        } catch (MalformedObjectNameException e) {
+            System.out.println("Error creating object name: " + e.getMessage());
+            return null;
+        }
+    }
+
+	// RecoveryStore interface implementation
+
+	public ObjectStateWrapper allObjUids(String type, int m) throws ObjectStoreException {
+        InputObjectState ios = new InputObjectState();
+		boolean ok = rs.allObjUids (type, ios, m);
+        return new ObjectStateWrapper(ios, ok);
+	}
+
+	public ObjectStateWrapper allObjUids(String type) throws ObjectStoreException {
+        InputObjectState ios = new InputObjectState();
+		boolean ok = rs.allObjUids (type, ios);
+        return new ObjectStateWrapper(ios, ok);
+	}
+
+	public ObjectStateWrapper allTypes() throws ObjectStoreException {
+        InputObjectState ios = new InputObjectState();
+        boolean ok = rs.allTypes(ios);
+		return new ObjectStateWrapper(ios, ok);
+	}
+
+	public int currentState (Uid u, String tn) throws ObjectStoreException {
+		return rs.currentState (u, tn);
+	}
+
+	public boolean hide_state (Uid u, String tn) throws ObjectStoreException {
+		return rs.hide_state (u, tn);
+	}
+
+	public boolean reveal_state (Uid u, String tn) throws ObjectStoreException {
+		return rs.reveal_state (u, tn);
+	}
+
+	public ObjectStateWrapper read_committed (Uid u, String tn) throws ObjectStoreException {
+		InputObjectState ios = rs.read_committed (u, tn);
+        return new ObjectStateWrapper(ios);
+	}
+
+	public boolean isType (Uid u, String tn, int st) throws ObjectStoreException {
+		return rs.isType (u, tn, st);
+	}
+}

Added: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/api/mbeans/RecoveryStoreBeanMBean.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/api/mbeans/RecoveryStoreBeanMBean.java	                        (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/api/mbeans/RecoveryStoreBeanMBean.java	2010-12-01 22:22:12 UTC (rev 36152)
@@ -0,0 +1,27 @@
+package com.arjuna.ats.arjuna.tools.osb.api.mbeans;
+
+import com.arjuna.ats.arjuna.common.Uid;
+import com.arjuna.ats.arjuna.exceptions.ObjectStoreException;
+
+/**
+ * JMX interface to the JBossTS recovery store
+ * OutputObjectState and InputObjectState are wrapped since they are not convertible to
+ * open MBean types.
+ *
+ * @see com.arjuna.ats.arjuna.tools.osb.api.proxy.RecoveryStoreProxy
+ * for the actual remote RecoveryStore proxy
+ *
+ * @see com.arjuna.ats.arjuna.objectstore.RecoveryStore for the interface it implements
+ */
+public interface RecoveryStoreBeanMBean extends TxLogBeanMBean
+{
+    public ObjectStateWrapper allObjUids(String type, int match) throws ObjectStoreException;
+    public ObjectStateWrapper allObjUids(String type) throws ObjectStoreException;
+
+    public ObjectStateWrapper allTypes() throws ObjectStoreException;
+    public int currentState (Uid u, String tn) throws ObjectStoreException;
+    public boolean hide_state (Uid u, String tn) throws ObjectStoreException;
+    public boolean reveal_state (Uid u, String tn) throws ObjectStoreException;
+    public ObjectStateWrapper read_committed (Uid u, String tn) throws ObjectStoreException;
+    public boolean isType (Uid u, String tn, int st) throws ObjectStoreException;
+}

Added: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/api/mbeans/TxLogBean.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/api/mbeans/TxLogBean.java	                        (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/api/mbeans/TxLogBean.java	2010-12-01 22:22:12 UTC (rev 36152)
@@ -0,0 +1,39 @@
+package com.arjuna.ats.arjuna.tools.osb.api.mbeans;
+
+import com.arjuna.ats.arjuna.common.Uid;
+import com.arjuna.ats.arjuna.exceptions.ObjectStoreException;
+import com.arjuna.ats.arjuna.objectstore.TxLog;
+
+import javax.management.ObjectName;
+
+/**
+ * abstract implementation of the TxLog MBean
+ */
+public abstract class TxLogBean extends BaseStoreBean implements TxLogBeanMBean {
+	private TxLog store;
+
+	public TxLogBean(TxLog store) {
+        super(store);
+		this.store = store;
+    }
+
+    protected TxLog getStore() {
+        return store;
+    }
+
+    @Override
+    protected abstract ObjectName getMBeanName();
+
+    public void sync () throws java.io.SyncFailedException, ObjectStoreException {
+		store.sync ();
+	}
+
+	public boolean write_committed (Uid u, String tn, OutputObjectStateWrapper buff) throws ObjectStoreException {
+		return store.write_committed (u, tn, buff.getOOS());
+	}
+    
+	public boolean remove_committed (Uid u, String tn) throws ObjectStoreException {
+		return store.remove_committed(u, tn);
+	}
+
+}

Added: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/api/mbeans/TxLogBeanMBean.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/api/mbeans/TxLogBeanMBean.java	                        (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/api/mbeans/TxLogBeanMBean.java	2010-12-01 22:22:12 UTC (rev 36152)
@@ -0,0 +1,11 @@
+package com.arjuna.ats.arjuna.tools.osb.api.mbeans;
+
+import com.arjuna.ats.arjuna.common.Uid;
+import com.arjuna.ats.arjuna.exceptions.ObjectStoreException;
+
+public interface TxLogBeanMBean extends BaseStoreMBean
+{
+	public boolean remove_committed (Uid u, String tn) throws ObjectStoreException;
+    public boolean write_committed (Uid u, String tn, OutputObjectStateWrapper buff) throws ObjectStoreException;
+    public void sync () throws java.io.SyncFailedException, ObjectStoreException;
+}

Added: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/api/proxy/ParticipantStoreProxy.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/api/proxy/ParticipantStoreProxy.java	                        (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/api/proxy/ParticipantStoreProxy.java	2010-12-01 22:22:12 UTC (rev 36152)
@@ -0,0 +1,45 @@
+package com.arjuna.ats.arjuna.tools.osb.api.proxy;
+
+import com.arjuna.ats.arjuna.common.Uid;
+import com.arjuna.ats.arjuna.exceptions.ObjectStoreException;
+import com.arjuna.ats.arjuna.objectstore.ParticipantStore;
+import com.arjuna.ats.arjuna.state.InputObjectState;
+import com.arjuna.ats.arjuna.state.OutputObjectState;
+import com.arjuna.ats.arjuna.tools.osb.api.mbeans.OutputObjectStateWrapper;
+import com.arjuna.ats.arjuna.tools.osb.api.mbeans.ParticipantStoreBeanMBean;
+
+/**
+ * Remote proxy to a ParticipantStore
+ */
+public class ParticipantStoreProxy extends TxLogProxy implements ParticipantStore {
+    private ParticipantStoreBeanMBean psProxy;	// proxy for the participant store
+
+    public ParticipantStoreProxy(ParticipantStoreBeanMBean rsProxy) {
+        super(rsProxy);
+		this.psProxy = rsProxy;
+	}
+
+    public boolean commit_state(Uid u, String tn) throws ObjectStoreException {
+        return psProxy.commit_state(u, tn);
+    }
+
+    public InputObjectState read_committed(Uid u, String tn) throws ObjectStoreException {
+        return psProxy.read_committed(u, tn).getIOS();
+    }
+
+    public InputObjectState read_uncommitted(Uid u, String tn) throws ObjectStoreException {
+        return psProxy.read_uncommitted(u, tn).getIOS();
+    }
+
+    public boolean remove_uncommitted(Uid u, String tn) throws ObjectStoreException {
+        return psProxy.remove_uncommitted(u, tn);
+    }
+
+    public boolean write_uncommitted(Uid u, String tn, OutputObjectState buff) throws ObjectStoreException {
+        return psProxy.write_uncommitted(u, tn, new OutputObjectStateWrapper(buff));
+    }
+
+    public boolean fullCommitNeeded() {
+        return psProxy.fullCommitNeeded();
+    }
+}

Added: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/api/proxy/RecoveryStoreProxy.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/api/proxy/RecoveryStoreProxy.java	                        (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/api/proxy/RecoveryStoreProxy.java	2010-12-01 22:22:12 UTC (rev 36152)
@@ -0,0 +1,70 @@
+package com.arjuna.ats.arjuna.tools.osb.api.proxy;
+
+import com.arjuna.ats.arjuna.common.Uid;
+import com.arjuna.ats.arjuna.exceptions.ObjectStoreException;
+import com.arjuna.ats.arjuna.objectstore.RecoveryStore;
+import com.arjuna.ats.arjuna.state.InputObjectState;
+import com.arjuna.ats.arjuna.state.OutputObjectState;
+import com.arjuna.ats.arjuna.tools.osb.api.mbeans.ObjectStateWrapper;
+import com.arjuna.ats.arjuna.tools.osb.api.mbeans.RecoveryStoreBeanMBean;
+
+/**
+ * Remote proxy to a RecoveryStore
+ */
+public class RecoveryStoreProxy extends TxLogProxy implements RecoveryStore {
+    private RecoveryStoreBeanMBean rsProxy;	// proxy for the recovery store
+
+    public RecoveryStoreProxy(RecoveryStoreBeanMBean rsProxy) {
+        super(rsProxy);
+		this.rsProxy = rsProxy;
+	}
+
+
+    public boolean allObjUids(String type, InputObjectState buff, int match) throws ObjectStoreException {
+        ObjectStateWrapper ios = rsProxy.allObjUids(type, match);
+        OutputObjectState oos = ios.getOOS();
+        if (oos == null)
+            return false;
+        buff.copyFrom(oos);
+        return ios.isValid();
+    }
+
+    public boolean allObjUids(String type, InputObjectState buff) throws ObjectStoreException {
+        ObjectStateWrapper ios = rsProxy.allObjUids(type);
+        OutputObjectState oos = ios.getOOS();
+        if (oos == null)
+            return false;
+        buff.copyFrom(oos);
+        return ios.isValid();
+    }
+
+    public boolean allTypes(InputObjectState buff) throws ObjectStoreException {
+        ObjectStateWrapper ios = rsProxy.allTypes();
+        OutputObjectState oos = ios.getOOS();
+        if (oos == null)
+            return false;
+        buff.copyFrom(oos);
+        return ios.isValid();
+    }
+
+    public int currentState(Uid u, String tn) throws ObjectStoreException {
+        return rsProxy.currentState(u, tn);
+    }
+
+    public boolean hide_state(Uid u, String tn) throws ObjectStoreException {
+        return rsProxy.hide_state(u, tn);
+    }
+
+    public boolean reveal_state(Uid u, String tn) throws ObjectStoreException {
+        return rsProxy.reveal_state(u, tn);
+    }
+
+    public InputObjectState read_committed(Uid u, String tn) throws ObjectStoreException {
+        ObjectStateWrapper osw = rsProxy.read_committed(u, tn);
+        return osw.getIOS();
+    }
+
+    public boolean isType(Uid u, String tn, int st) throws ObjectStoreException {
+        return rsProxy.isType(u, tn, st);
+    }
+}

Added: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/api/proxy/StoreManagerProxy.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/api/proxy/StoreManagerProxy.java	                        (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/api/proxy/StoreManagerProxy.java	2010-12-01 22:22:12 UTC (rev 36152)
@@ -0,0 +1,246 @@
+package com.arjuna.ats.arjuna.tools.osb.api.proxy;
+
+import com.arjuna.ats.arjuna.tools.osb.api.mbeans.ParticipantStoreBeanMBean;
+import com.arjuna.ats.arjuna.tools.osb.api.mbeans.RecoveryStoreBeanMBean;
+import com.arjuna.ats.arjuna.tools.osb.util.JMXServer;
+
+import javax.management.*;
+import javax.management.remote.*;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Miscellaneous methods for obtaining remote proxies to the JBossTS Recovery and Participant stores
+ */
+public class StoreManagerProxy {
+    // class and bean names of MBeans representing the JBossTS recovery and participant stores
+    public static final String RECOVERY_BEAN_NAME = "jboss.jta:type=com.arjuna.ats.arjuna.tools.osb.api.mbeans.RecoveryStoreBean,name=store1";
+    public static final String PARTICIPANT_BEAN_NAME = "jboss.jta:type=com.arjuna.ats.arjuna.tools.osb.api.mbeans.ParticipantStoreBean,name=store1";
+
+//    public static final String SERVICE_URL = "service:jmx:rmi:///jndi/rmi://localhost:9999/server";
+
+    private static Map<String, StoreManagerProxy> proxies = Collections.synchronizedMap(new HashMap<String, StoreManagerProxy>());
+    private static JMXConnectorServer jmxCServer;
+
+    private MBeanServerConnection mbsc;	// MBean server implementing the object store MBeans
+
+    private JMXConnector jmxc;
+    private RecoveryStoreProxy rsProxy;	// proxy for the recovery store
+    private ParticipantStoreProxy psProxy;	// proxy for the participant store
+    private ObjectName recoveryStoreON;	// object name of the recover store MBean
+    private ObjectName participantStoreON;	// object name of the participant store MBean
+    private NotificationListener recoveryListener = null;
+    private NotificationListener participantListener = null;
+
+    /**
+     * Construct a holder for Participant and Recovery Store proxies. There is one instance for each connection
+     * to a JVM. In practice there will only ever be one instance.
+     *
+     * @param serviceUrl the url for the MBean server to connect to. Use default to connect to the local MBean Server
+     * @param listener optionally register a listener for notifications
+     * @throws JMException if there are JMX errors during registration of MBeans and notification listeners
+     * @throws IOException if there are errors on the connection to the MBean Server
+     */
+    private StoreManagerProxy(String serviceUrl, NotificationListener listener) throws JMException, IOException {
+        if ("default".equals(serviceUrl)) {
+            mbsc = JMXServer.getAgent().getServer();
+        } else {
+            // create an RMI connector
+            JMXServiceURL url = new JMXServiceURL(serviceUrl);
+            // connect to the target MBean server
+            jmxc = JMXConnectorFactory.connect(url, null);
+            mbsc = jmxc.getMBeanServerConnection();
+        }
+
+        recoveryStoreON = ObjectName.getInstance(RECOVERY_BEAN_NAME);
+        participantStoreON = ObjectName.getInstance(PARTICIPANT_BEAN_NAME);
+
+        rsProxy = new RecoveryStoreProxy(JMX.newMBeanProxy( mbsc, recoveryStoreON, RecoveryStoreBeanMBean.class, true));
+        psProxy = new ParticipantStoreProxy(JMX.newMBeanProxy( mbsc, participantStoreON, ParticipantStoreBeanMBean.class, true));
+
+        if (listener != null) {
+            mbsc.addNotificationListener(recoveryStoreON, listener, null, null);
+            mbsc.addNotificationListener(participantStoreON, listener, null, null);
+        }
+    }
+
+    /**
+     * Mechanism for JMX clients to remove listeners and to close the JMX connection if the client
+     * create one
+     * @throws JMException if there are errors removing listeners
+     * @throws IOException if there are errors removing listeners or closing the JMX connection
+     */
+    private void close() throws JMException, IOException {
+        System.out.println("Remove notification listener...");
+        // Remove notification listener on RecoveryStore MBean
+        if (this.recoveryListener != null)
+            mbsc.removeNotificationListener(recoveryStoreON, recoveryListener);
+        if (this.participantListener != null)
+            mbsc.removeNotificationListener(participantStoreON, participantListener);
+
+        recoveryListener = participantListener = null;
+
+        // close the connection to the JMX server
+        if (jmxc != null) {
+            jmxc.close();
+            jmxc = null;
+        }
+    }
+
+    /**
+     * Helper method for remote clients to connect to an MBean Server
+     *
+     * @param serviceUrl the url on which the target MBean Server resides
+     * @throws IOException if the serviceUrl is invalid or if the connection cannot be started
+     */
+    public static void startServerConnector(String serviceUrl) throws IOException {
+        jmxCServer = JMXConnectorServerFactory.newJMXConnectorServer(
+                new JMXServiceURL(serviceUrl), null, JMXServer.getAgent().getServer());
+
+        // accept JMX connections
+        jmxCServer.start();
+    }
+
+    public static void stopServerConnector() throws IOException {
+        jmxCServer.stop();
+    }
+
+    /**
+     * MBean registration helper method
+     * @param name MBean object name
+     * @param bean MBean implementation
+     * @param register whether to register or unregister the MBean
+     * @return true if the bean was successfully registered or unregistered
+     */
+    public static boolean registerBean(ObjectName name, Object bean, boolean register) {
+        try {
+            MBeanServer mbs = JMXServer.getAgent().getServer();
+            boolean isRegistered = mbs.isRegistered(name);
+
+            System.out.println((register ? "" : "un") + "registering bean " + name);
+
+            if (register && isRegistered) {
+                System.out.println(name + " is already registered");
+                return true;
+            } else if (!register && !isRegistered) {
+                System.out.println(name + " is not registered");
+                return true;
+            } else if (register) {
+                mbs.registerMBean(bean, name);
+            } else {
+                mbs.unregisterMBean(name);
+            }
+
+            return true;
+
+        } catch (JMException e) {
+            System.out.println("MBean registration error: " + e.getMessage());
+
+            return false;
+        }
+    }
+
+    // Obtain a JMX proxy to the ObjectStoreAPI
+    private static synchronized StoreManagerProxy getProxy(String serviceUrl, NotificationListener listener) throws IOException, JMException {
+        if (serviceUrl == null)
+            serviceUrl = "default";
+
+        if (!proxies.containsKey(serviceUrl))
+            proxies.put(serviceUrl, new StoreManagerProxy(serviceUrl, listener));
+
+        return proxies.get(serviceUrl);
+    }
+
+    /**
+     * release proxies to the object stores
+     * @throws JMException if there are errors removing listeners
+     * @throws IOException if there are errors removing listeners or closing the JMX connection
+     */
+    public static void releaseProxy() throws JMException, IOException {
+        releaseProxy("default");
+    }
+
+    /**
+     * release proxies to the object stores
+     *
+     * @param serviceUrl the service url of the MBean Server where the proxies are located
+     * @throws JMException if there are errors removing listeners
+     * @throws IOException if there are errors removing listeners or closing the JMX connection
+     */
+    public static void releaseProxy(String serviceUrl) throws JMException, IOException {
+        StoreManagerProxy psm = proxies.remove(serviceUrl);
+
+        if (psm != null)
+            psm.close();
+    }
+
+    /**
+     * Get a recovery store proxy from the local MBeanServer
+     * @return a proxy for the target RecoveryStore
+     * @throws JMException if there are JMX errors during registration of MBeans
+     * @throws IOException if there are errors on the connection to the MBean Server
+     */
+    public static synchronized RecoveryStoreProxy getRecoveryStore() throws IOException, JMException {
+        return getRecoveryStore(null);
+    }
+
+    /**
+     * Get a recovery store proxy from the local MBeanServer
+     * @param listener listener an optional notification listener (use null if one is not required)
+     * @return a proxy for the target RecoveryStore
+     * @throws JMException if there are JMX errors during registration of MBeans and notification listeners
+     * @throws IOException if there are errors on the connection to the MBean Server
+     */
+    public static synchronized RecoveryStoreProxy getRecoveryStore(NotificationListener listener) throws IOException, JMException {
+        return getProxy("default", listener).rsProxy;
+    }
+
+    /**
+     * Get a RecoveryStore proxy.
+     *
+     * @param serviceUrl the location of the MBean Server
+     * @param listener an optional notification listener (use null if one is not required)
+     * @return a proxy for the target RecoveryStore
+     * @throws JMException if there are JMX errors during registration of MBeans and notification listeners
+     * @throws IOException if there are errors on the connection to the MBean Server
+     */
+    public static synchronized RecoveryStoreProxy getRecoveryStore(String serviceUrl, NotificationListener listener) throws IOException, JMException {
+        return getProxy(serviceUrl, listener).rsProxy;
+    }
+
+    /**
+     * Get a participant store proxy from the local MBeanServer
+     * @return a proxy for the target ParticipantStore
+     * @throws JMException if there are JMX errors during registration of MBeans
+     * @throws IOException if there are errors on the connection to the MBean Server
+     */
+    public static synchronized ParticipantStoreProxy getParticipantStore() throws IOException, JMException {
+        return getParticipantStore(null);
+    }
+
+    /**
+     * Get a participant store proxy from the local MBeanServer
+     * @param listener listener an optional notification listener (use null if one is not required)
+     * @return a proxy for the target ParticipantStore
+     * @throws JMException if there are JMX errors during registration of MBeans and notification listeners
+     * @throws IOException if there are errors on the connection to the MBean Server
+     */
+    public static synchronized ParticipantStoreProxy getParticipantStore(NotificationListener listener) throws IOException, JMException {
+        return getProxy("default", listener).psProxy;
+    }
+
+    /**
+     * Get a participant store proxy.
+     *
+     * @param serviceUrl the location of the MBean Server
+     * @param listener an optional notification listener (use null if one is not required)
+     * @return a proxy for the target ParticipantStore
+     * @throws JMException if there are JMX errors during registration of MBeans and notification listeners
+     * @throws IOException if there are errors on the connection to the MBean Server
+     */
+    public static synchronized ParticipantStoreProxy getParticipantStore(String serviceUrl, NotificationListener listener) throws IOException, JMException {
+        return getProxy(serviceUrl, listener).psProxy;
+    }
+}

Added: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/api/proxy/TxLogProxy.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/api/proxy/TxLogProxy.java	                        (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/api/proxy/TxLogProxy.java	2010-12-01 22:22:12 UTC (rev 36152)
@@ -0,0 +1,45 @@
+package com.arjuna.ats.arjuna.tools.osb.api.proxy;
+
+import com.arjuna.ats.arjuna.common.Uid;
+import com.arjuna.ats.arjuna.exceptions.ObjectStoreException;
+import com.arjuna.ats.arjuna.objectstore.TxLog;
+import com.arjuna.ats.arjuna.state.OutputObjectState;
+import com.arjuna.ats.arjuna.tools.osb.api.mbeans.OutputObjectStateWrapper;
+import com.arjuna.ats.arjuna.tools.osb.api.mbeans.TxLogBeanMBean;
+
+/**
+ * Remote proxy to a TxLog Store
+ */
+public class TxLogProxy implements TxLog {
+	private TxLogBeanMBean txLogProxy;
+
+	public TxLogProxy(TxLogBeanMBean txLogProxy) {
+		this.txLogProxy = txLogProxy;
+    }
+
+    // TxLog methods
+    public boolean remove_committed (Uid u, String tn) throws ObjectStoreException {
+        return txLogProxy.remove_committed(u, tn);
+    }
+
+    public boolean write_committed (Uid u, String tn, OutputObjectState buff) throws ObjectStoreException {
+        return txLogProxy.write_committed(u, tn, new OutputObjectStateWrapper(buff));
+    }
+
+    public void sync () throws java.io.SyncFailedException, ObjectStoreException {
+        txLogProxy.sync();
+    }
+
+    // BaseStore methods
+    public String getStoreName () {
+        return txLogProxy.getStoreName();
+    }
+
+    public void start() {
+        txLogProxy.start();
+    }
+
+    public void stop() {
+        txLogProxy.stop();
+    }
+}

Added: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/tools/ObjectStoreAPIJMXTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/tools/ObjectStoreAPIJMXTest.java	                        (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/tools/ObjectStoreAPIJMXTest.java	2010-12-01 22:22:12 UTC (rev 36152)
@@ -0,0 +1,156 @@
+package com.hp.mwtests.ts.arjuna.tools;
+
+import com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean;
+import com.arjuna.ats.arjuna.common.Uid;
+import com.arjuna.ats.arjuna.objectstore.ObjectStoreIterator;
+import com.arjuna.ats.arjuna.objectstore.StateStatus;
+import com.arjuna.ats.arjuna.state.InputObjectState;
+import com.arjuna.ats.arjuna.state.OutputObjectState;
+import com.arjuna.ats.arjuna.tools.osb.api.proxy.ParticipantStoreProxy;
+import com.arjuna.ats.arjuna.tools.osb.api.proxy.RecoveryStoreProxy;
+import com.arjuna.ats.arjuna.tools.osb.api.proxy.StoreManagerProxy;
+import javax.management.*;
+
+import com.arjuna.ats.arjuna.tools.osb.api.mbeans.*;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+public class ObjectStoreAPIJMXTest {
+	private RecoveryStoreBean rsb;
+	private ParticipantStoreBean psb;
+
+	private RecoveryStoreProxy prs;
+	private ParticipantStoreProxy pps;
+    private boolean notified;
+
+    private NotificationListener listener = new NotificationListener() {
+        public void handleNotification(Notification notification, Object handback) {
+            notified = true;
+        }
+    };
+
+	@Before
+	public void setUp () throws Exception
+	{
+        notified = false;
+
+		// create MBeans representing the ObjectStore
+		rsb = new RecoveryStoreBean();
+		psb = new ParticipantStoreBean();
+
+		// and register them with the local MBean Server
+		rsb.start();
+		psb.start();
+
+		// obtain (JMX) proxies for the recovery and participant stores
+		prs = StoreManagerProxy.getRecoveryStore(listener);
+		pps = StoreManagerProxy.getParticipantStore(listener);
+	}
+
+	@After
+	public void tearDown () throws Exception
+	{
+		// Unregister MBeans
+		rsb.stop();
+		psb.stop();
+        StoreManagerProxy.releaseProxy();
+	}
+
+	@Test
+	public void testRecoveryStoreBean() throws Exception {
+		com.arjuna.common.tests.simple.EnvironmentBeanTest.testBeanByReflection(new RecoveryStoreBean());
+	}
+
+	@Test
+	public void testParticipantStoreBean() throws Exception {
+		com.arjuna.common.tests.simple.EnvironmentBeanTest.testBeanByReflection(new ParticipantStoreBean());
+	}
+
+	@Test
+	public void testShadowNoFileLockStore () throws Exception
+	{
+        final OutputObjectState buff = new OutputObjectState();
+        final String tn = "/StateManager/junit";
+
+        System.out.println("Testing shadow file store");
+
+        for (int i = 0; i < 10; i++)
+        {
+            Uid u = new Uid();
+
+            pps.write_uncommitted(u, tn, buff);
+
+            pps.commit_state(u, tn);
+
+            assertTrue(prs.currentState(u, tn) != StateStatus.OS_UNCOMMITTED);
+
+            InputObjectState ios = new InputObjectState();
+
+            prs.allObjUids("", ios);
+
+            assertTrue(pps.read_uncommitted(u, tn) == null);
+
+            prs.write_committed(u, tn, buff);
+            prs.read_committed(u, tn);
+
+            assertTrue(!pps.remove_uncommitted(u, tn));
+
+            prs.remove_committed(u, tn);
+
+            assertTrue(!prs.hide_state(u, tn));
+
+            assertTrue(!prs.reveal_state(u, tn));
+        }
+    }
+
+    //@Test
+    //TODO this test only works on an initially empty store
+    public void testIterator () throws Exception
+    {
+        Uid u1 = new Uid();
+        Uid u2 = new Uid();
+
+        prs.write_committed(u1, "foo", new OutputObjectState());
+        prs.write_committed(u2, "foo", new OutputObjectState());
+
+        ObjectStoreIterator iter = new ObjectStoreIterator(prs, "foo");
+
+        // iteration ordering is not guaranteed.
+
+        Uid x = iter.iterate();
+        assertTrue(x.notEquals(Uid.nullUid()));
+        assertTrue(x.equals(u1) || x.equals(u2));
+
+        Uid y = iter.iterate();
+        assertTrue(y.notEquals(Uid.nullUid()));
+        assertTrue(y.equals(u1) || y.equals(u2));
+
+        assertTrue(iter.iterate().equals(Uid.nullUid()));
+    }
+
+    @Test
+	public void testNotification() throws Exception {
+        // calling stop on the MBean should generate a notification
+        rsb.stop();
+
+        // make sure we wait long enough for it to be sent        
+        try {
+            Thread.sleep(1000);
+        } catch (InterruptedException e) {
+        }
+
+        // check that the MBean notification was sent
+        assertTrue(notified);
+    }
+
+    @Test
+    public void testStoreManagerProxyHelpers() throws Exception {
+        assertEquals(prs, StoreManagerProxy.getRecoveryStore());
+        assertEquals(pps, StoreManagerProxy.getParticipantStore());
+        assertEquals(prs, StoreManagerProxy.getRecoveryStore(null, null));
+        assertEquals(pps, StoreManagerProxy.getParticipantStore(null, null));
+    }
+}

Added: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/tools/OtherObjectStoreAPIJMXTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/tools/OtherObjectStoreAPIJMXTest.java	                        (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/tools/OtherObjectStoreAPIJMXTest.java	2010-12-01 22:22:12 UTC (rev 36152)
@@ -0,0 +1,338 @@
+package com.hp.mwtests.ts.arjuna.tools;
+
+import com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean;
+import com.arjuna.ats.arjuna.common.Uid;
+import com.arjuna.ats.arjuna.objectstore.ParticipantStore;
+import com.arjuna.ats.arjuna.objectstore.RecoveryStore;
+import com.arjuna.ats.arjuna.objectstore.StateStatus;
+import com.arjuna.ats.arjuna.state.InputObjectState;
+import com.arjuna.ats.arjuna.state.OutputObjectState;
+import com.arjuna.ats.arjuna.tools.osb.api.mbeans.ParticipantStoreBean;
+import com.arjuna.ats.arjuna.tools.osb.api.mbeans.RecoveryStoreBean;
+import com.arjuna.ats.arjuna.tools.osb.api.proxy.ParticipantStoreProxy;
+import com.arjuna.ats.arjuna.tools.osb.api.proxy.RecoveryStoreProxy;
+import com.arjuna.ats.arjuna.tools.osb.api.proxy.StoreManagerProxy;
+import com.arjuna.ats.internal.arjuna.objectstore.*;
+import org.junit.After;
+import org.junit.Test;
+
+import static org.junit.Assert.assertTrue;
+
+public class OtherObjectStoreAPIJMXTest {
+    private RecoveryStoreBean rsb;
+    private ParticipantStoreBean psb;
+
+    private RecoveryStoreProxy rsProxy;
+    private ParticipantStoreProxy psProxy;
+
+    public void createMBeans (RecoveryStore rs, ParticipantStore ps) throws Exception
+    {
+        // create MBeans representing the ObjectStore
+        rsb = new RecoveryStoreBean(rs);
+        psb = new ParticipantStoreBean(ps);
+
+        // and register them with the local MBean Server
+        rsb.start();
+        psb.start();
+
+        // obtain (JMX) proxies for the recovery and participant stores
+        rsProxy = StoreManagerProxy.getRecoveryStore(null);
+        psProxy = StoreManagerProxy.getParticipantStore(null);
+    }
+
+    @After
+    public void tearDown () throws Exception
+    {
+        // Unregister MBeans
+        rsb.stop();
+        psb.stop();
+
+        StoreManagerProxy.releaseProxy();
+    }
+
+    @Test
+    public void testActionStore() throws Exception
+    {
+        ObjectStoreEnvironmentBean objectStoreEnvironmentBean = new ObjectStoreEnvironmentBean();
+        objectStoreEnvironmentBean.setLocalOSRoot( System.getProperty("java.io.tmpdir") );
+
+        ActionStore as = new ActionStore(objectStoreEnvironmentBean);
+
+        final OutputObjectState buff = new OutputObjectState();
+        final String tn = "/StateManager/junit";
+
+        createMBeans(as, as);
+
+        for (int i = 0; i < 10; i++)
+        {
+            Uid u = new Uid();
+
+            psProxy.write_uncommitted(u, tn, buff);
+
+            psProxy.commit_state(u, tn);
+
+            assertTrue(rsProxy.currentState(u, tn) != StateStatus.OS_UNCOMMITTED);
+
+            InputObjectState ios = new InputObjectState();
+
+            rsProxy.allObjUids("", ios);
+
+            assertTrue(psProxy.read_uncommitted(u, tn) == null);
+
+            rsProxy.write_committed(u, tn, buff);
+            rsProxy.read_committed(u, tn);
+
+            assertTrue(!psProxy.remove_uncommitted(u, tn));
+
+            rsProxy.remove_committed(u, tn);
+
+            assertTrue(!rsProxy.hide_state(u, tn));
+
+            assertTrue(!rsProxy.reveal_state(u, tn));
+        }
+
+    }
+
+    @Test
+    public void testHashedStore () throws Exception
+    {
+        ObjectStoreEnvironmentBean objectStoreEnvironmentBean = new ObjectStoreEnvironmentBean();
+        objectStoreEnvironmentBean.setLocalOSRoot( System.getProperty("java.io.tmpdir") );
+
+        HashedStore as = new HashedStore(objectStoreEnvironmentBean);
+
+        final OutputObjectState buff = new OutputObjectState();
+        final String tn = "/StateManager/junit";
+
+        createMBeans(as, as);
+
+        for (int i = 0; i < 10; i++)
+        {
+            Uid u = new Uid();
+
+            psProxy.write_uncommitted(u, tn, buff);
+
+            psProxy.commit_state(u, tn);
+
+            assertTrue(rsProxy.currentState(u, tn) != StateStatus.OS_UNCOMMITTED);
+
+            InputObjectState ios = new InputObjectState();
+
+            rsProxy.allObjUids("", ios);
+
+            assertTrue(psProxy.read_uncommitted(u, tn) == null);
+
+            rsProxy.write_committed(u, tn, buff);
+            rsProxy.read_committed(u, tn);
+
+            assertTrue(!as.remove_uncommitted(u, tn));
+
+            rsProxy.remove_committed(u, tn);
+
+            assertTrue(!rsProxy.hide_state(u, tn));
+
+            assertTrue(!rsProxy.reveal_state(u, tn));
+        }
+    }
+
+    @Test
+    public void testHashedActionStore () throws Exception
+    {
+        ObjectStoreEnvironmentBean objectStoreEnvironmentBean = new ObjectStoreEnvironmentBean();
+        objectStoreEnvironmentBean.setLocalOSRoot( System.getProperty("java.io.tmpdir") );
+
+        HashedActionStore as = new HashedActionStore(objectStoreEnvironmentBean);
+
+        final OutputObjectState buff = new OutputObjectState();
+        final String tn = "/StateManager/junit";
+
+        createMBeans(as, as);
+
+        for (int i = 0; i < 10; i++)
+        {
+            Uid u = new Uid();
+
+            psProxy.write_uncommitted(u, tn, buff);
+
+            psProxy.commit_state(u, tn);
+
+            assertTrue(rsProxy.currentState(u, tn) != StateStatus.OS_UNCOMMITTED);
+
+            InputObjectState ios = new InputObjectState();
+
+            rsProxy.allObjUids("", ios);
+
+            assertTrue(psProxy.read_uncommitted(u, tn) == null);
+
+            rsProxy.write_committed(u, tn, buff);
+            rsProxy.read_committed(u, tn);
+
+            assertTrue(!psProxy.remove_uncommitted(u, tn));
+
+            rsProxy.remove_committed(u, tn);
+
+            assertTrue(!rsProxy.hide_state(u, tn));
+
+            assertTrue(!rsProxy.reveal_state(u, tn));
+        }
+    }
+
+    @Test
+    public void testShadowingStore () throws Exception
+    {
+        ObjectStoreEnvironmentBean objectStoreEnvironmentBean = new ObjectStoreEnvironmentBean();
+        objectStoreEnvironmentBean.setLocalOSRoot( System.getProperty("java.io.tmpdir") );
+
+        ShadowingStore as = new ShadowingStore(objectStoreEnvironmentBean);
+
+        final OutputObjectState buff = new OutputObjectState();
+        final String tn = "/StateManager/junit";
+
+        createMBeans(as, as);
+        for (int i = 0; i < 10; i++)
+        {
+            Uid u = new Uid();
+
+            psProxy.write_uncommitted(u, tn, buff);
+
+            psProxy.commit_state(u, tn);
+
+            assertTrue(rsProxy.currentState(u, tn) != StateStatus.OS_UNCOMMITTED);
+
+            InputObjectState ios = new InputObjectState();
+
+            rsProxy.allObjUids("", ios);
+
+            assertTrue(psProxy.read_uncommitted(u, tn) == null);
+
+            rsProxy.write_committed(u, tn, buff);
+            rsProxy.read_committed(u, tn);
+
+            assertTrue(!psProxy.remove_uncommitted(u, tn));
+
+            rsProxy.remove_committed(u, tn);
+
+            assertTrue(!rsProxy.hide_state(u, tn));
+
+            assertTrue(!rsProxy.reveal_state(u, tn));
+        }
+    }
+
+    @Test
+    public void testNullActionStore () throws Exception
+    {
+        ObjectStoreEnvironmentBean objectStoreEnvironmentBean = new ObjectStoreEnvironmentBean();
+        objectStoreEnvironmentBean.setLocalOSRoot( System.getProperty("java.io.tmpdir") );
+
+        NullActionStore as = new NullActionStore(objectStoreEnvironmentBean);
+
+        final OutputObjectState buff = new OutputObjectState();
+        final String tn = "/StateManager/junit";
+
+        createMBeans(as, as);
+        for (int i = 0; i < 10; i++)
+        {
+            Uid u = new Uid();
+
+            psProxy.write_uncommitted(u, tn, buff);
+
+            psProxy.commit_state(u, tn);
+
+            assertTrue(rsProxy.currentState(u, tn) != StateStatus.OS_UNCOMMITTED);
+
+            InputObjectState ios = new InputObjectState();
+
+            rsProxy.allObjUids("", ios);
+
+            assertTrue(psProxy.read_uncommitted(u, tn) == null);
+
+            rsProxy.write_committed(u, tn, buff);
+            rsProxy.read_committed(u, tn);
+
+            assertTrue(!psProxy.remove_uncommitted(u, tn));
+
+            rsProxy.remove_committed(u, tn);
+
+            assertTrue(!rsProxy.hide_state(u, tn));
+
+            assertTrue(!rsProxy.reveal_state(u, tn));
+        }
+    }
+
+    @Test
+    public void testVolatileStore () throws Exception
+    {
+        ObjectStoreEnvironmentBean objectStoreEnvironmentBean = new ObjectStoreEnvironmentBean();
+        objectStoreEnvironmentBean.setLocalOSRoot( System.getProperty("java.io.tmpdir") );
+
+        VolatileStore as = new VolatileStore(objectStoreEnvironmentBean);
+
+        final OutputObjectState buff = new OutputObjectState();
+        final String tn = "/StateManager/junit";
+
+        createMBeans(as, as);
+        for (int i = 0; i < 10; i++)
+        {
+            Uid u = new Uid();
+
+            InputObjectState ios = new InputObjectState();
+
+            try
+            {
+                rsProxy.allObjUids("", ios);
+            }
+            catch (final Exception ex)
+            {
+            }
+
+            try
+            {
+                assertTrue(psProxy.read_uncommitted(u, tn) == null);
+            }
+            catch (final Exception ex)
+            {
+            }
+
+            try
+            {
+                psProxy.commit_state(u, tn);
+            }
+            catch (final Exception ex)
+            {
+            }
+
+            rsProxy.write_committed(u, tn, buff);
+
+            assertTrue(rsProxy.currentState(u, tn) == StateStatus.OS_COMMITTED);
+
+            rsProxy.read_committed(u, tn);
+
+            try
+            {
+                assertTrue(psProxy.remove_uncommitted(u, tn));
+            }
+            catch (final Exception ex)
+            {
+            }
+
+            rsProxy.remove_committed(u, tn);
+
+            try
+            {
+                assertTrue(rsProxy.hide_state(u, tn));
+            }
+            catch (final Exception ex)
+            {
+            }
+
+            try
+            {
+                assertTrue(rsProxy.reveal_state(u, tn));
+            }
+            catch (final Exception ex)
+            {
+            }
+        }
+    }
+
+}



More information about the jboss-svn-commits mailing list