Refine search
public static <T> T getSingletonInstance(Class<T> beanClass) throws RuntimeException { // we don't mind sometimes instantiating the bean multiple times, // as long as the duplicates never escape into the outside world. if(!singletonBeanInstances.containsKey(beanClass)) { T bean = null; try { bean = beanClass.newInstance(); Properties properties = PropertiesFactory.getDefaultProperties(); configureFromProperties(bean, properties); } catch (Exception e) { throw new RuntimeException(e); } singletonBeanInstances.putIfAbsent(beanClass, bean); } return (T)singletonBeanInstances.get(beanClass); }
private static synchronized void initDefaultProperties(String fileNamePropertyKey) { if(defaultProperties != null) { return; } // This is where the properties loading takes place. The algorithm is as follows: // If the specified fileNamePropertyKey exists as a key is the system properties, take the value of that property as // the location of the module's properties file. This allows file location to be overriden easily. String propertyFileName = System.getProperty(fileNamePropertyKey); // If the system property is not set, try to load the build time properties. Build time properties // are not the module properties! These are optional and so loading may fail. That's not considered an error. // If the properties file name is defined by the build time properties, use that. // (In JBossTS it mostly does exist - the build scripts put build time properties into the .jars manifest file.) if (propertyFileName == null) { propertyFileName = "xts-properties.xml"; } // use the TS properties factory but supply the XTS property file name // we also need to pass the class loader in case we try to load // the file as a resource. this makes sure the resource load is performed // relative to the XTS deployment defaultProperties = PropertiesFactory.getPropertiesFromFile(propertyFileName, XTSPropertiesFactory.class.getClassLoader()); } }
/** * Returns the systems default properties, as read from the configuration file. * @return the configuration Properties */ public static Properties getDefaultProperties() { if(defaultProperties == null) { // TODO: pick and document new standard for global config file name property. For now use 'common' module value. initDefaultProperties("com.arjuna.ats.arjuna.common.propertiesFile"); } return defaultProperties; }
private static Properties loadFromFile(String uri) throws IOException { InputStream inputStream = null; Properties inputProperties = new Properties(); Properties outputProperties = new Properties(); if( new File(uri).exists() ) { inputStream = new FileInputStream(uri); } else { // it's probably a file embedded in a .jar inputStream = new URL(uri).openStream(); } try { loadFromXML(inputProperties,inputStream); } finally { inputStream.close(); } Enumeration namesEnumeration = inputProperties.propertyNames(); while(namesEnumeration.hasMoreElements()) { String propertyName = (String)namesEnumeration.nextElement(); String propertyValue = inputProperties.getProperty(propertyName); propertyValue = propertyValue.trim(); // perform JBossAS style property substitutions. JBTM-369 propertyValue = StringPropertyReplacer.replaceProperties(propertyValue); outputProperties.setProperty(propertyName, propertyValue); } return outputProperties; }
public static void main (String[] args) String timeout = PropertiesFactory.getDefaultProperties().getProperty( pollingTimeout);
/** * The recovery module will have chopped off this class name already. The * parameter should specify a property file from which the jndi name, user name, * password can be read. */ public boolean initialise(String parameter) throws SQLException { if (jdbcLogger.logger.isDebugEnabled()) jdbcLogger.logger.debug("JDBCXARecovery.initialise(" + parameter + ")"); if (parameter == null) return false; try { _props = PropertiesFactory.getPropertiesFromFile(parameter, JDBCXARecovery.class.getClassLoader()); _dbName = _props.getProperty(DATABASE_JNDI_NAME); _user = _props.getProperty(USER_NAME); _password = _props.getProperty(PASSWORD); } catch (Exception e) { jdbcLogger.i18NLogger.warn_recovery_xa_initexp(e); return false; } return true; }
arjPropertyManager.getObjectStoreEnvironmentBean().setLocalOSRoot(OS_ROOT); Properties props = PropertiesFactory.getDefaultProperties(); props.setProperty(PROPERTY_ENVIRONMENT_OBJECTSTORE_DIR, objectStoreDir); props.setProperty(PROPERTY_OBJECTSTORE_DIR, objectStoreDir); props.setProperty(PROPERTY_USER_DIR, muleInternalDir);
properties = loadFromFile(propertiesSourceUri); properties = applySystemProperties(properties);
public static Properties getDefaultProperties() { initPropertiesFactory(); return delegatePropertiesFactory.getDefaultProperties(); }
private static void initPropertiesFactory() { if (delegatePropertiesFactory != null) { return; } synchronized (PropertiesFactory.class) { if (delegatePropertiesFactory == null) { if (isStaxAvailable()) { delegatePropertiesFactory = new PropertiesFactoryStax(); } else { delegatePropertiesFactory = new PropertiesFactorySax(); } } } }
private static Properties loadFromFile(String uri) throws IOException { InputStream inputStream = null; Properties inputProperties = new Properties(); Properties outputProperties = new Properties(); if( new File(uri).exists() ) { inputStream = new FileInputStream(uri); } else { // it's probably a file embedded in a .jar inputStream = new URL(uri).openStream(); } try { loadFromXML(inputProperties,inputStream); } finally { inputStream.close(); } Enumeration namesEnumeration = inputProperties.propertyNames(); while(namesEnumeration.hasMoreElements()) { String propertyName = (String)namesEnumeration.nextElement(); String propertyValue = inputProperties.getProperty(propertyName); propertyValue = propertyValue.trim(); // perform JBossAS style property substitutions. JBTM-369 propertyValue = StringPropertyReplacer.replaceProperties(propertyValue); outputProperties.setProperty(propertyName, propertyValue); } return outputProperties; }
public static void main (String[] args) String timeout = PropertiesFactory.getDefaultProperties().getProperty( pollingTimeout);
/** * The recovery module will have chopped off this class name already. The * parameter should specify a property file from which the jndi name, user name, * password can be read. */ public boolean initialise(String parameter) throws SQLException { if (jdbcLogger.logger.isDebugEnabled()) jdbcLogger.logger.debug("JDBCXARecovery.initialise(" + parameter + ")"); if (parameter == null) return false; try { _props = PropertiesFactory.getPropertiesFromFile(parameter, JDBCXARecovery.class.getClassLoader()); _dbName = _props.getProperty(DATABASE_JNDI_NAME); _user = _props.getProperty(USER_NAME); _password = _props.getProperty(PASSWORD); } catch (Exception e) { jdbcLogger.i18NLogger.warn_recovery_xa_initexp(e); return false; } return true; }
properties = loadFromFile(propertiesSourceUri); properties = applySystemProperties(properties);
public static Properties getPropertiesFromFile(String propertyFileName, ClassLoader classLoader) { initPropertiesFactory(); return delegatePropertiesFactory.getPropertiesFromFile(propertyFileName, classLoader); }
private static void initPropertiesFactory() { if (delegatePropertiesFactory != null) { return; } synchronized (PropertiesFactory.class) { if (delegatePropertiesFactory == null) { if (isStaxAvailable()) { delegatePropertiesFactory = new PropertiesFactoryStax(); } else { delegatePropertiesFactory = new PropertiesFactorySax(); } } } }
private static Properties loadFromFile(String uri) throws IOException { InputStream inputStream = null; Properties inputProperties = new Properties(); Properties outputProperties = new Properties(); if( new File(uri).exists() ) { inputStream = new FileInputStream(uri); } else { // it's probably a file embedded in a .jar inputStream = new URL(uri).openStream(); } try { loadFromXML(inputProperties,inputStream); } finally { inputStream.close(); } Enumeration namesEnumeration = inputProperties.propertyNames(); while(namesEnumeration.hasMoreElements()) { String propertyName = (String)namesEnumeration.nextElement(); String propertyValue = inputProperties.getProperty(propertyName); propertyValue = propertyValue.trim(); // perform JBossAS style property substitutions. JBTM-369 propertyValue = StringPropertyReplacer.replaceProperties(propertyValue); outputProperties.setProperty(propertyName, propertyValue); } return outputProperties; }
public static void main (String[] args) String timeout = PropertiesFactory.getDefaultProperties().getProperty( pollingTimeout);
/** * The recovery module will have chopped off this class name already. The * parameter should specify a property file from which the jndi name, user name, * password can be read. */ public boolean initialise(String parameter) throws SQLException { if (jdbcLogger.logger.isDebugEnabled()) jdbcLogger.logger.debug("JDBCXARecovery.initialise(" + parameter + ")"); if (parameter == null) return false; try { _props = PropertiesFactory.getPropertiesFromFile(parameter, JDBCXARecovery.class.getClassLoader()); _dbName = _props.getProperty(DATABASE_JNDI_NAME); _user = _props.getProperty(USER_NAME); _password = _props.getProperty(PASSWORD); } catch (Exception e) { jdbcLogger.i18NLogger.warn_recovery_xa_initexp(e); return false; } return true; }
private static synchronized void initDefaultProperties(String fileNamePropertyKey) { if(defaultProperties != null) { return; } // This is where the properties loading takes place. The algorithm is as follows: // If the specified fileNamePropertyKey exists as a key is the system properties, take the value of that property as // the location of the module's properties file. This allows file location to be overriden easily. String propertyFileName = System.getProperty(fileNamePropertyKey); // If the system property is not set, try to load the build time properties. Build time properties // are not the module properties! These are optional and so loading may fail. That's not considered an error. // If the properties file name is defined by the build time properties, use that. // (In JBossTS it mostly does exist - the build scripts put build time properties into the .jars manifest file.) if (propertyFileName == null) { propertyFileName = "xts-properties.xml"; } // use the TS properties factory but supply the XTS property file name // we also need to pass the class loader in case we try to load // the file as a resource. this makes sure the resource load is performed // relative to the XTS deployment defaultProperties = PropertiesFactory.getPropertiesFromFile(propertyFileName, XTSPropertiesFactory.class.getClassLoader()); } }