KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > olstore > client > Configure


1 /**
2  * Copyright (c) 2005 Red Hat, Inc. All rights reserved.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or any later version.
8  *
9  * 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,v 1.2 2005/07/08 14:00:45 glapouch Exp $
25  * --------------------------------------------------------------------------
26  */

27 package olstore.client;
28
29 import java.util.Properties;
30
31 /**
32  * Loads a configuration file and returns a properties object
33  * that represents the properties set in the configuration file.
34  */

35 public class Configure {
36
37     /** Loaded properties. */
38     private Properties props;
39
40     /**
41      * Load values from a properties file and store them in field in this class.
42      * @throws Exception if the properties file is malformed
43      */

44     public Configure() throws Exception {
45         load("uddi.properties");
46     }
47
48     /**
49      * Given a configuration file load the properties from it.
50      * @param file The configuration file to pass in.
51      * @throws Exception If the file is malformed.
52      */

53     public void load(String file) throws Exception {
54         props = new Properties();
55         props.load(new java.io.FileInputStream(file));
56     }
57
58     /**
59      * Get a property by name
60      * @param name the name of the property
61      * @return the value of the property with the given name
62      */

63     public String getProperty(String name) {
64         return props.getProperty(name);
65     }
66 }
67
Popular Tags