[CVS nanning] transaction required interceptor added

Lecando Shared <[email protected]> Thu, 11 Sep 2003 06:25:38 -0500
Newsgroups gmane.comp.java.nanning.devel
Message-ID <[email protected]>
<html>
<head>
<style><!--
  body {background-color:#ffffff;}
  .file {border:1px solid #eeeeee;margin-top:1em;margin-bottom:1em;}
  .pathname {font-family:monospace; float:right;}
  .fileheader {margin-bottom:.5em;}
  .diff {margin:0;}
  .tasklist {padding:4px;border:1px dashed #000000;margin-top:1em;}
  .tasklist ul {margin-top:0;margin-bottom:0;}
  tr.alt {background-color:#eeeeee}
  #added {background-color:#ddffdd;}
  #addedchars {background-color:#99ff99;font-weight:bolder;}
  tr.alt #added {background-color:#ccf7cc;}
  #removed {background-color:#ffdddd;}
  #removedchars {background-color:#ff9999;font-weight:bolder;}
  tr.alt #removed {background-color:#f7cccc;}
  #info {color:#888888;}
  #context {background-color:#eeeeee;}
  td {padding-left:.3em;padding-right:.3em;}
  tr.head {border-bottom-width:1px;border-bottom-style:solid;}
  tr.head td {padding:0;padding-top:.2em;}
  .task {background-color:#ffff00;}
  .comment {padding:4px;border:1px dashed #000000;background-color:#ffffdd}
  .error {color:red;}
  hr {border-width:0px;height:2px;background:black;}
--></style>
</head>
<body>
<table cellspacing="0" cellpadding="0" border="0" rules="cols">
<tr class="head"><td colspan="4">Commit in <b><tt>nanning/src</tt></b> on <span id="info">MAIN</span></td></tr>
<tr><td><tt>frameworks/prevayler/src/main/org/codehaus/nanning/prevayler/<a href="#file1"><span id="added">TransactionRequiredException.java</span></a></tt></td><td align="right" id="added">+4</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr class="alt"><td><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/<a href="#file2">BasicIdentifyingSystem.java</a></tt></td><td align="right" id="added">+11</td><td align="right" id="removed">-4</td><td nowrap="nowrap" align="center">1.5 -&gt; 1.6</td></tr>
<tr><td><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/<a href="#file3">Identifiable.java</a></tt></td><td align="right" id="added">+1</td><td align="right" id="removed">-1</td><td nowrap="nowrap" align="center">1.1 -&gt; 1.2</td></tr>
<tr class="alt"><td><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/<a href="#file4">IdentifiableImpl.java</a></tt></td><td align="right" id="added">+1</td><td align="right" id="removed">-1</td><td nowrap="nowrap" align="center">1.1 -&gt; 1.2</td></tr>
<tr><td><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/<a href="#file5">PrevaylerAspect.java</a></tt></td><td align="right" id="added">+53</td><td align="right" id="removed">-9</td><td nowrap="nowrap" align="center">1.4 -&gt; 1.5</td></tr>
<tr class="alt"><td><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/<a href="#file6">RegisterObjectInterceptor.java</a></tt></td><td align="right" id="added">+1</td><td align="right" id="removed">-3</td><td nowrap="nowrap" align="center">1.3 -&gt; 1.4</td></tr>
<tr><td><tt>frameworks/prevayler/src/test/org/codehaus/nanning/prevayler/<a href="#file7">PrevaylerTest.java</a></tt></td><td align="right" id="added">+41</td><td align="right" id="removed">-18</td><td nowrap="nowrap" align="center">1.9 -&gt; 1.10</td></tr>
<tr class="alt"><td><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/<a href="#file8"><span id="removed">TestUnsupportedTransaction.java</span></a></tt></td><td></td><td align="right" id="removed">-8</td><td nowrap="nowrap">1.1 removed</td></tr>
<tr><td><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/<a href="#file9"><span id="removed">TestUnsupportedTransactionImpl.java</span></a></tt></td><td></td><td align="right" id="removed">-14</td><td nowrap="nowrap">1.1 removed</td></tr>
<tr class="alt"><td><tt>frameworks/remote/src/main/org/codehaus/nanning/remote/<a href="#file10">RemoteMarshaller.java</a></tt></td><td align="right" id="added">+6</td><td align="right" id="removed">-6</td><td nowrap="nowrap" align="center">1.4 -&gt; 1.5</td></tr>
<tr><td><tt>frameworks/remote/src/test/org/codehaus/nanning/remote/<a href="#file11">MyObject.java</a></tt></td><td align="right" id="added">+1</td><td></td><td nowrap="nowrap" align="center">1.2 -&gt; 1.3</td></tr>
<tr class="alt"><td><tt>test/org/codehaus/nanning/<a href="#file12">PerformanceTest.java</a></tt></td><td align="right" id="added">+16</td><td align="right" id="removed">-12</td><td nowrap="nowrap" align="center">1.2 -&gt; 1.3</td></tr>
<tr><td></td><td align="right" id="added">+135</td><td align="right" id="removed">-76</td><td></td></tr>
</table>
<small id="info">1 added + 2 removed + 9 modified, total 12 files</small><br />
<pre class="comment">
transaction required interceptor added
</pre>
<hr /><a name="file1" /><div class="file">
<span class="pathname" id="added">nanning/src/frameworks/prevayler/src/main/org/codehaus/nanning/prevayler<br /></span>
<div class="fileheader" id="added"><big><b>TransactionRequiredException.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N TransactionRequiredException.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ TransactionRequiredException.java	11 Sep 2003 11:25:37 -0000	1.1
@@ -0,0 +1,4 @@
</small></pre><pre class="diff" id="added">+package org.codehaus.nanning.prevayler;
+
+public class TransactionRequiredException extends RuntimeException {
+}
</pre></div>
<hr /><a name="file2" /><div class="file">
<span class="pathname">nanning/src/frameworks/prevayler/src/main/org/codehaus/nanning/prevayler<br /></span>
<div class="fileheader"><big><b>BasicIdentifyingSystem.java</b></big> <small id="info">1.5 -&gt; 1.6</small></div>
<pre class="diff"><small id="info">diff -u -r1.5 -r1.6
--- BasicIdentifyingSystem.java	10 Sep 2003 12:24:25 -0000	1.5
+++ BasicIdentifyingSystem.java	11 Sep 2003 11:25:37 -0000	1.6
@@ -1,9 +1,11 @@
</small></pre><pre class="diff" id="context"> package org.codehaus.nanning.prevayler;
 
</pre><pre class="diff" id="removed">-import java.io.*;
</pre><pre class="diff" id="added">+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
</pre><pre class="diff" id="context"> import java.lang.ref.ReferenceQueue;
 import java.lang.ref.SoftReference;
</pre><pre class="diff" id="removed">-import java.lang.ref.Reference;
</pre><pre class="diff" id="context"> import java.util.*;
 
 import org.apache.commons.logging.Log;
</pre><pre class="diff"><small id="info">@@ -64,7 +66,6 @@
</small></pre><pre class="diff" id="context">             throw new IllegalStateException("You have to be inside a transaction to register objects");
         }
 
</pre><pre class="diff" id="removed">-
</pre><pre class="diff" id="context">         if (!(object instanceof Identifiable)) {
             throw new AssertionException("Object is not instance of Identifiable");
         }
</pre><pre class="diff"><small id="info">@@ -72,11 +73,17 @@
</small></pre><pre class="diff" id="context">         long id = getNextId();
 
         Identifiable identifiable = (Identifiable) object;
</pre><pre class="diff" id="added">+
+        if (identifiable.hasObjectID()) {
+            throw new AssertionException("Object already registered");
+        }
+
</pre><pre class="diff" id="context">         identifiable.setObjectID(id);
 
</pre><pre class="diff" id="removed">-        if (isIDRegistered(identifiable.getObjectID())) {
</pre><pre class="diff" id="added">+        if (isIDRegistered(id)) {
</pre><pre class="diff" id="context">             throw new AssertionException("Object already registered");
         }
</pre><pre class="diff" id="added">+
</pre><pre class="diff" id="context">         register(identifiable);
 
         return id;
</pre></div>
<hr /><a name="file3" /><div class="file">
<span class="pathname">nanning/src/frameworks/prevayler/src/main/org/codehaus/nanning/prevayler<br /></span>
<div class="fileheader"><big><b>Identifiable.java</b></big> <small id="info">1.1 -&gt; 1.2</small></div>
<pre class="diff"><small id="info">diff -u -r1.1 -r1.2
--- Identifiable.java	9 Sep 2003 11:10:27 -0000	1.1
+++ Identifiable.java	11 Sep 2003 11:25:37 -0000	1.2
@@ -10,7 +10,7 @@
</small></pre><pre class="diff" id="context">     boolean hasObjectID();
 
     /**
</pre><pre class="diff" id="removed">-     * @transaction
</pre><pre class="diff" id="added">+     * @transaction<span id="addedchars">-required</span>
</pre><pre class="diff" id="context">      */
     void setObjectID(long objectID);
 }
</pre></div>
<hr /><a name="file4" /><div class="file">
<span class="pathname">nanning/src/frameworks/prevayler/src/main/org/codehaus/nanning/prevayler<br /></span>
<div class="fileheader"><big><b>IdentifiableImpl.java</b></big> <small id="info">1.1 -&gt; 1.2</small></div>
<pre class="diff"><small id="info">diff -u -r1.1 -r1.2
--- IdentifiableImpl.java	9 Sep 2003 11:10:27 -0000	1.1
+++ IdentifiableImpl.java	11 Sep 2003 11:25:37 -0000	1.2
@@ -15,7 +15,7 @@
</small></pre><pre class="diff" id="context"> 
     public long getObjectID() {
         if (!hasObjectID()) {
</pre><pre class="diff" id="removed">-            throw new AssertionException("object " + Aspects.getThis() + " had no object id, use BasicIdentifyingSystem.register<span id="removedchars">ObjectID</span>(Object)");
</pre><pre class="diff" id="added">+            throw new AssertionException("object " + Aspects.getThis() + " had no object id, use BasicIdentifyingSystem.register(Object)");
</pre><pre class="diff" id="context">         }
         return objectID;
     }
</pre></div>
<hr /><a name="file5" /><div class="file">
<span class="pathname">nanning/src/frameworks/prevayler/src/main/org/codehaus/nanning/prevayler<br /></span>
<div class="fileheader"><big><b>PrevaylerAspect.java</b></big> <small id="info">1.4 -&gt; 1.5</small></div>
<pre class="diff"><small id="info">diff -u -r1.4 -r1.5
--- PrevaylerAspect.java	9 Sep 2003 11:10:27 -0000	1.4
+++ PrevaylerAspect.java	11 Sep 2003 11:25:37 -0000	1.5
@@ -2,6 +2,8 @@
</small></pre><pre class="diff" id="context"> 
 import org.codehaus.nanning.AspectInstance;
 import org.codehaus.nanning.Mixin;
</pre><pre class="diff" id="added">+import org.codehaus.nanning.MethodInterceptor;
+import org.codehaus.nanning.Invocation;
</pre><pre class="diff" id="context"> import org.codehaus.nanning.config.Aspect;
 import org.codehaus.nanning.config.P;
 import org.codehaus.nanning.config.Pointcut;
</pre><pre class="diff"><small id="info">@@ -10,26 +12,68 @@
</small></pre><pre class="diff" id="context">  * TODO document PrevaylerInterceptor
  *
  * @author &lt;a href="mailto:[email protected]"&gt;Jon Tirsen&lt;/a&gt;
</pre><pre class="diff" id="removed">- * @version $Revision: 1.<span id="removedchars">4</span> $
</pre><pre class="diff" id="added">+ * @version $Revision: 1.<span id="addedchars">5</span> $
</pre><pre class="diff" id="context">  */
 public class PrevaylerAspect implements Aspect {
</pre><pre class="diff" id="removed">-    private TransactionUnsupportedInterceptor unsupportedInterceptor;
-    private CheckTransactionUnsupportedInterceptor checkUnsupportedInterceptor;
-    private PrevaylerInterceptor prevaylerInterceptor;
-    private RegisterObjectInterceptor registerObjectInterceptor;
-    
</pre><pre class="diff" id="context">     private Pointcut transactionUnsupportedPointcut = P.methodAttribute("transaction-unsupported");
</pre><pre class="diff" id="added">+    private MethodInterceptor transactionUnsupportedInterceptor = new MethodInterceptor() {
+        public Object invoke(Invocation invocation) throws Throwable {
+            enterTransactionsUnsupported();
+            try {
+                return invocation.invokeNext();
+            } finally {
+                exitTransactionsUnsupported();
+            }
+        }
+    };
+    private MethodInterceptor checkUnsupportedInterceptor = new MethodInterceptor() {
+        public Object invoke(Invocation invocation) throws Throwable {
+            if (!isTransactionsSupported()) {
+                throw new IllegalStateException("Transactions are not supported in the current calling context.");
+            }
+            return null;
+        }
+    };
+
+    private Pointcut transactionRequiredPointcut = P.methodAttribute("transaction-required");
+
</pre><pre class="diff" id="context">     private Pointcut transactionPointcut = P.methodAttribute("transaction");
</pre><pre class="diff" id="added">+    private PrevaylerInterceptor prevaylerInterceptor;
+    private RegisterObjectInterceptor registerObjectInterceptor;
+    private MethodInterceptor transactionRequiredInterceptor = new MethodInterceptor() {
+        public Object invoke(Invocation invocation) throws Throwable {
+            if (!CurrentPrevayler.isInTransaction()) {
+                throw new TransactionRequiredException();
+            }
+            return invocation.invokeNext();
+        }
+    };
+
</pre><pre class="diff" id="context"> 
     public PrevaylerAspect() {
</pre><pre class="diff" id="removed">-        <span id="removedchars">u</span>nsupportedInterceptor = new TransactionUnsupportedInterceptor();
</pre><pre class="diff" id="added">+        <span id="addedchars">transactionU</span>nsupportedInterceptor = new TransactionUnsupportedInterceptor();
</pre><pre class="diff" id="context">         checkUnsupportedInterceptor = new CheckTransactionUnsupportedInterceptor();
         prevaylerInterceptor = new PrevaylerInterceptor();
         registerObjectInterceptor = new RegisterObjectInterceptor();
     }
</pre><pre class="diff" id="removed">-    
</pre><pre class="diff" id="added">+
+    private static ThreadLocal transactionsUnsupported = new ThreadLocal();
+
+    static boolean isTransactionsSupported() {
+        return transactionsUnsupported.get() == null;
+    }
+
+    static void enterTransactionsUnsupported() {
+        transactionsUnsupported.set(transactionsUnsupported);
+    }
+
+    static void exitTransactionsUnsupported() {
+        transactionsUnsupported.set(null);
+    }
+
</pre><pre class="diff" id="context">     public void advise(AspectInstance aspectInstance) {
</pre><pre class="diff" id="removed">-        transactionUnsupportedPointcut.advise(aspectInstance, unsupportedInterceptor);
</pre><pre class="diff" id="added">+        transactionRequiredPointcut.advise(aspectInstance, transactionRequiredInterceptor);
+        transactionUnsupportedPointcut.advise(aspectInstance, transactionUnsupportedInterceptor);
</pre><pre class="diff" id="context">         transactionPointcut.advise(aspectInstance, checkUnsupportedInterceptor);
         transactionPointcut.advise(aspectInstance, prevaylerInterceptor);
 
</pre></div>
<hr /><a name="file6" /><div class="file">
<span class="pathname">nanning/src/frameworks/prevayler/src/main/org/codehaus/nanning/prevayler<br /></span>
<div class="fileheader"><big><b>RegisterObjectInterceptor.java</b></big> <small id="info">1.3 -&gt; 1.4</small></div>
<pre class="diff"><small id="info">diff -u -r1.3 -r1.4
--- RegisterObjectInterceptor.java	9 Sep 2003 11:10:27 -0000	1.3
+++ RegisterObjectInterceptor.java	11 Sep 2003 11:25:37 -0000	1.4
@@ -13,9 +13,7 @@
</small></pre><pre class="diff" id="context"> 
         if (CurrentPrevayler.isInTransaction()) {
             IdentifyingSystem system = (IdentifyingSystem) CurrentPrevayler.getSystem();
</pre><pre class="diff" id="removed">-            if (!((Identifiable) object).hasObjectID()) {
-                system.register(object);
-            }
</pre><pre class="diff" id="added">+            system.register(object);
</pre><pre class="diff" id="context">         }
         return object;
     }
</pre></div>
<hr /><a name="file7" /><div class="file">
<span class="pathname">nanning/src/frameworks/prevayler/src/test/org/codehaus/nanning/prevayler<br /></span>
<div class="fileheader"><big><b>PrevaylerTest.java</b></big> <small id="info">1.9 -&gt; 1.10</small></div>
<pre class="diff"><small id="info">diff -u -r1.9 -r1.10
--- PrevaylerTest.java	9 Sep 2003 11:10:27 -0000	1.9
+++ PrevaylerTest.java	11 Sep 2003 11:25:37 -0000	1.10
@@ -12,6 +12,7 @@
</small></pre><pre class="diff" id="context"> import org.codehaus.nanning.config.AspectSystem;
 import org.codehaus.nanning.config.FindTargetMixinAspect;
 import org.prevayler.PrevaylerFactory;
</pre><pre class="diff" id="added">+import junit.framework.Assert;
</pre><pre class="diff" id="context"> 
 public class PrevaylerTest extends AbstractAttributesTest {
 
</pre><pre class="diff"><small id="info">@@ -281,7 +282,31 @@
</small></pre><pre class="diff" id="context">     }
 
     /**
</pre><pre class="diff" id="removed">-     * Big badass functional test. I hate it, I want to kill it...
</pre><pre class="diff" id="added">+     * @entity
+     */
+    public interface TransactionRequired {
+        /**
+         * @transaction-required
+         */
+        public void transactionRequired();
+    }
+
+    public static class TransactionRequiredImpl implements TransactionRequired {
+        public void transactionRequired() {
+            fail("should not have been executed");
+        }
+    }
+
+    public void testCallsToMethodWithTransactionRequiredFailsOutsideATransaction() {
+        TransactionRequired transactionRequired = (TransactionRequired) aspectSystem.newInstance(TransactionRequired.class);
+        try {
+            transactionRequired.transactionRequired();
+        } catch (TransactionRequiredException e) {
+        }
+    }
+
+    /**
+     * Big badass functional test. I hate it, I want to kill it... --jon
</pre><pre class="diff" id="context">      */
 //    public void test() throws Exception {
 //        newPrevayler();
</pre><pre class="diff"><small id="info">@@ -439,23 +464,6 @@
</small></pre><pre class="diff" id="context">         assertEquals("value", myObject.getValue());
     }
 
</pre><pre class="diff" id="removed">-//    public void testOptionalDataException() throws IOException, ClassNotFoundException {
-//        MySystem mySystem = (MySystem) aspectSystem.newInstance(MySystem.class);
-//        mySystem.register(aspectSystem.newInstance(MyObject.class));
-//        assertEquals(1, ((Identifiable) mySystem).getObjectID());
-//        mySystem = (MySystem) serialize(mySystem);
-//        mySystem = (MySystem) serialize(mySystem);
-//        assertEquals(1, ((Identifiable) mySystem).getObjectID());
-//        assertEquals(2, mySystem.getAllRegisteredObjects().size());
-//    }
-//
-//    private Object serialize(Object o) throws IOException, ClassNotFoundException {
-//        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
-//        ObjectOutputStream objectOutputStream = new ObjectOutputStream(buffer);
-//        objectOutputStream.writeObject(o);
-//        return new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray())).readObject();
-//    }
-
</pre><pre class="diff" id="context">     private MySystem currentSystem() {
         return CurrentPrevayler.hasPrevayler()
                 ? (MySystem) CurrentPrevayler.getSystem()
</pre><pre class="diff"><small id="info">@@ -466,6 +474,21 @@
</small></pre><pre class="diff" id="context">         currentPrevayler = new CountingPrevayler(
                 PrevaylerFactory.createPrevayler((Serializable) Aspects.getCurrentAspectFactory().newInstance(MySystem.class),
                                                  prevaylerDir.getAbsolutePath()));
</pre><pre class="diff" id="added">+    }
+
+    public interface TestUnsupportedTransaction {
+        /**
+         * @transaction-unsupported
+         */
+        void callWithUnsupportedTransaction();
+    }
+
+    public static class TestUnsupportedTransactionImpl implements TestUnsupportedTransaction {
+        public void callWithUnsupportedTransaction() {
+            Assert.assertFalse(CheckTransactionUnsupportedInterceptor.isTransactionsSupported());
+            MyObject myObject = (MyObject) Aspects.getCurrentAspectFactory().newInstance(MyObject.class);
+            myObject.setValue("test"); // this call should not be permitted
+        }
</pre><pre class="diff" id="context">     }
 
     public void testUnsupportedTransaction() {
</pre></div>
<hr /><a name="file8" /><div class="file">
<span class="pathname" id="removed">nanning/src/frameworks/prevayler/src/test/org/codehaus/nanning/prevayler<br /></span>
<div class="fileheader" id="removed"><big><b>TestUnsupportedTransaction.java</b></big> <small id="info">removed after 1.1</small></div>
<pre class="diff"><small id="info">diff -N TestUnsupportedTransaction.java
--- TestUnsupportedTransaction.java	4 Jul 2003 10:53:58 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,8 +0,0 @@
</small></pre><pre class="diff" id="removed">-package org.codehaus.nanning.prevayler;
-
-public interface TestUnsupportedTransaction {
-    /**
-     * @transaction-unsupported
-     */
-    void callWithUnsupportedTransaction();
-}
</pre></div>
<hr /><a name="file9" /><div class="file">
<span class="pathname" id="removed">nanning/src/frameworks/prevayler/src/test/org/codehaus/nanning/prevayler<br /></span>
<div class="fileheader" id="removed"><big><b>TestUnsupportedTransactionImpl.java</b></big> <small id="info">removed after 1.1</small></div>
<pre class="diff"><small id="info">diff -N TestUnsupportedTransactionImpl.java
--- TestUnsupportedTransactionImpl.java	4 Jul 2003 10:53:58 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,14 +0,0 @@
</small></pre><pre class="diff" id="removed">-package org.codehaus.nanning.prevayler;
-
-import org.codehaus.nanning.Aspects;
-import org.codehaus.nanning.prevayler.CheckTransactionUnsupportedInterceptor;
-import org.codehaus.nanning.prevayler.TestUnsupportedTransaction;
-import junit.framework.Assert;
-
-public class TestUnsupportedTransactionImpl implements TestUnsupportedTransaction {
-    public void callWithUnsupportedTransaction() {
-        Assert.assertFalse(CheckTransactionUnsupportedInterceptor.isTransactionsSupported());
-        MyObject myObject = (MyObject) Aspects.getCurrentAspectFactory().newInstance(MyObject.class);
-        myObject.setValue("test"); // this call should not be permitted
-    }
-}
</pre></div>
<hr /><a name="file10" /><div class="file">
<span class="pathname">nanning/src/frameworks/remote/src/main/org/codehaus/nanning/remote<br /></span>
<div class="fileheader"><big><b>RemoteMarshaller.java</b></big> <small id="info">1.4 -&gt; 1.5</small></div>
<pre class="diff"><small id="info">diff -u -r1.4 -r1.5
--- RemoteMarshaller.java	9 Sep 2003 11:10:28 -0000	1.4
+++ RemoteMarshaller.java	11 Sep 2003 11:25:37 -0000	1.5
@@ -30,9 +30,9 @@
</small></pre><pre class="diff" id="context">             }
 
             public void introduce(AspectInstance aspectInstance) {
</pre><pre class="diff" id="removed">-                Mixin mixinInstance = new Mixin();
-                mixinInstance.setInterfaceClass(aspectInstance.getClassIdentifier());
-                aspectInstance.addMixin(mixinInstance);
</pre><pre class="diff" id="added">+                Mixin mixin = new Mixin();
+                mixin.setInterfaceClass(aspectInstance.getClassIdentifier());
+                aspectInstance.addMixin(mixin);
</pre><pre class="diff" id="context">             }
         });
 
</pre><pre class="diff"><small id="info">@@ -113,8 +113,8 @@
</small></pre><pre class="diff" id="context">         return objectTable.register(o);
     }
 
</pre><pre class="diff" id="removed">-    public static boolean isRemoteStub(Object o) {
-        return getSingleMixinTarget(o) instanceof RemoteIdentity;
</pre><pre class="diff" id="added">+    public boolean isRemoteStub(Object o) {
+        return Aspects.getAspectInstance(o).getAspectFactory() == aspectSystem;
</pre><pre class="diff" id="context">     }
 
     private static Object getSingleMixinTarget(Object o) {
</pre><pre class="diff"><small id="info">@@ -125,7 +125,7 @@
</small></pre><pre class="diff" id="context">         }
         Mixin mixinInstance = (Mixin) iterator.next();
         if (iterator.hasNext()) {
</pre><pre class="diff" id="removed">-            throw new AssertionException("don't support several mixins<span id="removedchars">"</span>);
</pre><pre class="diff" id="added">+            throw new AssertionException("don't support several mixins<span id="addedchars">:&nbsp;"&nbsp;+&nbsp;o</span>);
</pre><pre class="diff" id="context">         }
 
         Object target = mixinInstance.getTarget();
</pre></div>
<hr /><a name="file11" /><div class="file">
<span class="pathname">nanning/src/frameworks/remote/src/test/org/codehaus/nanning/remote<br /></span>
<div class="fileheader"><big><b>MyObject.java</b></big> <small id="info">1.2 -&gt; 1.3</small></div>
<pre class="diff"><small id="info">diff -u -r1.2 -r1.3
--- MyObject.java	9 Sep 2003 11:10:28 -0000	1.2
+++ MyObject.java	11 Sep 2003 11:25:37 -0000	1.3
@@ -4,6 +4,7 @@
</small></pre><pre class="diff" id="context"> 
 /**
  * @remote
</pre><pre class="diff" id="added">+ * @entity
</pre><pre class="diff" id="context">  */
 public interface MyObject extends Serializable {
     String getValue();
</pre></div>
<hr /><a name="file12" /><div class="file">
<span class="pathname">nanning/src/test/org/codehaus/nanning<br /></span>
<div class="fileheader"><big><b>PerformanceTest.java</b></big> <small id="info">1.2 -&gt; 1.3</small></div>
<pre class="diff"><small id="info">diff -u -r1.2 -r1.3
--- PerformanceTest.java	12 Jul 2003 16:48:16 -0000	1.2
+++ PerformanceTest.java	11 Sep 2003 11:25:37 -0000	1.3
@@ -16,16 +16,16 @@
</small></pre><pre class="diff" id="context"> /**
  * TODO document PerformanceTest
  *
</pre><pre class="diff" id="removed">- * &lt;!-- $Id: PerformanceTest.java,v 1.<span id="removedchars">2&nbsp;2003/07/12&nbsp;16:48:16</span> lecando Exp $ --&gt;
</pre><pre class="diff" id="added">+ * &lt;!-- $Id: PerformanceTest.java,v 1.<span id="addedchars">3&nbsp;2003/09/11&nbsp;11:25:37</span> lecando Exp $ --&gt;
</pre><pre class="diff" id="context">  *
  * @author $Author: lecando $
</pre><pre class="diff" id="removed">- * @version $Revision: 1.<span id="removedchars">2</span> $
</pre><pre class="diff" id="added">+ * @version $Revision: 1.<span id="addedchars">3</span> $
</pre><pre class="diff" id="context">  */
 public class PerformanceTest extends AbstractAttributesTest {
     public void testInvocation() throws IllegalAccessException, InstantiationException {
         // these are exceptionally high due to Clover...
</pre><pre class="diff" id="removed">-        double maxMemoryPerInvocation = 8;
-        double timesSlowerTolerance = 22;
</pre><pre class="diff" id="added">+        double maxMemoryPerInvocation = 15;
+        double timesSlowerTolerance = 4;
</pre><pre class="diff" id="context">         double maxTimePerInvocation = 0.014;
 
         int numberOfInvocations = 100000;
</pre><pre class="diff"><small id="info">@@ -73,9 +73,9 @@
</small></pre><pre class="diff" id="context">         //        System.out.println("memoryPerInvocation = " + aspect.getMemoryUsed(numberOfInvocations));
         System.out.println("timePerInvocation = " + aspect.getTimeSpent(numberOfInvocations));
 
</pre><pre class="diff" id="removed">-        assertTrue("memory per invocation exceeded", aspect.getMemoryUsed(numberOfInvocations) &lt; maxMemoryPerInvocation);
-        assertTrue("time per invocation exceeded", aspect.getTimeSpent(numberOfInvocations) &lt; maxTimePerInvocation);
-        assertTrue("time per invocation exceeded", timesSlowerTolerance &gt; timesSlower);
</pre><pre class="diff" id="added">+        assertLowerThan("memory per invocation exceeded", aspect.getMemoryUsed(numberOfInvocations), maxMemoryPerInvocation);
+        assertLowerThan("time per invocation exceeded", aspect.getTimeSpent(numberOfInvocations), maxTimePerInvocation);
+        assertLowerThan("time per invocation exceeded", timesSlower, timesSlowerTolerance);
</pre><pre class="diff" id="context">     }
 
     public void testAttributes() throws NoSuchMethodException {
</pre><pre class="diff"><small id="info">@@ -96,12 +96,16 @@
</small></pre><pre class="diff" id="context">         System.out.println();
         System.out.println("time spent " + stopWatch.getTimeSpent());
         System.out.println("memory used " + stopWatch.getMemoryUsed());
</pre><pre class="diff" id="removed">-        assertTrue("time exceeded", stopWatch.getTimeSpent() &lt;= maxTime);
-        assertTrue("memory exceeded", stopWatch.getMemoryUsed() &lt;= maxMemory);
</pre><pre class="diff" id="added">+        assertLowerThan("time exceeded", stopWatch.getTimeSpent(), maxTime);
+        assertLowerThan("memory exceeded", stopWatch.getMemoryUsed(), maxMemory);
+    }
+
+    private void assertLowerThan(String reason, double observed, double maximum) {
+        assertTrue(reason + ", " + observed + " &gt; " + maximum, observed &lt;= maximum);
</pre><pre class="diff" id="context">     }
 
     public void testInheritedAttributes() throws NoSuchMethodException {
</pre><pre class="diff" id="removed">-        long maxTime = <span id="removedchars">17</span>;
</pre><pre class="diff" id="added">+        long maxTime = <span id="addedchars">60</span>;
</pre><pre class="diff" id="context">         long maxMemory = 180000;
 
         // let the cache do it's thang
</pre><pre class="diff"><small id="info">@@ -118,7 +122,7 @@
</small></pre><pre class="diff" id="context">         System.out.println();
         System.out.println("time spent " + stopWatch.getTimeSpent());
         System.out.println("memory used " + stopWatch.getMemoryUsed());
</pre><pre class="diff" id="removed">-        assertTrue("time exceeded", stopWatch.getTimeSpent() &lt; maxTime);
-        assertTrue("memory exceeded", stopWatch.getMemoryUsed() &lt; maxMemory);
</pre><pre class="diff" id="added">+        assertLowerThan("time exceeded", stopWatch.getTimeSpent(), maxTime);
+        assertLowerThan("memory exceeded", stopWatch.getMemoryUsed(), maxMemory);
</pre><pre class="diff" id="context">     }
 }
</pre></div>
</body></html>