[jboss-svn-commits] JBL Code SVN: r25874 - in labs/jbosstm/workspace/mlittle: STM-Arjuna and 21 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Sun Mar 29 16:10:29 EDT 2009


Author: mark.little at jboss.com
Date: 2009-03-29 16:10:29 -0400 (Sun, 29 Mar 2009)
New Revision: 25874

Added:
   labs/jbosstm/workspace/mlittle/STM-Arjuna/
   labs/jbosstm/workspace/mlittle/STM-Arjuna/.classpath
   labs/jbosstm/workspace/mlittle/STM-Arjuna/.project
   labs/jbosstm/workspace/mlittle/STM-Arjuna/checkstyle.xml
   labs/jbosstm/workspace/mlittle/STM-Arjuna/lib/
   labs/jbosstm/workspace/mlittle/STM-Arjuna/lib/Licenses.txt
   labs/jbosstm/workspace/mlittle/STM-Arjuna/lib/jbosscore.jar
   labs/jbosstm/workspace/mlittle/STM-Arjuna/lib/jbossts-common.jar
   labs/jbosstm/workspace/mlittle/STM-Arjuna/log4j.properties
   labs/jbosstm/workspace/mlittle/STM-Arjuna/pom.xml
   labs/jbosstm/workspace/mlittle/STM-Arjuna/src/
   labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/
   labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/
   labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/
   labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/
   labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/stm/
   labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/stm/InvalidAnnotationException.java
   labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/stm/LockException.java
   labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/stm/PersistentContainer.java
   labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/stm/RecoverableContainer.java
   labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/stm/TransactionException.java
   labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/stm/annotations/
   labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/stm/annotations/DurableState.java
   labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/stm/annotations/Nested.java
   labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/stm/annotations/ReadLock.java
   labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/stm/annotations/RestoreState.java
   labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/stm/annotations/SaveState.java
   labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/stm/annotations/Transactional.java
   labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/stm/annotations/WriteLock.java
   labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/stm/internal/
   labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/stm/internal/proxy/
   labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/stm/internal/proxy/LockManagerProxy.java
   labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/stm/internal/reflect/
   labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/stm/internal/reflect/InvocationHandler.java
   labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/stm/types/
   labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/stm/types/AtomicInteger.java
   labs/jbosstm/workspace/mlittle/STM-Arjuna/src/test/
   labs/jbosstm/workspace/mlittle/STM-Arjuna/src/test/java/
   labs/jbosstm/workspace/mlittle/STM-Arjuna/src/test/java/org/
   labs/jbosstm/workspace/mlittle/STM-Arjuna/src/test/java/org/jboss/
   labs/jbosstm/workspace/mlittle/STM-Arjuna/src/test/java/org/jboss/stm/
   labs/jbosstm/workspace/mlittle/STM-Arjuna/src/test/java/org/jboss/stm/BasicContainerUnitTest.java
   labs/jbosstm/workspace/mlittle/STM-Arjuna/src/test/java/org/jboss/stm/HammerUnitTest.java
   labs/jbosstm/workspace/mlittle/STM-Arjuna/src/test/java/org/jboss/stm/InvocationHandlerUnitTest.java
   labs/jbosstm/workspace/mlittle/STM-Arjuna/src/test/java/org/jboss/stm/NestedHammerUnitTest.java
   labs/jbosstm/workspace/mlittle/STM-Arjuna/src/test/java/org/jboss/stm/PersistentContainerUnitTest.java
   labs/jbosstm/workspace/mlittle/STM-Arjuna/src/test/java/org/jboss/stm/ProxyUnitTest.java
   labs/jbosstm/workspace/mlittle/STM-Arjuna/src/test/java/org/jboss/stm/RecoverableContainerUnitTest.java
   labs/jbosstm/workspace/mlittle/STM-Arjuna/src/test/java/org/jboss/stm/TestContainer.java
   labs/jbosstm/workspace/mlittle/STM-Arjuna/src/test/java/org/jboss/stm/annotations/
   labs/jbosstm/workspace/mlittle/STM-Arjuna/src/test/java/org/jboss/stm/annotations/BasicUnitTest.java
   labs/jbosstm/workspace/mlittle/STM-Arjuna/src/test/java/org/jboss/stm/annotations/InheritedUnitTest.java
   labs/jbosstm/workspace/mlittle/STM-Arjuna/src/test/java/org/jboss/stm/internal/
   labs/jbosstm/workspace/mlittle/STM-Arjuna/src/test/java/org/jboss/stm/internal/proxy/
   labs/jbosstm/workspace/mlittle/STM-Arjuna/src/test/java/org/jboss/stm/internal/proxy/ComplexLockManagerProxyUnitTest.java
   labs/jbosstm/workspace/mlittle/STM-Arjuna/src/test/java/org/jboss/stm/internal/proxy/InheritenceLockManagerProxyUnitTest.java
   labs/jbosstm/workspace/mlittle/STM-Arjuna/src/test/java/org/jboss/stm/internal/proxy/LockManagerProxyUnitTest.java
   labs/jbosstm/workspace/mlittle/STM-Arjuna/src/test/java/org/jboss/stm/internal/reflect/
   labs/jbosstm/workspace/mlittle/STM-Arjuna/src/test/java/org/jboss/stm/internal/reflect/TestInvocationHandler.java
Log:
initial thoughts

Added: labs/jbosstm/workspace/mlittle/STM-Arjuna/.classpath
===================================================================
--- labs/jbosstm/workspace/mlittle/STM-Arjuna/.classpath	                        (rev 0)
+++ labs/jbosstm/workspace/mlittle/STM-Arjuna/.classpath	2009-03-29 20:10:29 UTC (rev 25874)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src/test/java"/>
+	<classpathentry kind="src" path="src/main/java"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/JBossTS_trunk"/>
+	<classpathentry kind="lib" path="/Users/marklittle/Documents/workspace/JBossTS_trunk/ext/junit.jar"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>

Added: labs/jbosstm/workspace/mlittle/STM-Arjuna/.project
===================================================================
--- labs/jbosstm/workspace/mlittle/STM-Arjuna/.project	                        (rev 0)
+++ labs/jbosstm/workspace/mlittle/STM-Arjuna/.project	2009-03-29 20:10:29 UTC (rev 25874)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>STM-Arjuna</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>

Added: labs/jbosstm/workspace/mlittle/STM-Arjuna/checkstyle.xml
===================================================================

