Search in sources :

Example 1 with GenieInjector

use of act.inject.genie.GenieInjector in project actframework by actframework.

the class App method hasSingletonAnnotation.

private boolean hasSingletonAnnotation(Class<?> cls) {
    boolean found = false;
    GenieInjector injector = Act.app().injector();
    Annotation[] aa = cls.getAnnotations();
    for (Annotation a : aa) {
        Class<? extends Annotation> type = a.annotationType();
        if (injector.isInheritedScopeStopper(type)) {
            return false;
        }
        if (InheritedStateless.class == type || Stateless.class == type || Singleton.class == type) {
            found = true;
        }
    }
    return found;
}
Also used : GenieInjector(act.inject.genie.GenieInjector) Singleton(javax.inject.Singleton) Annotation(java.lang.annotation.Annotation)

Example 2 with GenieInjector

use of act.inject.genie.GenieInjector in project actframework by actframework.

the class App method registerMetricProvider.

private void registerMetricProvider() {
    GenieInjector gi = this.injector();
    MetricProvider mp = new MetricProvider();
    gi.registerNamedProvider(Metric.class, mp);
    gi.registerProvider(Metric.class, mp);
}
Also used : MetricProvider(act.metric.MetricProvider) GenieInjector(act.inject.genie.GenieInjector)

Example 3 with GenieInjector

use of act.inject.genie.GenieInjector in project actframework by actframework.

the class AutoConfigPluginTest method before.

@Before
public void before() throws Exception {
    setup();
    resolverManager = new StringValueResolverManager(mockApp);
    when(mockApp.resolverManager()).thenReturn(resolverManager);
    injector = new GenieInjector(mockApp);
    when(mockApp.injector()).thenReturn(injector);
    GenericPluginManager pluginManager = mock(GenericPluginManager.class);
    Field field = Act.class.getDeclaredField("pluginManager");
    field.setAccessible(true);
    field.set(null, pluginManager);
    when(mockAppConfig.getIgnoreCase(argThat(new ContainsIgnoreCase(".int")))).thenReturn(intVal);
    when(mockAppConfig.getIgnoreCase(argThat(new ContainsIgnoreCase(".long")))).thenReturn(longVal);
    when(mockAppConfig.getIgnoreCase(argThat(new ContainsIgnoreCase(".bool")))).thenReturn(boolVal);
    when(mockAppConfig.getIgnoreCase(argThat(new ContainsIgnoreCase(".str")))).thenReturn(stringVal);
    when(mockAppConfig.getIgnoreCase(argThat(new ContainsIgnoreCase(".method")))).thenReturn(enumVal);
    when(mockAppConfig.getIgnoreCase(argThat(new ContainsIgnoreCase(".list")))).thenReturn(intListVal);
}
Also used : Field(java.lang.reflect.Field) GenericPluginManager(act.plugin.GenericPluginManager) GenieInjector(act.inject.genie.GenieInjector) StringValueResolverManager(act.app.data.StringValueResolverManager) Before(org.junit.Before)

Aggregations

GenieInjector (act.inject.genie.GenieInjector)3 StringValueResolverManager (act.app.data.StringValueResolverManager)1 MetricProvider (act.metric.MetricProvider)1 GenericPluginManager (act.plugin.GenericPluginManager)1 Annotation (java.lang.annotation.Annotation)1 Field (java.lang.reflect.Field)1 Singleton (javax.inject.Singleton)1 Before (org.junit.Before)1