'How to intercept a method call in Play Framework (Not http call)
I have a class generates and return some string. I need to append a common string value to the return value of the method.
Example
// Generates a string
public class StringGenerator {
public static String getString(){
return "abc";
}
}
// An interceptor intercepts the method call and append string to the return value (sudo code)
public class InterceptorClass {
public static String interceptStringGeneratorMethod (){
// append "def" to return value of the method
}
}
// Calling string generation method
public Result index(Http.Request request) throws IOException {
return ok(StringGenerator.getString());
// Expected output of the method call is "abcdef"
}
I am using latest play framework 2.8.12
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