Added: labs/jbosstm/workspace/mlittle/STM-Arjuna/lib/Licenses.txt
===================================================================
--- labs/jbosstm/workspace/mlittle/STM-Arjuna/lib/Licenses.txt	                        (rev 0)
+++ labs/jbosstm/workspace/mlittle/STM-Arjuna/lib/Licenses.txt	2009-03-29 20:10:29 UTC (rev 25874)
@@ -0,0 +1,709 @@
+The jars used by and/or shipped with JBossESB are covered by a range of licences, as described
+below.
+
+JBoss jars:
+
+/*
+ *
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated 
+ * by the @authors tag. All rights reserved. 
+ * 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) 2005-2006,
+ */
+ 
+Apache Jakarta Commons Collections, Commons Logging, jUDDI, Scout, JAXR-API, DBCP, Pooling:
+
+Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+   
+   
+   
+   
+   Enterprise Distributed Technologies edtftpj.jar
+   
+   edtFTPj is Open Source, licensed under the LGPL, the GNU Lesser General 
+   Public License.   http://www.gnu.org/licenses/lgpl.html
+   
+--- jsch-0.1.jar
+JSch 0.0.* was released under the GNU LGPL license.  Later, we have switched 
+over to a BSD-style license. 
+
+------------------------------------------------------------------------------
+Copyright (c) 2002,2003,2004,2005,2006 Atsuhiko Yamanaka, JCraft,Inc. 
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+  1. Redistributions of source code must retain the above copyright notice,
+     this list of conditions and the following disclaimer.
+
+  2. Redistributions in binary form must reproduce the above copyright 
+     notice, this list of conditions and the following disclaimer in 
+     the documentation and/or other materials provided with the distribution.
+
+  3. The names of the authors may not be used to endorse or promote products
+     derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
+INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+---
+
+   
+--- Milyn Jars----------------------------------------------------------------
+
+	Milyn - Copyright (C) 2006
+
+	This library is free software; you can redistribute it and/or
+	modify it under the terms of the GNU Lesser General Public
+	License (version 2.1) as published by the Free Software 
+	Foundation.
+
+	This library is distributed in the hope that it will be useful,
+	but WITHOUT ANY WARRANTY; without even the implied warranty of
+	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
+    
+	See the GNU Lesser General Public License for more details:    
+	http://www.gnu.org/licenses/lgpl.txt
+------------------------------------------------------------------------------
+
+--- JSF Facelets -------------------------------------------------------------
+
+COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0:
+	http://www.opensource.org/licenses/cddl1.txt
+
+      1. Definitions.
+
+            1.1. ÒContributorÓ means each individual or entity that
+            creates or contributes to the creation of Modifications.
+
+            1.2. ÒContributor VersionÓ means the combination of the
+            Original Software, prior Modifications used by a
+            Contributor (if any), and the Modifications made by that
+            particular Contributor.
+
+            1.3. ÒCovered SoftwareÓ means (a) the Original Software, or
+            (b) Modifications, or (c) the combination of files
+            containing Original Software with files containing
+            Modifications, in each case including portions thereof.
+
+            1.4. ÒExecutableÓ means the Covered Software in any form
+            other than Source Code. 
+
+            1.5. ÒInitial DeveloperÓ means the individual or entity
+            that first makes Original Software available under this
+            License. 
+            
+            1.6. ÒLarger WorkÓ means a work which combines Covered
+            Software or portions thereof with code not governed by the
+            terms of this License.
+
+            1.7. ÒLicenseÓ means this document.
+
+            1.8. ÒLicensableÓ means having the right to grant, to the
+            maximum extent possible, whether at the time of the initial
+            grant or subsequently acquired, any and all of the rights
+            conveyed herein.
+            
+            1.9. ÒModificationsÓ means the Source Code and Executable
+            form of any of the following: 
+
+                  A. Any file that results from an addition to,
+                  deletion from or modification of the contents of a
+                  file containing Original Software or previous
+                  Modifications; 
+
+                  B. Any new file that contains any part of the
+                  Original Software or previous Modification; or 
+
+                  C. Any new file that is contributed or otherwise made
+                  available under the terms of this License.
+
+            1.10. ÒOriginal SoftwareÓ means the Source Code and
+            Executable form of computer software code that is
+            originally released under this License. 
+
+            1.11. ÒPatent ClaimsÓ means any patent claim(s), now owned
+            or hereafter acquired, including without limitation,
+            method, process, and apparatus claims, in any patent
+            Licensable by grantor. 
+
+            1.12. ÒSource CodeÓ means (a) the common form of computer
+            software code in which modifications are made and (b)
+            associated documentation included in or with such code.
+
+            1.13. ÒYouÓ (or ÒYourÓ) means an individual or a legal
+            entity exercising rights under, and complying with all of
+            the terms of, this License. For legal entities, ÒYouÓ
+            includes any entity which controls, is controlled by, or is
+            under common control with You. For purposes of this
+            definition, ÒcontrolÓ means (a) the power, direct or
+            indirect, to cause the direction or management of such
+            entity, whether by contract or otherwise, or (b) ownership
+            of more than fifty percent (50%) of the outstanding shares
+            or beneficial ownership of such entity.
+
+      2. License Grants. 
+
+            2.1. The Initial Developer Grant.
+
+            Conditioned upon Your compliance with Section 3.1 below and
+            subject to third party intellectual property claims, the
+            Initial Developer hereby grants You a world-wide,
+            royalty-free, non-exclusive license: 
+
+                  (a) under intellectual property rights (other than
+                  patent or trademark) Licensable by Initial Developer,
+                  to use, reproduce, modify, display, perform,
+                  sublicense and distribute the Original Software (or
+                  portions thereof), with or without Modifications,
+                  and/or as part of a Larger Work; and 
+
+                  (b) under Patent Claims infringed by the making,
+                  using or selling of Original Software, to make, have
+                  made, use, practice, sell, and offer for sale, and/or
+                  otherwise dispose of the Original Software (or
+                  portions thereof). 
+
+                  (c) The licenses granted in Sections 2.1(a) and (b)
+                  are effective on the date Initial Developer first
+                  distributes or otherwise makes the Original Software
+                  available to a third party under the terms of this
+                  License. 
+
+                  (d) Notwithstanding Section 2.1(b) above, no patent
+                  license is granted: (1) for code that You delete from
+                  the Original Software, or (2) for infringements
+                  caused by: (i) the modification of the Original
+                  Software, or (ii) the combination of the Original
+                  Software with other software or devices. 
+
+            2.2. Contributor Grant.
+
+            Conditioned upon Your compliance with Section 3.1 below and
+            subject to third party intellectual property claims, each
+            Contributor hereby grants You a world-wide, royalty-free,
+            non-exclusive license:
+
+                  (a) under intellectual property rights (other than
+                  patent or trademark) Licensable by Contributor to
+                  use, reproduce, modify, display, perform, sublicense
+                  and distribute the Modifications created by such
+                  Contributor (or portions thereof), either on an
+                  unmodified basis, with other Modifications, as
+                  Covered Software and/or as part of a Larger Work; and
+                  
+
+                  (b) under Patent Claims infringed by the making,
+                  using, or selling of Modifications made by that
+                  Contributor either alone and/or in combination with
+                  its Contributor Version (or portions of such
+                  combination), to make, use, sell, offer for sale,
+                  have made, and/or otherwise dispose of: (1)
+                  Modifications made by that Contributor (or portions
+                  thereof); and (2) the combination of Modifications
+                  made by that Contributor with its Contributor Version
+                  (or portions of such combination). 
+
+                  (c) The licenses granted in Sections 2.2(a) and
+                  2.2(b) are effective on the date Contributor first
+                  distributes or otherwise makes the Modifications
+                  available to a third party. 
+
+                  (d) Notwithstanding Section 2.2(b) above, no patent
+                  license is granted: (1) for any code that Contributor
+                  has deleted from the Contributor Version; (2) for
+                  infringements caused by: (i) third party
+                  modifications of Contributor Version, or (ii) the
+                  combination of Modifications made by that Contributor
+                  with other software (except as part of the
+                  Contributor Version) or other devices; or (3) under
+                  Patent Claims infringed by Covered Software in the
+                  absence of Modifications made by that Contributor. 
+
+      3. Distribution Obligations.
+
+            3.1. Availability of Source Code.
+
+            Any Covered Software that You distribute or otherwise make
+            available in Executable form must also be made available in
+            Source Code form and that Source Code form must be
+            distributed only under the terms of this License. You must
+            include a copy of this License with every copy of the
+            Source Code form of the Covered Software You distribute or
+            otherwise make available. You must inform recipients of any
+            such Covered Software in Executable form as to how they can
+            obtain such Covered Software in Source Code form in a
+            reasonable manner on or through a medium customarily used
+            for software exchange.
+
+            3.2. Modifications.
+
+            The Modifications that You create or to which You
+            contribute are governed by the terms of this License. You
+            represent that You believe Your Modifications are Your
+            original creation(s) and/or You have sufficient rights to
+            grant the rights conveyed by this License.
+
+            3.3. Required Notices.
+
+            You must include a notice in each of Your Modifications
+            that identifies You as the Contributor of the Modification.
+            You may not remove or alter any copyright, patent or
+            trademark notices contained within the Covered Software, or
+            any notices of licensing or any descriptive text giving
+            attribution to any Contributor or the Initial Developer.
+
+            3.4. Application of Additional Terms.
+
+            You may not offer or impose any terms on any Covered
+            Software in Source Code form that alters or restricts the
+            applicable version of this License or the recipientsÕ
+            rights hereunder. You may choose to offer, and to charge a
+            fee for, warranty, support, indemnity or liability
+            obligations to one or more recipients of Covered Software.
+            However, you may do so only on Your own behalf, and not on
+            behalf of the Initial Developer or any Contributor. You
+            must make it absolutely clear that any such warranty,
+            support, indemnity or liability obligation is offered by
+            You alone, and You hereby agree to indemnify the Initial
+            Developer and every Contributor for any liability incurred
+            by the Initial Developer or such Contributor as a result of
+            warranty, support, indemnity or liability terms You offer.
+          
+
+            3.5. Distribution of Executable Versions.
+
+            You may distribute the Executable form of the Covered
+            Software under the terms of this License or under the terms
+            of a license of Your choice, which may contain terms
+            different from this License, provided that You are in
+            compliance with the terms of this License and that the
+            license for the Executable form does not attempt to limit
+            or alter the recipientÕs rights in the Source Code form
+            from the rights set forth in this License. If You
+            distribute the Covered Software in Executable form under a
+            different license, You must make it absolutely clear that
+            any terms which differ from this License are offered by You
+            alone, not by the Initial Developer or Contributor. You
+            hereby agree to indemnify the Initial Developer and every
+            Contributor for any liability incurred by the Initial
+            Developer or such Contributor as a result of any such terms
+            You offer.
+
+            3.6. Larger Works.
+
+            You may create a Larger Work by combining Covered Software
+            with other code not governed by the terms of this License
+            and distribute the Larger Work as a single product. In such
+            a case, You must make sure the requirements of this License
+            are fulfilled for the Covered Software. 
+            
+      4. Versions of the License. 
+
+            4.1. New Versions.
+
+            Sun Microsystems, Inc. is the initial license steward and
+            may publish revised and/or new versions of this License
+            from time to time. Each version will be given a
+            distinguishing version number. Except as provided in
+            Section 4.3, no one other than the license steward has the
+            right to modify this License. 
+
+            4.2. Effect of New Versions.
+
+            You may always continue to use, distribute or otherwise
+            make the Covered Software available under the terms of the
+            version of the License under which You originally received
+            the Covered Software. If the Initial Developer includes a
+            notice in the Original Software prohibiting it from being
+            distributed or otherwise made available under any
+            subsequent version of the License, You must distribute and
+            make the Covered Software available under the terms of the
+            version of the License under which You originally received
+            the Covered Software. Otherwise, You may also choose to
+            use, distribute or otherwise make the Covered Software
+            available under the terms of any subsequent version of the
+            License published by the license steward. 
+
+            4.3. Modified Versions.
+
+            When You are an Initial Developer and You want to create a
+            new license for Your Original Software, You may create and
+            use a modified version of this License if You: (a) rename
+            the license and remove any references to the name of the
+            license steward (except to note that the license differs
+            from this License); and (b) otherwise make it clear that
+            the license contains terms which differ from this License.
+            
+
+      5. DISCLAIMER OF WARRANTY.
+
+      COVERED SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN ÒAS ISÓ
+      BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
+      INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED
+      SOFTWARE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR
+      PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND
+      PERFORMANCE OF THE COVERED SOFTWARE IS WITH YOU. SHOULD ANY
+      COVERED SOFTWARE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE
+      INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF
+      ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF
+      WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF
+      ANY COVERED SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS
+      DISCLAIMER. 
+
+      6. TERMINATION. 
+
+            6.1. This License and the rights granted hereunder will
+            terminate automatically if You fail to comply with terms
+            herein and fail to cure such breach within 30 days of
+            becoming aware of the breach. Provisions which, by their
+            nature, must remain in effect beyond the termination of
+            this License shall survive.
+
+            6.2. If You assert a patent infringement claim (excluding
+            declaratory judgment actions) against Initial Developer or
+            a Contributor (the Initial Developer or Contributor against
+            whom You assert such claim is referred to as ÒParticipantÓ)
+            alleging that the Participant Software (meaning the
+            Contributor Version where the Participant is a Contributor
+            or the Original Software where the Participant is the
+            Initial Developer) directly or indirectly infringes any
+            patent, then any and all rights granted directly or
+            indirectly to You by such Participant, the Initial
+            Developer (if the Initial Developer is not the Participant)
+            and all Contributors under Sections 2.1 and/or 2.2 of this
+            License shall, upon 60 days notice from Participant
+            terminate prospectively and automatically at the expiration
+            of such 60 day notice period, unless if within such 60 day
+            period You withdraw Your claim with respect to the
+            Participant Software against such Participant either
+            unilaterally or pursuant to a written agreement with
+            Participant.
+
+            6.3. In the event of termination under Sections 6.1 or 6.2
+            above, all end user licenses that have been validly granted
+            by You or any distributor hereunder prior to termination
+            (excluding licenses granted to You by any distributor)
+            shall survive termination.
+
+      7. LIMITATION OF LIABILITY.
+
+      UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT
+      (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE
+      INITIAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF
+      COVERED SOFTWARE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE
+      LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR
+      CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT
+      LIMITATION, DAMAGES FOR LOST PROFITS, LOSS OF GOODWILL, WORK
+      STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER
+      COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN
+      INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF
+      LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL
+      INJURY RESULTING FROM SUCH PARTYÕS NEGLIGENCE TO THE EXTENT
+      APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO
+      NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR
+      CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND LIMITATION MAY NOT
+      APPLY TO YOU.
+
+      8. U.S. GOVERNMENT END USERS.
+
+      The Covered Software is a Òcommercial item,Ó as that term is
+      defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of Òcommercial
+      computer softwareÓ (as that term is defined at 48 C.F.R. ¤
+      252.227-7014(a)(1)) and Òcommercial computer software
+      documentationÓ as such terms are used in 48 C.F.R. 12.212 (Sept.
+      1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1
+      through 227.7202-4 (June 1995), all U.S. Government End Users
+      acquire Covered Software with only those rights set forth herein.
+      This U.S. Government Rights clause is in lieu of, and supersedes,
+      any other FAR, DFAR, or other clause or provision that addresses
+      Government rights in computer software under this License.
+
+      9. MISCELLANEOUS.
+
+      This License represents the complete agreement concerning subject
+      matter hereof. If any provision of this License is held to be
+      unenforceable, such provision shall be reformed only to the
+      extent necessary to make it enforceable. This License shall be
+      governed by the law of the jurisdiction specified in a notice
+      contained within the Original Software (except to the extent
+      applicable law, if any, provides otherwise), excluding such
+      jurisdictionÕs conflict-of-law provisions. Any litigation
+      relating to this License shall be subject to the jurisdiction of
+      the courts located in the jurisdiction and venue specified in a
+      notice contained within the Original Software, with the losing
+      party responsible for costs, including, without limitation, court
+      costs and reasonable attorneysÕ fees and expenses. The
+      application of the United Nations Convention on Contracts for the
+      International Sale of Goods is expressly excluded. Any law or
+      regulation which provides that the language of a contract shall
+      be construed against the drafter shall not apply to this License.
+      You agree that You alone are responsible for compliance with the
+      United States export administration regulations (and the export
+      control laws and regulation of any other countries) when You use,
+      distribute or otherwise make available any Covered Software.
+
+      10. RESPONSIBILITY FOR CLAIMS.
+
+      As between Initial Developer and the Contributors, each party is
+      responsible for claims and damages arising, directly or
+      indirectly, out of its utilization of rights under this License
+      and You agree to work with Initial Developer and Contributors to
+      distribute such responsibility on an equitable basis. Nothing
+      herein is intended or shall be deemed to constitute any admission
+      of liability.
+
+------------------------------------------------------------------------------
+
+
+--- Postgres JDBC Drivers ----------------------------------------------------
+
+BSD License:
+* Copyright (c) <year>, <copyright holder>
+* All rights reserved.
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+*
+*     * Redistributions of source code must retain the above copyright
+*       notice, this list of conditions and the following disclaimer.
+*     * Redistributions in binary form must reproduce the above copyright
+*       notice, this list of conditions and the following disclaimer in the
+*       documentation and/or other materials provided with the distribution.
+*     * Neither the name of the <organization> nor the
+*       names of its contributors may be used to endorse or promote products
+*       derived from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
+* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+------------------------------------------------------------------------------

Added: labs/jbosstm/workspace/mlittle/STM-Arjuna/lib/jbosscore.jar
===================================================================
(Binary files differ)


Property changes on: labs/jbosstm/workspace/mlittle/STM-Arjuna/lib/jbosscore.jar
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbosstm/workspace/mlittle/STM-Arjuna/lib/jbossts-common.jar
===================================================================
(Binary files differ)


Property changes on: labs/jbosstm/workspace/mlittle/STM-Arjuna/lib/jbossts-common.jar
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbosstm/workspace/mlittle/STM-Arjuna/log4j.properties
===================================================================
--- labs/jbosstm/workspace/mlittle/STM-Arjuna/log4j.properties	                        (rev 0)
+++ labs/jbosstm/workspace/mlittle/STM-Arjuna/log4j.properties	2009-03-29 20:10:29 UTC (rev 25874)
@@ -0,0 +1,37 @@
+#
+# JBoss, Home of Professional Open Source
+# Copyright 2006, 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) 2005-2006,
+# @author JBoss Inc.
+#
+# Default LOG4J Configuration
+# Arjuna Technologies Ltd.
+# $Id: log4j.properties 2342 2006-03-30 13:06:17Z  $
+
+log4j.category.com.arjuna=INFO, default, stdout
+
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
+log4j.appender.stdout.Threshold=INFO
+
+log4j.appender.default=org.apache.log4j.RollingFileAppender
+log4j.appender.default.File=transaction.log
+log4j.appender.default.MaxFileSize=500KB
+log4j.appender.default.MaxBackupIndex=2
+log4j.appender.default.layout=org.apache.log4j.PatternLayout
+log4j.appender.default.layout.ConversionPattern=%d [%t] %-5p %c - %m%n

Added: labs/jbosstm/workspace/mlittle/STM-Arjuna/pom.xml
===================================================================
--- labs/jbosstm/workspace/mlittle/STM-Arjuna/pom.xml	                        (rev 0)
+++ labs/jbosstm/workspace/mlittle/STM-Arjuna/pom.xml	2009-03-29 20:10:29 UTC (rev 25874)
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>stm-arjuna</groupId>
+  <artifactId>core</artifactId>
+  <name>core</name>
+  <version>1.0-SNAPSHOT</version>
+  <url>http://maven.apache.org</url>
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <configuration> 
+          <source>1.5</source>
+          <target>1.5</target>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+  <dependencies>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.1</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>jboss</groupId>
+      <artifactId>jbossts-common</artifactId>
+      <version>4.5.0</version>
+      <scope>system</scope>
+      <systemPath>${basedir}/lib/jbossts-common.jar</systemPath>
+    </dependency>
+    <dependency>
+      <groupId>jboss</groupId>
+      <artifactId>jbosscore</artifactId>
+      <version>4.5.0</version>
+      <scope>system</scope>
+      <systemPath>${basedir}/lib/jbosscore.jar</systemPath>
+    </dependency>
+    <dependency>
+      <groupId>commons-logging</groupId>
+      <artifactId>commons-logging-api</artifactId>
+      <version>1.0.4</version>
+    </dependency>
+    <dependency>
+      <groupId>log4j</groupId>
+      <artifactId>log4j</artifactId>
+      <version>1.2.14</version>
+    </dependency>
+  </dependencies>
+</project>
+

Added: labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/stm/InvalidAnnotationException.java
===================================================================
--- labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/stm/InvalidAnnotationException.java	                        (rev 0)
+++ labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/stm/InvalidAnnotationException.java	2009-03-29 20:10:29 UTC (rev 25874)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.stm;
+
+public class InvalidAnnotationException extends Exception
+{
+    public InvalidAnnotationException (String reason)
+    {
+        super(reason);
+    }
+    
+    private static final long serialVersionUID = 1L;
+}

Added: labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/stm/LockException.java
===================================================================
--- labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/stm/LockException.java	                        (rev 0)
+++ labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/stm/LockException.java	2009-03-29 20:10:29 UTC (rev 25874)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.stm;
+
+public class LockException extends RuntimeException
+{
+    public LockException (String reason)
+    {
+        super(reason);
+    }
+    
+    private static final long serialVersionUID = 1L;
+}

Added: labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/stm/PersistentContainer.java
===================================================================
--- labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/stm/PersistentContainer.java	                        (rev 0)
+++ labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/stm/PersistentContainer.java	2009-03-29 20:10:29 UTC (rev 25874)
@@ -0,0 +1,113 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, JBoss Inc., and others contributors as indicated 
+ * by the @authors tag. All rights reserved. 
+ * 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 mark.little at jboss.com
+ */
+
+package org.jboss.stm;
+
+import java.lang.reflect.Proxy;
+import org.jboss.stm.internal.reflect.InvocationHandler;
+
+import com.arjuna.ats.arjuna.ObjectType;
+import com.arjuna.ats.arjuna.common.Uid;
+
+/**
+ * Instances of this class represent the transactional memory within which user objects
+ * can be placed and managed.
+ * 
+ * Objects must implement an interface through which all transactional accesses occur. We don't
+ * mandate what the interface is, since that will depend upon the business logic. The interface, or
+ * the implementing class, must also use the @Lockable annotation.
+ * 
+ * TODO look at using JBossAOP to get round the problem of requiring an interface for proxying.
+ * 
+ * @author marklittle
+ */
+
+/*
+ * Could provide a container that works on any classes without annotations. The rules would have to be
+ * more restrictive:
+ * 
+ * (i) all operations are assumed to modify the state (therefore write lock).
+ * (ii) all state is saved and restored.
+ * 
+ * Or use a setter/getter pattern to provide flexibility around (i).
+ */
+
+public class PersistentContainer<T> extends RecoverableContainer<T>
+{
+    /**
+     * Return a handle through which the object should be used, rather than the one
+     * passed in.
+     */
+    
+    public synchronized T enlist (T member)
+    {
+        return super.create(member, ObjectType.ANDPERSISTENT);
+    }
+    
+    @SuppressWarnings(value={"unchecked"})
+    public synchronized T recreate (T member, Uid id)
+    {
+        /*
+         * Everything that is transactional needs to be explicitly marked as such in
+         * the public API, even if the private methods are the ones that do the
+         * real work.
+         */
+
+        checkObjectType(member);
+        
+        /*
+         * Is it already registered? If so just return the same instance.
+         */
+        
+        T proxy = _transactionalProxies.get(member);
+        
+        if (proxy == null)
+        {
+            Class c = member.getClass();
+            
+            proxy = (T) Proxy.newProxyInstance(c.getClassLoader(), c.getInterfaces(), new InvocationHandler<T>(this, member, id));
+            
+            _transactionalProxies.put(member, proxy);
+        }
+        
+        return proxy;
+    }
+    
+    @SuppressWarnings(value={"unchecked"})
+    public Uid getUid (T member)
+    {
+        T proxy = _transactionalProxies.get(member);
+        
+        if (proxy == null)
+            throw new IllegalArgumentException("No such instance in this container.");
+        
+        try
+        {
+            InvocationHandler<T> handler = (InvocationHandler<T>) Proxy.getInvocationHandler(proxy);
+            
+            return handler.get_uid();
+        }
+        catch (final Exception ex)
+        {
+            throw new IllegalArgumentException(ex);
+        }
+    }
+}

Added: labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/stm/RecoverableContainer.java
===================================================================
--- labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/stm/RecoverableContainer.java	                        (rev 0)
+++ labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/stm/RecoverableContainer.java	2009-03-29 20:10:29 UTC (rev 25874)
@@ -0,0 +1,140 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, JBoss Inc., and others contributors as indicated 
+ * by the @authors tag. All rights reserved. 
+ * 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 mark.little at jboss.com
+ */
+
+package org.jboss.stm;
+
+import java.lang.reflect.Proxy;
+import java.util.WeakHashMap;
+
+import org.jboss.stm.annotations.Transactional;
+import org.jboss.stm.internal.reflect.InvocationHandler;
+
+import com.arjuna.ats.arjuna.ObjectType;
+import com.arjuna.ats.arjuna.StateManager;
+import com.arjuna.ats.txoj.LockManager;
+
+/**
+ * Instances of this class represent the transactional memory within which user objects
+ * can be placed and managed.
+ * 
+ * Objects must implement an interface through which all transactional accesses occur. We don't
+ * mandate what the interface is, since that will depend upon the business logic. The interface, or
+ * the implementing class, must also use the @Lockable annotation.
+ * 
+ * TODO look at using JBossAOP to get round the problem of requiring an interface for proxying.
+ * 
+ * @author marklittle
+ */
+
+/*
+ * Could provide a container that works on any classes without annotations. The rules would have to be
+ * more restrictive:
+ * 
+ * (i) all operations are assumed to modify the state (therefore write lock).
+ * (ii) all state is saved and restored.
+ * 
+ * Or use a setter/getter pattern to provide flexibility around (i).
+ */
+
+// TODO AtomicInteger AtomicBoolean etc.
+
+public class RecoverableContainer<T>
+{
+    /**
+     * Given an object we create a new transactional instance of it and return that
+     * for future use. All accesses on the returned object will be managed according to
+     * the rules defined in the various annotations. If the original object instance is used
+     * then no transactional manipulation will occur so you need to be careful!
+     */
+    
+    /**
+     * Return a handle through which the object should be used, rather than the one
+     * passed in.
+     */
+
+    public synchronized T enlist (T member)
+    {
+        return create(member, ObjectType.RECOVERABLE);
+    }
+    
+    @SuppressWarnings(value={"unchecked"})
+    protected synchronized T create (T member, int ot)
+    {
+        /*
+         * Everything that is transactional needs to be explicitly marked as such in
+         * the public API, even if the private methods are the ones that do the
+         * real work.
+         */
+
+        checkObjectType(member);
+        
+        /*
+         * Is it already registered? If so just return the same instance.
+         */
+        
+        T proxy = _transactionalProxies.get(member);
+        
+        if (proxy == null)
+        {
+            Class c = member.getClass();
+            
+            proxy = (T) Proxy.newProxyInstance(c.getClassLoader(), c.getInterfaces(), new InvocationHandler<T>(this, member, ot));
+            
+            _transactionalProxies.put(member, proxy);
+        }
+        
+        return proxy;
+    }
+    
+    @SuppressWarnings(value={"unchecked"})
+    protected final void checkObjectType (Object member)
+    {
+        if ((member instanceof LockManager) || (member instanceof StateManager))
+            throw new IllegalArgumentException(
+                    "Object type not supported by this transactional container!");
+
+        Class c = member.getClass().getSuperclass();
+
+        while (c != null)
+        {
+            if (c.getAnnotation(Transactional.class) != null)
+            {
+                return;
+            }
+
+            c = c.getSuperclass();
+        }
+        
+        Class[] interfaces = member.getClass().getInterfaces();
+
+        for (Class i : interfaces)
+        {
+            if (i.getAnnotation(Transactional.class) != null)
+            {
+                return;
+            }
+        }
+
+        throw new IllegalArgumentException("Object is not Lockable!");
+    }
+    
+    protected WeakHashMap<T, T> _transactionalProxies = new WeakHashMap<T, T>();
+}

Added: labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/stm/TransactionException.java
===================================================================
--- labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/stm/TransactionException.java	                        (rev 0)
+++ labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/stm/TransactionException.java	2009-03-29 20:10:29 UTC (rev 25874)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.stm;
+
+public class TransactionException extends RuntimeException
+{
+    public TransactionException (String reason, int status)
+    {
+        super(reason);
+        
+        _status = status;
+    }
+    
+    public final int getStatus ()
+    {
+        return _status;
+    }
+    
+    private int _status;
+    
+    private static final long serialVersionUID = 1L;
+}

Added: labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/stm/annotations/DurableState.java
===================================================================
--- labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/stm/annotations/DurableState.java	                        (rev 0)
+++ labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/stm/annotations/DurableState.java	2009-03-29 20:10:29 UTC (rev 25874)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated 
+ * by the @authors tag. All rights reserved. 
+ * 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) 2005-2006,
+ * @author mark.little at jboss.com
+ */
+
+package org.jboss.stm.annotations;
+
+import java.lang.annotation.*;
+
+/**
+ * State that will be written to the log (or restored).
+ * 
+ * @author marklittle
+ */
+
+ at Retention(RetentionPolicy.RUNTIME)
+ at Target({ ElementType.FIELD })
+public @interface DurableState
+{
+}
\ No newline at end of file

Added: labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/stm/annotations/Nested.java
===================================================================
--- labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/stm/annotations/Nested.java	                        (rev 0)
+++ labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/stm/annotations/Nested.java	2009-03-29 20:10:29 UTC (rev 25874)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated 
+ * by the @authors tag. All rights reserved. 
+ * 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) 2005-2006,
+ * @author mark.little at jboss.com
+ */
+
+package org.jboss.stm.annotations;
+
+import java.lang.annotation.*;
+
+/**
+ * Defines that the container will create a new transaction
+ * for each method invocation, regardless of whether there is
+ * already a transaction associated with the caller. These transactions
+ * will then either be top-level transactions or nested automatically.
+ * 
+ * @author marklittle
+ *
+ */
+ at Retention(RetentionPolicy.RUNTIME)
+ at Target({ ElementType.TYPE })
+public @interface Nested
+{
+}
\ No newline at end of file

