diff --git a/org.springframework.beans/src/main/java/org/springframework/beans/factory/config/PropertiesFactoryBean.java b/org.springframework.beans/src/main/java/org/springframework/beans/factory/config/PropertiesFactoryBean.java index fd4932d71da..9e0673ccfb0 100644 --- a/org.springframework.beans/src/main/java/org/springframework/beans/factory/config/PropertiesFactoryBean.java +++ b/org.springframework.beans/src/main/java/org/springframework/beans/factory/config/PropertiesFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2010 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -66,7 +66,7 @@ public class PropertiesFactoryBean extends PropertiesLoaderSupport public final void afterPropertiesSet() throws IOException { if (this.singleton) { - this.singletonInstance = mergeProperties(); + this.singletonInstance = createProperties(); } } @@ -75,7 +75,7 @@ public class PropertiesFactoryBean extends PropertiesLoaderSupport return this.singletonInstance; } else { - return mergeProperties(); + return createProperties(); } } @@ -83,4 +83,34 @@ public class PropertiesFactoryBean extends PropertiesLoaderSupport return Properties.class; } + + /** + * Template method that subclasses may override to construct the object + * returned by this factory. The default implementation returns the + * plain merged Properties instance. + *

Invoked on initialization of this FactoryBean in case of a + * shared singleton; else, on each {@link #getObject()} call. + * @return the object returned by this factory + * @throws IOException if an exception occured during properties loading + * @see #mergeProperties() + */ + protected Properties createProperties() throws IOException { + return (Properties) createInstance(); + } + + /** + * Template method that subclasses may override to construct the object + * returned by this factory. The default implementation returns the + * plain merged Properties instance. + *

Invoked on initialization of this FactoryBean in case of a + * shared singleton; else, on each {@link #getObject()} call. + * @return the object returned by this factory + * @throws IOException if an exception occured during properties loading + * @deprecated as of Spring 3.0, in favor of {@link #createProperties()} + */ + @Deprecated + protected Object createInstance() throws IOException { + return mergeProperties(); + } + }