Search in sources :

Example 1 with PetiteContainer

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

the class WebApplication method initWebApplication.

/**
	 * Initializes web application. Invoked very first.
	 * By default, it creates a Logger and creates internal Petite container.
	 * Also adds itself into it.
	 */
protected void initWebApplication() {
    log = LoggerFactory.getLogger(WebApplication.class);
    log.debug("Initializing Madvoc web application");
    madpc = new PetiteContainer();
    madpc.addSelf(MADVOC_CONTAINER_NAME);
}
Also used : PetiteContainer(jodd.petite.PetiteContainer)

Example 2 with PetiteContainer

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

the class InterceptorsManagerTest method testExpandStack.

@SuppressWarnings({ "unchecked" })
@Test
public void testExpandStack() {
    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 };
    Class<? extends ActionInterceptor>[] in = new Class[] { TestStack.class, DefaultWebAppInterceptors.class, EchoInterceptor.class };
    Class<? extends ActionInterceptor>[] out = im.expand(in);
    assertEquals(7, out.length);
    assertEquals(AnnotatedPropertyInterceptor.class, out[0]);
    assertEquals(LogEchoInterceptor.class, out[1]);
    assertEquals(EchoInterceptor.class, out[2]);
    assertEquals(ServletConfigInterceptor.class, out[3]);
    assertEquals(EchoInterceptor.class, out[4]);
    assertEquals(ServletConfigInterceptor.class, out[5]);
    assertEquals(EchoInterceptor.class, out[6]);
}
Also used : PetiteContainer(jodd.petite.PetiteContainer) Test(org.junit.Test)

Example 3 with PetiteContainer

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

the class MadvocParamsInjectorTest method testInjection.

@Test
public void testInjection() {
    WebApplication webapp = new WebApplication(true);
    webapp.registerMadvocComponents();
    PetiteContainer madpc = (PetiteContainer) webapp.getComponent(WebApplication.MADVOC_CONTAINER_NAME);
    MadvocConfig madvocConfig = new MadvocConfig();
    String baseName = FooBean.class.getName();
    madpc.defineParameter("foo", "1");
    madpc.defineParameter(baseName + ".integer", "173");
    madpc.defineParameter(baseName + ".string", "jodd");
    madpc.defineParameter(baseName, "huh");
    MadvocParamsInjector madvocParamsInjector = new MadvocParamsInjector(madvocConfig);
    FooBean fooBean = new FooBean();
    madvocParamsInjector.injectContext(new Target(fooBean), null, madpc);
    assertEquals(173, fooBean.getInteger().intValue());
    assertEquals("jodd", fooBean.getString());
}
Also used : WebApplication(jodd.madvoc.WebApplication) PetiteContainer(jodd.petite.PetiteContainer) MadvocConfig(jodd.madvoc.component.MadvocConfig) Test(org.junit.Test)

Example 4 with PetiteContainer

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

the class DefaultAppCoreTest method testAppPropsNameAndPattern.

@Test
public void testAppPropsNameAndPattern() {
    AppCore appCore = new AppCore();
    appCore.initCore();
    Assert.assertEquals("app.props", appCore.appPropsName);
    Assert.assertEquals("/app*.prop*", appCore.appPropsNamePattern);
    Assert.assertEquals("core", AppCore.PETITE_CORE);
    appCore.initLogger();
    appCore.initProps();
    appCore.initScanner();
    appCore.startPetite();
    PetiteContainer pc = appCore.petite;
    AppScanner as = pc.getBean(AppCore.PETITE_SCAN);
    assertSame(appCore.appScanner, as);
    assertTrue(as.ignoreExceptions);
    assertEquals(3, as.includedEntries.length);
    assertEquals("jodd.*", as.includedEntries[0]);
    assertEquals("foo.*", as.includedEntries[1]);
    assertEquals("bar.*", as.includedEntries[2]);
    assertEquals(1, as.includedJars.length);
    assertEquals("xxx", as.includedJars[0]);
}
Also used : PetiteContainer(jodd.petite.PetiteContainer) Test(org.junit.Test)

Example 5 with PetiteContainer

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

the class PetiteWebApplication method registerMadvocComponents.

/**
	 * Registers {@link #providePetiteContainer() provided Petite container}
	 * and Petite-aware Madvoc components.
	 */
@Override
public void registerMadvocComponents() {
    super.registerMadvocComponents();
    PetiteContainer petiteContainer = providePetiteContainer();
    registerComponent("petiteContainer", petiteContainer);
    registerComponent(PetiteMadvocController.class);
    registerComponent(PetiteFilterManager.class);
    registerComponent(PetiteInterceptorManager.class);
    registerComponent(PetiteResultsManager.class);
}
Also used : PetiteContainer(jodd.petite.PetiteContainer)

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