public void defineParams(final Props props) { madpc.defineParameters(props); }
public void defineParams(final Map params) { madpc.defineParameters(params); }
@Test void testProperties() { PetiteContainer pc = new PetiteContainer(); pc.registerPetiteBean(Foo.class, null, null, null, false, null); Properties p = new Properties(); p.setProperty("foo.name", "${name}"); p.setProperty("name", "${name2}"); p.setProperty("name2", "FOONAME"); pc.defineParameters(p); Foo foo = pc.getBean("foo"); assertNotNull(foo); assertEquals("FOONAME", foo.getName()); }
/** * Creates and initializes Petite container. * It will be auto-magically configured by scanning the classpath. */ @Override public void start() { initLogger(); log.info("PETITE start ----------"); petiteContainer = createPetiteContainer(); if (externalsCache) { petiteContainer.setExternalsCache(TypeCache.createDefault()); } log.info("Web application? " + isWebApplication); if (!isWebApplication) { // make session scope to act as singleton scope // if this is not a web application (and http session is not available). petiteContainer.registerScope(SessionScope.class, new SingletonScope(petiteContainer)); } // load parameters from properties files petiteContainer.defineParameters(joyPropsSupplier.get().getProps()); // automagic configuration if (autoConfiguration) { final AutomagicPetiteConfigurator automagicPetiteConfigurator = new AutomagicPetiteConfigurator(petiteContainer); automagicPetiteConfigurator.registerAsConsumer(joyScannerSupplier.get().getClassScanner()); } petiteContainerConsumers.accept(this.petiteContainer); log.info("PETITE OK!"); }
@Test void testProps() { Props props = new Props(); props.load("pojoBean2.val2=123"); props.load("pojoBean2.val1=\\\\${pojo}"); assertEquals("123", props.getValue("pojoBean2.val2")); assertEquals("\\${pojo}", props.getValue("pojoBean2.val1")); PetiteContainer pc = new PetiteContainer(); pc.registerPetiteBean(PojoBean2.class, null, null, null, false, null); pc.defineParameters(props); PojoBean2 pojoBean2 = pc.getBean(PojoBean2.class); assertEquals(123, pojoBean2.getVal2().intValue()); assertEquals("${pojo}", pojoBean2.getVal1()); }
/** * Initialized web application parameters. Provided properties object is always non-<code>null</code>. * Simple defines parameters for internal container. */ protected void defineParams(Properties properties) { if (log.isDebugEnabled()) { log.debug("Defining Madvoc parameters"); } madpc.defineParameters(properties); }
protected void defineParams(Props props) { if (log.isDebugEnabled()) { log.debug("Defining Madvoc parameters"); } madpc.defineParameters(props); }
/** * Creates and initializes Petite container. * It will be auto-magically configured by scanning the classpath. */ @Override public void start() { initLogger(); log.info("PETITE start ----------"); petiteContainer = createPetiteContainer(); if (externalsCache) { petiteContainer.setExternalsCache(TypeCache.createDefault()); } log.info("Web application? " + isWebApplication); if (!isWebApplication) { // make session scope to act as singleton scope // if this is not a web application (and http session is not available). petiteContainer.registerScope(SessionScope.class, new SingletonScope(petiteContainer)); } // load parameters from properties files petiteContainer.defineParameters(joyPropsSupplier.get().getProps()); // automagic configuration if (autoConfiguration) { final AutomagicPetiteConfigurator automagicPetiteConfigurator = new AutomagicPetiteConfigurator(petiteContainer); automagicPetiteConfigurator.registerAsConsumer(joyScannerSupplier.get().getClassScanner()); } petiteContainerConsumers.accept(this.petiteContainer); log.info("PETITE OK!"); }