View Javadoc
1   /**
2    * Copyright 2005-2014 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.rice.xml.spring;
17  
18  import org.kuali.common.util.execute.Executable;
19  import org.kuali.common.util.spring.env.EnvironmentService;
20  import org.kuali.common.util.spring.event.ApplicationEventListenerConfig;
21  import org.kuali.common.util.spring.event.ExecutableApplicationEventListener;
22  import org.kuali.common.util.spring.service.SpringServiceConfig;
23  import org.springframework.beans.factory.annotation.Autowired;
24  import org.springframework.context.annotation.Bean;
25  import org.springframework.context.annotation.Configuration;
26  import org.springframework.context.annotation.Import;
27  import org.springframework.context.event.ContextRefreshedEvent;
28  import org.springframework.context.event.SmartApplicationListener;
29  import org.springframework.core.Ordered;
30  
31  /**
32   * Sets up a {@code SmartApplicationListener} that ingests workflow XML when it receives a
33   * {@code ContextRefreshedEvent}.
34   * 
35   * @author Kuali Rice Team (rice.collab@kuali.org)
36   */
37  @Configuration
38  @Import({ SpringServiceConfig.class })
39  public class IngestXmlConfig implements ApplicationEventListenerConfig {
40  
41      private static final String ORDER_KEY = "rice.ingest.order";
42  
43      /**
44       * The ingestion executable.
45       */
46      @Autowired
47      IngestXmlExecConfig config;
48  
49      /**
50       * The Spring environment.
51       */
52  	@Autowired
53  	EnvironmentService env;
54  
55      /**
56       * {@inheritDoc}
57       */
58  	@Override
59  	@Bean
60  	public SmartApplicationListener applicationEventListener() {
61  		Executable executable = config.ingestXmlExecutable();
62          Integer order = env.getInteger(ORDER_KEY, Integer.valueOf(Ordered.LOWEST_PRECEDENCE));
63  
64  		return ExecutableApplicationEventListener.builder(executable, ContextRefreshedEvent.class).order(order.intValue()).build();
65  	}
66  
67  }