[jboss-svn-commits] JBL Code SVN: r29314 - in labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM: src/main/java/uk/ac/ncl/sdia/a8905943/aspects and 15 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Fri Sep 11 14:12:04 EDT 2009


Author: whitingjr
Date: 2009-09-11 14:12:03 -0400 (Fri, 11 Sep 2009)
New Revision: 29314

Added:
   labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/aspects/STMDisabledAspect.java
   labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/stm/activation/
   labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/stm/activation/STMDisabled.java
   labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/stm/object/Updater.java
   labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/stm/object/update/
   labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/stm/object/update/FieldUpdate.java
   labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/stm/object/update/IdentityFieldUpdate.java
   labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/stm/object/update/ModelUpdate.java
   labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/stm/object/update/NullFieldUpdate.java
   labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/stm/query/xpath/
   labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/stm/query/xpath/extension/
   labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/stm/query/xpath/extension/NotInExtensionFunction.java
Modified:
   labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/pom.xml
   labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/entitymanager/STMEntityManagerImpl.java
   labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/impl/STMTransactionImpl.java
   labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/isolation/RepeatableReadIsolationImpl.java
   labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/stm/STM.java
   labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/stm/field/FieldWriteParameter.java
   labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/stm/field/IdentityFieldWriteParameter.java
   labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/stm/object/TransactedObjectReference.java
   labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/stm/query/STMQueryImpl.java
   labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/resources/META-INF/jboss-aop.xml
   labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/test/java/uk/ac/ncl/sdia/a8905943/entitymanager/TestSTMEntityManagerImpl.java
   labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/test/java/uk/ac/ncl/sdia/a8905943/stm/TestUnitModelReplicatedMemory.java
   labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/test/java/uk/ac/ncl/sdia/a8905943/stm/transaction/TestUnitTransactionManager.java
Log:
Added test cases. 

Modified: labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/pom.xml
===================================================================
--- labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/pom.xml	2009-09-11 14:29:09 UTC (rev 29313)
+++ labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/pom.xml	2009-09-11 18:12:03 UTC (rev 29314)
@@ -57,6 +57,8 @@
 								<include>uk/ac/ncl/sdia/a8905943/model/LeccyCar.class</include>
 								<include>uk/ac/ncl/sdia/a8905943/aspects/STMWriteAspect.class</include>
 								<include>uk/ac/ncl/sdia/a8905943/aspects/STMReadAspect.class</include>
+								<include>uk/ac/ncl/sdia/a8905943/entitymanager/STMEntityManagerImpl.class</include>
+								<include>uk/ac/ncl/sdia/a8905943/aspects/STMDisabledAspect.class</include>
 							</includes>
 							<report>false</report>
 						</configuration>

Added: labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/aspects/STMDisabledAspect.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/aspects/STMDisabledAspect.java	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/aspects/STMDisabledAspect.java	2009-09-11 18:12:03 UTC (rev 29314)
@@ -0,0 +1,52 @@
+ /*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, 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 uk.ac.ncl.sdia.a8905943.aspects;
+
+import org.jboss.aop.joinpoint.MethodInvocation;
+
+import uk.ac.ncl.sdia.a8905943.stm.STM;
+import uk.ac.ncl.sdia.a8905943.stm.annotation.InjectedSTM;
+
+/**
+ * The purpose of this object is to turn control the behaviour
+ * flag on the STM proxy object.
+ * 
+ * 
+ * @author <a href="whitingjr at hotmail.com">Jeremy Whiting</a>
+ * @version $Revision: 1.1 $
+ */
+public class STMDisabledAspect
+{
+   @InjectedSTM
+   private STM stm;
+   
+   public Object nonTransactional(MethodInvocation invocation) 
+   throws Throwable
+   {
+      this.stm.setTrackingStatus(Boolean.FALSE);
+      Object returnValue = invocation.invokeNext();
+      this.stm.setTrackingStatus(Boolean.TRUE);
+      return returnValue;
+   }
+
+}

