From cd55d08a6829f05a8a42fb0ca625615aa5be81f2 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Wed, 27 Mar 2013 12:12:50 +0000
Subject: [PATCH] OPENDJ-832 Leverage the work queue for processing requests received on the HTTP connection handler
---
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/AsynchronousFutureResult.java | 25 +++++++++++++++++++------
1 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/AsynchronousFutureResult.java b/opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/AsynchronousFutureResult.java
index 370a27d..a47d440 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/AsynchronousFutureResult.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/AsynchronousFutureResult.java
@@ -26,7 +26,7 @@
package com.forgerock.opendj.util;
-import static org.forgerock.opendj.ldap.ErrorResultException.newErrorResult;
+import static org.forgerock.opendj.ldap.ErrorResultException.*;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
@@ -63,9 +63,13 @@
* </ul>
*
* @param <M>
- * The type of result returned by this completion future.
+ * The type of result returned by this future.
+ * @param <H>
+ * The type of {@link ResultHandler} associated to this future.
*/
-public class AsynchronousFutureResult<M> implements FutureResult<M>, ResultHandler<M> {
+public class AsynchronousFutureResult<M, H extends ResultHandler<? super M>> implements
+ FutureResult<M>, ResultHandler<M> {
+
@SuppressWarnings("serial")
private final class Sync extends AbstractQueuedSynchronizer {
// State value representing the initial state before a result has
@@ -212,7 +216,7 @@
private final Sync sync = new Sync();
- private final ResultHandler<? super M> handler;
+ private final H handler;
private final int requestID;
@@ -224,7 +228,7 @@
* A result handler which will be forwarded the result or error
* when it arrives, may be {@code null}.
*/
- public AsynchronousFutureResult(final ResultHandler<? super M> handler) {
+ public AsynchronousFutureResult(final H handler) {
this(handler, -1);
}
@@ -239,7 +243,7 @@
* The request ID which will be returned by the default
* implementation of {@link #getRequestID}.
*/
- public AsynchronousFutureResult(final ResultHandler<? super M> handler, final int requestID) {
+ public AsynchronousFutureResult(final H handler, final int requestID) {
this.handler = handler;
this.requestID = requestID;
}
@@ -270,6 +274,15 @@
}
/**
+ * Returns the request handler associated to this FutureResult.
+ *
+ * @return the request handler associated to this FutureResult.
+ */
+ public H getRequestHandler() {
+ return handler;
+ }
+
+ /**
* {@inheritDoc}
* <p>
* The default implementation returns the request ID passed in during
--
Gitblit v1.10.0