Search in sources :

Example 1 with ParamValueLoaderManager

use of act.inject.param.ParamValueLoaderManager in project actframework by actframework.

the class ReflectedJobInvoker method init.

private synchronized void init() {
    if (null != jobClass) {
        return;
    }
    disabled = false;
    jobClass = $.classForName(classInfo.className(), cl);
    disabled = disabled || !Env.matches(jobClass);
    method = methodInfo.method();
    disabled = disabled || !Env.matches(method);
    if (disabled) {
        return;
    }
    isStatic = methodInfo.isStatic();
    if (!isStatic) {
        singleton = ReflectedInvokerHelper.tryGetSingleton(jobClass, app);
    }
    ParamValueLoaderManager paramValueLoaderManager = app.service(ParamValueLoaderManager.class);
    if (null != paramValueLoaderManager) {
        paramValueLoaderService = paramValueLoaderManager.get(JobContext.class);
    } else {
    // this job is scheduled to run before ParamValueLoaderManager initialized
    }
    if (!Modifier.isStatic(method.getModifiers())) {
        Class[] paramTypes = paramTypes();
        // constructorAccess = ConstructorAccess.get(controllerClass);
        methodAccess = MethodAccess.get(jobClass);
        methodIndex = methodAccess.getIndex(methodInfo.name(), paramTypes);
    } else {
        method.setAccessible(true);
    }
}
Also used : ParamValueLoaderManager(act.inject.param.ParamValueLoaderManager) JobContext(act.job.JobContext)

Example 2 with ParamValueLoaderManager

use of act.inject.param.ParamValueLoaderManager 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");
}
Also used : AppCodeScannerManager(act.app.AppCodeScannerManager) C(org.osgl.util.C) AppByteCodeScanner(act.app.AppByteCodeScanner) JobByteCodeScanner(act.job.bytecode.JobByteCodeScanner) ParamValueLoaderManager(act.inject.param.ParamValueLoaderManager) TestingAppClassLoader(act.app.TestingAppClassLoader) EventBus(act.event.EventBus) JobManager(act.job.JobManager) ClassInfoRepository(act.util.ClassInfoRepository) File(java.io.File) Before(org.junit.Before)

Aggregations

ParamValueLoaderManager (act.inject.param.ParamValueLoaderManager)2 AppByteCodeScanner (act.app.AppByteCodeScanner)1 AppCodeScannerManager (act.app.AppCodeScannerManager)1 TestingAppClassLoader (act.app.TestingAppClassLoader)1 EventBus (act.event.EventBus)1 JobContext (act.job.JobContext)1 JobManager (act.job.JobManager)1 JobByteCodeScanner (act.job.bytecode.JobByteCodeScanner)1 ClassInfoRepository (act.util.ClassInfoRepository)1 File (java.io.File)1 Before (org.junit.Before)1 C (org.osgl.util.C)1