Find example code below for an extension of the ExecuteAndWaitInterceptor.
The goal of this code is to allow a background process to execute while having access to the same open Hibernate session object.
The SessionFactory dependency is injected into the OpenSessionExecuteAndWaitInterceptor by Spring. You may use other methods of dependency injection if you are more comfortable with them. By overriding the getNewBackgroundProcess() method, this interceptor uses our custom OpenSessionBackgroundProcess instead of the WebWork default.
Overriding the beforeInvocation() and afterInvocation() methods in the OpenSessionBackgroundProcess ensure that the session will stay open throughout the life of the background process, and any Spring transaction management will also be used.
As this code is heavily dependent on Spring and Hibernate, you shouldn't expect to see it packaged with a WebWork distribution. It does, however, serve as a useful example of extending the Execute and Wait Interceptor