public class Settings4jFactoryBean extends Object implements org.springframework.beans.factory.FactoryBean<Object>, org.springframework.beans.factory.InitializingBean
Settings4j.getObject(String)
.
The following Example can be configured with the settings4j-Key "env/MyVariable".
e.g.: System.setProperty("env/MyVariable", "Hallo World");
OR with JNDI-Context OR in a Classpath-File under "classpath:env/MyVariable" Or with a custom Connector
-Implementation.
<bean id="MyConfigurableValue" class="org.settings4j.helper.spring.Settings4jFactoryBean"> <property name="key"><value>env/MyVariable</value></property> </bean>
This Example shows how a Hibernate SessionFactory can optional customized with additional HibernateProperties.
<bean id="hibernateProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean"> <property name="locations"> <list> <value>classpath:org/settings4j/helper/spring/DefaultHibernate.properties</value> <bean class="org.settings4j.helper.spring.Settings4jFactoryBean"> <property name="key"> <value>env/MyCustomProprtiesLocationKey</value> </property> <property name="defaultObject"> <!-- This could also be an empty Property-File But it must Exist. --> <!-- PropertiesFactoryBean cannot handle invalid Paths. --> <value>classpath:org/settings4j/helper/spring/DefaultHibernate.properties</value> </property> </bean> </list> </property> </bean> <bean id="mySessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource" ref="db2Datasource2" /> <property name="hibernateProperties" ref="hibernateProperties" /> .... </bean>
Constructor and Description |
---|
Settings4jFactoryBean() |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet() |
Object |
getDefaultObject() |
Class<?> |
getExpectedType()
Return the type that the configured object is supposed to be assignable to, if any.
|
String |
getKey() |
Object |
getObject() |
Class<?> |
getObjectType() |
boolean |
isSingleton() |
void |
setDefaultObject(Object defaultObject) |
void |
setExpectedType(Class<?> expectedType)
Specify the type that the configured object is supposed to be assignable to, if any.
|
void |
setKey(String key) |
void |
setSingleton(boolean singleton) |
public String getKey()
public void setKey(String key)
key
- - the Setting4j-Key for Your Configuration-Value.public void setSingleton(boolean singleton)
singleton
- - If true
, the Value will be read during SpringBean-Initialization. Default is
true
public void setExpectedType(Class<?> expectedType)
expectedType
- the expected Class
.public Class<?> getExpectedType()
public Object getDefaultObject()
public void setDefaultObject(Object defaultObject)
public Object getObject()
getObject
in interface org.springframework.beans.factory.FactoryBean<Object>
public Class<?> getObjectType()
getObjectType
in interface org.springframework.beans.factory.FactoryBean<Object>
public boolean isSingleton()
isSingleton
in interface org.springframework.beans.factory.FactoryBean<Object>
public void afterPropertiesSet()
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
Copyright © 2008–2016 Brabenetz Harald, Austria. All rights reserved.