use of act.app.App in project actframework by actframework.
the class SimpleEventListenerMetaInfo method convert.
public static List<BeanSpec> convert(List<String> paramTypes, String className, String methodName, $.Var<Method> methodHolder) {
int sz = paramTypes.size();
App app = Act.app();
ClassLoader cl = app.classLoader();
Class c = $.classForName(className, cl);
Class[] paramClasses = new Class[sz];
int i = 0;
for (String s : paramTypes) {
paramClasses[i++] = $.classForName(s, cl);
}
Method method = $.getMethod(c, methodName, paramClasses);
method.setAccessible(true);
methodHolder.set(method);
if (0 == sz) {
return C.list();
}
List<BeanSpec> retVal = new ArrayList<>(sz);
Type[] types = method.getGenericParameterTypes();
Annotation[][] annotations = method.getParameterAnnotations();
DependencyInjector injector = app.injector();
for (i = 0; i < types.length; ++i) {
retVal.add(BeanSpec.of(types[i], annotations[i], null, injector));
}
return C.list(retVal);
}
use of act.app.App in project actframework by actframework.
the class RouterTestBase method prepareClass.
@BeforeClass
public static void prepareClass() throws Exception {
AppConfig config = appConfig();
app = mock(App.class);
when(app.config()).thenReturn(config);
when(app.file(anyString())).thenAnswer(new Answer<File>() {
@Override
public File answer(InvocationOnMock invocation) throws Throwable {
String path = (String) invocation.getArguments()[0];
return new File(BASE, path);
}
});
Field f = App.class.getDeclaredField("INST");
f.setAccessible(true);
f.set(null, app);
}
use of act.app.App in project actframework by actframework.
the class RythmView method loadTemplate.
@Override
protected Template loadTemplate(String resourcePath) {
App app = Act.app();
if (isDev) {
return loadTemplateFromResource(resourcePath, app);
}
if (missings.containsKey(resourcePath)) {
return null;
}
Template template = templates.get(resourcePath);
if (null == template) {
Template newTemplate = loadTemplateFromResource(resourcePath, app);
if (null != newTemplate) {
template = templates.putIfAbsent(resourcePath, newTemplate);
if (null == template) {
template = newTemplate;
}
} else {
missings.put(resourcePath, resourcePath);
}
}
return template;
}
use of act.app.App in project actframework by actframework.
the class ActHttpHandler method createActionContext.
private ActionContext createActionContext(HttpServerExchange exchange) {
App app = client.app();
AppConfig config = app.config();
return ActionContext.create(app, req(exchange, config), resp(exchange, config));
}
use of act.app.App in project actframework by actframework.
the class NetworkBase method start.
@Override
public void start() {
bootUp();
for (int port : registry.keySet()) {
NetworkHandler client = registry.get(port);
if (!trySetUpClient(client, port, securePorts.contains(port))) {
failed.put(port, client);
} else {
Act.LOGGER.info("network client hooked on port: %s", port);
}
}
started = true;
App app = Act.app();
if (null != app) {
app.registerHotReloadListener(new App.HotReloadListener() {
@Override
public void preHotReload() {
simpleWebSocketConnector = null;
}
});
}
}
Aggregations