Added: labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/stm/annotations/ReadLock.java
===================================================================
--- labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/stm/annotations/ReadLock.java	                        (rev 0)
+++ labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/stm/annotations/ReadLock.java	2009-03-29 20:10:29 UTC (rev 25874)
@@ -0,0 +1,30 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated 
+ * by the @authors tag. All rights reserved. 
+ * 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) 2005-2006,
+ * @author mark.little at jboss.com
+ */
+
+package org.jboss.stm.annotations;
+
+import java.lang.annotation.*;
+
+ at Retention(RetentionPolicy.RUNTIME)
+ at Target({ ElementType.METHOD })
+public @interface ReadLock
+{
+}
\ No newline at end of file

Added: labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/stm/annotations/RestoreState.java
===================================================================
--- labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/stm/annotations/RestoreState.java	                        (rev 0)
+++ labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/stm/annotations/RestoreState.java	2009-03-29 20:10:29 UTC (rev 25874)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated 
+ * by the @authors tag. All rights reserved. 
+ * 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) 2005-2006,
+ * @author mark.little at jboss.com
+ */
+
+package org.jboss.stm.annotations;
+
+import java.lang.annotation.*;
+
+/**
+ * Used to define the specific restore_state method for the class. This
+ * is used in preference to any @DurableState indications on the class
+ * state.
+ * 
+ * @author marklittle
+ */
+
+ at Retention(RetentionPolicy.RUNTIME)
+ at Target({ ElementType.METHOD })
+public @interface RestoreState
+{
+}
\ No newline at end of file

Added: labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/stm/annotations/SaveState.java
===================================================================
--- labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/stm/annotations/SaveState.java	                        (rev 0)
+++ labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/stm/annotations/SaveState.java	2009-03-29 20:10:29 UTC (rev 25874)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated 
+ * by the @authors tag. All rights reserved. 
+ * 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) 2005-2006,
+ * @author mark.little at jboss.com
+ */
+
+package org.jboss.stm.annotations;
+
+import java.lang.annotation.*;
+
+/**
+ * Used to define the specific save_state method for the class. This
+ * is used in preference to any @DurableState indications on the class
+ * state. This is the case no matter where in the class hierarchy it
+ * occurs. So if you have a base class that uses save/restore methods the
+ * inherited classes must have them too if their state is to be durable.
+ * In future we may save/restore specifically for each class in the
+ * inheritance hierarchy.
+ * 
+ * TODO save/restore specifically for each class in the inheritance hierarchy.
+ * 
+ * @author marklittle
+ */
+
+ at Retention(RetentionPolicy.RUNTIME)
+ at Target({ ElementType.METHOD })
+public @interface SaveState
+{
+}
\ No newline at end of file

Added: labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/stm/annotations/Transactional.java
===================================================================
--- labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/stm/annotations/Transactional.java	                        (rev 0)
+++ labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/stm/annotations/Transactional.java	2009-03-29 20:10:29 UTC (rev 25874)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated 
+ * by the @authors tag. All rights reserved. 
+ * 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) 2005-2006,
+ * @author mark.little at jboss.com
+ */
+
+package org.jboss.stm.annotations;
+
+import java.lang.annotation.*;
+
+/**
+ * Defines that the class is to be managed within a transactional
+ * container. Unless specified using other annotations, all public
+ * methods will be assumed to modify the state of the object, i.e.,
+ * require write locks. The only state that will be saved/restored is that
+ * which is marked using the DurableState annotation or SaveState/RestoreState.
+ * 
+ * @author marklittle
+ *
+ */
+ at Retention(RetentionPolicy.RUNTIME)
+ at Target({ ElementType.TYPE })
+public @interface Transactional
+{
+}
\ No newline at end of file

