Search in sources :

Example 11 with App

use of act.app.App in project actframework by actframework.

the class GenieInjector method addModuleClass.

public static void addModuleClass(Class<?> moduleClass) {
    if (!isModuleAllowed(moduleClass)) {
        return;
    }
    App app = App.instance();
    GenieInjector genieInjector = app.injector();
    genieInjector.addModule(moduleClass);
}
Also used : App(act.app.App)

Example 12 with App

use of act.app.App in project actframework by actframework.

the class GenieInjector method foundProviderBase.

@SubClassFinder
public static void foundProviderBase(Class<? extends ActProvider> providerClass) {
    App app = App.instance();
    GenieInjector genieInjector = app.injector();
    ActProvider provider = app.getInstance(providerClass);
    genieInjector.genie().registerProvider(provider.targetType(), provider);
}
Also used : App(act.app.App)

Example 13 with App

use of act.app.App in project actframework by actframework.

the class GenieInjector method foundGenericTypedBeanLoader.

@SubClassFinder
public static void foundGenericTypedBeanLoader(Class<? extends GenericTypedBeanLoader> loaderClass) {
    App app = App.instance();
    GenieInjector genieInjector = app.injector();
    Type[] ta = loaderClass.getGenericInterfaces();
    for (Type t : ta) {
        if (t instanceof ParameterizedType) {
            ParameterizedType pt = (ParameterizedType) t;
            if (GenericTypedBeanLoader.class == pt.getRawType()) {
                Type compoentType = pt.getActualTypeArguments()[0];
                genieInjector.genie().registerGenericTypedBeanLoader((Class) compoentType, app.getInstance(loaderClass));
            }
        }
    }
}
Also used : App(act.app.App) ParameterizedType(java.lang.reflect.ParameterizedType) ParameterizedType(java.lang.reflect.ParameterizedType) Type(java.lang.reflect.Type)

Example 14 with App

use of act.app.App in project actframework by actframework.

the class GenieInjector method foundValueLoader.

@AnnotatedClassFinder(value = LoadValue.class, noAbstract = false, callOn = SysEventId.DEPENDENCY_INJECTOR_LOADED)
public static void foundValueLoader(Class<? extends Annotation> valueLoader) {
    App app = App.instance();
    GenieInjector genieInjector = app.injector();
    genieInjector.injectTags.add(valueLoader);
}
Also used : App(act.app.App)

Example 15 with App

use of act.app.App in project actframework by actframework.

the class Job method run.

@Override
public void run() {
    invokeParallelJobs();
    runPrecedenceJobs();
    try {
        if (Act.isDev() && app.isStarted()) {
            app.checkUpdates(false);
        }
        doJob();
    } catch (Throwable e) {
        boolean isFatal = FATAL_EXCEPTIONS.contains(e.getClass());
        Throwable cause = e;
        if (!isFatal) {
            cause = e.getCause();
            while (null != cause) {
                isFatal = FATAL_EXCEPTIONS.contains(cause.getClass());
                if (isFatal) {
                    break;
                }
                cause = cause.getCause();
            }
        }
        if (isFatal) {
            if (Act.isDev()) {
                app.setBlockIssue(e);
            } else {
                Act.shutdown(App.instance());
                destroy();
                if (App.instance().isMainThread()) {
                    if (cause instanceof RuntimeException) {
                        throw (RuntimeException) cause;
                    }
                    throw E.unexpected(e);
                } else {
                    logger.fatal(cause, "Fatal error executing job %s", id());
                }
            }
            return;
        }
        // TODO inject Job Exception Handling mechanism here
        logger.warn(e, "error executing job %s", id());
    } finally {
        if (!isDestroyed()) {
            executed = true;
            if (isOneTime()) {
                App app = App.instance();
                if (app.isStarted()) {
                    manager.removeJob(this);
                } else {
                    app.eventBus().bind(SysEventId.POST_START, new SysEventListenerBase() {

                        @Override
                        public void on(EventObject event) throws Exception {
                            manager.removeJob(Job.this);
                        }
                    });
                }
            }
            progress.destroy();
        }
    }
    runFollowingJobs();
}
Also used : App(act.app.App) SysEventListenerBase(act.event.SysEventListenerBase) NotAppliedException(org.osgl.exception.NotAppliedException) DuplicateRouteMappingException(act.route.DuplicateRouteMappingException) UnexpectedException(org.osgl.exception.UnexpectedException) ConfigurationException(org.osgl.exception.ConfigurationException)

Aggregations

App (act.app.App)19 AppConfig (act.conf.AppConfig)2 SubClassFinder (act.util.SubClassFinder)2 Type (java.lang.reflect.Type)2 Act (act.Act)1 SysEventListenerBase (act.event.SysEventListenerBase)1 DependencyInjector (act.inject.DependencyInjector)1 DuplicateRouteMappingException (act.route.DuplicateRouteMappingException)1 AnnotatedClassFinder (act.util.AnnotatedClassFinder)1 ClassInfoRepository (act.util.ClassInfoRepository)1 ClassNode (act.util.ClassNode)1 Template (act.view.Template)1 File (java.io.File)1 Field (java.lang.reflect.Field)1 Method (java.lang.reflect.Method)1 ParameterizedType (java.lang.reflect.ParameterizedType)1 ArrayList (java.util.ArrayList)1 NotNull (javax.validation.constraints.NotNull)1 BeforeClass (org.junit.BeforeClass)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1