Esempio n. 1
0
        /**
         * Load the JMeter properties file; if not found, then
         * default to "org/apache/jmeter/jmeter.properties" from the classpath
         *
         * c.f. loadProperties
         *
         */
        public static void loadJMeterProperties(String file)
        {
            Properties  p   = new Properties(System.getProperties());
            InputStream ins = null;

            try
            {
                File f = new File(file);
                ins = new FileInputStream(f);
                p.load(ins);
            }
            catch (IOException e)
            {
                try
                {
                    ins = ClassLoader.getSystemResourceAsStream("org/apache/jmeter/jmeter.properties"); // $NON-NLS-1$
                    if (ins == null)
                    {
                        //throw new RuntimeException("Could not read JMeter properties file");
                    }
                    p.load(ins);
                }
                catch (IOException ex)
                {
                    // JMeter.fail("Could not read internal resource. " +
                    // "Archive is broken.");
                }
            }
            finally
            {
                JOrphanUtils.closeQuietly(ins);
            }
            appProperties = p;
        }
Esempio n. 2
0
        private Properties loadProperties(string path)
        {
            Properties properties = new Properties(loadDefaultProperties());

            // try to find and load properties
            Stream input = null;

            try
            {
                input = Thread.CurrentThread.ContextClassLoader.getResourceAsStream(path);
            }
            catch (SecurityException)
            {
                input = ClassLoader.getSystemResourceAsStream(path);
            }
            if (input != null)
            {
                try
                {
                    properties.load(input);
                }
                catch (IOException e)
                {
                    throw new ELException("Cannot read EL properties", e);
                }
                finally
                {
                    try
                    {
                        input.Close();
                    }
                    catch (IOException)
                    {
                        // ignore...
                    }
                }
            }

            return(properties);
        }