Created
August 15, 2012 14:05
-
-
Save lucascs/3360420 to your computer and use it in GitHub Desktop.
Forcing commit on redirects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Intercepts | |
public class RedirectCommitInterceptor implements Interceptor { | |
private Session session; | |
private MutableResponse response; | |
public RedirectCommitInterceptor(Session session, MutableResponse response) { | |
this.session = session; | |
this.response = response; | |
} | |
public boolean accept(ResourceMethod method) { | |
return true; | |
} | |
public void intercept(ResourceMethod method, Object instance, InterceptorStack stack) { | |
response.addRedirectListener(new RedirectListener() { | |
@Override | |
public void beforeRedirect() { | |
session.getTransaction().commit(); | |
} | |
}); | |
stack.next(method, instance); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment