use of act.cli.CliContext in project actframework by actframework.
the class OptionLoader method load.
@Override
public Object load(Object cachedBean, ActContext<?> context, boolean noDefaultValue) {
CliContext ctx = (CliContext) context;
String optVal = ctx.paramVal(bindName);
if (S.blank(optVal) && required) {
optVal = getFirstArgument(ctx);
}
Object val = null;
if (S.notBlank(optVal)) {
val = resolve(optVal);
}
if (null == val && null != cachedBean) {
val = cachedBean;
}
if (null == val) {
if (!required) {
val = S.notBlank(defVal) ? resolve(defVal) : resolve(null);
}
}
if (null != val && required) {
ctx.parsingContext().foundRequired(requiredGroup);
}
return val;
}
use of act.cli.CliContext in project actframework by actframework.
the class CliArgumentLoader method load.
@Override
public Object load(Object cached, ActContext<?> context, boolean noDefaultValue) {
CliContext ctx = (CliContext) context;
int id = ctx.parsingContext().curArgId().getAndIncrement();
String optVal = ctx.commandLine().argument(id);
Object val = null;
if (S.notBlank(optVal)) {
val = resolver.resolve(optVal);
}
if (null == val && null != cached) {
val = cached;
}
return val;
}
use of act.cli.CliContext in project actframework by actframework.
the class RequestScope method get.
@Override
public <T> T get(String key) {
ActionContext actionContext = ActionContext.current();
if (null != actionContext) {
return actionContext.attribute(key);
}
CliContext cliContext = CliContext.current();
if (null != cliContext) {
return cliContext.attribute(key);
}
return null;
}
use of act.cli.CliContext 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.cli.CliContext 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);
}
}
Aggregations