001 /***************************************************************************** 002 * Copyright (C) PicoContainer Organization. All rights reserved. * 003 * ------------------------------------------------------------------------- * 004 * The software in this package is published under the terms of the BSD * 005 * style license a copy of which has been included with this distribution in * 006 * the LICENSE.txt file. * 007 * * 008 * Original code by Aslak Hellesoy and Paul Hammant * 009 *****************************************************************************/ 010 011 package org.picocontainer.script.testmodel; 012 013 import java.io.File; 014 import java.io.FileInputStream; 015 import java.io.IOException; 016 import java.util.PropertyResourceBundle; 017 import java.util.ResourceBundle; 018 019 public class ResourceBundleWebServerConfig implements WebServerConfig { 020 021 String host = "localhost"; 022 int port = 8080; 023 024 public ResourceBundleWebServerConfig() throws IOException { 025 026 File file = new File(System.getProperty("basedir"), "ResourceBundleWebServerConfig.properties"); 027 // how do you get this working in intellij, maven and eclipse ? 028 if (file.exists()) { 029 ResourceBundle bundle = new PropertyResourceBundle(new FileInputStream(file)); 030 host = bundle.getString("host"); 031 port = Integer.parseInt(bundle.getString("port")); 032 } 033 } 034 035 public String getHost() { 036 return host; 037 } 038 039 public int getPort() { 040 return port; 041 } 042 043 }