portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject svn commit: r380298 - in /portals/jetspeed-2/trunk/components/page-manager/src/test: interceptors.xml org/apache/jetspeed/page/TestTransactions.java tx-page-manager.xml
Date Fri, 24 Feb 2006 01:52:36 GMT
Author: taylor
Date: Thu Feb 23 17:52:36 2006
New Revision: 380298

URL: http://svn.apache.org/viewcvs?rev=380298&view=rev
Log:
http://issues.apache.org/jira/browse/JS2-495
Using Spring method interceptor to clear OJB cache for Page Manager
After an object is added, 
OJB seems to be holding on to objects in the cache after rollback
Sometimes I really wonder if iBatis or even JDBC would suite us better than this endless stream
of bugs

The really fucked up thing is that this works fine in my unit test
But in production, a commit sneaks in before the rollback
No idea where that one is coming from

Modified:
    portals/jetspeed-2/trunk/components/page-manager/src/test/interceptors.xml
    portals/jetspeed-2/trunk/components/page-manager/src/test/org/apache/jetspeed/page/TestTransactions.java
    portals/jetspeed-2/trunk/components/page-manager/src/test/tx-page-manager.xml

Modified: portals/jetspeed-2/trunk/components/page-manager/src/test/interceptors.xml
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/page-manager/src/test/interceptors.xml?rev=380298&r1=380297&r2=380298&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/page-manager/src/test/interceptors.xml (original)
+++ portals/jetspeed-2/trunk/components/page-manager/src/test/interceptors.xml Thu Feb 23
17:52:36 2006
@@ -1,27 +1,35 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
-
+<!--
+    Database PSML Manager Interception for handling Cache Rollback
+    We also have examples here of replay interception for failover to 
+    a second database on update failures
+   -->    
 <beans>
-   <bean id="replayDecisionMakerBean"
-        class="org.apache.jetspeed.util.interceptors.TransactionalMethodReplayDecisionMaker">
-        <property name="sqlErrorCodes">
-<!--            <value>400, -80</value> -->
-             <value>9999</value>
-        </property>
+
+    <bean id="pageManagerInterceptor" class="org.apache.jetspeed.util.interceptors.PageManagerInterceptor">
     </bean>
 
-    <bean id="methodReplayInterceptor" class="org.apache.jetspeed.util.interceptors.MethodReplayInterceptor">
-        <property name="retryCount">
-            <value>3</value>
+
+    <bean id="PageManagerTransactionProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"
+                        abstract="true">
+        <property name="transactionManager"><ref bean="transactionManager"/></property>
+        <property name="transactionAttributes">
+            <props>
+                <prop key="*">PROPAGATION_REQUIRED</prop>
+            </props>
         </property>
-        <property name="retryInterval">
-            <value>500</value></property> <!-- retry every 500 milliseconds
-->
-        <property name="replayDecisionMaker">
-            <ref bean="replayDecisionMakerBean"/>
+        <property name="preInterceptors"> 
+            <list>
+                <ref local="pageManagerInterceptor" />
+            </list>
         </property>
     </bean>
 
-    <bean id="baseTransactionProxy2" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"
+    <!--    
+        Replay support:
+        
+    <bean id="replayTransactionProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"
                         abstract="true">
         <property name="transactionManager"><ref bean="transactionManager"/></property>
         <property name="transactionAttributes">
@@ -35,5 +43,25 @@
             </list>
         </property>
     </bean>
-    
+        
+   <bean id="replayDecisionMakerBean"
+        class="org.apache.jetspeed.util.interceptors.TransactionalMethodReplayDecisionMaker">
+        <property name="sqlErrorCodes">
+            <value>9999, 400, -80</value> 
+             <value>9999</value>
+        </property>
+    </bean>
+
+    <bean id="methodReplayInterceptor" class="org.apache.jetspeed.util.interceptors.MethodReplayInterceptor">
+        <property name="retryCount">
+            <value>3</value>
+        </property>
+        <property name="retryInterval">
+            <value>500</value></property>  retry every 500 milliseconds

+        <property name="replayDecisionMaker">
+            <ref bean="replayDecisionMakerBean"/>
+        </property>
+    </bean>
+ -->
+            
 </beans>

Modified: portals/jetspeed-2/trunk/components/page-manager/src/test/org/apache/jetspeed/page/TestTransactions.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/page-manager/src/test/org/apache/jetspeed/page/TestTransactions.java?rev=380298&r1=380297&r2=380298&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/page-manager/src/test/org/apache/jetspeed/page/TestTransactions.java
(original)
+++ portals/jetspeed-2/trunk/components/page-manager/src/test/org/apache/jetspeed/page/TestTransactions.java
Thu Feb 23 17:52:36 2006
@@ -18,10 +18,10 @@
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
-import org.apache.jetspeed.components.test.AbstractSpringTestCase;
 import org.apache.jetspeed.components.util.DatasourceEnabledSpringTestCase;
 import org.apache.jetspeed.om.folder.Folder;
 import org.apache.jetspeed.om.page.Page;
+import org.apache.jetspeed.page.impl.DatabasePageManagerCache;
 
 /**
  * Test Transactions
@@ -51,10 +51,10 @@
 
     public static Test suite()
     {
-        System.setProperty("org.apache.jetspeed.database.url", "jdbc:mysql://j2-server/j2");

-        System.setProperty("org.apache.jetspeed.database.driver", "com.mysql.jdbc.Driver");
-        System.setProperty("org.apache.jetspeed.database.user", "j2");
-        System.setProperty("org.apache.jetspeed.database.password", "digital");
+//        System.setProperty("org.apache.jetspeed.database.url", "jdbc:mysql://j2-server/j2");

+//        System.setProperty("org.apache.jetspeed.database.driver", "com.mysql.jdbc.Driver");
+//        System.setProperty("org.apache.jetspeed.database.user", "j2");
+//        System.setProperty("org.apache.jetspeed.database.password", "xxxxx");
         
         // All methods starting with "test" will be executed in the test suite.
         return new TestSuite(TestTransactions.class);
@@ -63,7 +63,7 @@
     protected String[] getConfigurations()
     {
         return new String[]
-        { "tx-page-manager.xml", "transaction.xml" }; // "interceptors.xml" }; 
+        { "tx-page-manager.xml", "transaction.xml", "interceptors.xml" }; 
     }
 
     protected String[] getBootConfigurations()
@@ -80,10 +80,18 @@
         }
         Folder root = pageManager.newFolder("/");
         pageManager.updateFolder(root);
+        
+        System.out.println("--- before new Page");
+        DatabasePageManagerCache.dump();
+        
         Page[] pages = new Page[3];
-        pages[0] = pageManager.newPage("/test1.psml");
-        pages[1] = pageManager.newPage("/test2.psml");
-        pages[2] = pageManager.newPage("/test3.psml");
+        pages[0] = pageManager.newPage("/tx__test1.psml");
+        pages[1] = pageManager.newPage("/tx__test2.psml");
+        pages[2] = pageManager.newPage("/tx__test3.psml");
+        
+        System.out.println("--- after new Page");
+        DatabasePageManagerCache.dump();
+        
         try
         {
             pageManager.addPages(pages);
@@ -91,11 +99,13 @@
         catch (Exception e)
         {
             System.out.println("Exception adding pages" + e);
-            e.printStackTrace();
+           // e.printStackTrace();
             
         }
-//        assertFalse("page 1 found", pageManager.pageExists("/test1.psml"));
-//        assertFalse("page 2 found", pageManager.pageExists("/test2.psml"));
-//        assertFalse("page 3 found", pageManager.pageExists("/test3.psml"));
+        System.out.println("--- after rollback");
+        DatabasePageManagerCache.dump();
+        assertFalse("page 1 found", pageManager.pageExists("/tx__test1.psml"));
+        assertFalse("page 2 found", pageManager.pageExists("/tx__test2.psml"));
+        assertFalse("page 3 found", pageManager.pageExists("/tx__test3.psml"));
     }
 }

Modified: portals/jetspeed-2/trunk/components/page-manager/src/test/tx-page-manager.xml
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/page-manager/src/test/tx-page-manager.xml?rev=380298&r1=380297&r2=380298&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/page-manager/src/test/tx-page-manager.xml (original)
+++ portals/jetspeed-2/trunk/components/page-manager/src/test/tx-page-manager.xml Thu Feb
23 17:52:36 2006
@@ -35,7 +35,7 @@
     </bean>
 
     <!-- Transaction Proxying -->
-    <bean id="org.apache.jetspeed.page.PageManager" name="pageManager" parent="baseTransactionProxy">

+    <bean id="org.apache.jetspeed.page.PageManager" name="pageManager" parent="PageManagerTransactionProxy">

         <property name="proxyInterfaces">
             <value>org.apache.jetspeed.page.PageManager</value>
         </property>



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message