summaryrefslogtreecommitdiff
path: root/qpid/java/client/src/main
diff options
context:
space:
mode:
authorWeston M. Price <wprice@apache.org>2012-05-13 10:27:23 +0000
committerWeston M. Price <wprice@apache.org>2012-05-13 10:27:23 +0000
commit850bd17e9cfc9196478bddf9668238db8432811f (patch)
tree4186e1b9164277e29069de49bacb9ff44645911e /qpid/java/client/src/main
parent30c12a0d7fb3855ff7d4b2fb8c5245f8b63a0ab8 (diff)
downloadqpid-python-850bd17e9cfc9196478bddf9668238db8432811f.tar.gz
QPID-3994: add support for optionally retrieving FindBugs using Ivy
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1337829 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/client/src/main')
-rw-r--r--qpid/java/client/src/main/java/org/apache/qpid/jndi/PropertiesFileInitialContextFactory.java59
1 files changed, 24 insertions, 35 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 9b202a13ee..935b4e7d9d 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
@@ -69,46 +69,24 @@ public class PropertiesFileInitialContextFactory implements InitialContextFactor
public Context getInitialContext(Hashtable environment) throws NamingException
{
Map data = new ConcurrentHashMap();
-
+ File file = null;
+ BufferedInputStream inputStream = null;
try
{
- String file = null;
-
- if (environment.containsKey(Context.PROVIDER_URL))
- {
- file = (String) environment.get(Context.PROVIDER_URL);
- }
- else
- {
- file = System.getProperty(Context.PROVIDER_URL);
- }
+ String fileName = (environment.containsKey(Context.PROVIDER_URL))
+ ? (String)environment.get(Context.PROVIDER_URL) : System.getProperty(Context.PROVIDER_URL);
- // Load the properties specified
- if (file != null)
+ _logger.info("Attempting to load " + fileName);
+
+
+ if (fileName != null)
{
- _logger.info("Loading Properties from:" + file);
- BufferedInputStream inputStream = null;
- if(file.contains("file:"))
- {
- inputStream = new BufferedInputStream(new FileInputStream(new File(new URI(file))));
- }
- else
- {
- inputStream = new BufferedInputStream(new FileInputStream(file));
- }
-
+ inputStream = new BufferedInputStream(new FileInputStream((fileName.contains("file:"))
+ ? new File(new URI(fileName)) : new File(fileName)));
Properties p = new Properties();
-
- try
- {
- p.load(inputStream);
- }
- finally
- {
- inputStream.close();
- }
+ p.load(inputStream);
Strings.Resolver resolver = new Strings.ChainedResolver
(Strings.SYSTEM_RESOLVER, new Strings.PropertiesResolver(p));
@@ -134,12 +112,23 @@ public class PropertiesFileInitialContextFactory implements InitialContextFactor
catch (IOException ioe)
{
_logger.warn("Unable to load property file specified in Provider_URL:" + environment.get(Context.PROVIDER_URL) +"\n" +
- "Due to:"+ioe.getMessage());
+ "Due to:" + ioe.getMessage());
}
catch(URISyntaxException uoe)
{
_logger.warn("Unable to load property file specified in Provider_URL:" + environment.get(Context.PROVIDER_URL) +"\n" +
- "Due to:"+uoe.getMessage());
+ "Due to:" + uoe.getMessage());
+ }
+ finally
+ {
+ try
+ {
+ if(inputStream != null)
+ {
+ inputStream.close();
+ }
+ }
+ catch(Exception ignore){}
}
createConnectionFactories(data, environment);