Do concurrency control on the request using the semaphore. @param request The servlet request to be processed @param response The servlet response to be created @exception IOException if an input/output error occurs @exception ServletException if a servlet error occurs
(Request request, Response response)
| 219 | * @exception ServletException if a servlet error occurs |
| 220 | */ |
| 221 | @Override |
| 222 | public void invoke(Request request, Response response) throws IOException, ServletException { |
| 223 | |
| 224 | if (controlConcurrency(request, response)) { |
| 225 | boolean shouldRelease = true; |
| 226 | try { |
| 227 | if (block) { |
| 228 | if (interruptible) { |
| 229 | try { |
| 230 | semaphore.acquire(); |
| 231 | } catch (InterruptedException e) { |
| 232 | shouldRelease = false; |
| 233 | permitDenied(request, response); |
| 234 | return; |
| 235 | } |
| 236 | } else { |
| 237 | semaphore.acquireUninterruptibly(); |
| 238 | } |
| 239 | } else { |
| 240 | if (!semaphore.tryAcquire()) { |
| 241 | shouldRelease = false; |
| 242 | permitDenied(request, response); |
| 243 | return; |
| 244 | } |
| 245 | } |
| 246 | getNext().invoke(request, response); |
| 247 | } finally { |
| 248 | if (shouldRelease) { |
| 249 | semaphore.release(); |
| 250 | } |
| 251 | } |
| 252 | } else { |
| 253 | getNext().invoke(request, response); |
| 254 | } |
| 255 | |
| 256 | } |
| 257 | |
| 258 | |
| 259 | /** |