Class ReportSemaphoreHandling
- java.lang.Object
-
- org.openbravo.client.application.report.ReportSemaphoreHandling
-
- All Implemented Interfaces:
OBProvidable
,OBSingleton
public class ReportSemaphoreHandling extends Object implements OBSingleton
A class which can be used to limit the number of parallel processes running. If no semaphore is available anOBException
is thrown. This semaphore handler can/should be used by heavy resource intensive reporting processes.To prevent too many to run at the same time. Implementation is based onSemaphore
. Theacquire()
andrelease()
methods should be called using a try finally block:// call acquire before the try: ReportSemaphoreHandling.getInstance().acquire(); try { } finally { ReportSemaphoreHandling.getInstance().release(); }
- Author:
- mtaal
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
acquire()
Increments the threadCounter by one unit.static ReportSemaphoreHandling
getInstance()
void
release()
Decreases the threadCounter by one unit.
-
-
-
Method Detail
-
getInstance
public static ReportSemaphoreHandling getInstance()
-
acquire
public void acquire() throws OBException
Increments the threadCounter by one unit. The Max value of the counter can be parameterized by setting the OBUIAPP_MaxReportThreads System preference. If no preference is found or it is wrongly configured DEFAULT_MAX_THREADS default value is used.- Throws:
OBException
- When the threadCounter is in its max value.
-
release
public void release()
Decreases the threadCounter by one unit.
-
-