1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kew.engine.node.var.schemes;
17
18 import java.io.IOException;
19 import java.io.InputStream;
20
21 import org.apache.log4j.Logger;
22 import org.kuali.rice.kew.engine.RouteContext;
23 import org.kuali.rice.kew.engine.node.PropertiesUtil;
24 import org.kuali.rice.kew.engine.node.var.Property;
25 import org.kuali.rice.kew.engine.node.var.PropertyScheme;
26
27
28
29
30
31
32
33 public class ResourceScheme implements PropertyScheme {
34 private static final Logger LOG = Logger.getLogger(ResourceScheme.class);
35
36 public String getName() {
37 return "resource";
38 }
39 public String getShortName() {
40 return "res";
41 }
42
43 public Object load(Property property, RouteContext context) {
44 String resource;
45 boolean relative = false;
46
47 resource = property.locator;
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63 String resStr = property.locator + (relative ? "(" + resource + ")" : "");
64 LOG.info("Reading resource " + resStr + "...");
65
66 InputStream is = getClass().getResourceAsStream(resource);
67 if (is == null) {
68 throw new RuntimeException("Resource not found: " + resStr);
69 }
70 try {
71 return PropertiesUtil.readResource(is);
72 } catch (IOException ioe) {
73 throw new RuntimeException("Error loading resource: " + resStr, ioe);
74 }
75 }
76
77 public String toString() {
78 return "[ResourceScheme]";
79 }
80 }