Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateThreadContext.java')
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateThreadContext.java164
1 files changed, 82 insertions, 82 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateThreadContext.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateThreadContext.java
index 5f1dab0322..5636773854 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateThreadContext.java
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateThreadContext.java
@@ -1,82 +1,82 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Martin Taal - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.server.internal.hibernate;
-
-import org.eclipse.emf.cdo.server.StoreThreadLocal;
-import org.eclipse.emf.cdo.server.internal.hibernate.bundle.OM;
-import org.eclipse.emf.cdo.spi.server.InternalCommitContext;
-
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-/**
- * @author Martin Taal
- */
-public class HibernateThreadContext
-{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, HibernateThreadContext.class);
-
- private static ThreadLocal<HibernateCommitContext> commitContext = new ThreadLocal<HibernateCommitContext>();
-
- public static HibernateStoreAccessor getCurrentStoreAccessor()
- {
- return (HibernateStoreAccessor)StoreThreadLocal.getAccessor();
- }
-
- public static HibernateCommitContext getCommitContext()
- {
- HibernateCommitContext result = commitContext.get();
- if (result == null)
- {
- throw new IllegalStateException("CommitContext not set"); //$NON-NLS-1$
- }
-
- return result;
- }
-
- public static boolean isCommitContextSet()
- {
- return commitContext.get() != null;
- }
-
- public static void setCommitContext(InternalCommitContext newCommitContext)
- {
- // in case of xa transactions then the commit context is set again
- // if (newCommitContext != null && commitContext.get() != null)
- // {
- // throw new IllegalStateException("CommitContext already set");
- // }
-
- if (TRACER.isEnabled())
- {
- if (newCommitContext == null)
- {
- TRACER.trace("Clearing commitcontext in threadlocal"); //$NON-NLS-1$
- }
- else
- {
- TRACER.trace("Setting commitcontext in threadlocal"); //$NON-NLS-1$
- }
- }
-
- // reset the context
- if (newCommitContext == null)
- {
- commitContext.set(null);
- }
- else
- {
- final HibernateCommitContext hcc = new HibernateCommitContext();
- hcc.setCommitContext(newCommitContext);
- commitContext.set(hcc);
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Taal - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.server.internal.hibernate;
+
+import org.eclipse.emf.cdo.server.StoreThreadLocal;
+import org.eclipse.emf.cdo.server.internal.hibernate.bundle.OM;
+import org.eclipse.emf.cdo.spi.server.InternalCommitContext;
+
+import org.eclipse.net4j.util.om.trace.ContextTracer;
+
+/**
+ * @author Martin Taal
+ */
+public class HibernateThreadContext
+{
+ private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, HibernateThreadContext.class);
+
+ private static ThreadLocal<HibernateCommitContext> commitContext = new ThreadLocal<HibernateCommitContext>();
+
+ public static HibernateStoreAccessor getCurrentStoreAccessor()
+ {
+ return (HibernateStoreAccessor)StoreThreadLocal.getAccessor();
+ }
+
+ public static HibernateCommitContext getCommitContext()
+ {
+ HibernateCommitContext result = commitContext.get();
+ if (result == null)
+ {
+ throw new IllegalStateException("CommitContext not set"); //$NON-NLS-1$
+ }
+
+ return result;
+ }
+
+ public static boolean isCommitContextSet()
+ {
+ return commitContext.get() != null;
+ }
+
+ public static void setCommitContext(InternalCommitContext newCommitContext)
+ {
+ // in case of xa transactions then the commit context is set again
+ // if (newCommitContext != null && commitContext.get() != null)
+ // {
+ // throw new IllegalStateException("CommitContext already set");
+ // }
+
+ if (TRACER.isEnabled())
+ {
+ if (newCommitContext == null)
+ {
+ TRACER.trace("Clearing commitcontext in threadlocal"); //$NON-NLS-1$
+ }
+ else
+ {
+ TRACER.trace("Setting commitcontext in threadlocal"); //$NON-NLS-1$
+ }
+ }
+
+ // reset the context
+ if (newCommitContext == null)
+ {
+ commitContext.set(null);
+ }
+ else
+ {
+ final HibernateCommitContext hcc = new HibernateCommitContext();
+ hcc.setCommitContext(newCommitContext);
+ commitContext.set(hcc);
+ }
+ }
+}

Back to the top