diff options
| author | Martin Ritchie <ritchiem@apache.org> | 2007-01-09 10:36:53 +0000 |
|---|---|---|
| committer | Martin Ritchie <ritchiem@apache.org> | 2007-01-09 10:36:53 +0000 |
| commit | abc4451482042140a9926bc1d33a275a363612f7 (patch) | |
| tree | fd0e4b3698acce21975bfb2c94506e35765f4d4e /qpid/java/client/src | |
| parent | 0d64b49f6588c40c40101657ca7c72957b33726e (diff) | |
| download | qpid-python-abc4451482042140a9926bc1d33a275a363612f7.tar.gz | |
Merged Changes
Merged ability to use Provider_URL to load properties file. As committed in r488624
QPID-266
changed contains to containsKey
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/branches/perftesting@494363 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/client/src')
| -rw-r--r-- | qpid/java/client/src/main/java/org/apache/qpid/jndi/PropertiesFileInitialContextFactory.java | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/jndi/PropertiesFileInitialContextFactory.java b/qpid/java/client/src/main/java/org/apache/qpid/jndi/PropertiesFileInitialContextFactory.java index 53e7fd066e..a49869212c 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/jndi/PropertiesFileInitialContextFactory.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/jndi/PropertiesFileInitialContextFactory.java @@ -40,11 +40,15 @@ import javax.naming.spi.InitialContextFactory; import java.util.Hashtable; import java.util.Iterator; import java.util.Map; +import java.util.Properties; import java.util.concurrent.ConcurrentHashMap; +import java.io.BufferedInputStream; +import java.io.FileInputStream; +import java.io.IOException; public class PropertiesFileInitialContextFactory implements InitialContextFactory { - protected final Logger _logger = Logger.getLogger(getClass()); + protected final Logger _logger = Logger.getLogger(PropertiesFileInitialContextFactory.class); private String CONNECTION_FACTORY_PREFIX = "connectionfactory."; private String DESTINATION_PREFIX = "destination."; @@ -55,6 +59,41 @@ public class PropertiesFileInitialContextFactory implements InitialContextFactor { Map data = new ConcurrentHashMap(); + try + { + + String file = null; + if (environment.containsKey(Context.PROVIDER_URL)) + { + file = (String) environment.get(Context.PROVIDER_URL); + } + else + { + file = System.getProperty(Context.PROVIDER_URL); + } + + if (file != null) + { + _logger.info("Loading Properties from:" + file); + //Load the properties specified + Properties p = new Properties(); + + p.load(new BufferedInputStream(new FileInputStream(file))); + + environment.putAll(p); + _logger.info("Loaded Context Properties:" + environment.toString()); + } + else + { + _logger.warn("No Provider URL specified."); + } + } + catch (IOException ioe) + { + _logger.warn("Unable to load property file specified in Provider_URL:" + + environment.get(Context.PROVIDER_URL)); + } + createConnectionFactories(data, environment); createDestinations(data, environment); |
