summaryrefslogtreecommitdiff
path: root/lib/java/src
diff options
context:
space:
mode:
authorbelugabehr <12578579+belugabehr@users.noreply.github.com>2021-02-04 09:14:11 -0500
committerGitHub <noreply@github.com>2021-02-04 09:14:11 -0500
commitebc2ab558dce946b2a3134028b08ed59d49cd1e3 (patch)
tree9d4cb03da8ad3135eb7301d357f1dd9e364ee85c /lib/java/src
parent55016bff2b19f2c5d3c85ae9985c49527ffffabb (diff)
downloadthrift-ebc2ab558dce946b2a3134028b08ed59d49cd1e3.tar.gz
THRIFT-5345: Allow the ServerContext to be Unwrapped Programmatically
Client: Java Patch: David Mollitor
Diffstat (limited to 'lib/java/src')
-rw-r--r--lib/java/src/org/apache/thrift/server/ServerContext.java29
1 files changed, 26 insertions, 3 deletions
diff --git a/lib/java/src/org/apache/thrift/server/ServerContext.java b/lib/java/src/org/apache/thrift/server/ServerContext.java
index 9b0b99eea..b7c587f37 100644
--- a/lib/java/src/org/apache/thrift/server/ServerContext.java
+++ b/lib/java/src/org/apache/thrift/server/ServerContext.java
@@ -18,9 +18,32 @@
*/
/**
- * Interface for storing server's connection context
+ * Interface for storing server's connection context.
*/
-
package org.apache.thrift.server;
-public interface ServerContext {}
+public interface ServerContext {
+
+ /**
+ * Returns an object that implements the given interface to allow access to
+ * application specific contexts.
+ *
+ * @param iface A Class defining an interface that the result must implement
+ * @return an object that implements the interface
+ * @throws RuntimeException If the context cannot be unwrapped to the provided
+ * class
+ */
+ <T> T unwrap(Class<T> iface);
+
+ /**
+ * Returns true if this server context is a wrapper for the provided
+ * application specific context interface argument or returns false otherwise.
+ *
+ * @param iface a Class defining the underlying context
+ * @return true if this implements the interface can be unwrapped to the
+ * provided class
+ * @throws RuntimeException if an error occurs while determining whether the
+ * provided class can be unwrapped from this context.
+ */
+ boolean isWrapperFor(Class<?> iface);
+}