Added: labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/stm/annotations/WriteLock.java
===================================================================
--- labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/stm/annotations/WriteLock.java	                        (rev 0)
+++ labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/stm/annotations/WriteLock.java	2009-03-29 20:10:29 UTC (rev 25874)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated 
+ * by the @authors tag. All rights reserved. 
+ * 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) 2005-2006,
+ * @author mark.little at jboss.com
+ */
+
+package org.jboss.stm.annotations;
+
+import java.lang.annotation.*;
+
+// TODO lock priority rules
+
+ at Retention(RetentionPolicy.RUNTIME)
+ at Target({ ElementType.METHOD })
+public @interface WriteLock
+{
+}
\ No newline at end of file

Added: labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/stm/internal/proxy/LockManagerProxy.java
===================================================================
--- labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/stm/internal/proxy/LockManagerProxy.java	                        (rev 0)
+++ labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/stm/internal/proxy/LockManagerProxy.java	2009-03-29 20:10:29 UTC (rev 25874)
@@ -0,0 +1,476 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, JBoss Inc., and others contributors as indicated 
+ * by the @authors tag. All rights reserved. 
+ * 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 mark.little at jboss.com
+ */
+
+package org.jboss.stm.internal.proxy;
+
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+
+import org.jboss.stm.InvalidAnnotationException;
+import org.jboss.stm.annotations.DurableState;
+import org.jboss.stm.annotations.RestoreState;
+import org.jboss.stm.annotations.SaveState;
+
+import com.arjuna.ats.arjuna.common.Uid;
+import com.arjuna.ats.arjuna.state.InputObjectState;
+import com.arjuna.ats.arjuna.state.OutputObjectState;
+import com.arjuna.ats.txoj.LockManager;
+
+public class LockManagerProxy<T> extends LockManager
+{
+    public LockManagerProxy (T candidate)
+    {
+        this(candidate, com.arjuna.ats.arjuna.ObjectType.RECOVERABLE);
+    }
+    
+    public LockManagerProxy (T candidate, int ot)
+    {
+        super(ot);
+        
+        _theObject = candidate;
+    }
+    
+    // if there's a Uid then this is a persistent object
+    
+    public LockManagerProxy (T candidate, Uid u)
+    {
+        super(u);  // TODO make configurable through annotation
+        
+        _theObject = candidate;
+    }
+    
+    public boolean save_state (OutputObjectState os, int ot)
+    {
+        if (!super.save_state(os, ot))
+            return false;
+        
+        /*
+         * Priority is for @SaveState and @RestoreState first.
+         */
+        
+        boolean res = false;
+        
+        try
+        {
+            res = saveState(os);
+        }
+        catch (final InvalidAnnotationException ex)
+        {
+            ex.printStackTrace();  // TODO logging
+            
+            return false;
+        }
+
+        if (!res)  // no save_state/restore_state
+        {
+            res = true;
+            
+            if (_fields == null)
+            {
+                Field[] fields = _theObject.getClass().getDeclaredFields(); // get all fields including private
+            
+                _fields = new ArrayList<Field>();
+                
+                try
+                {
+                    for (Field afield : fields)
+                    {
+                        // ignore if not flagged with @DurableState
+        
+                        if (afield.isAnnotationPresent(DurableState.class))
+                            _fields.add(afield);
+                    }
+                }
+                catch (final Throwable ex)
+                {
+                    res = false;
+                }
+            }
+            
+            for (int i = 0; (i < _fields.size()) && res; i++)
+            {
+                Field afield = _fields.get(i);
+                
+                // ignore if not flagged with @DurableState
+                
+                if (afield.isAnnotationPresent(DurableState.class))
+                {
+                    afield.setAccessible(true);
+
+                    /*
+                     * TODO check that the user hasn't marked statics, finals etc.
+                     */
+
+                    if (afield.getType().isPrimitive())
+                    {
+                        res = packPrimitive(afield, os);
+                    }
+                    else
+                        res = packObjectType(afield, os);
+
+                    afield.setAccessible(false);
+                }
+            }
+        }
+        
+        return res;
+    }
+    
+    public boolean restore_state (InputObjectState os, int ot)
+    {
+        if (!super.restore_state(os, ot))
+            return false;
+        
+        /*
+         * Priority is for @SaveState and @RestoreState first.
+         */
+        
+        boolean res = false;
+        
+        try
+        {
+            res = restoreState(os);
+        }
+        catch (final InvalidAnnotationException ex)
+        {
+            ex.printStackTrace();  // TODO logging
+            
+            return false;
+        }
+        
+        if (!res)
+        {
+            res = true;
+            
+            if (_fields == null)
+            {
+                Field[] fields = _theObject.getClass().getDeclaredFields(); // get all fields including private
+                
+                try
+                {
+                    for (Field afield : fields)
+                    {
+                        // ignore if not flagged with DurableState
+                        
+                        if (afield.isAnnotationPresent(DurableState.class))
+                            _fields.add(afield);
+                    }
+                }
+                catch (final Throwable ex)
+                {
+                    res = false;
+                }
+            }
+            
+            for (int i = 0; (i < _fields.size()) && res; i++)
+            {
+                Field afield = _fields.get(i);
+                
+                afield.setAccessible(true);
+                
+                /*
+                 * TODO check that the user hasn't marked statics, finals etc.
+                 */
+                
+                if (afield.getType().isPrimitive())
+                {
+                    res = unpackPrimitive(afield, os);
+                }
+                else
+                    res = unpackObjectType(afield, os);
+                
+                afield.setAccessible(false);
+            }
+        }
+        
+        return res;
+    }
+    
+    public String type ()
+    {
+        return "/StateManager/LockManager/"+_theObject.getClass();
+    }
+    
+    private boolean packPrimitive (final Field afield, OutputObjectState os)
+    {
+        try
+        {
+            // TODO arrays
+            
+            if (afield.getType().equals(Boolean.TYPE))
+                os.packBoolean(afield.getBoolean(_theObject));
+            else if (afield.getType().equals(Byte.TYPE))
+                os.packByte(afield.getByte(_theObject));
+            else if (afield.getType().equals(Short.TYPE))
+                os.packShort(afield.getShort(_theObject));
+            else if (afield.getType().equals(Integer.TYPE))
+                os.packInt(afield.getInt(_theObject));
+            else if (afield.getType().equals(Long.TYPE))
+                os.packLong(afield.getLong(_theObject));
+            else if (afield.getType().equals(Float.TYPE))
+                os.packFloat(afield.getFloat(_theObject));
+            else if (afield.getType().equals(Double.TYPE))
+                os.packDouble(afield.getDouble(_theObject));
+            else if (afield.getType().equals(Character.TYPE))
+                os.packChar(afield.getChar(_theObject));
+            else
+                return false;
+        }
+        catch (final IOException ex)
+        {
+            return false;
+        }
+        catch (final Exception ex)
+        {
+            return false;
+        }
+        
+        return true;
+    }
+    
+    private boolean packObjectType (final Field afield, OutputObjectState os)
+    {
+        try
+        {
+            if (afield.getType().equals(Boolean.class))
+                os.packBoolean(((Boolean) afield.get(_theObject)).booleanValue());
+            else if (afield.getType().equals(Byte.class))
+                os.packByte(((Byte) afield.get(_theObject)).byteValue());
+            else if (afield.getType().equals(Short.class))
+                os.packShort(((Short) afield.get(_theObject)).shortValue());
+            else if (afield.getType().equals(Integer.class))
+                os.packInt(((Integer) afield.get(_theObject)).intValue());
+            else if (afield.getType().equals(Long.class))
+                os.packLong(((Long) afield.get(_theObject)).longValue());
+            else if (afield.getType().equals(Float.class))
+                os.packFloat(((Float) afield.get(_theObject)).floatValue());
+            else if (afield.getType().equals(Double.class))
+                os.packDouble(((Double) afield.get(_theObject)).doubleValue());
+            else if (afield.getType().equals(Character.class))
+                os.packChar(((Character) afield.get(_theObject)).charValue());
+            else if (afield.getType().equals(String.class))
+                os.packString((String) afield.get(_theObject));
+            else
+                return false;
+        }
+        catch (final Exception ex)
+        {
+            ex.printStackTrace();
+            
+            return false;
+        }
+        
+        return true;
+    }
+    
+    private boolean saveState (OutputObjectState os) throws InvalidAnnotationException
+    {
+        boolean res = false;
+        
+        checkValidity(_theObject.getClass());
+        
+        if (_saveState != null)
+        {
+            try
+            {
+                _saveState.invoke(_theObject, os);
+                
+                res = true;
+            }
+            catch (final Throwable ex)
+            {
+                ex.printStackTrace();
+            }
+        }
+        
+        return res;
+    }
+    
+    private boolean restoreState (InputObjectState os) throws InvalidAnnotationException
+    {
+        boolean res = false;
+        
+        checkValidity(_theObject.getClass());
+        
+        if (_restoreState != null)
+        {
+            try
+            {
+                _restoreState.invoke(_theObject, os);
+                
+                res = true;
+            }
+            catch (final Throwable ex)
+            {
+                ex.printStackTrace();
+            }
+        }
+        
+        return res;
+    }
+    
+    @SuppressWarnings("unchecked")
+    private void checkValidity (Class toCheck) throws InvalidAnnotationException
+    {
+        if (_checkSaveRestore)
+            return;
+        
+        try
+        {
+            Method[] methods = toCheck.getDeclaredMethods();
+    
+            if (methods != null)
+            {
+                for (Method mt : methods)
+                {
+                    if ((mt.isAnnotationPresent(SaveState.class) && (_saveState == null)))
+                    {
+                        _saveState = mt;
+                    }
+                    
+                    if ((mt.isAnnotationPresent(RestoreState.class) && (_restoreState == null)))
+                    {
+                        _restoreState = mt;
+                    }
+                }
+            }
+            
+            if ((_saveState != null) && (_restoreState != null))
+            {
+                return;
+            }
+            else
+            {
+                if ((_restoreState == null) && (_saveState == null))
+                {
+                    Class superClass = toCheck.getSuperclass();
+    
+                    if (superClass != Object.class)
+                        checkValidity(superClass);
+                }
+                else
+                    throw new InvalidAnnotationException("WARNING: both save_state and restore_state are not present!");
+            }
+        }
+        finally
+        {      
+            _checkSaveRestore = true;
+        }
+    }
+    
+    private boolean unpackPrimitive (final Field afield, InputObjectState os)
+    {
+        try
+        {
+            // TODO arrays
+
+            if (afield.getType().equals(Boolean.TYPE))
+                afield.setBoolean(_theObject, os.unpackBoolean());
+            else if (afield.getType().equals(Byte.TYPE))
+                afield.setByte(_theObject, os.unpackByte());
+            else if (afield.getType().equals(Short.TYPE))
+                afield.setShort(_theObject, os.unpackShort());
+            else if (afield.getType().equals(Integer.TYPE))
+                afield.setInt(_theObject, os.unpackInt());
+            else if (afield.getType().equals(Long.TYPE))
+                afield.setLong(_theObject, os.unpackLong());
+            else if (afield.getType().equals(Float.TYPE))
+                afield.setFloat(_theObject, os.unpackFloat());
+            else if (afield.getType().equals(Double.TYPE))
+                afield.setDouble(_theObject, os.unpackDouble());
+            else if (afield.getType().equals(Character.TYPE))
+                afield.setChar(_theObject, os.unpackChar());
+            else
+                return false;
+        }
+        catch (final IOException ex)
+        {
+            ex.printStackTrace();
+            
+            return false;
+        }
+        catch (final Exception ex)
+        {
+            ex.printStackTrace();
+            
+            return false;
+        }
+        
+        return true;
+    }
+    
+    private boolean unpackObjectType (final Field afield, InputObjectState os)
+    {
+        try
+        {
+            // TODO arrays
+            
+            if (afield.getType().equals(Boolean.class))
+                afield.set(_theObject, new Boolean(os.unpackBoolean()));
+            else if (afield.getType().equals(Byte.class))
+                afield.set(_theObject, new Byte(os.unpackByte()));
+            else if (afield.getType().equals(Short.class))
+                afield.set(_theObject, new Short(os.unpackShort()));
+            else if (afield.getType().equals(Integer.class))
+                afield.set(_theObject, new Integer(os.unpackInt()));
+            else if (afield.getType().equals(Long.class))
+                afield.set(_theObject, new Long(os.unpackLong()));
+            else if (afield.getType().equals(Float.class))
+                afield.set(_theObject, new Float(os.unpackFloat()));
+            else if (afield.getType().equals(Double.class))
+                afield.set(_theObject, new Double(os.unpackDouble()));
+            else if (afield.getType().equals(Character.class))
+                afield.set(_theObject, new Character(os.unpackChar()));
+            else if (afield.getType().equals(String.class))
+                afield.set(_theObject, os.unpackString());
+            else
+                return false;
+        }
+        catch (final IOException ex)
+        {
+            ex.printStackTrace();
+            
+            return false;
+        }
+        catch (final Exception ex)
+        {
+            ex.printStackTrace();
+            
+            return false;
+        }
+        
+        return true;
+    }
+    
+    // the object we are working on.
+    
+    private T _theObject;
+    
+    // the cached methods/fields
+    
+    private boolean _checkSaveRestore = false;
+    private Method _saveState = null;
+    private Method _restoreState = null;
+    
+    private ArrayList<Field> _fields = null;
+}

