List of usage examples for org.apache.commons.configuration.beanutils BeanHelper createBean
public static Object createBean(BeanDeclaration data) throws ConfigurationRuntimeException
From source file:com.shanke.common.conf.CustomConfigurationBuilder.java
/** * Creates a configuration object from the specified configuration * declaration.//from w w w. j a va2 s .c o m * * @param decl * the configuration declaration * @return the new configuration object * @throws ConfigurationException * if an error occurs */ private AbstractConfiguration createConfigurationAt(ConfigurationDeclaration decl) throws ConfigurationException { try { return (AbstractConfiguration) BeanHelper.createBean(decl); } catch (Exception ex) { // redirect to configuration exceptions throw new ConfigurationException(ex); } }
From source file:nz.co.senanque.madura.configuration.MaduraConfiguration.java
public Object getProperty(String arg0) { Configuration config = m_configuration; if (config instanceof XMLConfiguration) { try {/*from w ww.java 2 s . c om*/ BeanDeclaration decl = new XMLBeanDeclaration((XMLConfiguration) config, arg0); return BeanHelper.createBean(decl); } catch (IllegalArgumentException e) { return null; } } else { return config.getString(arg0); } }
From source file:nz.co.senanque.madura.spring.ConfigProxyFactoryBean.java
public Object getObject() throws Exception { Configuration config = m_configuration.getConfiguration(); if (config instanceof XMLConfiguration) { BeanDeclaration decl = new XMLBeanDeclaration((XMLConfiguration) config, getKey()); Object o = decl.getBeanClassName(); if (o == null) { String value = config.getString(getKey()); return value; }/*from ww w. j a v a 2s. co m*/ return BeanHelper.createBean(decl); } else { return config.getString(getKey()); } }
From source file:org.ssh.comm.conf.CustomConfigurationBuilder.java
/** * Registers providers defined in the configuration. * /*from ww w . j av a 2 s . com*/ * @throws ConfigurationException * if an error occurs */ protected void registerConfiguredProviders() throws ConfigurationException { List<HierarchicalConfiguration> nodes = configurationsAt(KEY_CONFIGURATION_PROVIDERS); for (HierarchicalConfiguration config : nodes) { XMLBeanDeclaration decl = new XMLBeanDeclaration(config); String key = config.getString(KEY_PROVIDER_KEY); addConfigurationProvider(key, (ConfigurationProvider) BeanHelper.createBean(decl)); } }
From source file:org.ssh.comm.conf.CustomConfigurationBuilder.java
/** * Registers StrLookups defined in the configuration. * /*w w w.ja v a2 s. c o m*/ * @throws ConfigurationException * if an error occurs */ protected void registerConfiguredLookups() throws ConfigurationException { List<HierarchicalConfiguration> nodes = configurationsAt(KEY_CONFIGURATION_LOOKUPS); for (HierarchicalConfiguration config : nodes) { XMLBeanDeclaration decl = new XMLBeanDeclaration(config); String key = config.getString(KEY_LOOKUP_KEY); StrLookup lookup = (StrLookup) BeanHelper.createBean(decl); BeanHelper.setProperty(lookup, "configuration", this); ConfigurationInterpolator.registerGlobalLookup(key, lookup); this.getInterpolator().registerLookup(key, lookup); } }
From source file:org.ssh.comm.conf.CustomConfigurationBuilder.java
protected void initFileSystem() throws ConfigurationException { if (getMaxIndex(FILE_SYSTEM) == 0) { HierarchicalConfiguration config = configurationAt(FILE_SYSTEM); XMLBeanDeclaration decl = new XMLBeanDeclaration(config); setFileSystem((FileSystem) BeanHelper.createBean(decl)); }/*from w w w . j a v a 2s .co m*/ }