Search in sources :

Example 6 with ClassInfoRepository

use of act.util.ClassInfoRepository in project actframework by actframework.

the class ControllerEnhancerTest method setup.

@Before
public void setup() throws Exception {
    super.setup();
    invokeLog = mock(InvokeLog.class);
    scanner = new ControllerByteCodeScanner();
    scanner.setApp(mockApp);
    eventBus = mock(EventBus.class);
    classLoader = new TestingAppClassLoader(mockApp);
    classInfoRepository = mock(ClassInfoRepository.class);
    $.setProperty(classLoader, classInfoRepository, "classInfoRepository");
    infoSrc = classLoader.controllerClassMetaInfoManager();
    scannerManager = mock(AppCodeScannerManager.class);
    when(mockApp.classLoader()).thenReturn(classLoader);
    when(mockApp.scannerManager()).thenReturn(scannerManager);
    when(mockApp.eventBus()).thenReturn(eventBus);
    when(mockAppConfig.possibleControllerClass(anyString())).thenReturn(true);
    when(mockRouter.isActionMethod(anyString(), anyString())).thenReturn(false);
    C.List<AppByteCodeScanner> scanners = C.list(scanner);
    when(scannerManager.byteCodeScanners()).thenReturn(scanners);
    InvokeLogFactory.set(invokeLog);
    ActionContext.clearCurrent();
    ctx = ActionContext.create(mockApp, mockReq, mockResp);
    ctx.saveLocal();
    base = new File("./target/test-classes");
}
Also used : AppCodeScannerManager(act.app.AppCodeScannerManager) C(org.osgl.util.C) AppByteCodeScanner(act.app.AppByteCodeScanner) TestingAppClassLoader(act.app.TestingAppClassLoader) EventBus(act.event.EventBus) ClassInfoRepository(act.util.ClassInfoRepository) InvokeLog(testapp.util.InvokeLog) Before(org.junit.Before)

Example 7 with ClassInfoRepository

use of act.util.ClassInfoRepository in project actframework by actframework.

the class ActionMethodMetaInfo method mergeFromWithList.

private void mergeFromWithList(final ControllerClassMetaInfoManager infoBase, final App app) {
    C.Set<String> withClasses = this.withList;
    if (withClasses.isEmpty()) {
        return;
    }
    ClassInfoRepository repo = app.classLoader().classInfoRepository();
    for (final String withClass : withClasses) {
        String curWithClass = withClass;
        ControllerClassMetaInfo withClassInfo = infoBase.controllerMetaInfo(curWithClass);
        while (null == withClassInfo && !"java.lang.Object".equals(curWithClass)) {
            ClassNode node = repo.node(curWithClass);
            if (null != node) {
                node = node.parent();
            }
            if (null == node) {
                break;
            }
            curWithClass = node.name();
            withClassInfo = infoBase.controllerMetaInfo(curWithClass);
        }
        if (null != withClassInfo) {
            withClassInfo.merge(infoBase, app);
            interceptors.mergeFrom(withClassInfo.interceptors);
        }
    }
}
Also used : ClassNode(act.util.ClassNode) C(org.osgl.util.C) ClassInfoRepository(act.util.ClassInfoRepository)

Example 8 with ClassInfoRepository

use of act.util.ClassInfoRepository in project actframework by actframework.

the class ControllerClassMetaInfo method mergeFromWithList.

private void mergeFromWithList(final ControllerClassMetaInfoManager infoBase, final App app) {
    C.Set<String> withClasses = C.newSet();
    getAllWithList(withClasses, infoBase);
    final ControllerClassMetaInfo me = this;
    ClassInfoRepository repo = app.classLoader().classInfoRepository();
    for (final String withClass : withClasses) {
        String curWithClass = withClass;
        ControllerClassMetaInfo withClassInfo = infoBase.controllerMetaInfo(curWithClass);
        while (null == withClassInfo && !"java.lang.Object".equals(curWithClass)) {
            ClassNode node = repo.node(curWithClass);
            if (null != node) {
                node = node.parent();
            }
            if (null == node) {
                break;
            }
            curWithClass = node.name();
            withClassInfo = infoBase.controllerMetaInfo(curWithClass);
        }
        if (null != withClassInfo) {
            withClassInfo.merge(infoBase, app);
            if (isMyAncestor(withClassInfo)) {
                interceptors.mergeFrom(withClassInfo.interceptors, me);
            } else {
                interceptors.mergeFrom(withClassInfo.interceptors);
            }
        }
    }
}
Also used : ClassNode(act.util.ClassNode) C(org.osgl.util.C) ClassInfoRepository(act.util.ClassInfoRepository)

Example 9 with ClassInfoRepository

use of act.util.ClassInfoRepository in project actframework by actframework.

the class ControllerClassMetaInfoManager method buildControllerHierarchies.

public void buildControllerHierarchies() {
    AppClassLoader cl = Act.app().classLoader();
    ControllerClassMetaInfoManager manager = cl.controllerClassMetaInfoManager();
    ClassInfoRepository repo = cl.classInfoRepository();
    for (ControllerClassMetaInfo info : manager.controllers.values()) {
        buildSuperClassMetaInfo(info, manager, repo);
    }
}
Also used : AppClassLoader(act.app.AppClassLoader) ClassInfoRepository(act.util.ClassInfoRepository)

Aggregations

ClassInfoRepository (act.util.ClassInfoRepository)9 ClassNode (act.util.ClassNode)6 C (org.osgl.util.C)4 AppByteCodeScanner (act.app.AppByteCodeScanner)2 AppClassLoader (act.app.AppClassLoader)2 AppCodeScannerManager (act.app.AppCodeScannerManager)2 TestingAppClassLoader (act.app.TestingAppClassLoader)2 EventBus (act.event.EventBus)2 Before (org.junit.Before)2 App (act.app.App)1 ParamValueLoaderManager (act.inject.param.ParamValueLoaderManager)1 JobManager (act.job.JobManager)1 JobByteCodeScanner (act.job.bytecode.JobByteCodeScanner)1 File (java.io.File)1 org.osgl.$ (org.osgl.$)1 InvokeLog (testapp.util.InvokeLog)1