use of act.app.App in project actframework by actframework.
the class RequestHandlerProxy method generateHandlers.
private void generateHandlers() {
ControllerClassMetaInfo ctrlInfo = app.classLoader().controllerClassMetaInfo(controllerClassName);
ActionMethodMetaInfo actionInfo = ctrlInfo.action(actionMethodName);
if (null == actionInfo) {
actionInfo = findActionInfoFromParent(ctrlInfo, actionMethodName);
}
webSocketConnectionHandler = tryGenerateWebSocketConnectionHandler(actionInfo);
// if (null != webSocketConnectionHandler) {
// return;
// }
Act.Mode mode = Act.mode();
actionHandler = mode.createRequestHandler(actionInfo, app);
actionMethod = actionHandler.invoker().invokeMethod();
sessionFree = actionHandler.sessionFree();
missingAuthenticationHandler = actionHandler.missingAuthenticationHandler();
csrfFailureHandler = actionHandler.csrfFailureHandler();
express = actionHandler.express();
cacheSupport = actionHandler.cacheSupport();
supportCache = cacheSupport.enabled;
App app = this.app;
if (supportCache) {
cache = app.cache();
}
GroupInterceptorMetaInfo interceptorMetaInfo = new GroupInterceptorMetaInfo(actionInfo.interceptors());
interceptorMetaInfo.mergeFrom(globalFreeStyleInterceptor);
for (GroupInterceptorMetaInfo freeStyleInterceptor : globalFreeStyleInterceptors) {
interceptorMetaInfo.mergeFrom(freeStyleInterceptor);
}
for (InterceptorMethodMetaInfo info : interceptorMetaInfo.beforeList()) {
if (!applied(info)) {
continue;
}
BeforeInterceptor interceptor = mode.createBeforeInterceptor(info, app);
beforeInterceptors.add(interceptor);
sessionFree = sessionFree && interceptor.sessionFree();
express = express && interceptor.express();
}
for (InterceptorMethodMetaInfo info : interceptorMetaInfo.afterList()) {
if (!applied(info)) {
continue;
}
AfterInterceptor interceptor = mode.createAfterInterceptor(info, app);
afterInterceptors.add(interceptor);
sessionFree = sessionFree && interceptor.sessionFree();
express = express && interceptor.express();
}
for (CatchMethodMetaInfo info : interceptorMetaInfo.catchList()) {
if (!applied(info)) {
continue;
}
ExceptionInterceptor interceptor = mode.createExceptionInterceptor(info, app);
exceptionInterceptors.add(interceptor);
sessionFree = sessionFree && interceptor.sessionFree();
express = express && interceptor.express();
}
Collections.sort(exceptionInterceptors);
for (InterceptorMethodMetaInfo info : interceptorMetaInfo.finallyList()) {
if (!applied(info)) {
continue;
}
FinallyInterceptor interceptor = mode.createFinallyInterceptor(info, app);
finallyInterceptors.add(interceptor);
sessionFree = sessionFree && interceptor.sessionFree();
express = express && interceptor.express();
}
}
use of act.app.App in project actframework by actframework.
the class FindBy method initialized.
@Override
protected void initialized() {
App app = App.instance();
rawType = spec.rawType();
notNull = spec.hasAnnotation(NotNull.class);
findOne = !(Iterable.class.isAssignableFrom(rawType));
dao = app.dbServiceManager().dao(findOne ? rawType : (Class) spec.typeParams().get(0));
queryFieldName = S.string(options.get("field"));
byId = findOne && S.blank(queryFieldName) && (Boolean) options.get("byId");
resolver = app.resolverManager().resolver(byId ? dao.idType() : (Class) options.get("fieldType"));
if (null == resolver) {
throw new IllegalArgumentException("Cannot find String value resolver for type: " + dao.idType());
}
requestParamName = S.string(value());
if (S.blank(requestParamName)) {
requestParamName = ParamValueLoaderService.bindName(spec);
}
if (!byId) {
if (S.blank(queryFieldName)) {
queryFieldName = requestParamName;
}
}
}
use of act.app.App in project actframework by actframework.
the class ReflectedSimpleEventListener method host.
private Object host() {
if (isStatic) {
return null;
} else {
if (null == host) {
synchronized (this) {
if (null == host) {
App app = App.instance();
host = app.getInstance(hostClass);
}
}
}
return host;
}
}
use of act.app.App in project actframework by actframework.
the class ReflectedSimpleEventListener method invoke.
@Override
public void invoke(Object... args) {
int paramNo = paramTypes.size();
int argsNo = args.length;
Object[] realArgs = args;
if (paramNo != argsNo || providedParamSize > 0) {
realArgs = new Object[paramNo + providedParamSize];
System.arraycopy(args, 0, realArgs, 0, Math.min(paramNo, argsNo));
App app = Act.app();
for (int i = 0; i < providedParamSize; ++i) {
realArgs[i + paramNo] = app.getInstance(providedParamTypes.get(i));
}
}
Object host = host();
if (null == host) {
$.invokeStatic(method, realArgs);
} else {
$.invokeVirtual(host, method, realArgs);
}
}
Aggregations