View Javadoc
1   /**
2    * Copyright 2005-2016 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.kew.engine;
17  
18  import org.kuali.rice.coreservice.framework.CoreFrameworkServiceLocator;
19  import org.kuali.rice.coreservice.framework.parameter.ParameterService;
20  import org.kuali.rice.kew.engine.node.service.RouteNodeService;
21  import org.kuali.rice.kew.engine.simulation.SimulationEngine;
22  import org.kuali.rice.kew.routeheader.service.RouteHeaderService;
23  import org.springframework.beans.factory.InitializingBean;
24  
25  /**
26   * An implementation of the {@link WorkflowEngineFactory}. 
27   * 
28   * @author Kuali Rice Team (rice.collab@kuali.org)
29   */
30  public class WorkflowEngineFactoryImpl implements WorkflowEngineFactory, InitializingBean {
31  
32      private RouteNodeService routeNodeService;
33      private RouteHeaderService routeHeaderService;
34      private ParameterService parameterService;
35      
36      
37      /**
38       * Ensures that all dependencies were injected into this factory.
39       * 
40       * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
41       * @throws IllegalStateException if any of the required services are null
42       */
43      @Override
44      public void afterPropertiesSet() {
45          if (routeNodeService == null) {
46              throw new IllegalStateException("routeNodeService not properly injected, was null.");
47          }
48          if (routeHeaderService == null) {
49              throw new IllegalStateException("routeHeaderService not properly injected, was null.");
50          }
51          //if (parameterService == null) {
52          //    throw new IllegalStateException("parameterService not properly injected, was null.");
53          //}
54      }
55      
56      /**
57       * @see org.kuali.rice.kew.engine.WorkflowEngineFactory#newEngine(org.kuali.rice.kew.engine.OrchestrationConfig)
58       */
59      @SuppressWarnings("unchecked")
60      @Override
61      public <E extends WorkflowEngine> E newEngine(OrchestrationConfig config) {
62          switch (config.getCapability()) {
63              case STANDARD:
64                  return (E) new StandardWorkflowEngine(routeNodeService, routeHeaderService, parameterService, config);
65              case BLANKET_APPROVAL:
66                  return (E) new BlanketApproveEngine(routeNodeService, routeHeaderService, parameterService, config);
67              case SIMULATION:
68                  return (E) new SimulationEngine(routeNodeService, routeHeaderService, parameterService, config);
69          }
70          
71          return null;
72      }
73      
74      /**
75       * @return the routeNodeService
76       */
77      public RouteNodeService getRouteNodeService() {
78          return this.routeNodeService;
79      }
80  
81  
82      /**
83       * @param routeNodeService the routeNodeService to set
84       */
85      public void setRouteNodeService(RouteNodeService routeNodeService) {
86          this.routeNodeService = routeNodeService;
87      }
88  
89  
90      /**
91       * @return the routeHeaderService
92       */
93      public RouteHeaderService getRouteHeaderService() {
94          return this.routeHeaderService;
95      }
96  
97  
98      /**
99       * @param routeHeaderService the routeHeaderService to set
100      */
101     public void setRouteHeaderService(RouteHeaderService routeHeaderService) {
102         this.routeHeaderService = routeHeaderService;
103     }
104 
105 
106     /**
107      * @return the parameterService
108      */
109     public ParameterService getParameterService() {
110         if (this.parameterService == null) {
111             this.parameterService = CoreFrameworkServiceLocator.getParameterService();
112         }
113         return this.parameterService;
114     }
115 
116 
117     /**
118      * @param parameterService the parameterService to set
119      */
120     public void setParameterService(ParameterService parameterService) {
121         this.parameterService = parameterService;
122     }
123 
124 }