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