Added: labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/stm/internal/reflect/InvocationHandler.java
===================================================================
--- labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/stm/internal/reflect/InvocationHandler.java	                        (rev 0)
+++ labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/stm/internal/reflect/InvocationHandler.java	2009-03-29 20:10:29 UTC (rev 25874)
@@ -0,0 +1,208 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, JBoss Inc., and others contributors as indicated 
+ * by the @authors tag. All rights reserved. 
+ * 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 mark.little at jboss.com
+ */
+
+package org.jboss.stm.internal.reflect;
+
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.HashMap;
+
+import org.jboss.stm.LockException;
+import org.jboss.stm.RecoverableContainer;
+import org.jboss.stm.TransactionException;
+import org.jboss.stm.annotations.Nested;
+import org.jboss.stm.annotations.ReadLock;
+import org.jboss.stm.annotations.Transactional;
+import org.jboss.stm.annotations.WriteLock;
+import org.jboss.stm.internal.proxy.LockManagerProxy;
+
+import com.arjuna.ats.arjuna.AtomicAction;
+import com.arjuna.ats.arjuna.ObjectType;
+import com.arjuna.ats.arjuna.common.Uid;
+import com.arjuna.ats.arjuna.coordinator.ActionStatus;
+import com.arjuna.ats.arjuna.coordinator.BasicAction;
+import com.arjuna.ats.txoj.Lock;
+import com.arjuna.ats.txoj.LockMode;
+import com.arjuna.ats.txoj.LockResult;
+
+public class InvocationHandler<T> implements java.lang.reflect.InvocationHandler
+{
+    public InvocationHandler (RecoverableContainer<T> c, T obj)
+    {
+        this(c, obj, ObjectType.RECOVERABLE);
+    }
+    
+    public InvocationHandler (RecoverableContainer<T> c, T obj, int ot)
+    {
+        this(c, obj, ot, null);
+    }
+    
+    public InvocationHandler (RecoverableContainer<T> c, T obj, Uid u)
+    {
+        this(c, obj, ObjectType.ANDPERSISTENT, u);  // ot not strictly needed
+    }
+    
+    @SuppressWarnings(value={"unchecked"})
+    public InvocationHandler (RecoverableContainer<T> cont, T obj, int ot, Uid u)
+    {
+        _container = cont;
+        _theObject = obj;
+        
+        if (u != null)
+            _txObject = new LockManagerProxy<T>(obj, u);
+        else
+            _txObject = new LockManagerProxy<T>(obj, ot);  // recoverable or persistent
+        
+        _methods = obj.getClass().getDeclaredMethods();
+        
+        /*
+         * Do we need to create (sub-) transactions when each method
+         * is called?
+         */
+        
+        Class c = obj.getClass().getSuperclass();
+
+        while (c != null)
+        {
+            if (c.getAnnotation(Nested.class) != null)
+            {
+                _nestedTransactions = true;
+                
+                break;
+            }
+
+            c = c.getSuperclass();
+        }
+        
+        if (!_nestedTransactions)
+        {
+            Class[] interfaces = obj.getClass().getInterfaces();
+    
+            for (Class i : interfaces)
+            {
+                if (i.getAnnotation(Nested.class) != null)
+                {
+                    _nestedTransactions = true;
+                    
+                    break;
+                }
+            }
+        }
+    }
+    
+    public Uid get_uid ()
+    {
+        return _txObject.get_uid();
+    }
+    
+    public Object invoke (Object proxy, java.lang.reflect.Method method, Object[] args) throws Throwable
+    {
+        /*
+         * Do nothing currently if not inside of a transaction and
+         * not asked to create transactions for this type of object.
+         * 
+         * Automatically create transactions in methods for nested
+         * transaction capability, i.e., duplicate what normal Arjuna
+         * programmers take for granted.
+         */
+        
+        AtomicAction act = null;
+        
+        if (_nestedTransactions)
+        {
+            act = new AtomicAction();
+        
+            act.begin();
+        }
+        
+        try
+        {
+            if (BasicAction.Current() != null)
+            {
+                Method theMethod = null;
+    
+                /*
+                 * Look for the corresponding method in the original object and
+                 * check the annotations applied there.
+                 * 
+                 * Check to see if we've cached this before.
+                 */
+                
+                Integer lockType = _cachedMethods.get(method);
+                
+                if (lockType == null)
+                {
+                    for (Method mt : _methods)
+                    {
+                        if (mt.getName().equals(method.getName()))
+                        {
+                            if (mt.getReturnType().equals(method.getReturnType()))
+                            {
+                                if (Arrays.equals(mt.getParameterTypes(), method.getParameterTypes()))
+                                    theMethod = mt;
+                            }
+                        }
+                    }
+                    
+                    if (theMethod == null)
+                        throw new LockException("Could not locate method");
+                    
+                    if (theMethod.isAnnotationPresent(ReadLock.class))
+                        lockType = new Integer(LockMode.READ);
+                    else
+                    {
+                        if (theMethod.isAnnotationPresent(WriteLock.class))
+                            lockType = new Integer(LockMode.WRITE);
+                    }
+                    
+                    _cachedMethods.put(method, lockType);
+                }          
+                
+                // TODO type specific concurrency control (define Lock class in annotation?)
+    
+                if (_txObject.setlock(new Lock(lockType.intValue()), 0) != LockResult.GRANTED)
+                {
+                    throw new LockException("Could not set "+LockMode.stringForm(lockType.intValue())+" lock.");
+                }
+            }
+            
+            return method.invoke(_theObject, args);
+        }
+        finally
+        {
+            if (act != null)
+            {
+                int status = act.commit();
+                
+                if ((status != ActionStatus.COMMITTED) && (status != ActionStatus.COMMITTING))
+                    throw new TransactionException("Failed to commit container transaction!", status);
+            }
+        }
+    }
+    
+    @SuppressWarnings(value={"unused"})
+    private RecoverableContainer<T> _container;  // could be a persistent container, but not an issue for this class
+    private T _theObject;
+    private LockManagerProxy<T> _txObject;
+    private Method[] _methods;
+    private HashMap<Method, Integer> _cachedMethods = new HashMap<Method, Integer>();
+    private boolean _nestedTransactions = false;
+}

Added: labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/stm/types/AtomicInteger.java
===================================================================
--- labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/stm/types/AtomicInteger.java	                        (rev 0)
+++ labs/jbosstm/workspace/mlittle/STM-Arjuna/src/main/java/org/jboss/stm/types/AtomicInteger.java	2009-03-29 20:10:29 UTC (rev 25874)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, JBoss Inc., and others contributors as indicated 
+ * by the @authors tag. All rights reserved. 
+ * 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 mark.little at jboss.com
+ */
+
+package org.jboss.stm.types;
+
+import org.jboss.stm.annotations.Transactional;
+
+// TODO maybe pull all of this into a separate jar
+
+ at Transactional
+public interface AtomicInteger
+{
+    public void set (int val);
+    public int get ();
+    
+    public AtomicInteger add (AtomicInteger obj);
+    public AtomicInteger subtract (AtomicInteger obj);
+}

Added: labs/jbosstm/workspace/mlittle/STM-Arjuna/src/test/java/org/jboss/stm/BasicContainerUnitTest.java
===================================================================
--- labs/jbosstm/workspace/mlittle/STM-Arjuna/src/test/java/org/jboss/stm/BasicContainerUnitTest.java	                        (rev 0)
+++ labs/jbosstm/workspace/mlittle/STM-Arjuna/src/test/java/org/jboss/stm/BasicContainerUnitTest.java	2009-03-29 20:10:29 UTC (rev 25874)
@@ -0,0 +1,151 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.stm;
+
+import org.jboss.stm.annotations.Transactional;
+import org.jboss.stm.annotations.ReadLock;
+import org.jboss.stm.annotations.DurableState;
+import org.jboss.stm.annotations.WriteLock;
+
+import com.arjuna.ats.arjuna.ObjectType;
+import com.arjuna.ats.arjuna.state.InputObjectState;
+import com.arjuna.ats.arjuna.state.OutputObjectState;
+import com.arjuna.ats.txoj.LockManager;
+
+import junit.framework.TestCase;
+
+/**
+ * Unit tests for the Class class.
+ * 
+ * @author Mark Little
+ */
+
+public class BasicContainerUnitTest extends TestCase
+{
+
+    public class TestObject extends LockManager
+    {
+        public TestObject ()
+        {
+            super(ObjectType.ANDPERSISTENT);
+        }
+        
+        public boolean save_state (OutputObjectState os)
+        {
+            return true;
+        }
+        
+        public boolean restore_state (InputObjectState os)
+        {
+            return true;
+        }
+        
+        public String type ()
+        {
+            return "/StateManager/LockManager/TestObject";
+        }
+    }
+    
+    @Transactional
+    public interface Sample
+    {
+       public void myWork ();
+       
+       public void doSomeWork ();
+
+       public boolean doSomeOtherWork ();
+       
+       public void notTransactionalWork ();
+    }
+    
+    @Transactional
+    public class SampleLockable implements Sample
+    {
+        public void myWork ()
+        {
+        }
+        
+        @ReadLock
+        public void doSomeWork ()
+        {
+
+        }
+
+        @WriteLock
+        public boolean doSomeOtherWork ()
+        {
+            return true;
+        }
+        
+        public void notTransactionalWork ()
+        {
+        }
+
+        @DurableState
+        @SuppressWarnings(value={"unused"})
+        private int _isState;
+        
+        @SuppressWarnings(value={"unused"})
+        private int _isNotState;
+    }
+
+    public void testInvalidEnlist ()
+    {
+        TestContainer<TestObject> theContainer = new TestContainer<TestObject>();
+        TestObject tester = new TestObject();
+        boolean success = false;
+        
+        try
+        {
+            theContainer.enlist(tester);
+        }
+        catch (final IllegalArgumentException ex)
+        {
+            success = true;
+        }
+
+        assertTrue(success);
+    }
+    
+    @SuppressWarnings(value={"unused"})
+    public void testValidEnlist ()
+    {
+        TestContainer<Sample> theContainer = new TestContainer<Sample>();
+        SampleLockable tester = new SampleLockable();
+        boolean success = true;
+        
+        try
+        {
+            Sample proxy = theContainer.enlist(tester);
+        }
+        catch (final Throwable ex)
+        {
+            ex.printStackTrace();
+            
+            success = false;
+        }
+        
+        assertTrue(success);
+    }
+    
+}

Added: labs/jbosstm/workspace/mlittle/STM-Arjuna/src/test/java/org/jboss/stm/HammerUnitTest.java
===================================================================
--- labs/jbosstm/workspace/mlittle/STM-Arjuna/src/test/java/org/jboss/stm/HammerUnitTest.java	                        (rev 0)
+++ labs/jbosstm/workspace/mlittle/STM-Arjuna/src/test/java/org/jboss/stm/HammerUnitTest.java	2009-03-29 20:10:29 UTC (rev 25874)
@@ -0,0 +1,173 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.stm;
+
+import java.util.Random;
+
+import org.jboss.stm.annotations.Transactional;
+import org.jboss.stm.annotations.ReadLock;
+import org.jboss.stm.annotations.DurableState;
+import org.jboss.stm.annotations.WriteLock;
+
+import com.arjuna.ats.arjuna.AtomicAction;
+
+import junit.framework.TestCase;
+
+/**
+ * Hammer equivalent test.
+ * 
+ * @author Mark Little
+ */
+
+public class HammerUnitTest extends TestCase
+{   
+    @Transactional
+    public interface Sample
+    {
+       public void increment ();
+       public void decrement ();
+       
+       public int value ();
+    }
+    
+    @Transactional
+    public class SampleLockable implements Sample
+    {
+        public SampleLockable (int init)
+        {
+            _isState = init;
+        }
+        
+        @ReadLock
+        public int value ()
+        {
+            return _isState;
+        }
+
+        @WriteLock
+        public void increment ()
+        {
+            _isState++;
+        }
+        
+        @WriteLock
+        public void decrement ()
+        {
+            _isState--;
+        }
+
+        @DurableState
+        private int _isState;
+    }
+    
+    public class Worker extends Thread
+    {
+        public Worker (Sample obj1, Sample obj2)
+        {
+            _obj1 = obj1;
+            _obj2 = obj2;
+        }
+        
+        public void run ()
+        {
+            Random rand = new Random();
+
+            for (int i = 0; i < 1000; i++)
+            {
+                AtomicAction A = new AtomicAction();
+                boolean doCommit = true;
+                
+                A.begin();
+                
+                try
+                {
+                    // always keep the two objects in sync.
+                    
+                    _obj1.increment();
+                    _obj2.decrement();
+                }
+                catch (final Throwable ex)
+                {
+                    doCommit = false;
+                }
+                
+                if (rand.nextInt() % 2 == 0)
+                    doCommit = false;
+                
+                if (doCommit)
+                    A.commit();
+                else
+                    A.abort();
+            }
+        }
+        
+        private Sample _obj1;
+        private Sample _obj2;
+    }
+
+    public void testRecoverableHammer ()
+    {
+        RecoverableContainer<Sample> theContainer = new RecoverableContainer<Sample>();
+        Sample obj1 = theContainer.enlist(new SampleLockable(10));
+        Sample obj2 = theContainer.enlist(new SampleLockable(10));
+        Worker worker1 = new Worker(obj1, obj2);
+        Worker worker2 = new Worker(obj1, obj2);
+        
+        worker1.start();
+        worker2.start();
+        
+        try
+        {
+            worker1.join();
+            worker2.join();
+        }
+        catch (final Throwable ex)
+        {
+        }
+        
+        assertEquals(obj1.value()+obj2.value(), 20);
+    }
+    
+    public void testPersistentHammer ()
+    {
+        PersistentContainer<Sample> theContainer = new PersistentContainer<Sample>();
+        Sample obj1 = theContainer.enlist(new SampleLockable(10));
+        Sample obj2 = theContainer.enlist(new SampleLockable(10));
+        Worker worker1 = new Worker(obj1, obj2);
+        Worker worker2 = new Worker(obj1, obj2);
+        
+        worker1.start();
+        worker2.start();
+        
+        try
+        {
+            worker1.join();
+            worker2.join();
+        }
+        catch (final Throwable ex)
+        {
+        }
+        
+        assertEquals(obj1.value()+obj2.value(), 20);
+    }
+}

