Search in sources :

Example 6 with PetiteContainer

use of jodd.petite.PetiteContainer in project jodd by oblac.

the class PetiteWebApplication method providePetiteContainer.

/**
	 * Provides {@link PetiteContainer Petite container} instance that will be used as application context.
	 * By default it {@link #createPetiteContainer() creates new container instance} and performs
	 * {@link jodd.petite.config.AutomagicPetiteConfigurator auto-magic configuration}.
	 */
protected PetiteContainer providePetiteContainer() {
    PetiteContainer pc = createPetiteContainer();
    AutomagicPetiteConfigurator configurator = new AutomagicPetiteConfigurator();
    configurator.configure(pc);
    return pc;
}
Also used : AutomagicPetiteConfigurator(jodd.petite.config.AutomagicPetiteConfigurator) PetiteContainer(jodd.petite.PetiteContainer)

Example 7 with PetiteContainer

use of jodd.petite.PetiteContainer in project jodd by oblac.

the class InterceptorsManagerTest method testExpandConfigurableStack.

@SuppressWarnings({ "unchecked" })
@Test
public void testExpandConfigurableStack() {
    InjectorsManager injectorsManager = new InjectorsManager();
    injectorsManager.scopeDataResolver = new ScopeDataResolver();
    injectorsManager.madvocConfig = new MadvocConfig();
    injectorsManager.madpc = new PetiteContainer();
    InterceptorsManager im = new InterceptorsManager();
    im.contextInjectorComponent = new ContextInjectorComponent();
    im.contextInjectorComponent.injectorsManager = injectorsManager;
    im.contextInjectorComponent.madvocController = new MadvocController();
    im.contextInjectorComponent.scopeDataResolver = injectorsManager.scopeDataResolver;
    im.contextInjectorComponent.madpc = injectorsManager.madpc;
    im.madvocConfig = injectorsManager.madvocConfig;
    im.madvocConfig.defaultInterceptors = new Class[] { EchoInterceptor.class, ServletConfigInterceptor.class };
    injectorsManager.madpc.defineParameter(TestConfigurableStack.class.getName() + ".interceptors", AnnotatedPropertyInterceptor.class.getName() + "," + ServletConfigInterceptor.class.getName() + "," + LogEchoInterceptor.class.getName());
    injectorsManager.createInjectors();
    Class<? extends ActionInterceptor>[] in = new Class[] { TestConfigurableStack.class, TestConfigurableStack2.class, EchoInterceptor.class };
    Class<? extends ActionInterceptor>[] out = im.expand(in);
    // 3 + 2 + 1
    assertEquals(6, out.length);
    // assert: TestConfigurableStack => defined in madpc
    assertEquals(AnnotatedPropertyInterceptor.class, out[0]);
    assertEquals(ServletConfigInterceptor.class, out[1]);
    assertEquals(LogEchoInterceptor.class, out[2]);
    //assert: TestConfigurableStack2 => madvocConfig.defaultInterceptors
    assertEquals(EchoInterceptor.class, out[3]);
    assertEquals(ServletConfigInterceptor.class, out[4]);
    assertEquals(EchoInterceptor.class, out[5]);
}
Also used : PetiteContainer(jodd.petite.PetiteContainer) Test(org.junit.Test)

Example 8 with PetiteContainer

use of jodd.petite.PetiteContainer in project jodd by oblac.

the class InterceptorsManagerTest method testExpandStack2.

@SuppressWarnings({ "unchecked" })
@Test
public void testExpandStack2() {
    InjectorsManager injectorsManager = new InjectorsManager();
    injectorsManager.scopeDataResolver = new ScopeDataResolver();
    injectorsManager.madvocConfig = new MadvocConfig();
    injectorsManager.madpc = new PetiteContainer();
    injectorsManager.createInjectors();
    InterceptorsManager im = new InterceptorsManager();
    im.contextInjectorComponent = new ContextInjectorComponent();
    im.contextInjectorComponent.injectorsManager = injectorsManager;
    im.contextInjectorComponent.madvocController = new MadvocController();
    im.contextInjectorComponent.scopeDataResolver = injectorsManager.scopeDataResolver;
    im.contextInjectorComponent.madpc = injectorsManager.madpc;
    im.madvocConfig = injectorsManager.madvocConfig;
    im.madvocConfig.defaultInterceptors = new Class[] { EchoInterceptor.class, ServletConfigInterceptor.class, Test2Stack.class };
    Class<? extends ActionInterceptor>[] in = new Class[] { DefaultWebAppInterceptors.class };
    Class<? extends ActionInterceptor>[] out = im.expand(in);
    assertEquals(4, out.length);
    assertEquals(EchoInterceptor.class, out[0]);
    assertEquals(ServletConfigInterceptor.class, out[1]);
    assertEquals(AnnotatedPropertyInterceptor.class, out[2]);
    assertEquals(LogEchoInterceptor.class, out[3]);
}
Also used : PetiteContainer(jodd.petite.PetiteContainer) Test(org.junit.Test)

Aggregations

PetiteContainer (jodd.petite.PetiteContainer)8 Test (org.junit.Test)5 WebApplication (jodd.madvoc.WebApplication)1 MadvocConfig (jodd.madvoc.component.MadvocConfig)1 AutomagicPetiteConfigurator (jodd.petite.config.AutomagicPetiteConfigurator)1