We are in the process of migrating a Swing two tier application to a web application (tomcat, Spring MVC, extJS if it makes any difference).
We found code like this in the application (simplified Javaesc pseudo code).
class DoSomethingComplicatedAction extends Action{
public performAction(..){
// do lots of stuff here
// decend about 40 steps in the call stack
answer = JOptionPane.showConfirmDialog()
if (answer == something){
// do something convoluted here
} else {
// do something even more convoluted here
}
}
i.e. in the middle of some processing, some interaction with the user is started. Obviously I can't do that directly with a servlet.
One thing that could handle this rather nicely are continuations. So I checked if I can use those and were surprised that there are actually libraries that enable this kind of stuff: Continuations in Java
When checking the libraries mentioned in that question and its answers I ran across this statement
Continuations will be replaced by standard Servlet-3.0 suspendable requests once the specification is finalized. Early releases of Jetty-7 are now available that implement the proposed standard suspend/resume API
But I couldn't find an example how to do stuff like the above with the Servlet 3.0 API
So the questions are:
Can the above be done using the Servlet-3.0 API without completely refactoring the code sketched above into two or more separate actions
If the answer to the above is yes: How? Are there somewhat complete examples for this or a similar use case available?
Should I use Continuations or the Servlet API? Or if this can't be answered directly on what conditions does this decision depend on?