xmlns:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:c="http://www.springframework.org/schema/c"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-3.1.xsd">
<bean id="messageProvider"
class="com.apress.prospring3.ch4.xml.HelloWorldMessageProvider"/>
</beans>
Listing 4-22. Annotation Configuration (app-context-annotation.xml)
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:c="http://www.springframework.org/schema/c"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-3.1.xsd">
<context:annotation-config/>
<context:component-scan
base-package="com.apress.prospring3.ch4.annotation"/>
</beans>
Using Setter Injection
To configure Setter Injection using XML configuration, you need to specify <property> tags under the
<bean> tag for each <property> into which you want to inject a dependency. For example, to assign the
message provider bean to the messageProvider property of the messageRenderer bean, you simply change
the <bean> tag for the messageRenderer bean, as shown in Listing 4-23.
Listing 4-23. Setter Injection (XML)
<bean id="messageRenderer" class="com.apress.prospring3.ch4.xml.StandardOutMessageRenderer">
<property name="messageProvider">
<ref bean="messageProvider"/>
</property>
</bean>
Search WWH :
Custom Search
Previous Page
Spring Framework 3 Topic Index
Next Page
Spring Framework 3 Bookmarks
Home