1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.reactive.configuration;
18
19 import org.apache.commons.configuration.ConfigurationFactory;
20 import org.springframework.core.io.Resource;
21
22 import java.io.IOException;
23
24 /***
25 * An extension of the org.apache.commons.configuration.ConfigurationFactory that takes a spring
26 * org.springframework.core.io.Resource.
27 *
28 * <p>An example of the bean factory configuration required for Commons Configuration</p>
29 * <pre>
30 * <bean id="commonsConfigurationFactory" class="org.reactive.configuration.CommonsConfigurationFactory" singleton="true">
31 * <property name="configurationResource">
32 * <value>classpath:/org/reactive/beans/factory/config/ConfigurationPlaceholderProcessorTest_configuration.xml</value>
33 * </property>
34 * </bean>
35 *
36 * <bean id="configuration" factory-bean="commonsConfigurationFactory" factory-method="getConfiguration" />
37 *
38 * <bean id="configurationPlaceholderProcessor" class="org.reactive.beans.factory.config.ConfigurationPlaceholderProcessor">
39 * <property name="placeholderEvaluator">
40 * <bean class="org.reactive.beans.factory.config.commons.CommonsPlaceholderEvaluator">
41 * <property name="configuration">
42 * <ref bean="configuration"/>
43 * </property>
44 * </bean>
45 * </property>
46 * </bean>
47 * </pre>
48 *
49 * @author Dan Washusen
50 * @version $Id: CommonsConfigurationFactory.java,v 1.1 2004/12/26 23:42:29 dan_washusen Exp $
51 * @since 16.12.2004
52 * @see org.springframework.core.io.DefaultResourceLoader
53 */
54 public class CommonsConfigurationFactory
55 extends ConfigurationFactory {
56 /***
57 * Set the resource that the configuration factory will use to instantiate instances of
58 * org.apache.commons.configuration.Configuration. This method simple calls
59 * org.apache.commons.configuration.ConfigurationFactory.setConfigurationURL(resource.getURL()).
60 * <p>An example might be "classpath:/configuration.xml" to load the configuration.xml file from
61 * the root of the classpath.</p>
62 * @param resource The resource that the configuration factory will use to instantiate instances of
63 * org.apache.commons.configuration.Configuration
64 * @throws IOException If an error occurs while attempting to create a URL for the resource.
65 */
66 public void setConfigurationResource(Resource resource)
67 throws IOException {
68 super.setConfigurationURL(resource.getURL());
69 }
70 }