/** * Wires beans property. Example: * <code>wire("").property("").ref(...).bind();</code> * @see PetiteBeans#registerPetitePropertyInjectionPoint(String, String, String) */ public BeanWireProperty property(final String propertyName) { return new BeanWireProperty(propertyName); }
@Test void testManualDefinition2() { PetiteRegistry petiteRegistry = PetiteRegistry.of(new PetiteContainer()); petiteRegistry.bean(SomeService.class).register(); petiteRegistry.bean(PojoBean.class).name("pojo").define().register(); assertEquals(2, petiteRegistry.petiteContainer().beansCount()); petiteRegistry.wire("pojo").ctor().bind(); petiteRegistry.wire("pojo").property("service").ref("someService").bind(); petiteRegistry.wire("pojo").method("injectService").ref("someService").bind(); petiteRegistry.init("pojo").invoke(POST_INITIALIZE).methods("init").register(); PojoBean pojoBean = petiteRegistry.petiteContainer().getBean("pojo"); SomeService ss = petiteRegistry.petiteContainer().getBean("someService"); assertNotNull(pojoBean); assertNotNull(ss); assertSame(ss, pojoBean.fservice); assertSame(ss, pojoBean.service); assertSame(ss, pojoBean.service2); assertEquals(1, pojoBean.count); }
@Test void testManualRegistration2() { PetiteContainer pc = new PetiteContainer(); PetiteRegistry.of(pc).bean(SomeService.class).register(); PetiteRegistry.of(pc).bean(PojoBean.class).name("pojo").register(); assertEquals(2, pc.beansCount()); PetiteRegistry.of(pc).wire("pojo").ctor().bind(); PetiteRegistry.of(pc).wire("pojo").property("service").ref("someService").bind(); PetiteRegistry.of(pc).wire("pojo").method("injectService").ref("someService").bind(); PetiteRegistry.of(pc).init("pojo").invoke(POST_INITIALIZE).methods("init").register(); PojoBean pojoBean = pc.getBean("pojo"); SomeService ss = pc.getBean("someService"); assertNotNull(pojoBean); assertNotNull(ss); assertSame(ss, pojoBean.fservice); assertSame(ss, pojoBean.service); assertSame(ss, pojoBean.service2); assertEquals(1, pojoBean.count); }
/** * Wires beans property. Example: * <code>wire("").property("").ref(...).bind();</code> * @see PetiteBeans#registerPetitePropertyInjectionPoint(String, String, String) */ public BeanWireProperty property(final String propertyName) { return new BeanWireProperty(propertyName); }