DataContext hasThreadDataContext()

From: Malcolm Edgar (malcolm.edga..mail.com)
Date: Mon Aug 14 2006 - 20:58:49 EDT

  • Next message: Marcel (JIRA): "[JIRA] Created: (CAY-628) xml/XMLEncoderTst.java fails on Windows"

    Hi All,

    It would be good if the DataContext class had a method:

       public static boolean hasThreadDataContext() {
           return (threadDataContext.get() != null);
       }

    I am working with a scenario where a third party library is making
    direct calls to Cayenne service methods. If I can test whether the
    thread local dataContext is not defined I can then initialize it.

    Currently I have hacked the DataContext class as a work around:

        public static DataContext getThreadDataContext() throws
    IllegalStateException {
            DataContext dc = (DataContext) threadDataContext.get();
            if (dc == null) {
                dc = createDataContext();
                threadDataContext.set(dc);
            }

            return dc;
        }

    regards Malcolm Edgar



    This archive was generated by hypermail 2.0.0 : Mon Aug 14 2006 - 20:59:14 EDT