openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dwo...@apache.org
Subject svn commit: r888497 - in /openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel: AbstractBrokerFactory.java BrokerImpl.java
Date Tue, 08 Dec 2009 17:54:13 GMT
Author: dwoods
Date: Tue Dec  8 17:54:12 2009
New Revision: 888497

URL: http://svn.apache.org/viewvc?rev=888497&view=rev
Log:
OPENJPA-1348 Embeddable data not persisted when using WriteBehind cache flush operation. 
Patch from Fay Wang.

Modified:
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractBrokerFactory.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractBrokerFactory.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractBrokerFactory.java?rev=888497&r1=888496&r2=888497&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractBrokerFactory.java
(original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractBrokerFactory.java
Tue Dec  8 17:54:12 2009
@@ -191,6 +191,11 @@
     }
 
     public Broker newBroker(String user, String pass, boolean managed, int connRetainMode,
boolean findExisting) {
+        return newBroker(user, pass, managed, connRetainMode, findExisting, false);
+    }
+    
+    public Broker newBroker(String user, String pass, boolean managed, int connRetainMode,
boolean findExisting,
+        boolean writeBehindCallback) {
         try {
             assertOpen();
             makeReadOnly();
@@ -200,7 +205,7 @@
                 broker = findBroker(user, pass, managed);
             if (broker == null) {
                 broker = newBrokerImpl(user, pass);
-                initializeBroker(managed, connRetainMode, broker, false);
+                initializeBroker(managed, connRetainMode, broker, false, writeBehindCallback);
             }
             return broker;
         } catch (OpenJPAException ke) {
@@ -211,12 +216,18 @@
     }
 
     void initializeBroker(boolean managed, int connRetainMode, Broker broker, boolean fromDeserialization)
{
+        initializeBroker(managed, connRetainMode, broker, fromDeserialization, false);
+    }    
+    
+    void initializeBroker(boolean managed, int connRetainMode, Broker broker, boolean fromDeserialization,
+        boolean fromWriteBehindCallback) {
         assertOpen();
         makeReadOnly();
         
         DelegatingStoreManager dsm = createDelegatingStoreManager();
 
-        ((BrokerImpl) broker).initialize(this, dsm, managed, connRetainMode, fromDeserialization);
+        ((BrokerImpl) broker).initialize(this, dsm, managed, connRetainMode, fromDeserialization,
+            fromWriteBehindCallback);
         if (!fromDeserialization)
             addListeners(broker);
 
@@ -873,7 +884,7 @@
                           _conf.getConnectionPassword(), 
                           false, // WriteBehind broker is always unmanaged.
                           _conf.getConnectionRetainModeConstant(),
-                          false);
+                          false, true);
 
             // The Broker used by the WriteBehind cache should not be tracked
             // by the factory - we'll manually clean up when the factory is

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java?rev=888497&r1=888496&r2=888497&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java Tue
Dec  8 17:54:12 2009
@@ -248,6 +248,7 @@
     private int _lifeCallbackMode = 0;
 
     private transient boolean _initializeWasInvoked = false;
+    private transient boolean _fromWriteBehindCallback = false;
     private LinkedList _fcs;
     
     // Set of supported property keys. The keys in this set correspond to bean-style setter
methods
@@ -304,6 +305,13 @@
     public void initialize(AbstractBrokerFactory factory,
         DelegatingStoreManager sm, boolean managed, int connMode,
         boolean fromDeserialization) {
+        initialize(factory, sm, managed, connMode, fromDeserialization, false);
+    }
+    
+    public void initialize(AbstractBrokerFactory factory,
+        DelegatingStoreManager sm, boolean managed, int connMode,
+        boolean fromDeserialization, boolean fromWriteBehindCallback) {
+        _fromWriteBehindCallback = fromWriteBehindCallback;
         _initializeWasInvoked = true;
         _loader = AccessController.doPrivileged(
             J2DoPrivHelper.getContextClassLoaderAction());
@@ -4449,9 +4457,10 @@
         boolean assertThisContext) {
         if (ImplHelper.isManageable(obj)) {
             PersistenceCapable pc = ImplHelper.toPersistenceCapable(obj, _conf);
-            if (pc.pcGetGenericContext() == this)
+            BrokerImpl pcBroker = (BrokerImpl)pc.pcGetGenericContext();
+            if (pcBroker == this || isFromWriteBehindCallback())
                 return (StateManagerImpl) pc.pcGetStateManager();
-            if (assertThisContext && pc.pcGetGenericContext() != null)
+            if (assertThisContext && pcBroker != null)
                 throw new UserException(_loc.get("not-managed",
                     Exceptions.toString(obj))).setFailedObject(obj);
         }
@@ -4938,4 +4947,8 @@
             unlock();
         }
     }
+    
+    public boolean isFromWriteBehindCallback() {
+        return _fromWriteBehindCallback;
+    }
 }



Mime
View raw message