1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.common.util.spring.config;
17
18 import java.util.ArrayList;
19 import java.util.List;
20
21 import org.kuali.common.util.execute.Executable;
22 import org.kuali.common.util.spring.beans.DefaultMessageImpl;
23 import org.kuali.common.util.spring.beans.Message;
24 import org.kuali.common.util.spring.beans.PrintMessagesExecutable;
25 import org.springframework.beans.factory.annotation.Autowired;
26 import org.springframework.context.annotation.Bean;
27 import org.springframework.context.annotation.Configuration;
28
29 @Configuration
30 public class AutowiredMessagesConfig {
31
32 @Bean
33 public String helloWorldString() {
34 return "Hello World";
35 }
36
37 @Bean
38 public String goodbyeString() {
39 return "Good bye";
40 }
41
42 @Bean
43 public Message helloWorldMessage() {
44 DefaultMessageImpl message = new DefaultMessageImpl();
45 message.setMessage(helloWorldString());
46 return message;
47 }
48
49 @Bean
50 public Message goodbyeMessage() {
51 DefaultMessageImpl message = new DefaultMessageImpl();
52 message.setMessage(goodbyeString());
53 return message;
54 }
55
56 @Bean
57 @Autowired
58 public List<Message> messages() {
59 return null;
60 }
61
62 @Bean
63 public Executable printMessagesExecutable() {
64 List<Message> messages = new ArrayList<Message>();
65 messages.add(helloWorldMessage());
66 messages.add(goodbyeMessage());
67
68 PrintMessagesExecutable pme = new PrintMessagesExecutable();
69 pme.setMessages(messages);
70 return pme;
71 }
72 }