Added: labs/jbosstm/workspace/mlittle/STM-Arjuna/src/test/java/org/jboss/stm/InvocationHandlerUnitTest.java
===================================================================
--- labs/jbosstm/workspace/mlittle/STM-Arjuna/src/test/java/org/jboss/stm/InvocationHandlerUnitTest.java	                        (rev 0)
+++ labs/jbosstm/workspace/mlittle/STM-Arjuna/src/test/java/org/jboss/stm/InvocationHandlerUnitTest.java	2009-03-29 20:10:29 UTC (rev 25874)
@@ -0,0 +1,143 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.stm;
+
+import org.jboss.stm.annotations.Transactional;
+import org.jboss.stm.annotations.ReadLock;
+import org.jboss.stm.annotations.DurableState;
+import org.jboss.stm.annotations.WriteLock;
+
+import com.arjuna.ats.arjuna.AtomicAction;
+
+import junit.framework.TestCase;
+
+/**
+ * Unit tests for the Class class.
+ * 
+ * @author Mark Little
+ */
+
+public class InvocationHandlerUnitTest extends TestCase
+{
+    @Transactional
+    public interface Sample
+    {
+        public void myWork ();
+
+        public int readValue ();
+
+        public boolean writeValue ();
+
+        public void notTransactionalWork ();
+    }
+
+    @Transactional
+    public class SampleLockable implements Sample
+    {
+        public void myWork ()
+        {
+            _isState = 0;
+            _isNotState = 0;
+        }
+
+        @ReadLock
+        public int readValue ()
+        {
+            return _isState;
+        }
+
+        @WriteLock
+        public boolean writeValue ()
+        {
+            _isState++;
+            
+            return true;
+        }
+
+        public void notTransactionalWork ()
+        {
+        }
+
+        @DurableState
+        private int _isState;
+
+        @SuppressWarnings(value =
+        { "unused" })
+        private int _isNotState;
+    }
+
+    @SuppressWarnings(value={"unused"})
+    public void testNullTxWriteLock () throws Throwable
+    {
+        PersistentContainer<Sample> theContainer = new PersistentContainer<Sample>();
+        SampleLockable tester = new SampleLockable();
+        boolean success = true;
+        Sample proxy = theContainer.enlist(tester);
+
+        assertNotNull(proxy);
+        
+        proxy.writeValue();
+    }
+    
+    @SuppressWarnings(value={"unused"})
+    public void testTxWriteLockCommit () throws Throwable
+    {
+        PersistentContainer<Sample> theContainer = new PersistentContainer<Sample>();
+        SampleLockable tester = new SampleLockable();
+        boolean success = true;
+        Sample proxy = theContainer.enlist(tester);
+        
+        assertNotNull(proxy);
+        
+        AtomicAction act = new AtomicAction();
+        
+        act.begin();
+        
+        proxy.writeValue();
+        
+        act.commit();
+        
+        assertEquals(proxy.readValue(), 1);
+    }
+    
+    @SuppressWarnings(value={"unused"})
+    public void testTxWriteLockRollback () throws Throwable
+    {
+        PersistentContainer<Sample> theContainer = new PersistentContainer<Sample>();
+        SampleLockable tester = new SampleLockable();
+        boolean success = true;
+        Sample proxy = theContainer.enlist(tester);
+        
+        assertNotNull(proxy);
+        
+        AtomicAction act = new AtomicAction();
+
+        act.begin();
+        
+        proxy.writeValue();
+
+        act.abort();
+        
+        assertEquals(proxy.readValue(), 0);
+    }
+}

Added: labs/jbosstm/workspace/mlittle/STM-Arjuna/src/test/java/org/jboss/stm/NestedHammerUnitTest.java
===================================================================
--- labs/jbosstm/workspace/mlittle/STM-Arjuna/src/test/java/org/jboss/stm/NestedHammerUnitTest.java	                        (rev 0)
+++ labs/jbosstm/workspace/mlittle/STM-Arjuna/src/test/java/org/jboss/stm/NestedHammerUnitTest.java	2009-03-29 20:10:29 UTC (rev 25874)
@@ -0,0 +1,175 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.stm;
+
+import java.util.Random;
+
+import org.jboss.stm.annotations.Nested;
+import org.jboss.stm.annotations.Transactional;
+import org.jboss.stm.annotations.ReadLock;
+import org.jboss.stm.annotations.DurableState;
+import org.jboss.stm.annotations.WriteLock;
+
+import com.arjuna.ats.arjuna.AtomicAction;
+
+import junit.framework.TestCase;
+
+/**
+ * Hammer equivalent test.
+ * 
+ * @author Mark Little
+ */
+
+public class NestedHammerUnitTest extends TestCase
+{   
+    @Transactional
+    @Nested
+    public interface Sample
+    {
+       public void increment ();
+       public void decrement ();
+       
+       public int value ();
+    }
+    
+    @Transactional
+    public class SampleLockable implements Sample
+    {
+        public SampleLockable (int init)
+        {
+            _isState = init;
+        }
+        
+        @ReadLock
+        public int value ()
+        {
+            return _isState;
+        }
+
+        @WriteLock
+        public void increment ()
+        {
+            _isState++;
+        }
+        
+        @WriteLock
+        public void decrement ()
+        {
+            _isState--;
+        }
+
+        @DurableState
+        private int _isState;
+    }
+    
+    public class Worker extends Thread
+    {
+        public Worker (Sample obj1, Sample obj2)
+        {
+            _obj1 = obj1;
+            _obj2 = obj2;
+        }
+        
+        public void run ()
+        {
+            Random rand = new Random();
+
+            for (int i = 0; i < 1000; i++)
+            {
+                AtomicAction A = new AtomicAction();
+                boolean doCommit = true;
+                
+                A.begin();
+                
+                try
+                {
+                    // always keep the two objects in sync.
+                    
+                    _obj1.increment();
+                    _obj2.decrement();
+                }
+                catch (final Throwable ex)
+                {
+                    doCommit = false;
+                }
+                
+                if (rand.nextInt() % 2 == 0)
+                    doCommit = false;
+                
+                if (doCommit)
+                    A.commit();
+                else
+                    A.abort();
+            }
+        }
+        
+        private Sample _obj1;
+        private Sample _obj2;
+    }
+
+    public void testRecoverableHammer ()
+    {
+        RecoverableContainer<Sample> theContainer = new RecoverableContainer<Sample>();
+        Sample obj1 = theContainer.enlist(new SampleLockable(10));
+        Sample obj2 = theContainer.enlist(new SampleLockable(10));
+        Worker worker1 = new Worker(obj1, obj2);
+        Worker worker2 = new Worker(obj1, obj2);
+        
+        worker1.start();
+        worker2.start();
+        
+        try
+        {
+            worker1.join();
+            worker2.join();
+        }
+        catch (final Throwable ex)
+        {
+        }
+        
+        assertEquals(obj1.value()+obj2.value(), 20);
+    }
+    
+    public void testPersistentHammer ()
+    {
+        PersistentContainer<Sample> theContainer = new PersistentContainer<Sample>();
+        Sample obj1 = theContainer.enlist(new SampleLockable(10));
+        Sample obj2 = theContainer.enlist(new SampleLockable(10));
+        Worker worker1 = new Worker(obj1, obj2);
+        Worker worker2 = new Worker(obj1, obj2);
+        
+        worker1.start();
+        worker2.start();
+        
+        try
+        {
+            worker1.join();
+            worker2.join();
+        }
+        catch (final Throwable ex)
+        {
+        }
+        
+        assertEquals(obj1.value()+obj2.value(), 20);
+    }
+}

Added: labs/jbosstm/workspace/mlittle/STM-Arjuna/src/test/java/org/jboss/stm/PersistentContainerUnitTest.java
===================================================================
--- labs/jbosstm/workspace/mlittle/STM-Arjuna/src/test/java/org/jboss/stm/PersistentContainerUnitTest.java	                        (rev 0)
+++ labs/jbosstm/workspace/mlittle/STM-Arjuna/src/test/java/org/jboss/stm/PersistentContainerUnitTest.java	2009-03-29 20:10:29 UTC (rev 25874)
@@ -0,0 +1,174 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.stm;
+
+import org.jboss.stm.annotations.Transactional;
+import org.jboss.stm.annotations.ReadLock;
+import org.jboss.stm.annotations.DurableState;
+import org.jboss.stm.annotations.WriteLock;
+
+import com.arjuna.ats.arjuna.ObjectType;
+import com.arjuna.ats.arjuna.common.Uid;
+import com.arjuna.ats.arjuna.state.InputObjectState;
+import com.arjuna.ats.arjuna.state.OutputObjectState;
+import com.arjuna.ats.txoj.LockManager;
+
+import junit.framework.TestCase;
+
+/**
+ * Unit tests for the Class class.
+ * 
+ * @author Mark Little
+ */
+
+public class PersistentContainerUnitTest extends TestCase
+{
+
+    public class TestObject extends LockManager
+    {
+        public TestObject ()
+        {
+            super(ObjectType.ANDPERSISTENT);
+        }
+        
+        public boolean save_state (OutputObjectState os)
+        {
+            return true;
+        }
+        
+        public boolean restore_state (InputObjectState os)
+        {
+            return true;
+        }
+        
+        public String type ()
+        {
+            return "/StateManager/LockManager/TestObject";
+        }
+    }
+    
+    @Transactional
+    public interface Sample
+    {
+       public void myWork ();
+       
+       public void doSomeWork ();
+
+       public boolean doSomeOtherWork ();
+       
+       public void notTransactionalWork ();
+    }
+    
+    @Transactional
+    public class SampleLockable implements Sample
+    {
+        public void myWork ()
+        {
+        }
+        
+        @ReadLock
+        public void doSomeWork ()
+        {
+
+        }
+
+        @WriteLock
+        public boolean doSomeOtherWork ()
+        {
+            return true;
+        }
+        
+        public void notTransactionalWork ()
+        {
+        }
+
+        @DurableState
+        @SuppressWarnings(value={"unused"})
+        private int _isState;
+        
+        @SuppressWarnings(value={"unused"})
+        private int _isNotState;
+    }
+
+    public void testInvalidEnlist ()
+    {
+        PersistentContainer<TestObject> theContainer = new PersistentContainer<TestObject>();
+        TestObject tester = new TestObject();
+        boolean success = false;
+        
+        try
+        {
+            theContainer.enlist(tester);
+        }
+        catch (final IllegalArgumentException ex)
+        {
+            success = true;
+        }
+
+        assertTrue(success);
+    }
+    
+    @SuppressWarnings(value={"unused"})
+    public void testValidEnlist ()
+    {
+        PersistentContainer<Sample> theContainer = new PersistentContainer<Sample>();
+        SampleLockable tester = new SampleLockable();
+        boolean success = true;
+        
+        try
+        {
+            Sample proxy = theContainer.enlist(tester);
+        }
+        catch (final Throwable ex)
+        {
+            ex.printStackTrace();
+            
+            success = false;
+        }
+        
+        assertTrue(success);
+    }
+    
+    public void testGetUid ()
+    {
+        PersistentContainer<Sample> theContainer = new PersistentContainer<Sample>();
+        SampleLockable tester = new SampleLockable();
+        boolean success = true;
+        
+        try
+        {
+            Sample proxy = theContainer.enlist(tester);
+            Uid u = theContainer.getUid(proxy);
+            
+            assertNotNull(u);
+        }
+        catch (final Throwable ex)
+        {
+            ex.printStackTrace();
+            
+            success = false;
+        }
+        
+        assertTrue(success);
+    }
+}

Added: labs/jbosstm/workspace/mlittle/STM-Arjuna/src/test/java/org/jboss/stm/ProxyUnitTest.java
===================================================================
--- labs/jbosstm/workspace/mlittle/STM-Arjuna/src/test/java/org/jboss/stm/ProxyUnitTest.java	                        (rev 0)
+++ labs/jbosstm/workspace/mlittle/STM-Arjuna/src/test/java/org/jboss/stm/ProxyUnitTest.java	2009-03-29 20:10:29 UTC (rev 25874)
@@ -0,0 +1,100 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.stm;
+
+import org.jboss.stm.annotations.Transactional;
+import org.jboss.stm.annotations.ReadLock;
+import org.jboss.stm.annotations.DurableState;
+import org.jboss.stm.annotations.WriteLock;
+
+import junit.framework.TestCase;
+
+/**
+ * Unit tests for the Class class.
+ * 
+ * @author Mark Little
+ */
+
+public class ProxyUnitTest extends TestCase
+{
+    @Transactional
+    public interface Sample
+    {
+        public void myWork ();
+
+        public void doSomeWork ();
+
+        public boolean doSomeOtherWork ();
+
+        public void notTransactionalWork ();
+    }
+
+    @Transactional
+    public class SampleLockable implements Sample
+    {
+        public void myWork ()
+        {
+        }
+
+        @ReadLock
+        public void doSomeWork ()
+        {
+
+        }
+
+        @WriteLock
+        public boolean doSomeOtherWork ()
+        {
+            return true;
+        }
+
+        public void notTransactionalWork ()
+        {
+        }
+
+        @DurableState
+        @SuppressWarnings(value =
+        { "unused" })
+        private int _isState;
+
+        @SuppressWarnings(value =
+        { "unused" })
+        private int _isNotState;
+    }
+
+    @SuppressWarnings(value={"unused"})
+    public void testInvoke () throws Throwable
+    {
+        PersistentContainer<Sample> theContainer = new PersistentContainer<Sample>();
+        SampleLockable tester = new SampleLockable();
+        boolean success = true;
+        Sample proxy = theContainer.enlist(tester);
+
+        assertNotNull(proxy);
+        
+        proxy.myWork();
+        proxy.doSomeWork();
+        proxy.doSomeOtherWork();
+        proxy.notTransactionalWork();
+    }
+}

