KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > nanocontainer > testmodel > ResourceBundleWebServerConfig


1 /*****************************************************************************
2  * Copyright (C) NanoContainer Organization. All rights reserved. *
3  * ------------------------------------------------------------------------- *
4  * The software in this package is published under the terms of the BSD *
5  * style license a copy of which has been included with this distribution in *
6  * the LICENSE.txt file. *
7  * *
8  * Original code by Aslak Hellesoy and Paul Hammant *
9  *****************************************************************************/

10
11 package org.nanocontainer.testmodel;
12
13 import java.io.File JavaDoc;
14 import java.io.FileInputStream JavaDoc;
15 import java.io.IOException JavaDoc;
16 import java.util.PropertyResourceBundle JavaDoc;
17 import java.util.ResourceBundle JavaDoc;
18
19 public class ResourceBundleWebServerConfig implements WebServerConfig {
20
21     String JavaDoc host = "localhost";
22     int port = 8080;
23
24     public ResourceBundleWebServerConfig() throws IOException JavaDoc {
25
26         File JavaDoc file = new File JavaDoc(System.getProperty("basedir"), "ResourceBundleWebServerConfig.properties");
27         // how do you get this working in intellij, maven and eclipse ?
28
if (file.exists()) {
29             ResourceBundle JavaDoc bundle = new PropertyResourceBundle JavaDoc(new FileInputStream JavaDoc(file));
30             host = bundle.getString("host");
31             port = Integer.parseInt(bundle.getString("port"));
32         }
33     }
34
35     public String JavaDoc getHost() {
36         return host;
37     }
38
39     public int getPort() {
40         return port;
41     }
42
43 }
44
Popular Tags