View Javadoc

1   /**
2    * Copyright 2010-2013 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
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  }