Added: labs/jbosstm/workspace/mlittle/STM-Arjuna/src/test/java/org/jboss/stm/RecoverableContainerUnitTest.java
===================================================================
--- labs/jbosstm/workspace/mlittle/STM-Arjuna/src/test/java/org/jboss/stm/RecoverableContainerUnitTest.java	                        (rev 0)
+++ labs/jbosstm/workspace/mlittle/STM-Arjuna/src/test/java/org/jboss/stm/RecoverableContainerUnitTest.java	2009-03-29 20:10:29 UTC (rev 25874)
@@ -0,0 +1,150 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.stm;
+
+import org.jboss.stm.annotations.Transactional;
+import org.jboss.stm.annotations.ReadLock;
+import org.jboss.stm.annotations.DurableState;
+import org.jboss.stm.annotations.WriteLock;
+
+import com.arjuna.ats.arjuna.ObjectType;
+import com.arjuna.ats.arjuna.state.InputObjectState;
+import com.arjuna.ats.arjuna.state.OutputObjectState;
+import com.arjuna.ats.txoj.LockManager;
+
+import junit.framework.TestCase;
+
+/**
+ * Unit tests for the Class class.
+ * 
+ * @author Mark Little
+ */
+
+public class RecoverableContainerUnitTest extends TestCase
+{
+
+    public class TestObject extends LockManager
+    {
+        public TestObject ()
+        {
+            super(ObjectType.ANDPERSISTENT);
+        }
+        
+        public boolean save_state (OutputObjectState os)
+        {
+            return true;
+        }
+        
+        public boolean restore_state (InputObjectState os)
+        {
+            return true;
+        }
+        
+        public String type ()
+        {
+            return "/StateManager/LockManager/TestObject";
+        }
+    }
+    
+    @Transactional
+    public interface Sample
+    {
+       public void myWork ();
+       
+       public void doSomeWork ();
+
+       public boolean doSomeOtherWork ();
+       
+       public void notTransactionalWork ();
+    }
+    
+    @Transactional
+    public class SampleLockable implements Sample
+    {
+        public void myWork ()
+        {
+        }
+        
+        @ReadLock
+        public void doSomeWork ()
+        {
+
+        }
+
+        @WriteLock
+        public boolean doSomeOtherWork ()
+        {
+            return true;
+        }
+        
+        public void notTransactionalWork ()
+        {
+        }
+
+        @DurableState
+        @SuppressWarnings(value={"unused"})
+        private int _isState;
+        
+        @SuppressWarnings(value={"unused"})
+        private int _isNotState;
+    }
+
+    public void testInvalidEnlist ()
+    {
+        RecoverableContainer<TestObject> theContainer = new RecoverableContainer<TestObject>();
+        TestObject tester = new TestObject();
+        boolean success = false;
+        
+        try
+        {
+            theContainer.enlist(tester);
+        }
+        catch (final IllegalArgumentException ex)
+        {
+            success = true;
+        }
+
+        assertTrue(success);
+    }
+    
+    @SuppressWarnings(value={"unused"})
+    public void testValidEnlist ()
+    {
+        RecoverableContainer<Sample> theContainer = new RecoverableContainer<Sample>();
+        SampleLockable tester = new SampleLockable();
+        boolean success = true;
+        
+        try
+        {
+            Sample proxy = theContainer.enlist(tester);
+        }
+        catch (final Throwable ex)
+        {
+            ex.printStackTrace();
+            
+            success = false;
+        }
+        
+        assertTrue(success);
+    }
+}

Added: labs/jbosstm/workspace/mlittle/STM-Arjuna/src/test/java/org/jboss/stm/TestContainer.java
===================================================================
--- labs/jbosstm/workspace/mlittle/STM-Arjuna/src/test/java/org/jboss/stm/TestContainer.java	                        (rev 0)
+++ labs/jbosstm/workspace/mlittle/STM-Arjuna/src/test/java/org/jboss/stm/TestContainer.java	2009-03-29 20:10:29 UTC (rev 25874)
@@ -0,0 +1,96 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, JBoss Inc., and others contributors as indicated 
+ * by the @authors tag. All rights reserved. 
+ * 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 mark.little at jboss.com
+ */
+
+package org.jboss.stm;
+
+import java.lang.reflect.Proxy;
+import java.util.WeakHashMap;
+
+import org.jboss.stm.internal.reflect.InvocationHandler;
+
+/**
+ * Instances of this class represent the transactional memory within which user objects
+ * can be placed and managed.
+ * 
+ * Objects must implement an interface through which all transactional accesses occur. We don't
+ * mandate what the interface is, since that will depend upon the business logic. The interface, or
+ * the implementing class, must also use the @Lockable annotation.
+ * 
+ * TODO look at using JBossAOP to get round the problem of requiring an interface for proxying.
+ * 
+ * @author marklittle
+ */
+
+/*
+ * Could provide a container that works on any classes without annotations. The rules would have to be
+ * more restrictive:
+ * 
+ * (i) all operations are assumed to modify the state (therefore write lock).
+ * (ii) all state is saved and restored.
+ * 
+ * Or use a setter/getter pattern to provide flexibility around (i).
+ */
+
+public class TestContainer<T> extends RecoverableContainer<T>
+{
+    /**
+     * Given an object we create a new transactional instance of it and return that
+     * for future use. All accesses on the returned object will be managed according to
+     * the rules defined in the various annotations. If the original object instance is used
+     * then no transactional manipulation will occur so you need to be careful!
+     */
+    
+    /**
+     * Return a handle through which the object should be used, rather than the one
+     * passed in.
+     */
+    
+    @SuppressWarnings(value={"unchecked"})
+    public T enlist (T member)
+    {
+        /*
+         * Everything that is transactional needs to be explicitly marked as such in
+         * the public API, even if the private methods are the ones that do the
+         * real work.
+         */
+
+        checkObjectType(member);
+        
+        /*
+         * Is it already registered? If so just return the same instance.
+         */
+        
+        T proxy = _transactionalProxies.get(member);
+        
+        if (proxy == null)
+        {
+            Class c = member.getClass();
+            
+            proxy = (T) Proxy.newProxyInstance(c.getClassLoader(), c.getInterfaces(), new InvocationHandler<T>(this, member));
+            
+            _transactionalProxies.put(member, proxy);
+        }
+        
+        return proxy;
+    }
+
+    private WeakHashMap<T, T> _transactionalProxies = new WeakHashMap<T, T>();
+}

Added: labs/jbosstm/workspace/mlittle/STM-Arjuna/src/test/java/org/jboss/stm/annotations/BasicUnitTest.java
===================================================================
--- labs/jbosstm/workspace/mlittle/STM-Arjuna/src/test/java/org/jboss/stm/annotations/BasicUnitTest.java	                        (rev 0)
+++ labs/jbosstm/workspace/mlittle/STM-Arjuna/src/test/java/org/jboss/stm/annotations/BasicUnitTest.java	2009-03-29 20:10:29 UTC (rev 25874)
@@ -0,0 +1,127 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.stm.annotations;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import junit.framework.TestCase;
+
+/**
+ * Unit tests for the Class class.
+ * 
+ * @author Mark Little
+ */
+
+public class BasicUnitTest extends TestCase
+{
+
+    @Transactional
+    public class TestObject
+    {
+        @ReadLock
+        public void doSomeWork ()
+        {
+
+        }
+
+        @WriteLock
+        public boolean doSomeOtherWork ()
+        {
+            return true;
+        }
+        
+        public void notTransactionalWork ()
+        {
+        }
+
+        @DurableState
+        @SuppressWarnings(value={"unused"})
+        private int _isState;
+
+        @SuppressWarnings(value={"unused"})
+        private Integer _isNotState;
+    }
+
+    public void testLockableClass ()
+    {
+        TestObject tester = new TestObject();
+        
+        assertTrue(tester.getClass().isAnnotationPresent(Transactional.class));
+    }
+    
+    public void testNotLockableClass ()
+    {
+        BasicUnitTest tester = new BasicUnitTest();
+        
+        assertFalse(tester.getClass().isAnnotationPresent(Transactional.class));
+    }
+
+    public void testMethodTypes () throws Exception
+    {
+        TestObject tester = new TestObject();
+        Method[] methods = tester.getClass().getDeclaredMethods();
+
+        assertNotNull(methods);
+
+        Method someWork = tester.getClass().getDeclaredMethod("doSomeWork", (Class[]) null);
+        
+        assertNotNull(someWork);
+        assertTrue(someWork.isAnnotationPresent(ReadLock.class));
+        
+        Method someOtherWork = tester.getClass().getDeclaredMethod("doSomeOtherWork", (Class[]) null);
+        
+        assertNotNull(someOtherWork);
+        assertTrue(someOtherWork.isAnnotationPresent(WriteLock.class));
+        
+        Method someBasicWork = tester.getClass().getDeclaredMethod("notTransactionalWork", (Class[]) null);
+        
+        assertNotNull(someBasicWork);
+        assertFalse(someBasicWork.isAnnotationPresent(WriteLock.class));
+        assertFalse(someBasicWork.isAnnotationPresent(ReadLock.class));
+    }
+    
+    public void testFields () throws Exception
+    {
+        TestObject tester = new TestObject();
+        Field[] fields = tester.getClass().getDeclaredFields(); // get all fields including private
+        
+        assertNotNull(fields);
+        
+        for (Field afield : fields)
+        {
+            if (afield.getName().equals("_isState"))
+            {
+                assertTrue(afield.isAnnotationPresent(DurableState.class));
+                assertTrue(afield.getType().equals(Integer.TYPE));
+            }
+            
+            if (afield.getName().equals("_isNotState"))
+            {
+                assertFalse(afield.isAnnotationPresent(DurableState.class));
+                assertTrue(afield.getType().equals(Integer.class));
+            }
+        }
+    }
+    
+}

Added: labs/jbosstm/workspace/mlittle/STM-Arjuna/src/test/java/org/jboss/stm/annotations/InheritedUnitTest.java
===================================================================
--- labs/jbosstm/workspace/mlittle/STM-Arjuna/src/test/java/org/jboss/stm/annotations/InheritedUnitTest.java	                        (rev 0)
+++ labs/jbosstm/workspace/mlittle/STM-Arjuna/src/test/java/org/jboss/stm/annotations/InheritedUnitTest.java	2009-03-29 20:10:29 UTC (rev 25874)
@@ -0,0 +1,163 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.stm.annotations;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import junit.framework.TestCase;
+
+/**
+ * Unit tests for the Class class.
+ * 
+ * @author Mark Little
+ */
+
+public class InheritedUnitTest extends TestCase
+{
+    @Transactional
+    public class Sample
+    {
+       @ReadLock
+       public void myWork ()
+       {
+       }
+    }
+    
+    public class TestObject extends Sample
+    {
+        @ReadLock
+        public void doSomeWork ()
+        {
+
+        }
+
+        @WriteLock
+        public boolean doSomeOtherWork ()
+        {
+            return true;
+        }
+        
+        public void notTransactionalWork ()
+        {
+        }
+
+        @DurableState
+        @SuppressWarnings(value={"unused"})
+        private int _isState;
+
+        @SuppressWarnings(value={"unused"})
+        private int _isNotState;
+    }
+
+    @SuppressWarnings(value={"unchecked"})
+    public void testLockableClass ()
+    {
+        TestObject tester = new TestObject();
+        Class c = tester.getClass().getSuperclass();
+        boolean present = false;
+        
+        while (c != null)
+        {
+            if (c.getAnnotation(Transactional.class) != null)
+            {
+                present = true;
+                
+                break;
+            }
+            
+            c = c.getSuperclass();
+        }
+        
+        assertTrue(present);
+    }
+    
+    public void testNotLockableClass ()
+    {
+        InheritedUnitTest tester = new InheritedUnitTest();
+        
+        assertFalse(tester.getClass().isAnnotationPresent(Transactional.class));
+    }
+
+    public void testMethodTypes () throws Exception
+    {
+        TestObject tester = new TestObject();
+        Method[] methods = tester.getClass().getDeclaredMethods();
+
+        assertNotNull(methods);
+
+        Method someWork = tester.getClass().getDeclaredMethod("doSomeWork", (Class[]) null);
+        
+        assertNotNull(someWork);
+        assertTrue(someWork.isAnnotationPresent(ReadLock.class));
+        
+        Method someOtherWork = tester.getClass().getDeclaredMethod("doSomeOtherWork", (Class[]) null);
+        
+        assertNotNull(someOtherWork);
+        assertTrue(someOtherWork.isAnnotationPresent(WriteLock.class));
+        
+        Method someBasicWork = tester.getClass().getDeclaredMethod("notTransactionalWork", (Class[]) null);
+        
+        assertNotNull(someBasicWork);
+        assertFalse(someBasicWork.isAnnotationPresent(WriteLock.class));
+        assertFalse(someBasicWork.isAnnotationPresent(ReadLock.class));
+        
+        methods = tester.getClass().getMethods();
+        boolean found = false;
+        
+        for (Method m : methods)
+        {
+            if (m.getName().equals("myWork"))
+            {
+                assertTrue(m.isAnnotationPresent(ReadLock.class));
+                
+                found = true;
+                break;
+            }
+        }
+        
+        assertTrue(found);
+    }
+    
+    public void testFields () throws Exception
+    {
+        TestObject tester = new TestObject();
+        Field[] fields = tester.getClass().getDeclaredFields(); // get all fields including private
+        
+        assertNotNull(fields);
+        
+        for (Field afield : fields)
+        {
+            if (afield.getName().equals("_isState"))
+            {
+                assertTrue(afield.isAnnotationPresent(DurableState.class));
+            }
+            
+            if (afield.getName().equals("_isNotState"))
+            {
+                assertFalse(afield.isAnnotationPresent(DurableState.class));
+            }
+        }
+    }
+    
+}

