/** * Creates {@link jodd.petite.BeanDefinition} on * {@link #registerPetiteBean(Class, String, Class, WiringMode, boolean, Consumer) bean registration}. * This is a hook for modifying the bean data, like passing proxifed class etc. * By default returns new instance of {@link jodd.petite.BeanDefinition}. */ protected <T> BeanDefinition createBeanDefinitionForRegistration( final String name, final Class<T> type, final Scope scope, final WiringMode wiringMode, final Consumer<T> consumer) { return new BeanDefinition<>(name, type, scope, wiringMode, consumer); }
/** * Creates {@link jodd.petite.BeanDefinition} for all external beans. */ protected <T> BeanDefinition createBeandDefinitionForExternalBeans( final Class<T> type, final WiringMode wiringMode) { final String name = resolveBeanName(type); return new BeanDefinition<>(name, type, null, wiringMode, null); }
/** * Creates {@link jodd.petite.BeanDefinition} on * {@link #registerPetiteBean(Class, String, Class, WiringMode, boolean, Consumer) bean registration}. * This is a hook for modifying the bean data, like passing proxifed class etc. * By default returns new instance of {@link jodd.petite.BeanDefinition}. */ protected <T> BeanDefinition createBeanDefinitionForRegistration( final String name, final Class<T> type, final Scope scope, final WiringMode wiringMode, final Consumer<T> consumer) { return new BeanDefinition<>(name, type, scope, wiringMode, consumer); }
/** * Creates {@link jodd.petite.BeanDefinition} for all external beans. */ protected <T> BeanDefinition createBeandDefinitionForExternalBeans( final Class<T> type, final WiringMode wiringMode) { final String name = resolveBeanName(type); return new BeanDefinition<>(name, type, null, wiringMode, null); }
/** * Wires provided bean with the container and optionally invokes init methods. * Bean is not registered. */ public void wire(Object bean, WiringMode wiringMode, boolean init) { wiringMode = petiteConfig.resolveWiringMode(wiringMode); BeanDefinition def = new BeanDefinition(null, bean.getClass(), null, wiringMode); wireBean(bean, def, new HashMap<String, Object>()); if (init) { invokeInitMethods(bean, def, null); } }
/** * Creates and wires a bean within the container and optionally invokes init methods. However, bean is * <b>not</b> registered. */ @SuppressWarnings({"unchecked"}) public <E> E createBean(Class<E> type, WiringMode wiringMode, boolean init) { wiringMode = petiteConfig.resolveWiringMode(wiringMode); BeanDefinition def = new BeanDefinition(null, type, null, wiringMode); Map<String, Object> acquiredBeans = new HashMap<String, Object>(); Object bean = newBeanInstance(def, acquiredBeans); wireBean(bean, def, acquiredBeans); if (init) { invokeInitMethods(bean, def, null); } return (E) bean; }
BeanDefinition beanDefinition = new BeanDefinition(name, type, scope, wiringMode); beans.put(name, beanDefinition); return beanDefinition;