01: /*
02: * Copyright 2005-2007 The Kuali Foundation.
03: *
04: *
05: * Licensed under the Educational Community License, Version 1.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * http://www.opensource.org/licenses/ecl1.php
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package edu.iu.uis.eden.routemodule;
18:
19: import org.apache.log4j.Logger;
20: import org.kuali.rice.definition.ObjectDefinition;
21: import org.kuali.rice.resourceloader.GlobalResourceLoader;
22:
23: import edu.iu.uis.eden.EdenConstants;
24: import edu.iu.uis.eden.actionrequests.ActionRequestValue;
25: import edu.iu.uis.eden.engine.node.RouteNode;
26: import edu.iu.uis.eden.exception.ResourceUnavailableException;
27:
28: /**
29: * @author ewestfal
30: */
31: public class RouteModuleServiceImpl implements RouteModuleService {
32:
33: private static final Logger LOG = Logger
34: .getLogger(RouteModuleServiceImpl.class);
35:
36: public RouteModule findRouteModule(RouteNode node)
37: throws ResourceUnavailableException {
38: String routeMethodName = node.getRouteMethodName();
39: LOG.debug("Finding route module for routeMethodName="
40: + routeMethodName + " at route level "
41: + node.getRouteNodeName());
42: RouteModule routeModule = null;
43: if (node.isFlexRM()) {
44: routeModule = getFlexRMRouteModule(routeMethodName);
45: } else {
46: routeModule = getRouteModule(routeMethodName);
47: }
48: return routeModule;
49: }
50:
51: public RouteModule findRouteModule(ActionRequestValue actionRequest)
52: throws ResourceUnavailableException {
53: if (actionRequest.getNodeInstance() == null) {
54: return null;
55: }
56: return findRouteModule(actionRequest.getNodeInstance()
57: .getRouteNode());
58: }
59:
60: private RouteModule getRouteModule(String routeMethodName)
61: throws ResourceUnavailableException {
62: if (routeMethodName == null) {
63: return null;
64: } else if ("".equals(routeMethodName.trim())
65: || EdenConstants.ROUTE_LEVEL_NO_ROUTE_MODULE
66: .equals(routeMethodName)) {
67: return null;
68: }
69: return (RouteModule) GlobalResourceLoader
70: .getObject(new ObjectDefinition(routeMethodName));//SpringServiceLocator.getExtensionService().getRouteModule(routeMethodName);
71: }
72:
73: private RouteModule getFlexRMRouteModule(String ruleTemplateName) {
74: return new FlexRMAdapter(ruleTemplateName);
75: }
76:
77: }
|