View Javadoc

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