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