Modified: labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/entitymanager/STMEntityManagerImpl.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/entitymanager/STMEntityManagerImpl.java	2009-09-11 14:29:09 UTC (rev 29313)
+++ labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/entitymanager/STMEntityManagerImpl.java	2009-09-11 18:12:03 UTC (rev 29314)
@@ -29,7 +29,7 @@
 import uk.ac.ncl.sdia.a8905943.handle.HandleUtils;
 import uk.ac.ncl.sdia.a8905943.handle.exception.FieldNotFoundException;
 import uk.ac.ncl.sdia.a8905943.persistence.jdbc.STMConnection;
-import uk.ac.ncl.sdia.a8905943.stm.field.FieldWriteParameter;
+import uk.ac.ncl.sdia.a8905943.stm.activation.STMDisabled;
 import uk.ac.ncl.sdia.a8905943.stm.field.IdentityFieldWriteParameter;
 import uk.ac.ncl.sdia.a8905943.stm.query.STMQueryImpl;
 
@@ -44,6 +44,9 @@
          .getLogger(STMEntityManagerImpl.class);
 
    private boolean isOpen = false;
+   
+   private JXPathContext xpathContext ;
+   private static final String IDENTITY_VALUE = "identityValue";
 
    @Override
    public void clear()
@@ -79,6 +82,7 @@
     * verify if the entity exists in the model store.
     */
    @Override
+   @STMDisabled
    public boolean contains(Object entity)
    {// check the memory store for the
       // presence of the managed entity
@@ -97,22 +101,20 @@
             entityUniqueIdentity = fieldUtils.getValue(idField, entity);
             
             /* Check the field store for the identity field first, doing this detects if the entity has been removed beforehand. The model store*/
-            
-            JXPathContext context = JXPathContext.newContext(getSTMConnection()
-                  .getSTM());
-            context.setLenient(true);
+            this.xpathContext.setLenient(true);
             StringBuffer query = new StringBuffer();
             query.append("model/").append(entityFQCN).append("[");
             query.append(idField.getName()).append("=$identityValue]");
-            context.getVariables().declareVariable("identityValue",
+            this.xpathContext.getVariables().declareVariable(IDENTITY_VALUE,
                   entityUniqueIdentity);
             if (logger.isTraceEnabled())
             {
                logger.trace("executing query [" + query.toString() + "]");
             }
-            returnValue = (null == context.getValue(query.toString()) ? Boolean.FALSE
+            returnValue = (null == this.xpathContext.getValue(query.toString()) ? Boolean.FALSE
                   .booleanValue()
                   : Boolean.TRUE.booleanValue());
+            this.xpathContext.getVariables().undeclareVariable(IDENTITY_VALUE);
          }
          catch (FieldNotFoundException fnfe)
          {
@@ -177,9 +179,7 @@
       Query returnValue = null;
       if (null != qlString)
       {
-         JXPathContext context = JXPathContext.newContext(this
-               .getSTMConnection().getSTM());
-         returnValue = new STMQueryImpl(context, qlString);
+         returnValue = new STMQueryImpl(this.xpathContext, qlString);
       }
       else
       {
@@ -199,6 +199,7 @@
     * This method does not hit the STM system and only uses reflection to create
     * an instance of the entity.
     */
+   @STMDisabled
    public <T> T find(Class<T> entityClass, Object primaryKey)
    {
       detectectClosedConnection();
@@ -379,15 +380,13 @@
          Long identity = fieldUtils.getValue(identityField, entity);
          long fieldStoreHandle = new HandleUtils().getHandle(entity.getClass(), identity, identityField.getName());
          
-         IdentityFieldWriteParameter write = new IdentityFieldWriteParameter(fieldStoreHandle, nullref, identity);
+         IdentityFieldWriteParameter write = new IdentityFieldWriteParameter(fieldStoreHandle, nullref, identity, entity.getClass());
          this.getSTMConnection().getSTM().write(write);
       }
       catch (FieldNotFoundException fnfe)
       {
          logger.error(fnfe.getMessage());
       }
-      
-      
    }
 
    @Override
@@ -398,15 +397,12 @@
 
    }
 
-   private STMEntityManagerImpl()
-   {
-   }
 
    public STMEntityManagerImpl(Connection connection)
    {
-      this();
       this.connection = connection;
       STMFactory.getFactoryInstance().allocate(getSTMConnection().getSTM());
+      this.xpathContext = JXPathContext.newContext(getSTMConnection().getSTM());
    }
 
    public STMConnection getSTMConnection()

Modified: labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/impl/STMTransactionImpl.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/impl/STMTransactionImpl.java	2009-09-11 14:29:09 UTC (rev 29313)
+++ labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/impl/STMTransactionImpl.java	2009-09-11 18:12:03 UTC (rev 29314)
@@ -38,8 +38,9 @@
    protected volatile int status = Status.STATUS_NO_TRANSACTION;
    protected final Map<Long, TransactedObjectReference> deferredReads = new HashMap<Long, TransactedObjectReference>();
    protected final Map<Long, TransactedObjectReference> deferredWrites = new HashMap<Long, TransactedObjectReference>();
-   protected final Set<Long> deletedEntities = new HashSet<Long>();
-   public Set<Long> getDeletedEntities()
+   protected final Map<String, Set<Long>> deletedEntities = new HashMap<String, Set<Long>>();
+   
+   public Map<String, Set<Long>> getDeletedEntities()
    {
       return deletedEntities;
    }

Modified: labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/isolation/RepeatableReadIsolationImpl.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/isolation/RepeatableReadIsolationImpl.java	2009-09-11 14:29:09 UTC (rev 29313)
+++ labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/isolation/RepeatableReadIsolationImpl.java	2009-09-11 18:12:03 UTC (rev 29314)
@@ -1,5 +1,8 @@
 package uk.ac.ncl.sdia.a8905943.isolation;
 
+import java.util.HashSet;
+import java.util.Set;
+
 import org.apache.log4j.Logger;
 
 import uk.ac.ncl.sdia.a8905943.stm.field.FieldReadParameter;
@@ -34,7 +37,7 @@
       if (fieldRead.getWrites().containsKey(fieldRead.getHandle()))
       {// found
          returnValue = fieldRead.getWrites().get(fieldRead.getHandle()).getValue();
-         if (!fieldRead.getReads().containsKey(fieldRead.getHandle()))
+         if (!fieldRead.getReads().containsKey(fieldRead.getHandle()) && fieldRead.isTransactional())
          {// in case the field has not previously been read
             fieldRead.getReads().put(fieldRead.getHandle(), fieldRead.getWrites().get(fieldRead.getHandle()));
          }
@@ -55,7 +58,11 @@
             logger.info("Field not found.");
          }
          // log the read in the read history, even if the return value is null
-         fieldRead.getReads().put(fieldRead.getHandle(), new TransactedObjectReference(fieldRead.getHandle() , returnValue , fieldRead.getVersion()));
+         if (fieldRead.isTransactional())
+         {
+            fieldRead.getReads().put(fieldRead.getHandle(), new TransactedObjectReference(fieldRead.getHandle() , returnValue , fieldRead.getVersion()));
+         }
+         
       }
       return returnValue;
    }
