01: package org.vraptor.webapp;
02:
03: import java.io.IOException;
04: import java.io.InputStream;
05: import java.util.Properties;
06:
07: import org.apache.log4j.Logger;
08: import org.vraptor.view.OverridableViewManager;
09: import org.vraptor.view.ViewManager;
10:
11: /**
12: * Reads a view properties file and gives back a new ViewManager based on the
13: * current one.
14: */
15: public class ViewsPropertiesReader {
16:
17: private static final Logger LOG = Logger
18: .getLogger(ViewsPropertiesReader.class);
19:
20: /**
21: * Creates a new view manager which overrides all view properties in the
22: * resource with their new values... old values will use the current
23: * manager's response
24: *
25: * @param currentManager
26: * default manager
27: * @param resource
28: * properties resource
29: * @return the new view manager
30: * @throws IOException
31: */
32: public ViewManager overrideViews(ViewManager currentManager,
33: InputStream resource) throws IOException {
34: OverridableViewManager manager = new OverridableViewManager(
35: currentManager);
36: Properties properties = new Properties();
37: properties.load(resource);
38:
39: for (Object key : properties.keySet()) {
40: manager.overrideView(key.toString(), properties.get(key)
41: .toString());
42: }
43:
44: return manager;
45: }
46:
47: }
|