
json.java.application.AjaxContext Maven / Gradle / Ivy
package json.java.application;
import javax.servlet.ServletContext;
import json.java.http.AjaxRequestInfo;
import json.java.http.MutableRequest;
import json.java.http.MutableResponse;
public final class AjaxContext {
private static ThreadLocal requests = new ThreadLocal();
private static AjaxContext instance;
private AjaxContext() {
}
public synchronized static AjaxContext getInstance() {
if(instance == null) {
instance = new AjaxContext();
}
return instance;
}
public AjaxContext(AjaxRequestInfo requestInfo) {
if(requestInfo == null) {
throw new IllegalArgumentException("Request info cannot be null.");
}
requests.set(requestInfo);
}
private AjaxRequestInfo getContext() {
return requests.get();
}
public ServletContext getServletContext() {
return getContext().getServletContext();
}
public MutableRequest getRequest() {
return getContext().getRequest();
}
public MutableResponse getResponse() {
return getContext().getResponse();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy