Example usage for java.util Properties clear

List of usage examples for java.util Properties clear

Introduction

In this page you can find the example usage for java.util Properties clear.

Prototype

@Override
    public synchronized void clear() 

Source Link

Usage

From source file:hoot.services.controllers.info.AboutResourceTest.java

@Test
@Category(UnitTest.class)
public void getServicesVersionDetail() throws IOException {
    Properties hootProps = HootProperties.getInstance();
    hootProps.clear();
    hootProps.setProperty("testProp1", "testVal1");
    HootProperties.setProperties(hootProps);

    mockBuildInfo();//w w  w . j ava 2s .  c o  m

    ServicesDetail responseData = null;
    try {
        responseData = resource().path("/about/servicesVersionDetail").accept(MediaType.APPLICATION_JSON)
                .get(ServicesDetail.class);
    } catch (UniformInterfaceException e) {
        ClientResponse r = e.getResponse();
        Assert.fail("Unexpected response " + r.getStatus() + " " + r.getEntity(String.class));
    }

    Assert.assertNotNull(StringUtils.trimToNull(responseData.getClassPath()));
    Assert.assertEquals(1, responseData.getProperties().length);
    Assert.assertEquals("testProp1", responseData.getProperties()[0].getName());
    Assert.assertEquals("testVal1", responseData.getProperties()[0].getValue());
    //not sure of a better way to test this one yet...
    Assert.assertTrue(responseData.getResources().length > 0);
}

From source file:core.PlanC.java

private static void initEnviorement() {
    try {//from  www .j av  a2s . c o m
        connectToLocalDB();
        TSplash splash = new TSplash();
        // connection a perfiles de datos
        DBAccess dba = ConnectionManager.getAccessTo("t_connections");
        Vector v = dba.search(null, null);
        Properties prps = new Properties();
        for (int i = 0; i < v.size(); i++) {
            Record r = (Record) v.elementAt(i);
            // for planc: save the conection user as master user
            if (r.getFieldValue("t_cnname").equals("SleOracle")) {
                Session.setMasterUser((String) r.getFieldValue("t_cnuser"));
                // 1823: override fields value from table values to values stored in jdbc.properties file
                String[] rp = PUserLogIn.getJdbcProperties("jdbc.username", "jdbc.password", "jdbc.url");
                r.setFieldValue("T_CNUSER", rp[0]);
                r.setFieldValue("T_CNPASSWORD", rp[1]);
                r.setFieldValue("T_CNURL", rp[2]);
            }
            String pl = (String) r.getFieldValue("T_CNEXTENDED_PRP");
            prps.clear();
            TStringUtils.parseProperties(pl, prps);
            String sc = " (" + prps.getProperty("*schema", "") + ")";
            String msg = "Connecting to database " + r.getFieldValue("t_cnname") + sc;
            String ac = prps.getProperty("*autoconnection", "");
            SystemLog.info(msg + " with *autoconnection=" + ac);
            if (!ac.equals("false")) {
                splash.increment(msg);
                ConnectionManager.connect(r);
            }
        }
        // update running hardware info
        splash.increment("Updating instalation info");
        // checkInstalation();

        // EN ESTE ORDEN
        splash.increment("Starting download subsystem");
        DownloadManager.init();
        // patch update need download manager
        splash.increment("Checking for updates");
        // UpdateManager.checkForPTF();
        splash.increment("Starting task manager");
        TTaskManager.init();
        // load plugins MUST BE last
        splash.increment("Loading plugins");
        PluginManager.init();
        splash.increment("Configuring general aspect and L&F...");
        setContentPane(SIGNIN);
        splash.dispose();
    } catch (Exception e) {
        SystemLog.logException1(e, true);
        System.exit(-1);
    }
}

From source file:cn.newgxu.lab.core.config.SpringBeans.java

@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean() {
    LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();
    entityManagerFactoryBean.setDataSource(dataSource());
    entityManagerFactoryBean.setJpaVendorAdapter(jpaVendorAdapter());

    Properties properties = new Properties();
    properties.setProperty("hibernate.hbm2ddl.auto", "none");
    //      properties.setProperty("hibernate.hbm2ddl.auto", "update");
    entityManagerFactoryBean.setJpaProperties(properties);

    properties.clear();
    InputStream in = null;//  w w w  .  ja  v  a 2s . c o m
    try {
        in = this.getClass().getResourceAsStream("/config/entityPackages.properties");
        properties.load(in);
    } catch (IOException e) {
        L.error("?EntityManagerFactory", e);
    } finally {
        try {
            in.close();
        } catch (IOException e) {
            L.error("wtf!", e);
        }
    }
    String[] entityPackages = new String[properties.size()];
    int i = 0;
    for (Object pkg : properties.keySet()) {
        entityPackages[i++] = properties.getProperty(pkg.toString());
    }
    entityManagerFactoryBean.setPackagesToScan(entityPackages);
    return entityManagerFactoryBean;
}

From source file:com.cisco.dbds.utils.configfilehandler.ConfigFileHandler.java

/**
 * Gets the properties values.// w w  w .j a v a 2  s.c  om
 *
 * @param pfile the pfile
 * @param pvariable the pvariable
 * @return the properties values
 * @throws IOException Signals that an I/O exception has occurred.
 */
public String getPropertiesValues(String pfile, String pvariable) throws IOException {
    Properties pr = new Properties();
    FileInputStream fn;
    String separator = File.separator;
    String filename = "." + separator + "src" + separator + "it" + separator + "resources" + separator + pfile
            + ".properties";
    fn = new FileInputStream(filename);
    pr.load(fn);
    String ret = pr.getProperty(pvariable);
    fn.close();
    pr.clear();
    return ret;

}

From source file:net.rim.ejde.internal.util.VMUtils.java

/**
 * Gets the string value of an EE property from a given EE file.
 *
 * @param eeFile/*www .  java2  s . c  om*/
 *            the ee file
 * @param property
 *            the property
 *
 * @return the string value of the property
 */
static public String getPropertyFromEEFile(final File eeFile, final String property) {
    if ((null != eeFile) && eeFile.exists() && eeFile.isFile()) {
        InputStream inputStream = null;
        Properties properties = null;
        WeakReference<Properties> propsStub = null;
        WeakReference<InputStream> streamStub = null;

        try {
            propsStub = new WeakReference<Properties>(new Properties());
            properties = propsStub.get();

            streamStub = new WeakReference<InputStream>(new FileInputStream(eeFile));
            inputStream = streamStub.get();

            properties.load(inputStream);

            final String id = properties.getProperty(property);

            return id;
        } catch (final FileNotFoundException e) {
            _log.error("", e); //$NON-NLS-1$
        } catch (final IOException e) {
            _log.error("", e); //$NON-NLS-1$
        } finally {
            if (null != properties) {
                properties.clear();
                if (propsStub != null) {
                    propsStub.clear();
                    propsStub = null;
                }
            }
            if (null != inputStream) {
                try {
                    inputStream.close();
                    if (streamStub != null) {
                        streamStub.clear();
                        streamStub = null;
                    }
                } catch (final IOException e) {
                    _log.error("", e); //$NON-NLS-1$
                }
            }
        }
    }

    return StringUtils.EMPTY;
}

From source file:fr.fastconnect.factory.tibco.bw.maven.packaging.MergePropertiesMojo.java

private Properties sortProperties(Properties properties) throws ConfigurationException, IOException {
    Properties sp = new SortedProperties();
    sp.putAll(properties);//from ww  w. j a va2 s .  co m

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    sp.store(baos, null);

    properties.clear();
    properties.load(new ByteArrayInputStream(baos.toByteArray()));

    return properties;
}

From source file:com.agilejava.docbkx.maven.AbstractWebhelpMojo.java

private int retrieveCleanUpProps() {
    // Files for punctuation (only one for now)
    String[] punctuationFiles = new String[] { "punctuation.props" };
    FileInputStream input;//  www .  j av a  2  s.  c o m

    // Get the list of the props file containing the words to remove (not the punctuation)
    DirList props = new DirList(targetBaseDir, new String[] { "", "^(?!(punctuation)).*\\.props$" }, 1);
    //new String[]{"", "^(?!(punctuation)).*\\.props$"}
    ArrayList wordsList = props.getListFiles();

    //      System.out.println("props files:"+wordsList);epub now handles correctly multiples input files and also zip them correctly
    //TODO all properties are taken to a single arraylist. does it ok?.
    Properties enProps = new Properties();

    try {
        // Retrieve words to remove
        for (int i = 0; i < wordsList.size(); i++) {
            File aWordsList = (File) wordsList.get(i);

            if (aWordsList.exists()) {
                enProps.load(input = new FileInputStream(aWordsList));
                input.close();
                cleanUpStrings.addAll(enProps.values());

                enProps.clear();
            }
        }

        // Retrieve char to remove (punctuation for ex.)
        for (int i = 0; i < punctuationFiles.length; i++) {
            String punctuationFile = punctuationFiles[i];
            File ftemp = new File(searchBaseDir, punctuationFile);

            if (ftemp.exists()) {
                enProps.load(input = new FileInputStream(ftemp));
                input.close();
                cleanUpChars.addAll(enProps.values());
                enProps.clear();
            }
        }
    } catch (IOException e) {
        getLog().error("Unable to read one property file", e);

        return 1;
    }

    return 0;
}

From source file:com.asakusafw.cleaner.main.HDFSCleanerTest.java

@Before
public void setUp() throws Exception {
    UnitTestUtil.startUp();/*from  w  ww  .j ava 2s.c o m*/
    cleanDir01.mkdir();
    cleanDir02.mkdir();
    Properties p = ConfigurationLoader.getProperty();
    p.clear();
}

From source file:net.minecraftforge.fml.common.FMLCommonHandler.java

/**
 * Loads a lang file, first searching for a marker to enable the 'extended' format {escape charaters}
 * If the marker is not found it simply returns and let the vanilla code load things.
 * The Marker is 'PARSE_ESCAPES' by itself on a line starting with '#' as such:
 * #PARSE_ESCAPES/*ww w .  j ava2 s. c  o m*/
 *
 * @param table The Map to load each key/value pair into.
 * @param inputstream Input stream containing the lang file.
 * @return A new InputStream that vanilla uses to load normal Lang files, Null if this is a 'enhanced' file and loading is done.
 */
public InputStream loadLanguage(Map<String, String> table, InputStream inputstream) throws IOException {
    byte[] data = IOUtils.toByteArray(inputstream);

    boolean isEnhanced = false;
    for (String line : IOUtils.readLines(new ByteArrayInputStream(data), Charsets.UTF_8)) {
        if (!line.isEmpty() && line.charAt(0) == '#') {
            line = line.substring(1).trim();
            if (line.equals("PARSE_ESCAPES")) {
                isEnhanced = true;
                break;
            }
        }
    }

    if (!isEnhanced)
        return new ByteArrayInputStream(data);

    Properties props = new Properties();
    props.load(new InputStreamReader(new ByteArrayInputStream(data), Charsets.UTF_8));
    for (Entry e : props.entrySet()) {
        table.put((String) e.getKey(), (String) e.getValue());
    }
    props.clear();
    return null;
}

From source file:com.twitter.pig.backend.hadoop.executionengine.tez.TezExecutionEngine.java

/**
 * Method to apply pig properties to JobConf
 * (replaces properties with resulting jobConf values)
 * @param conf JobConf with appropriate hadoop resource files
 * @param properties Pig properties that will override hadoop properties; properties might be modified
 *//* w w  w. j a v  a2s  .  c om*/
@SuppressWarnings("deprecation")
private void recomputeProperties(JobConf jobConf, Properties properties) {
    // We need to load the properties from the hadoop configuration
    // We want to override these with any existing properties we have.
    if (jobConf != null && properties != null) {
        // set user properties on the jobConf to ensure that defaults
        // and deprecation is applied correctly
        Enumeration<Object> propertiesIter = properties.keys();
        while (propertiesIter.hasMoreElements()) {
            String key = (String) propertiesIter.nextElement();
            String val = properties.getProperty(key);
            // We do not put user.name, See PIG-1419
            if (!key.equals("user.name"))
                jobConf.set(key, val);
        }
        //clear user defined properties and re-populate
        properties.clear();
        Iterator<Map.Entry<String, String>> iter = jobConf.iterator();
        while (iter.hasNext()) {
            Map.Entry<String, String> entry = iter.next();
            properties.put(entry.getKey(), entry.getValue());
        }
    }
}