You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by aa...@apache.org on 2007/09/15 14:20:34 UTC
svn commit: r575911 - in /cayenne/main/trunk: docs/doc/src/main/resources/
framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/
framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/
framework/cayenne-jdk...
Author: aadamchik
Date: Sat Sep 15 05:20:33 2007
New Revision: 575911
URL: http://svn.apache.org/viewvc?rev=575911&view=rev
Log:
CAY-796 Deserialization of DataContext fails when useSharedCache is false
Added:
cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/resources/dml/access.DataContextSerializationTest.xml
Modified:
cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt
cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/DataContext.java
cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/DataRowStore.java
cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/DataContextSerializationTest.java
Modified: cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt?rev=575911&r1=575910&r2=575911&view=diff
==============================================================================
--- cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt (original)
+++ cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt Sat Sep 15 05:20:33 2007
@@ -36,6 +36,7 @@
Bug Fixes Since M1:
+CAY-796 Deserialization of DataContext fails when useSharedCache is false
CAY-797 Lifecycle callbacks *CallbackInterceptor concept introduces problems for testing equality of contexts
CAY-832 enum-mapped columns improperly handled in in expressions
CAY-835 setting meaningful pk to zero turn on autogenerated keys
Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/DataContext.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/DataContext.java?rev=575911&r1=575910&r2=575911&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/DataContext.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/DataContext.java Sat Sep 15 05:20:33 2007
@@ -370,6 +370,14 @@
// guarantee that a new channel uses the same EventManager.
EventUtil.listenForChannelEvents(channel, mergeHandler);
}
+
+ if (!usingSharedSnaphsotCache && getObjectStore() != null) {
+ DataRowStore cache = getObjectStore().getDataRowCache();
+
+ if (cache != null) {
+ cache.setEventManager(eventManager);
+ }
+ }
}
}
}
Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/DataRowStore.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/DataRowStore.java?rev=575911&r1=575910&r2=575911&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/DataRowStore.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/DataRowStore.java Sat Sep 15 05:20:33 2007
@@ -594,7 +594,10 @@
}
void stopListeners() {
- eventManager.removeListener(this);
+ if (eventManager != null) {
+ eventManager.removeListener(this);
+ }
+
if (remoteNotificationsHandler != null) {
try {
remoteNotificationsHandler.shutdown();
@@ -607,29 +610,36 @@
}
void startListeners() {
- if (remoteNotificationsHandler != null) {
- try {
- // listen to EventBridge ... must add itself as non-blocking listener
- // otherwise a deadlock can occur as "processRemoteEvent" will attempt to
- // obtain a lock on this object when the dispatch queue is locked... And
- // another commit thread may have this object locked and attempt to lock
- // dispatch queue
+ if (eventManager != null) {
+ if (remoteNotificationsHandler != null) {
+ try {
+ // listen to EventBridge ... must add itself as non-blocking listener
+ // otherwise a deadlock can occur as "processRemoteEvent" will attempt
+ // to
+ // obtain a lock on this object when the dispatch queue is locked...
+ // And
+ // another commit thread may have this object locked and attempt to
+ // lock
+ // dispatch queue
- eventManager.addNonBlockingListener(
- this,
- "processRemoteEvent",
- SnapshotEvent.class,
- getSnapshotEventSubject(),
- remoteNotificationsHandler);
+ eventManager.addNonBlockingListener(
+ this,
+ "processRemoteEvent",
+ SnapshotEvent.class,
+ getSnapshotEventSubject(),
+ remoteNotificationsHandler);
- // start EventBridge - it will listen to all event sources for this
- // subject
- remoteNotificationsHandler.startup(
- eventManager,
- EventBridge.RECEIVE_LOCAL_EXTERNAL);
- }
- catch (Exception ex) {
- throw new CayenneRuntimeException("Error initializing DataRowStore.", ex);
+ // start EventBridge - it will listen to all event sources for this
+ // subject
+ remoteNotificationsHandler.startup(
+ eventManager,
+ EventBridge.RECEIVE_LOCAL_EXTERNAL);
+ }
+ catch (Exception ex) {
+ throw new CayenneRuntimeException(
+ "Error initializing DataRowStore.",
+ ex);
+ }
}
}
}
Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/DataContextSerializationTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/DataContextSerializationTest.java?rev=575911&r1=575910&r2=575911&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/DataContextSerializationTest.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/DataContextSerializationTest.java Sat Sep 15 05:20:33 2007
@@ -22,6 +22,7 @@
import java.util.List;
import org.apache.art.Artist;
+import org.apache.cayenne.DataObjectUtils;
import org.apache.cayenne.PersistenceState;
import org.apache.cayenne.conf.Configuration;
import org.apache.cayenne.unit.CayenneCase;
@@ -34,6 +35,7 @@
protected void setUp() throws Exception {
fixSharedConfiguration();
+ deleteTestData();
}
protected void fixSharedConfiguration() {
@@ -71,6 +73,8 @@
}
public void testSerializeWithSharedCache() throws Exception {
+
+ createTestData("prepare");
DataContext context = createDataContextWithSharedCache();
@@ -90,9 +94,16 @@
assertNotNull(deserializedContext.getEntityResolver());
assertSame(context.getEntityResolver(), deserializedContext.getEntityResolver());
+
+ Artist a = (Artist) DataObjectUtils.objectForPK(deserializedContext, Artist.class, 33001);
+ assertNotNull(a);
+ a.setArtistName(a.getArtistName() + "___");
+ deserializedContext.commitChanges();
}
public void testSerializeWithLocalCache() throws Exception {
+
+ createTestData("prepare");
DataContext context = createDataContextWithDedicatedCache();
@@ -114,6 +125,13 @@
assertNotSame(
deserializedContext.getParentDataDomain().getSharedSnapshotCache(),
deserializedContext.getObjectStore().getDataRowCache());
+
+ Artist a = (Artist) DataObjectUtils.objectForPK(deserializedContext, Artist.class, 33001);
+ assertNotNull(a);
+ a.setArtistName(a.getArtistName() + "___");
+
+ // this blows per CAY-796
+ deserializedContext.commitChanges();
}
public void testSerializeNew() throws Exception {
Added: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/resources/dml/access.DataContextSerializationTest.xml
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/resources/dml/access.DataContextSerializationTest.xml?rev=575911&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/resources/dml/access.DataContextSerializationTest.xml (added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/resources/dml/access.DataContextSerializationTest.xml Sat Sep 15 05:20:33 2007
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
+
+<beans default-lazy-init="true">
+
+ <bean id="INSERT" class="org.apache.cayenne.unit.util.UpdatingSQLTemplate">
+ <constructor-arg type="java.lang.Class"><value>org.apache.art.Artist</value></constructor-arg>
+ <constructor-arg><value>
+ insert into ARTIST (ARTIST_ID, ARTIST_NAME) values (33001, 'aaa')
+ </value></constructor-arg>
+ </bean>
+
+
+ <!-- ======================================= -->
+ <!-- Data Sets -->
+ <!-- ======================================= -->
+
+ <bean id="prepare" class="java.util.ArrayList">
+ <constructor-arg>
+ <list>
+ <ref bean="INSERT"/>
+ </list>
+ </constructor-arg>
+ </bean>
+</beans>
\ No newline at end of file