1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
package org.kuali.rice.kew.routemodule.service.impl; |
18 | |
|
19 | |
import org.apache.log4j.Logger; |
20 | |
import org.kuali.rice.core.reflect.ObjectDefinition; |
21 | |
import org.kuali.rice.core.resourceloader.GlobalResourceLoader; |
22 | |
import org.kuali.rice.kew.actionrequest.ActionRequestValue; |
23 | |
import org.kuali.rice.kew.engine.node.RouteNode; |
24 | |
import org.kuali.rice.kew.exception.ResourceUnavailableException; |
25 | |
import org.kuali.rice.kew.exception.WorkflowRuntimeException; |
26 | |
import org.kuali.rice.kew.role.RoleRouteModule; |
27 | |
import org.kuali.rice.kew.routemodule.FlexRMAdapter; |
28 | |
import org.kuali.rice.kew.routemodule.RouteModule; |
29 | |
import org.kuali.rice.kew.routemodule.RouteModuleRemote; |
30 | |
import org.kuali.rice.kew.routemodule.RouteModuleRemoteAdapter; |
31 | |
import org.kuali.rice.kew.routemodule.service.RouteModuleService; |
32 | |
import org.kuali.rice.kew.util.KEWConstants; |
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | 0 | public class RouteModuleServiceImpl implements RouteModuleService { |
39 | |
|
40 | 0 | private static final Logger LOG = Logger.getLogger(RouteModuleServiceImpl.class); |
41 | |
|
42 | |
public RouteModule findRouteModule(RouteNode node) throws ResourceUnavailableException { |
43 | 0 | String routeMethodName = node.getRouteMethodName(); |
44 | 0 | LOG.debug("Finding route module for routeMethodName="+routeMethodName+" at route level "+node.getRouteNodeName()); |
45 | 0 | RouteModule routeModule = null; |
46 | |
|
47 | 0 | if (routeMethodName == null || node.isFlexRM()) { |
48 | 0 | routeModule = getFlexRMRouteModule(routeMethodName); |
49 | |
} else { |
50 | 0 | routeModule = getRouteModule(routeMethodName); |
51 | |
} |
52 | 0 | return routeModule; |
53 | |
} |
54 | |
|
55 | |
public RouteModule findRouteModule(ActionRequestValue actionRequest) throws ResourceUnavailableException { |
56 | 0 | if (!actionRequest.getResolveResponsibility()) { |
57 | 0 | return new RoleRouteModule(); |
58 | |
} |
59 | 0 | if (actionRequest.getNodeInstance() == null) { |
60 | 0 | return null; |
61 | |
} |
62 | 0 | return findRouteModule(actionRequest.getNodeInstance().getRouteNode()); |
63 | |
} |
64 | |
|
65 | |
private RouteModule getRouteModule(String routeMethodName) throws ResourceUnavailableException { |
66 | 0 | if (routeMethodName == null) { |
67 | 0 | return null; |
68 | 0 | } else if ("".equals(routeMethodName.trim()) || KEWConstants.ROUTE_LEVEL_NO_ROUTE_MODULE.equals(routeMethodName)) { |
69 | 0 | return null; |
70 | |
} |
71 | 0 | Object routeModule = GlobalResourceLoader.getObject(new ObjectDefinition(routeMethodName)); |
72 | 0 | if (routeModule instanceof RouteModule) { |
73 | 0 | return (RouteModule)routeModule; |
74 | 0 | } else if (routeModule instanceof RouteModuleRemote) { |
75 | 0 | return new RouteModuleRemoteAdapter((RouteModuleRemote)routeModule); |
76 | |
} |
77 | 0 | throw new WorkflowRuntimeException("Could not locate the Route Module with the given name: " + routeMethodName); |
78 | |
} |
79 | |
|
80 | |
private RouteModule getFlexRMRouteModule(String ruleTemplateName) { |
81 | 0 | return new FlexRMAdapter(); |
82 | |
} |
83 | |
|
84 | |
|
85 | |
} |