1. @Autowired vs. setter
@Autowired can mark in field or setter, with @Autowired, setter is not necessary;
If @Autowired is not apply to property, then setter is necesary for injection.
2. @Controller, @Service, @Repository, @Component
<context:annotation-config />
<context:component-scan base-package="hk.com.mtr" />
3. org.springframework.beans.factory.config.PropertyPlaceholderConfigurer
We can't define 'propertyConfigurer' bean in 'eanRefContext.xml', define it in normal applicationContext.xml
4. define properties bean:
<util:properties id="jdbcProperties" location="classpath:org/example/config/jdbc.properties"/>
5. Spring integrate with Seam:
faces-config.xml
--------------------------------------------------------------------------------
<application>
<variable-resolver>org.springframework.web.jsf.DelegatingVariableResolver</variable-resolver>
</application>
components.xml
--------------------------------------------------------------------------------
<spring:context-loader config-locations="/WEB-INF/applicationContext.xml"/>
***.java
--------------------------------------------------------------------------------
@In("#{bookingService}")
private BookingService bookingService;
applicationContext.xml
--------------------------------------------------------------------------------
<jee:jndi-lookup id="securityFacade" expected-type="hk.com.mtr.trs.facade.sa.SecurityFacade" jndi-name="hk.com.mtr.trs.facade.sa.SecurityFacade" environment-ref="jndiConfig"/>
<bean id="someSpringBean" class="SomeSpringBeanClass" scope="prototype">
<seam:component/>
</bean>
6. Spring integrate with EJB3:
put beanRefContext.xml in classpath root:
--------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<bean id="businessBeanFactory" class="org.springframework.context.support.ClassPathXmlApplicationContext">
<constructor-arg value="spring/applicationContext.xml" />
</bean>
</beans>
****.java
--------------------------------------------------------------------------------
@Local
@Stateless
@Interceptors(SpringBeanAutowiringInterceptor.class)
public class EmailNotificationServiceImpl implements EmailNotificationService {
@Autowired
private EmailNotificationDelegate emailNotificationDelegate;
}