diff --git a/jOOQ/src/main/java/org/jooq/Scope.java b/jOOQ/src/main/java/org/jooq/Scope.java index 92baf3962a..1ae091fe0e 100644 --- a/jOOQ/src/main/java/org/jooq/Scope.java +++ b/jOOQ/src/main/java/org/jooq/Scope.java @@ -50,7 +50,48 @@ import org.jooq.conf.Settings; *
* The scope of the various objects contained in this type (e.g.
* {@link #configuration()}, {@link #settings()}, etc.) are implementation
- * dependent and will be specified by the concrete subtype of Scope.
+ * dependent and will be specified by the concrete subtype of
+ * Scope. Examples of such scope types are:
+ *
+ * One of Scope's most interesting features for client code
+ * implementing any SPI is the {@link #data()} map, which provides access to a
+ * {@link Map} where client code can register user-defined values for the entire
+ * lifetime of a scope. For instance, in an {@link ExecuteListener}
+ * implementation that measures time for fetching data, it is perfectly possible
+ * to store timestamps in that map:
+ *
+ *
*
* @author Lukas Eder
*/
+ * class FetchTimeMeasuringListener extends DefaultExecuteListener {
+ * @Override
+ * public void fetchStart(ExecuteContext ctx) {
+ *
+ * // Put any arbitrary object in this map:
+ * ctx.data("org.jooq.example.fetch-start-time", System.nanoTime());
+ * }
+ *
+ * @Override
+ * public void fetchEnd(ExecuteContext ctx) {
+ *
+ * // Retrieve that object again in a later step:
+ * Long startTime = (Long) ctx.data("org.jooq.example.fetch-start-time");
+ * System.out.println("Time taken: " + (System.nanoTime() - startTime) / 1000 / 1000.0 + " ms");
+ * }
+ * }
+ *