03 | 새로운 GroovyBeanDefinitionReader 컨텍스트에서 빈 스코프 사용하기
새로운 그루비 연동을 사용하면 mydocuments.groovy 파일에서 scope만 설정하면 될 정도로 쉽다(예제 4-6 참고).
예제 4-6 mydocuments.groovy
import com.apress.isf.spring.service.SearchEngineService
import com.apress.isf.spring.data.DocumentRepository
import com.apress.isf.java.model.Document
beans {
engine(SearchEngineService) { bean ->
bean.scope = "prototype"
documentDAO = ref("documentDAO")
}
documentDAO(DocumentRepository) { bean ->
bean.scope = "prototype"
doc1 = ref("doc1")
doc2 = ref("doc2")
doc3 = ref("doc3")
doc4 = ref("doc4")
}
doc1(Document) {
name = "Book Template"
type = ref("pdfType")
location = "/Users/felipeg/Documents/Random/Book Template.pdf"
}
doc2(Document) {
name = "Sample Contract"
type = ref("pdfType")
location = "/Users/felipeg/Documents/Contracts/Sample Contract.pdf"
}
doc3(Document) {
name = "Clustering with RabbitMQ"
type = ref("noteType")
location = "/Users/felipeg/Documents/Random/Clustering with RabbitMQ.txt"
}
doc4(Document) {
name = "Pro Spring Security Book"
type = ref("webType")
location = "http://www.apress.com/9781430248187"
}
webType(com.apress.isf.java.model.Type) {
name = "WEB"
desc = "Web Link"
extension = ".url"
}
pdfType(com.apress.isf.java.model.Type) {
name = "PDF"
desc = "Portable Document Format"
extension = ".url"
}
noteType(com.apress.isf.java.model.Type) {
name = "NOTE"
desc = "Text Notes"
extension = ".txt"
}
}