use of com.peterphi.std.guice.web.HttpCallContext in project stdlib by petergeneric.
the class GuiceServlet method service.
@Override
protected final void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
final HttpCallContext ctx = HttpCallContext.set(req, resp, getServletContext());
try {
// Share the call id to log4j
Tracing.start(ctx.getLogId(), ctx.isVerbose());
// If necessary set up Guice
if (!ready.get()) {
if (registry == null)
registry = new GuiceRegistry(new GuiceBuilder().withRole(new WebappGuiceRole(getServletConfig())));
registry.register(this, true);
}
// Make the call
doService(req, resp);
} finally {
HttpCallContext.clear();
Tracing.clear();
}
}
use of com.peterphi.std.guice.web.HttpCallContext in project stdlib by petergeneric.
the class SessionScoping method seed.
public <T> void seed(Key<T> key, T instance) {
final String name = key.toString();
final HttpCallContext ctx = HttpCallContext.get();
final HttpSession session = ctx.getRequest().getSession();
synchronized (session) {
if (exists(key))
throw new IllegalArgumentException("Cannot seed Session scope with instance for " + key + ": Session scope already has an instance of this key!");
if (instance != null)
session.setAttribute(name, instance);
else
session.setAttribute(name, NullObject.INSTANCE);
}
}
Aggregations