click-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From med...@apache.org
Subject svn commit: r768703 - /incubator/click/trunk/click/extras/src/org/apache/click/extras/cayenne/CayenneTemplate.java
Date Sun, 26 Apr 2009 13:19:56 GMT
Author: medgar
Date: Sun Apr 26 13:19:56 2009
New Revision: 768703

URL: http://svn.apache.org/viewvc?rev=768703&view=rev
Log:
added support for unbound data context resolution

Modified:
    incubator/click/trunk/click/extras/src/org/apache/click/extras/cayenne/CayenneTemplate.java

Modified: incubator/click/trunk/click/extras/src/org/apache/click/extras/cayenne/CayenneTemplate.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/extras/src/org/apache/click/extras/cayenne/CayenneTemplate.java?rev=768703&r1=768702&r2=768703&view=diff
==============================================================================
--- incubator/click/trunk/click/extras/src/org/apache/click/extras/cayenne/CayenneTemplate.java
(original)
+++ incubator/click/trunk/click/extras/src/org/apache/click/extras/cayenne/CayenneTemplate.java
Sun Apr 26 13:19:56 2009
@@ -122,13 +122,22 @@
     }
 
     /**
-     * Return the thread local DataContext.
+     * Return the thread local DataContext. If a DataContext not not bound to
+     * the current thread, this method will create a new DataContext and bind
+     * it to the thread.
      *
      * @return the thread local DataContext
      * @throws IllegalStateException if there is no DataContext bound to the current thread
      */
     protected DataContext getDataContext() {
-        return DataContext.getThreadDataContext();
+        try {
+            return DataContext.getThreadDataContext();
+
+        } catch (IllegalStateException ise) {
+            DataContext dataContext = DataContext.createDataContext();
+            DataContext.bindThreadDataContext(dataContext);
+            return dataContext;
+        }
     }
 
     /**



Mime
View raw message