use of act.util.ClassInfoRepository in project actframework by actframework.
the class ResultClassLookup method loadResultClasses.
private void loadResultClasses() {
final String RESULT = Result.class.getName();
_set.add(RESULT);
ClassInfoRepository repo = Act.app().classLoader().classInfoRepository();
ClassNode resultNode = repo.node(RESULT);
if (null == resultNode) {
// inside unit test
add(Ok.class, NotFound.class, ErrorResult.class, NotAcceptable.class, Forbidden.class, NotImplemented.class, BadRequest.class, Conflict.class, MethodNotAllowed.class, Unauthorized.class, ServerError.class, NotModified.class, RenderBinary.class, Accepted.class, Created.class, NoResult.class, Redirect.class, RenderTemplate.class, RenderAny.class, ZXingResult.class, RenderJsonMap.class, RenderJSON.class, RenderContent.class, RenderXML.class, RenderCSV.class, RenderHtml.class, FilteredRenderJSON.class, FilteredRenderXML.class, RenderText.class);
} else {
resultNode.visitPublicSubTreeNodes(new $.Visitor<ClassNode>() {
@Override
public void visit(ClassNode classNode) throws Osgl.Break {
_set.add(classNode.name());
}
});
}
}
use of act.util.ClassInfoRepository in project actframework by actframework.
the class ControllerClassMetaInfo method getAllWithList.
private void getAllWithList(final Set<String> withList, final ControllerClassMetaInfoManager infoBase) {
withList.addAll(this.withList);
if (null != superType) {
final String superClass = superType.getClassName();
App app = App.instance();
ClassInfoRepository repo = app.classLoader().classInfoRepository();
ControllerClassMetaInfo info = infoBase.controllerMetaInfo(superClass);
String curSuperClass = superClass;
while (null == info && !"java.lang.Object".equals(curSuperClass)) {
ClassNode node = repo.node(curSuperClass);
if (null != node) {
node = node.parent();
}
if (null == node) {
break;
}
curSuperClass = node.name();
info = infoBase.controllerMetaInfo(curSuperClass);
}
if (null != info) {
withList.add(superClass);
}
}
}
use of act.util.ClassInfoRepository in project actframework by actframework.
the class ControllerClassMetaInfo method parent.
public ControllerClassMetaInfo parent(boolean checkClassInfoRepo) {
if (null != parent) {
return parent;
}
if (!checkClassInfoRepo) {
return null;
}
AppClassLoader classLoader = Act.app().classLoader();
ClassInfoRepository repo = classLoader.classInfoRepository();
ClassNode parentNode = repo.node(superType.getClassName());
while (null != parentNode) {
parentNode = parentNode.parent();
if (null != parentNode) {
ControllerClassMetaInfo parentInfo = classLoader.controllerClassMetaInfo(parentNode.name());
if (null != parentInfo) {
return parentInfo;
}
} else {
return null;
}
}
return null;
}
use of act.util.ClassInfoRepository in project actframework by actframework.
the class FullStackAppBootstrapClassLoader method cache.
private synchronized ClassNode cache(Class<?> c) {
String cname = canonicalName(c);
if (null == cname) {
return null;
}
String name = c.getName();
ClassInfoRepository repo = (ClassInfoRepository) classInfoRepository();
if (repo.has(cname)) {
return repo.node(name, cname);
}
actClasses.add(c);
ClassNode node = repo.node(name);
node.modifiers(c.getModifiers());
Class[] ca = c.getInterfaces();
for (Class pc : ca) {
if (pc == Object.class)
continue;
String pcname = canonicalName(pc);
if (null != pcname) {
cache(pc);
node.addInterface(pcname);
}
}
Class pc = c.getSuperclass();
if (null != pc && Object.class != pc) {
String pcname = canonicalName(pc);
if (null != pcname) {
cache(pc);
node.parent(pcname);
}
}
return node;
}
use of act.util.ClassInfoRepository in project actframework by actframework.
the class ControllerByteCodeScannerTest method setup.
@Before
public void setup() throws Exception {
super.setup();
controllerScanner = new ControllerByteCodeScanner();
jobScanner = new JobByteCodeScanner();
scannerManager = mock(AppCodeScannerManager.class);
classInfoRepository = mock(ClassInfoRepository.class);
eventBus = mock(EventBus.class);
when(mockApp.eventBus()).thenReturn(eventBus);
jobManager = new JobManager(mockApp);
classLoader = new TestingAppClassLoader(mockApp);
$.setProperty(classLoader, classInfoRepository, "classInfoRepository");
when(mockApp.classLoader()).thenReturn(classLoader);
infoSrc = classLoader.controllerClassMetaInfoManager();
when(mockApp.classLoader()).thenReturn(classLoader);
when(mockApp.scannerManager()).thenReturn(scannerManager);
when(mockApp.jobManager()).thenReturn(jobManager);
when(mockAppConfig.possibleControllerClass(anyString())).thenReturn(true);
when(mockRouter.isActionMethod(anyString(), anyString())).thenReturn(false);
C.List<AppByteCodeScanner> scanners = $.cast(C.listOf(controllerScanner, jobScanner));
// C.List<AppByteCodeScanner> scanners = C.list(controllerScanner);
when(scannerManager.byteCodeScanners()).thenReturn(scanners);
paramValueLoaderManager = mock(ParamValueLoaderManager.class);
when(mockApp.service(ParamValueLoaderManager.class)).thenReturn(paramValueLoaderManager);
controllerScanner.setApp(mockApp);
jobScanner.setApp(mockApp);
base = new File("./target/test-classes");
}
Aggregations