Added: labs/jbosstm/workspace/mlittle/STM-Arjuna/src/test/java/org/jboss/stm/internal/proxy/ComplexLockManagerProxyUnitTest.java
===================================================================
--- labs/jbosstm/workspace/mlittle/STM-Arjuna/src/test/java/org/jboss/stm/internal/proxy/ComplexLockManagerProxyUnitTest.java	                        (rev 0)
+++ labs/jbosstm/workspace/mlittle/STM-Arjuna/src/test/java/org/jboss/stm/internal/proxy/ComplexLockManagerProxyUnitTest.java	2009-03-29 20:10:29 UTC (rev 25874)
@@ -0,0 +1,119 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.stm.internal.proxy;
+
+import java.io.IOException;
+
+import org.jboss.stm.annotations.DurableState;
+import org.jboss.stm.annotations.Transactional;
+import org.jboss.stm.annotations.RestoreState;
+import org.jboss.stm.annotations.SaveState;
+
+import com.arjuna.ats.arjuna.ObjectType;
+import com.arjuna.ats.arjuna.state.InputObjectState;
+import com.arjuna.ats.arjuna.state.OutputObjectState;
+
+import junit.framework.TestCase;
+
+/**
+ * Unit tests for the Class class.
+ * 
+ * @author Mark Little
+ */
+
+public class ComplexLockManagerProxyUnitTest extends TestCase
+{
+    @Transactional
+    public class BasicLockable
+    {
+        public BasicLockable ()
+        {
+            _isState = 4;
+            _isNotState = 2;
+            _saved = 1234;
+        }
+        
+        public String toString ()
+        {
+            return "SampleLockable < "+_isState+", "+_isNotState+", "+_saved+" >";
+        }
+        
+        @SaveState
+        public void save_state (OutputObjectState os) throws IOException
+        {
+           os.packInt(_saved);
+        }
+        
+        @RestoreState
+        public void restore_state (InputObjectState os) throws IOException
+        {
+            _saved = os.unpackInt();
+        }
+        
+        @DurableState // will be ignored!!
+        public int _isState;
+
+        public int _isNotState;
+        
+        public int _saved;
+    }
+    
+    // this one will fail because it defined a save but no restore
+    
+    @Transactional
+    class InvalidLockable
+    {
+        @SaveState
+        public void save_state (OutputObjectState os) throws IOException
+        {
+        }
+    }
+    
+    public void testInvalidSaveRestore ()
+    {
+       InvalidLockable obj = new InvalidLockable();
+       LockManagerProxy<InvalidLockable> proxy = new LockManagerProxy<InvalidLockable>(obj);
+       OutputObjectState os = new OutputObjectState();
+       
+       assertFalse(proxy.save_state(os, ObjectType.RECOVERABLE));
+    }
+    
+    public void testSaveRestore ()
+    {
+        BasicLockable obj = new BasicLockable();
+        LockManagerProxy<BasicLockable> proxy = new LockManagerProxy<BasicLockable>(obj);
+        OutputObjectState os = new OutputObjectState();
+        
+        assertTrue(proxy.save_state(os, ObjectType.RECOVERABLE));     
+        
+        obj._saved = 4567;
+        obj._isState = 0;  // make sure it's ignored by save/restore.
+        
+        InputObjectState ios = new InputObjectState(os);
+        
+        assertTrue(proxy.restore_state(ios, ObjectType.RECOVERABLE));
+        
+        assertEquals(obj._saved, 1234);
+        assertEquals(obj._isState, 0);
+    }
+}

Added: labs/jbosstm/workspace/mlittle/STM-Arjuna/src/test/java/org/jboss/stm/internal/proxy/InheritenceLockManagerProxyUnitTest.java
===================================================================
--- labs/jbosstm/workspace/mlittle/STM-Arjuna/src/test/java/org/jboss/stm/internal/proxy/InheritenceLockManagerProxyUnitTest.java	                        (rev 0)
+++ labs/jbosstm/workspace/mlittle/STM-Arjuna/src/test/java/org/jboss/stm/internal/proxy/InheritenceLockManagerProxyUnitTest.java	2009-03-29 20:10:29 UTC (rev 25874)
@@ -0,0 +1,161 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.stm.internal.proxy;
+
+import java.io.IOException;
+
+import org.jboss.stm.annotations.DurableState;
+import org.jboss.stm.annotations.Transactional;
+import org.jboss.stm.annotations.RestoreState;
+import org.jboss.stm.annotations.SaveState;
+
+import com.arjuna.ats.arjuna.ObjectType;
+import com.arjuna.ats.arjuna.state.InputObjectState;
+import com.arjuna.ats.arjuna.state.OutputObjectState;
+
+import junit.framework.TestCase;
+
+/**
+ * Unit tests for the Class class.
+ * 
+ * @author Mark Little
+ */
+
+public class InheritenceLockManagerProxyUnitTest extends TestCase
+{
+    public interface Blank
+    {       
+    }
+    
+    @Transactional
+    public class Base
+    {
+        public Base ()
+        {
+            valid = true;
+        }
+        
+        @SaveState
+        public void saveMyState (OutputObjectState os) throws IOException
+        {
+            os.packBoolean(valid);
+        }
+        
+        @RestoreState
+        public void restoreMyState (InputObjectState os) throws IOException
+        {
+            valid = os.unpackBoolean();
+        }
+        
+        public boolean valid;
+    }
+    
+    @Transactional
+    public class Inherit extends Base implements Blank
+    {
+        public Inherit ()
+        {
+            myString = "Hello World";
+        }
+        
+        public String myString;
+    }
+    
+    @Transactional
+    public class BasicLockable extends Base
+    {
+        public BasicLockable ()
+        {
+            _isState = 4;
+            _isNotState = 2;
+            _saved = 1234;
+        }
+        
+        public String toString ()
+        {
+            return "BasicLockable < "+_isState+", "+_isNotState+", "+_saved+" >";
+        }
+        
+        @SaveState
+        public void save_state (OutputObjectState os) throws IOException
+        {
+            super.saveMyState(os);
+            
+            os.packInt(_saved);
+        }
+        
+        @RestoreState
+        public void restore_state (InputObjectState os) throws IOException
+        {
+            super.restoreMyState(os);
+            
+            _saved = os.unpackInt();
+        }
+        
+        @DurableState // will be ignored!!
+        public int _isState;
+
+        public int _isNotState;
+        
+        public int _saved;
+    }
+    
+    public void testInheritSaveRestore ()
+    {
+        Inherit obj = new Inherit();
+        LockManagerProxy<Inherit> proxy = new LockManagerProxy<Inherit>(obj);
+        OutputObjectState os = new OutputObjectState();
+
+        assertTrue(proxy.save_state(os, ObjectType.RECOVERABLE));
+        
+        obj.myString = "";
+        
+        InputObjectState ios = new InputObjectState(os);
+        
+        assertTrue(proxy.restore_state(ios, ObjectType.RECOVERABLE));
+        
+        assertEquals(obj.myString, "");
+    }
+    
+    public void testSaveRestore ()
+    {
+        BasicLockable obj = new BasicLockable();
+        LockManagerProxy<BasicLockable> proxy = new LockManagerProxy<BasicLockable>(obj);
+        OutputObjectState os = new OutputObjectState();
+        
+        assertTrue(proxy.save_state(os, ObjectType.RECOVERABLE));     
+        
+        obj._saved = 4567;
+        obj._isState = 0;  // make sure it's ignored by save/restore.
+        ((Base) obj).valid = false;
+        
+        InputObjectState ios = new InputObjectState(os);
+        
+        assertTrue(proxy.restore_state(ios, ObjectType.RECOVERABLE));
+        
+        assertEquals(obj._saved, 1234);
+        assertEquals(obj._isState, 0);
+        
+        assertTrue(((Base) obj).valid);
+    }
+}

Added: labs/jbosstm/workspace/mlittle/STM-Arjuna/src/test/java/org/jboss/stm/internal/proxy/LockManagerProxyUnitTest.java
===================================================================
--- labs/jbosstm/workspace/mlittle/STM-Arjuna/src/test/java/org/jboss/stm/internal/proxy/LockManagerProxyUnitTest.java	                        (rev 0)
+++ labs/jbosstm/workspace/mlittle/STM-Arjuna/src/test/java/org/jboss/stm/internal/proxy/LockManagerProxyUnitTest.java	2009-03-29 20:10:29 UTC (rev 25874)
@@ -0,0 +1,157 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.stm.internal.proxy;
+
+import org.jboss.stm.annotations.DurableState;
+
+import com.arjuna.ats.arjuna.AtomicAction;
+import com.arjuna.ats.arjuna.ObjectType;
+import com.arjuna.ats.arjuna.state.InputObjectState;
+import com.arjuna.ats.arjuna.state.OutputObjectState;
+import com.arjuna.ats.txoj.Lock;
+import com.arjuna.ats.txoj.LockMode;
+import com.arjuna.ats.txoj.LockResult;
+
+import junit.framework.TestCase;
+
+/**
+ * Unit tests for the Class class.
+ * 
+ * @author Mark Little
+ */
+
+public class LockManagerProxyUnitTest extends TestCase
+{
+    public class BasicLockable
+    {
+        public BasicLockable ()
+        {
+            _isState = 4;
+            _isNotState = 2;
+        }
+        
+        public String toString ()
+        {
+            return "SampleLockable < "+_isState+", "+_isNotState+" >";
+        }
+        
+        @DurableState
+        public int _isState;
+
+        public int _isNotState;
+    }
+    
+    public class ExtendedLockable
+    {
+        public ExtendedLockable ()
+        {
+            _isState = new Double(1.234);
+            _isNotState = new Integer(5678);
+            _field = "Hello World";
+        }
+        
+        public void set (String s)
+        {
+            _field = s;
+        }
+        
+        public String get ()
+        {
+            return _field;
+        }
+        
+        @DurableState
+        public Double _isState;
+        
+        public Integer _isNotState;
+        
+        @DurableState
+        private String _field;
+    }
+
+    public void testBasicSaveRestore ()
+    {
+       BasicLockable sample = new BasicLockable();
+       LockManagerProxy<BasicLockable> proxy = new LockManagerProxy<BasicLockable>(sample);
+       OutputObjectState os = new OutputObjectState();
+       
+       assertNotNull(proxy.type());
+       
+       assertTrue(proxy.save_state(os, ObjectType.RECOVERABLE));
+       
+       InputObjectState ios = new InputObjectState(os);
+       
+       sample._isState = -1;
+       sample._isNotState = -1;
+       
+       assertTrue(proxy.restore_state(ios, ObjectType.RECOVERABLE));
+       
+       assertTrue(sample._isState == 4);
+       assertTrue(sample._isNotState == -1);
+    }
+    
+    public void testExtendedSaveRestore ()
+    {
+       ExtendedLockable sample = new ExtendedLockable();
+       LockManagerProxy<ExtendedLockable> proxy = new LockManagerProxy<ExtendedLockable>(sample);
+       OutputObjectState os = new OutputObjectState();
+       
+       assertNotNull(proxy.type());
+       
+       assertTrue(proxy.save_state(os, ObjectType.RECOVERABLE));
+       
+       InputObjectState ios = new InputObjectState(os);
+       
+       sample._isState = new Double(0.0);
+       sample._isNotState = new Integer(0);
+       sample.set("");
+       
+       assertTrue(proxy.restore_state(ios, ObjectType.RECOVERABLE));
+       
+       assertTrue(sample._isState.doubleValue() == 1.234);
+       assertTrue(sample._isNotState.intValue() == 0);
+       assertEquals(sample.get(), "Hello World");
+    }
+    
+    public void testTransactionalUpdate ()
+    {
+       ExtendedLockable sample = new ExtendedLockable();
+       LockManagerProxy<ExtendedLockable> proxy = new LockManagerProxy<ExtendedLockable>(sample);
+       
+       assertNotNull(proxy.type());
+       
+       AtomicAction A = new AtomicAction();
+       
+       A.begin();
+       
+       sample._isState = new Double(1.0);
+       
+       assertEquals(proxy.setlock(new Lock(LockMode.WRITE)), LockResult.GRANTED);
+       
+       sample._isState = new Double(4.0);
+       
+       A.abort();
+       
+       assertEquals(sample._isState, new Double(1.0));
+    }
+}

Added: labs/jbosstm/workspace/mlittle/STM-Arjuna/src/test/java/org/jboss/stm/internal/reflect/TestInvocationHandler.java
===================================================================
--- labs/jbosstm/workspace/mlittle/STM-Arjuna/src/test/java/org/jboss/stm/internal/reflect/TestInvocationHandler.java	                        (rev 0)
+++ labs/jbosstm/workspace/mlittle/STM-Arjuna/src/test/java/org/jboss/stm/internal/reflect/TestInvocationHandler.java	2009-03-29 20:10:29 UTC (rev 25874)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, JBoss Inc., and others contributors as indicated 
+ * by the @authors tag. All rights reserved. 
+ * 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 mark.little at jboss.com
+ */
+
+package org.jboss.stm.internal.reflect;
+
+import org.jboss.stm.TestContainer;
+
+public class TestInvocationHandler<T> implements java.lang.reflect.InvocationHandler
+{
+    public TestInvocationHandler (TestContainer<T> c, T obj)
+    {
+        _container = c;
+        _theObject = obj;
+    }
+    
+    public Object invoke (Object proxy, java.lang.reflect.Method method, Object[] args) throws Throwable
+    {
+        return method.invoke(_theObject, args);
+    }
+    
+    @SuppressWarnings(value={"unused"})
+    private TestContainer<T> _container;
+    private T _theObject;
+}




More information about the jboss-svn-commits mailing list