Day 23
Spring?
Container
Container
DI
Container
DIAOP
Container
DIAOP
Framework
Container
DIAOP
Framework
Lightweight
Bean Configuration
<bean id="employee" class="com.all4rest.domain.Employee" />
<bean id="employee" class="com.all4rest.domain.Employee" > <constructor-arg name="name" value="oleg" /> <constructor-arg name="salary" value="200.00" /></bean>
<bean id="employee" class="com.all4rest.domain.Employee" > <property name="name" value="oleg" /></bean>
<bean id="salonService" class="com.all4rest.domain.SalonService" > <property name="name" value="haircut" /></bean>
<bean id="employee" class="com.all4rest.domain.Employee" > <property name="salonService" ref="salonService" /></bean>
<bean id="employee" class="com.all4rest.domain.Employee" > <property name="salonService" > <bean class="com.all4rest.domain.SalonService" /> </property></bean>
<bean id="service.haircut" class="com.all4rest.domain.SalonService" > <property name="name" value="haircut" /></bean>
<bean id="service.manicure" class="com.all4rest.domain.SalonService" > <property name="name" value="manicure" /></bean>
<bean id="employee" class="com.all4rest.domain.Employee" > <property name="salonServices" > <list> <ref bean="service.haircut" /> <ref bean="service.manicure" /> </list> </property></bean>
<list>, <set>, <map>, <props>
<bean id="employee" class="com.all4rest.domain.Employee" > <property name="name" ><null /></property></bean>
Autowiring(byName, byType, constructor, auto-detect)
<bean id="employee" class="com.all4rest.domain.Employee“ scope="prototype" /> singleton request session web
Bean scoping
<bean id="employee" class="com.all4rest.domain.Employee“ factory-bean="employeeFactory“ factory-method="createEmployee" />
Factories
<bean id="employee" class="com.all4rest.domain.Employee“ init-method="employeeInit“ destroy-method="employeeDestroy" />
Initialization/Destruction methods
<bean id="abstractEmployee" class="com.all4rest.domain.AbstractEmployee“ abstract="true"/>
<bean id="employee" class="com.all4rest.domain.Employee“ parent="abstractEmployee" />
Parent/child beans
<bean id="contextRefreshListener“ class="com.all4rest.ContextRefreshListener" />
public class ContextRefreshListener implements ApplicationListener {
public void onApplicationEvent(ApplicationEvent event) { if (event instanceof ContextRefreshedEvent) { // do my staff } }}
Handling Application Events
BeanNameAware
ApplicationContextAware
AOP(aspect, advice, pointcut)