스프링이 XML 기반 설정에서 컬렉션을 표현하는 또 다른 방법을 제공한다고 생각한다면 맞다. 스프링 프레임워크는 네임스페이스를 기반으로 컬렉션을 선언하는 ‘단축 표기’를 지원한다. 이제 컬렉션을 사용하는 더 많은 옵션이 생겼다. 예제 5-7의 XML 설정 예제를 보자.
예제 5-7 mydocuments-util-context.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:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-4.0.xsd">
<bean id="engine" class="com.apress.isf.spring.service.ServiceSearchEngine">
<property name="documentDAO" ref="documentDAO" />
</bean>
<bean id="documentDAO" class="com.apress.isf.spring.data.DocumentRepository">
<property name="documents" ref="docs" />
</bean>
<util:list id="docs">
<ref bean="doc1" />
<ref bean="doc2" />
<ref bean="doc3" />
<ref bean="doc4" />
</util:list>
<bean id="typeDAO" class="com.apress.isf.spring.data.TypeDataRepository">
<property name="types" ref="types" />
</bean>
<util:map id="types">
<entry key="webType" value-ref="webType" />
<entry key="pdfType" value-ref="pdfType" />
<entry key="noteType" value-ref="noteType" />
</util:map>
<!-- Document와 Type 빈 정의 생략 -->
</beans>