01: /*
02: * Copyright 2000,2005 wingS development team.
03: *
04: * This file is part of wingS (http://wingsframework.org).
05: *
06: * wingS is free software; you can redistribute it and/or modify
07: * it under the terms of the GNU Lesser General Public License
08: * as published by the Free Software Foundation; either version 2.1
09: * of the License, or (at your option) any later version.
10: *
11: * Please see COPYING for the complete licence.
12: */
13: package org.wings.resource;
14:
15: import org.apache.commons.logging.Log;
16: import org.apache.commons.logging.LogFactory;
17: import org.wings.plaf.ResourceDefaults;
18: import org.wings.util.PropertyDiscovery;
19:
20: import java.io.IOException;
21: import java.util.Properties;
22:
23: /**
24: * For accessing static resources
25: *
26: * @author <a href="mailto:ole@freiheit.com">Ole Langbehn</a>
27: */
28: public class ResourceManager {
29: private final transient static Log log = LogFactory
30: .getLog(ResourceManager.class);
31:
32: private static final String PROPERTIES_FILENAME = "org/wings/resource/resource.properties";
33:
34: public static final ResourceDefaults RESOURCES;
35:
36: private ResourceManager() {
37: }
38:
39: static {
40: Properties properties;
41: try {
42: properties = PropertyDiscovery
43: .loadRequiredProperties(PROPERTIES_FILENAME);
44: } catch (IOException e) {
45: log.fatal(
46: "Cannot open resource properties file at location "
47: + PROPERTIES_FILENAME, e);
48: properties = new Properties();
49: }
50: RESOURCES = new ResourceDefaults(null, properties);
51: }
52:
53: public static Object getObject(String key, Class clazz) {
54: return RESOURCES.get(key, clazz);
55: }
56: }
|