01: /*
02: * Copyright 2005-2006 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:
18: package edu.iu.uis.eden.engine.node.var.schemes;
19:
20: import org.apache.log4j.Logger;
21:
22: import edu.iu.uis.eden.KEWServiceLocator;
23: import edu.iu.uis.eden.engine.RouteContext;
24: import edu.iu.uis.eden.engine.node.BranchService;
25: import edu.iu.uis.eden.engine.node.BranchState;
26: import edu.iu.uis.eden.engine.node.var.Property;
27: import edu.iu.uis.eden.engine.node.var.PropertyScheme;
28:
29: /**
30: * A property scheme that looks the property up in the state variable map
31: *
32: * @author Aaron Hamid (arh14 at cornell dot edu)
33: */
34: public final class VariableScheme implements PropertyScheme {
35: private static final Logger LOG = Logger
36: .getLogger(VariableScheme.class);
37:
38: public String getName() {
39: return "variable";
40: }
41:
42: public String getShortName() {
43: return "var";
44: }
45:
46: public Object load(Property property, RouteContext context) {
47: // try {
48: // return PropertyUtils.getProperty(doc.getVariables(), property.locator);
49: LOG.debug("getting variable: " + property.locator);
50: BranchService branchService = KEWServiceLocator
51: .getBranchService();
52: String value = branchService.getScopedVariableValue(context
53: .getNodeInstance().getBranch(),
54: BranchState.VARIABLE_PREFIX + property.locator);
55: LOG.debug("variable '" + property.locator + "': " + value);
56: return value;
57:
58: // } catch (NoSuchMethodException nsme) {
59: // throw new RuntimeException("Error loading resource: " + property.locator, nsme);
60: // } catch (InvocationTargetException ite) {
61: // throw new RuntimeException("Error loading resource: " + property.locator, ite);
62: // } catch (IllegalAccessException iae) {
63: // throw new RuntimeException("Error loading resource: " + property.locator, iae);
64: // }
65: }
66:
67: public String toString() {
68: return "[VariableScheme]";
69: }
70: }
|