You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@click.apache.org by me...@apache.org on 2009/04/26 15:19:56 UTC

svn commit: r768703 - /incubator/click/trunk/click/extras/src/org/apache/click/extras/cayenne/CayenneTemplate.java

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;
+        }
     }
 
     /**