org.dellroad.stuff.servlet
Class BigFatLock
java.lang.Object
org.springframework.web.filter.GenericFilterBean
org.springframework.web.filter.OncePerRequestFilter
org.dellroad.stuff.servlet.BigFatLock
- All Implemented Interfaces:
- Filter, BeanNameAware, DisposableBean, InitializingBean, ServletContextAware
public final class BigFatLock
- extends OncePerRequestFilter
Class for serializing processing using a big fat lock.
The lock can be acquired using runWithLock(java.lang.Runnable). This class can also be used as a servlet filter.
Trace-level logging for displaying lock acquire and release events is included.
| Methods inherited from class org.springframework.web.filter.GenericFilterBean |
addRequiredProperty, afterPropertiesSet, destroy, getFilterConfig, getFilterName, getServletContext, init, initBeanWrapper, initFilterBean, setBeanName, setServletContext |
BigFatLock
public BigFatLock()
doFilterInternal
protected void doFilterInternal(HttpServletRequest request,
HttpServletResponse response,
FilterChain filterChain)
throws ServletException,
IOException
- Specified by:
doFilterInternal in class OncePerRequestFilter
- Throws:
ServletException
IOException
runWithLock
public static void runWithLock(Runnable action)
- Invoke the given action after acquiring the big fat lock.
runWithLock
public static <V> V runWithLock(Callable<V> action)
throws Exception
- Invoke the given action after acquiring the big fat lock.
- Throws:
Exception
isLockHeld
public static boolean isLockHeld()
- Verify that the current thread is holding the big fat lock.
toString
public String toString()
- Overrides:
toString in class Object