01: /**
02: * Copyright (c) 2005 Red Hat, Inc. All rights reserved.
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2.1 of the License, or any later version.
08: *
09: * This library is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public
15: * License along with this library; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
17: * USA
18: *
19: * Component of: Red Hat Application Server
20: *
21: * Initial Developers: Gregory Lapouchnian
22: * Patrick Smith
23: * --------------------------------------------------------------------------
24: * $Id: Configure.java 7027 2005-07-08 14:00:45Z glapouch $
25: * --------------------------------------------------------------------------
26: */package olstore.client;
27:
28: import java.util.Properties;
29:
30: /**
31: * Loads a configuration file and returns a properties object
32: * that represents the properties set in the configuration file.
33: */
34: public class Configure {
35:
36: /** Loaded properties. */
37: private Properties props;
38:
39: /**
40: * Load values from a properties file and store them in field in this class.
41: * @throws Exception if the properties file is malformed
42: */
43: public Configure() throws Exception {
44: load("uddi.properties");
45: }
46:
47: /**
48: * Given a configuration file load the properties from it.
49: * @param file The configuration file to pass in.
50: * @throws Exception If the file is malformed.
51: */
52: public void load(String file) throws Exception {
53: props = new Properties();
54: props.load(new java.io.FileInputStream(file));
55: }
56:
57: /**
58: * Get a property by name
59: * @param name the name of the property
60: * @return the value of the property with the given name
61: */
62: public String getProperty(String name) {
63: return props.getProperty(name);
64: }
65: }
|