use of act.app.ActionContext in project actframework by actframework.
the class SessionScope method get.
@Override
public <T> T get(String key) {
ActionContext actionContext = ActionContext.current();
if (null != actionContext) {
H.Session session = actionContext.session();
T t = session.cached(key);
if (null != t) {
session.cache(key, t, TTL);
}
return t;
}
CliContext cliContext = CliContext.current();
if (null != cliContext) {
CliSession cliSession = cliContext.session();
return cliSession.attribute(key);
}
return null;
}
use of act.app.ActionContext in project actframework by actframework.
the class SessionScope method put.
@Override
public <T> void put(String key, T t) {
ActionContext actionContext = ActionContext.current();
if (null != actionContext) {
actionContext.session().cache(key, t, TTL);
}
CliContext cliContext = CliContext.current();
if (null != cliContext) {
CliSession cliSession = cliContext.session();
cliSession.attribute(key, t);
}
}
use of act.app.ActionContext in project actframework by actframework.
the class ActBlockingExchange method close.
@Override
public void close() throws IOException {
ActionContext ctx = ctx();
if (!exchange.isComplete()) {
try {
UndertowRequest req = (UndertowRequest) ctx.req();
req.closeAndDrainRequest();
} finally {
ActResponse resp = ctx.resp();
resp.close();
}
} else {
try {
UndertowRequest req = (UndertowRequest) ctx.req();
req.freeResources();
} finally {
UndertowResponse resp = (UndertowResponse) ctx.resp();
resp.freeResources();
}
}
}
use of act.app.ActionContext in project actframework by actframework.
the class ActHttpHandler method handleRequest.
@Override
public void handleRequest(final HttpServerExchange exchange) throws Exception {
ActionContext ctx = createActionContext(exchange);
client.handle(ctx, new UndertowNetworkDispatcher(exchange));
}
use of act.app.ActionContext in project actframework by actframework.
the class RenderCSV method setDownloadHeader.
private static void setDownloadHeader(ActContext context) {
if (context instanceof ActionContext) {
ActionContext ctx = (ActionContext) context;
UrlPath path = ctx.urlPath();
String fileName = S.concat(S.underscore(path.lastPart()), ".csv");
ctx.resp().contentDisposition(fileName, false);
}
}
Aggregations