@@ -64,30 +71,34 @@
    public Boolean write(FieldWriteParameter fieldWrite)
    {
       Boolean returnValue = null;
-      if (null != fieldWrite.getNewObject())
-      {
-         TransactedObjectReference fieldReference = null;
-         if (fieldWrite.getWrites().containsKey(fieldWrite.getHandle()))
-         {// this field has been written before, overwrite it
-            fieldReference = fieldWrite.getWrites().get(fieldWrite.getHandle());
-            fieldReference.setValue(fieldWrite.getNewObject());
+      TransactedObjectReference fieldReference = null;
+      if (fieldWrite.getWrites().containsKey(fieldWrite.getHandle()))
+      {// this field has been written before, overwrite it
+         fieldReference = fieldWrite.getWrites().get(fieldWrite.getHandle());
+         fieldReference.setValue(fieldWrite.getNewObject());
+      }
+      else
+      {// new write of field 
+         fieldReference = new TransactedObjectReference(fieldWrite.getHandle(), fieldWrite.getNewObject(), fieldWrite.getVersion());
+         fieldWrite.getWrites().put(fieldWrite.getHandle(), fieldReference);
+      }
+      if (null == fieldWrite.getNewObject() && fieldWrite.isIdentityField())
+      {// this is an entity being removed from the persistency system
+         Set<Long> removedEntityIdentities = null;
+         if (fieldWrite.getWrittenIdentityFields().containsKey(fieldWrite.getClass().getName()))
+         {// previous removal
+            removedEntityIdentities = fieldWrite.getWrittenIdentityFields().get(fieldWrite.getClass().getName());
          }
          else
-         {// new write of field
-            fieldReference = new TransactedObjectReference(fieldWrite.getHandle(), fieldWrite.getNewObject(), fieldWrite.getVersion());
-            fieldWrite.getWrites().put(fieldWrite.getHandle(), fieldReference);
+         {// first removal for entity type
+            removedEntityIdentities = new HashSet<Long>();
+            fieldWrite.getWrittenIdentityFields().put(fieldWrite.getClass().getName(), removedEntityIdentities);
          }
-         if (null == fieldWrite.getNewObject() && fieldWrite.isIdentityField())
-         {
-            fieldWrite.getWrittenIdentityFields().add(fieldWrite.getIdentity());
-         }
-         
-         returnValue = Boolean.TRUE;
+         removedEntityIdentities.add(fieldWrite.getIdentity());
       }
-      else
-      {// place in the store a transacted object representing a null 
-         //TODO:jrw complete this
-      }
+      
+      returnValue = Boolean.TRUE;
+   
       return returnValue;
    }
 }

Modified: labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/stm/STM.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/stm/STM.java	2009-09-11 14:29:09 UTC (rev 29313)
+++ labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/stm/STM.java	2009-09-11 18:12:03 UTC (rev 29314)
@@ -40,6 +40,7 @@
    private static final int RETRY_COUNT = 2000;
    private static final int DEFAULT_TIMEOUT = 5000; // 5 seconds
    private static final long EXPIRE_BEFORE_TIMEOUT = 2000;
+   private ThreadLocal<Boolean> trackingEnabled = new ThreadLocal<Boolean>(); // defaulted to true
    
    /**
     * This method is where transactional updates are made..
@@ -57,9 +58,9 @@
    }
    public Object read( FieldReadParameter fieldRead)
    {
+      fieldRead.setTransactional(this.trackingEnabled.get().booleanValue());
       fieldRead.setObjectStore(this.transactedFieldMemory);
       STMTransaction transaction = TransactionFactory.getFactory().getCurrentTransaction(false);
-      
       return transaction.read(fieldRead); 
    }
 
@@ -68,6 +69,7 @@
       this.databaseName = name;
       this.transactedFieldMemory = transactedFieldMemory;
       this.transactedModelMemory = transactedModelMemory;
+      this.trackingEnabled.set(Boolean.TRUE);
    }
    
    @Override
@@ -226,9 +228,18 @@
       {
          this.timeoutPeriod.set(timeout);
       }
-      
    }
    
+   public boolean isTrackingEnabled()
+   {
+      return this.trackingEnabled.get();
+   }
+   
+   public void setTrackingStatus(Boolean status)
+   {
+      this.trackingEnabled.set(status);
+   }
+   
    public Map<Long, TransactedObjectReference> getFieldStore()
    {
       return this.transactedFieldMemory;

Added: labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/stm/activation/STMDisabled.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/stm/activation/STMDisabled.java	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/stm/activation/STMDisabled.java	2009-09-11 18:12:03 UTC (rev 29314)
@@ -0,0 +1,44 @@
+ /*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, 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 uk.ac.ncl.sdia.a8905943.stm.activation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * 
+ * Use this method annotation to disable STM activity for the duration 
+ * of this method block. When control is returned the STM will be 
+ * active again. 
+ * 
+ * @author <a href="whitingjr at hotmail.com">Jeremy Whiting</a>
+ * @version $Revision: 1.1 $
+ */
+ at Target ({ElementType.METHOD})
+ at Retention(RetentionPolicy.RUNTIME)
+public @interface STMDisabled
+{
+
+}

Modified: labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/stm/field/FieldWriteParameter.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/stm/field/FieldWriteParameter.java	2009-09-11 14:29:09 UTC (rev 29313)
+++ labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/stm/field/FieldWriteParameter.java	2009-09-11 18:12:03 UTC (rev 29314)
@@ -6,6 +6,8 @@
  */
 package uk.ac.ncl.sdia.a8905943.stm.field;
 
+import java.util.HashMap;
+import java.util.Map;
 import java.util.Set;
 
 import uk.ac.ncl.sdia.a8905943.isolation.AbstractFieldParameter;
@@ -14,16 +16,19 @@
 public class FieldWriteParameter extends AbstractFieldParameter
 {
    private Object newObject;
-   private Set<Long> writtenIdentityFields;
+   private Map<String, Set<Long>> writtenIdentityFields = new HashMap<String, Set<Long>>();
 
-   public Set<Long> getWrittenIdentityFields()
+   public Map<String, Set<Long>> getWrittenIdentityFields()
    {
       return writtenIdentityFields;
    }
-   public void setWrittenIdentityFields(Set<Long> writtenIdentityFields)
+
+   public void setWrittenIdentityFields(
+         Map<String, Set<Long>> writtenIdentityFields)
    {
       this.writtenIdentityFields = writtenIdentityFields;
    }
+
    public Object getNewObject()
    {
       return newObject;

Modified: labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/stm/field/IdentityFieldWriteParameter.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/stm/field/IdentityFieldWriteParameter.java	2009-09-11 14:29:09 UTC (rev 29313)
+++ labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/stm/field/IdentityFieldWriteParameter.java	2009-09-11 18:12:03 UTC (rev 29314)
@@ -1,39 +1,54 @@
- /*
-  * JBoss, Home of Professional Open Source
-  * Copyright 2005, 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.
-  */
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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 uk.ac.ncl.sdia.a8905943.stm.field;
 
+
 public final class IdentityFieldWriteParameter extends FieldWriteParameter
 {
+   private Class type;
+   
    @Override
    public boolean isIdentityField()
    {
       return true;
    }
 
-   public IdentityFieldWriteParameter(long handle, Object newObject, Long identity)
+   public IdentityFieldWriteParameter(long handle, Object newObject,
+         Long identity, Class type)
    {
       super(handle, newObject);
       setIdentity(identity);
+      setType(type);
    }
 
+   public Class getType()
+   {
+      return type;
+   }
+
+   public void setType(Class type)
+   {
+      this.type = type;
+   }
+
 }

Modified: labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/stm/object/TransactedObjectReference.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/stm/object/TransactedObjectReference.java	2009-09-11 14:29:09 UTC (rev 29313)
+++ labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/stm/object/TransactedObjectReference.java	2009-09-11 18:12:03 UTC (rev 29314)
@@ -19,10 +19,10 @@
    private static final long serialVersionUID = 2497531722707627406L;
    final Long lookupIdentity;
    protected AtomicReference<Object> value = new AtomicReference<Object>();
-   //protected AtomicLong nextIdentity = new AtomicLong();
    protected AtomicLong version = new AtomicLong();
    transient final ReentrantLock prepared = new ReentrantLock(true);
    protected transient Long preparedVersion ;
+   private Updater updater;
    
    public TransactedObjectReference(Long identity, Object value, long version)
    {
@@ -40,16 +40,6 @@
    {
       return lookupIdentity;
    }
-/*
-   public Long getNextIdentity()
-   {
-      return nextIdentity.get();
-   }
-
-   public void setNextIdentity(Long nextIdentity)
-   {
-      this.nextIdentity.set( nextIdentity);
-   }*/
    public long getVersion()
    {
       return version.get();

Added: labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/stm/object/Updater.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/stm/object/Updater.java	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/stm/object/Updater.java	2009-09-11 18:12:03 UTC (rev 29314)
@@ -0,0 +1,28 @@
+ /*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, 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 uk.ac.ncl.sdia.a8905943.stm.object;
+
+public interface Updater
+{
+   public void update();
+}

Added: labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/stm/object/update/FieldUpdate.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/stm/object/update/FieldUpdate.java	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/stm/object/update/FieldUpdate.java	2009-09-11 18:12:03 UTC (rev 29314)
@@ -0,0 +1,45 @@
+ /*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, 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 uk.ac.ncl.sdia.a8905943.stm.object.update;
+
+import uk.ac.ncl.sdia.a8905943.stm.object.TransactedObjectReference;
+import uk.ac.ncl.sdia.a8905943.stm.object.Updater;
+
+public class FieldUpdate implements Updater
+{
+   private final TransactedObjectReference write;
+   private final TransactedObjectReference shared; 
+   
+   @Override
+   public void update()
+   {
+      // FIXME update
+      
+   }
+   public FieldUpdate(TransactedObjectReference writeField, TransactedObjectReference sharedField)
+   {
+      this.write = writeField;
+      this.shared = sharedField;
+   }
+
+}

Added: labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/stm/object/update/IdentityFieldUpdate.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/stm/object/update/IdentityFieldUpdate.java	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/stm/object/update/IdentityFieldUpdate.java	2009-09-11 18:12:03 UTC (rev 29314)
@@ -0,0 +1,37 @@
+ /*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, 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 uk.ac.ncl.sdia.a8905943.stm.object.update;
+
+import uk.ac.ncl.sdia.a8905943.stm.object.TransactedObjectReference;
+
+public class IdentityFieldUpdate extends FieldUpdate
+{
+
+   public IdentityFieldUpdate(TransactedObjectReference writeField,
+         TransactedObjectReference sharedField)
+   {
+      super(writeField, sharedField);
+   }
+
+   
+}

Added: labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/stm/object/update/ModelUpdate.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/stm/object/update/ModelUpdate.java	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/stm/object/update/ModelUpdate.java	2009-09-11 18:12:03 UTC (rev 29314)
@@ -0,0 +1,37 @@
+ /*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, 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 uk.ac.ncl.sdia.a8905943.stm.object.update;
+
+import uk.ac.ncl.sdia.a8905943.stm.object.Updater;
+
+public class ModelUpdate implements Updater
+{
+
+   @Override
+   public void update()
+   {
+      // FIXME update
+
+   }
+
+}

Added: labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/stm/object/update/NullFieldUpdate.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/stm/object/update/NullFieldUpdate.java	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/stm/object/update/NullFieldUpdate.java	2009-09-11 18:12:03 UTC (rev 29314)
@@ -0,0 +1,35 @@
+ /*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, 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 uk.ac.ncl.sdia.a8905943.stm.object.update;
+
+import uk.ac.ncl.sdia.a8905943.stm.object.TransactedObjectReference;
+
+public class NullFieldUpdate extends FieldUpdate
+{
+
+   public NullFieldUpdate(TransactedObjectReference writeField, TransactedObjectReference sharedField)
+   {
+      super(writeField, sharedField);
+
+   }
+}

Modified: labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/stm/query/STMQueryImpl.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/stm/query/STMQueryImpl.java	2009-09-11 14:29:09 UTC (rev 29313)
+++ labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/stm/query/STMQueryImpl.java	2009-09-11 18:12:03 UTC (rev 29314)
@@ -22,8 +22,10 @@
 
 package uk.ac.ncl.sdia.a8905943.stm.query;
 
+import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.Date;
+import java.util.Iterator;
 import java.util.List;
 
 import javax.persistence.FlushModeType;
@@ -32,8 +34,11 @@
 import javax.persistence.Query;
 import javax.persistence.TemporalType;
 
+import org.apache.commons.collections.IteratorUtils;
 import org.apache.commons.jxpath.JXPathContext;
 
+import uk.ac.ncl.sdia.a8905943.stm.activation.STMDisabled;
+
 public class STMQueryImpl implements Query {
 
 	private final String query;
@@ -47,9 +52,9 @@
 	}
 
 	@Override
+	@STMDisabled
 	public List getResultList() {
-		// FIXME getResultList
-		return null;
+		return IteratorUtils.toList(this.xpathContext.iterate(this.query));
 	}
 
 	/**

Added: labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/stm/query/xpath/extension/NotInExtensionFunction.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/stm/query/xpath/extension/NotInExtensionFunction.java	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/stm/query/xpath/extension/NotInExtensionFunction.java	2009-09-11 18:12:03 UTC (rev 29314)
@@ -0,0 +1,63 @@
+ /*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, 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 uk.ac.ncl.sdia.a8905943.stm.query.xpath.extension;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.commons.jxpath.ExpressionContext;
+import org.apache.commons.lang.StringUtils;
+import org.apache.log4j.Logger;
+
+public class NotInExtensionFunction
+{
+   private static final Logger logger = Logger.getLogger(NotInExtensionFunction.class);
+   /**
+    * This method provides the sql like two expression functions NOT, IN (...).
+    * Use this function to exclude values. 
+    * 
+    * @param expressionContext
+    * @return
+    */
+   public static boolean notIn(ExpressionContext expressionContext, String value)
+   {
+      boolean returnValue = true;
+      
+      logger.info("VAlue of exclusion variable is ["+expressionContext.getJXPathContext().getVariables().getVariable("exclusionList")+"]");
+      //Object excludedVariable = expressionContext.getJXPathContext().getVariables().getVariable("exclusionList");
+      //List excludedList = (List)excludedVariable;
+      List<String> exclusionList =  Arrays.asList( StringUtils.split((String)expressionContext.getJXPathContext().getVariables().getVariable("exclusionList"), ","));
+      for (String excludedValue : exclusionList)
+      {
+         if (StringUtils.equals(excludedValue, value))
+         {
+            returnValue = false;
+         }
+      }
+      return returnValue;
+   }
+
+   public NotInExtensionFunction()
+   {
+   }
+}

Modified: labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/resources/META-INF/jboss-aop.xml
===================================================================
--- labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/resources/META-INF/jboss-aop.xml	2009-09-11 14:29:09 UTC (rev 29313)
+++ labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/resources/META-INF/jboss-aop.xml	2009-09-11 18:12:03 UTC (rev 29314)
@@ -4,8 +4,8 @@
 	<aspect name="stmwriteaspect" class="uk.ac.ncl.sdia.a8905943.aspects.STMWriteAspect" />
 	<aspect name="stminjectionaspect"
 		class="uk.ac.ncl.sdia.a8905943.aspects.STMInjectionAspect" />
+	<aspect name="stmdisabled" class="uk.ac.ncl.sdia.a8905943.aspects.STMDisabledAspect"/>
 
-
    <bind
       pointcut="execution(* *->@uk.ac.ncl.sdia.a8905943.aspects.annotation.STMWriteable(..))">
       <advice name="stmwrite" aspect="stmwriteaspect" />
@@ -20,4 +20,10 @@
       pointcut="field(uk.ac.ncl.sdia.a8905943.stm.STM *->@uk.ac.ncl.sdia.a8905943.stm.annotation.InjectedSTM )">
       <advice name="access" aspect="stminjectionaspect" />
    </bind>
+   
+   <bind
+      pointcut="execution(* *->@uk.ac.ncl.sdia.a8905943.stm.activation.STMDisabled(..) )">
+      <advice name="nonTransactional" aspect="stmdisabled" />
+   </bind>
+   
 </aop>

Modified: labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/test/java/uk/ac/ncl/sdia/a8905943/entitymanager/TestSTMEntityManagerImpl.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/test/java/uk/ac/ncl/sdia/a8905943/entitymanager/TestSTMEntityManagerImpl.java	2009-09-11 14:29:09 UTC (rev 29313)
+++ labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/test/java/uk/ac/ncl/sdia/a8905943/entitymanager/TestSTMEntityManagerImpl.java	2009-09-11 18:12:03 UTC (rev 29314)
@@ -14,11 +14,13 @@
 import org.apache.commons.jxpath.JXPathContext;
 import org.junit.Test;
 
+import uk.ac.ncl.sdia.a8905943.factory.TransactionFactory;
 import uk.ac.ncl.sdia.a8905943.model.LeccyCar;
 import uk.ac.ncl.sdia.a8905943.persistence.jdbc.STMConnection;
 import uk.ac.ncl.sdia.a8905943.persistence.xa.STMXAConnectionImpl;
 import uk.ac.ncl.sdia.a8905943.persistence.xa.STMXADatasourceImpl;
 import uk.ac.ncl.sdia.a8905943.stm.AbstractUnitT;
+import uk.ac.ncl.sdia.a8905943.stm.transaction.STMTransaction;
 
 public class TestSTMEntityManagerImpl extends AbstractUnitT {
 	private STMEntityManagerImpl entityManager;
@@ -123,7 +125,8 @@
 		Assert.assertNotNull(foundEntity);
 		Assert.assertNotNull(foundEntity.getId());
 		Assert.assertEquals(foundEntity.getId(), carId	);
-		
+		STMTransaction transaction = TransactionFactory.getFactory().getCurrentTransaction(false);
+		Assert.assertEquals(0, transaction.getDeferredReads().size());
 	}
 	
 	@Test
@@ -165,6 +168,7 @@
       
       this.entityManager.remove(car);
       Query query = this.entityManager.createQuery("model/"+car.getClass().getName());
+      Assert.assertNotNull(query);
       List resultSet = query.getResultList();
       Assert.assertNotNull(resultSet);
       Assert.assertEquals(0, resultSet.size());

Modified: labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/test/java/uk/ac/ncl/sdia/a8905943/stm/TestUnitModelReplicatedMemory.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/test/java/uk/ac/ncl/sdia/a8905943/stm/TestUnitModelReplicatedMemory.java	2009-09-11 14:29:09 UTC (rev 29313)
+++ labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/test/java/uk/ac/ncl/sdia/a8905943/stm/TestUnitModelReplicatedMemory.java	2009-09-11 18:12:03 UTC (rev 29314)
@@ -7,16 +7,20 @@
 package uk.ac.ncl.sdia.a8905943.stm;
 
 import java.util.ArrayList;
+import java.util.Iterator;
 import java.util.List;
 
 import junit.framework.Assert;
 
+import org.apache.commons.collections.IteratorUtils;
+import org.apache.commons.jxpath.ClassFunctions;
 import org.apache.commons.jxpath.JXPathContext;
 import org.junit.Before;
 import org.junit.Test;
 
 import uk.ac.ncl.sdia.a8905943.model.Car;
 import uk.ac.ncl.sdia.a8905943.model.untransactional.Fish;
+import uk.ac.ncl.sdia.a8905943.stm.query.xpath.extension.NotInExtensionFunction;
 
 /**
  * This is a test case to try out searches on the model store of
@@ -86,8 +90,32 @@
       Assert.assertEquals("MG", car.getMake());
       Assert.assertEquals (new Long(2) , car.getId());
    }
+   @Test
+   public void testCheckQueryWithExclusion()
+   {
+      JXPathContext context = JXPathContext.newContext(this.stm);
+      Iterator<Car> carIterator = context.iterate("model/uk.ac.ncl.sdia.a8905943.model.Car[make!='MG']");
+      Assert.assertNotNull(carIterator);
+      List carList = IteratorUtils.toList(carIterator);
+      Assert.assertNotNull(carList);
+      Assert.assertEquals(2, carList.size());
+   }
    
+   @Test
+   public void testCheckQueryWithMultipleExclusion()
+   {
+      JXPathContext context = JXPathContext.newContext(this.stm);
+      context.setFunctions(new ClassFunctions(NotInExtensionFunction.class, "query-func"));
+      context.getVariables().declareVariable("exclusionList", "MG,Ford");
+      Iterator<Car> carIterator = context.iterate("model/uk.ac.ncl.sdia.a8905943.model.Car[query-func:notIn(make)]");
+      Assert.assertNotNull(carIterator);
+      List<Car> carList = IteratorUtils.toList(carIterator);
+      Assert.assertNotNull(carList);
+      Assert.assertEquals(1, carList.size());
+      Assert.assertEquals("Jaguar", carList.get(0).getMake());
+   }
    
+   
    @Before
    public void setUp()
    {

Modified: labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/test/java/uk/ac/ncl/sdia/a8905943/stm/transaction/TestUnitTransactionManager.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/test/java/uk/ac/ncl/sdia/a8905943/stm/transaction/TestUnitTransactionManager.java	2009-09-11 14:29:09 UTC (rev 29313)
+++ labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/test/java/uk/ac/ncl/sdia/a8905943/stm/transaction/TestUnitTransactionManager.java	2009-09-11 18:12:03 UTC (rev 29314)
@@ -244,6 +244,7 @@
       public ConflictingRunnableTransaction(STM stmref)
       {
          this.stm = stmref;
+         this.stm.setTrackingStatus(Boolean.TRUE);
       }
       
    }



More information about the jboss-svn-commits mailing list