01: /*****************************************************************************
02: * Copyright (C) NanoContainer Organization. All rights reserved. *
03: * ------------------------------------------------------------------------- *
04: * The software in this package is published under the terms of the BSD *
05: * style license a copy of which has been included with this distribution in *
06: * the LICENSE.txt file. *
07: * *
08: * Original code by Aslak Hellesoy and Paul Hammant *
09: *****************************************************************************/package org.nanocontainer.testmodel;
10:
11: import java.io.File;
12: import java.io.FileInputStream;
13: import java.io.IOException;
14: import java.util.PropertyResourceBundle;
15: import java.util.ResourceBundle;
16:
17: public class ResourceBundleWebServerConfig implements WebServerConfig {
18:
19: String host = "localhost";
20: int port = 8080;
21:
22: public ResourceBundleWebServerConfig() throws IOException {
23:
24: File file = new File(System.getProperty("basedir"),
25: "ResourceBundleWebServerConfig.properties");
26: // how do you get this working in intellij, maven and eclipse ?
27: if (file.exists()) {
28: ResourceBundle bundle = new PropertyResourceBundle(
29: new FileInputStream(file));
30: host = bundle.getString("host");
31: port = Integer.parseInt(bundle.getString("port"));
32: }
33: }
34:
35: public String getHost() {
36: return host;
37: }
38:
39: public int getPort() {
40: return port;
41: }
42:
43: }
|