[Alerting] Added closeOtherSessions public method
authorAnder Iraceburu <ander.iraceburu@openbravo.com>
Wed, 13 Jun 2018 13:17:59 +0200
changeset 34000 7df31b728967
parent 33999 86cb314ebf98
child 34001 9795ccaab86a
[Alerting] Added closeOtherSessions public method
src/org/openbravo/dal/core/DalThreadHandler.java
--- a/src/org/openbravo/dal/core/DalThreadHandler.java	Tue May 29 16:49:08 2018 +0200
+++ b/src/org/openbravo/dal/core/DalThreadHandler.java	Wed Jun 13 13:17:59 2018 +0200
@@ -39,6 +39,29 @@
   /** @see ThreadHandler#doFinal */
   @Override
   public void doFinal(boolean errorOccured) {
+    closeSessions(errorOccured);
+  }
+
+  private static void closeDefaultPoolSession(boolean errorOccured) {
+    SessionHandler sessionHandler = SessionHandler.isSessionHandlerPresent() ? SessionHandler
+        .getInstance() : null;
+    if (sessionHandler != null && sessionHandler.doSessionInViewPatter()) {
+      // application software can force a rollback
+      if (sessionHandler.getDoRollback() || errorOccured) {
+        sessionHandler.rollback();
+      } else if (sessionHandler.getSession().getTransaction().isActive()) {
+        sessionHandler.commitAndClose();
+      }
+    }
+  }
+
+  private static void closeOtherSessions() {
+    if (SessionHandler.existsOpenedSessions()) {
+      SessionHandler.getInstance().cleanUpSessions();
+    }
+  }
+
+  public static void closeSessions(boolean errorOccured) {
     try {
       closeDefaultPoolSession(errorOccured);
     } finally {
@@ -56,23 +79,4 @@
       }
     }
   }
-
-  private void closeDefaultPoolSession(boolean errorOccured) {
-    SessionHandler sessionHandler = SessionHandler.isSessionHandlerPresent() ? SessionHandler
-        .getInstance() : null;
-    if (sessionHandler != null && sessionHandler.doSessionInViewPatter()) {
-      // application software can force a rollback
-      if (sessionHandler.getDoRollback() || errorOccured) {
-        sessionHandler.rollback();
-      } else if (sessionHandler.getSession().getTransaction().isActive()) {
-        sessionHandler.commitAndClose();
-      }
-    }
-  }
-
-  private void closeOtherSessions() {
-    if (SessionHandler.existsOpenedSessions()) {
-      SessionHandler.getInstance().cleanUpSessions();
-    }
-  }
 }
\ No newline at end of file