org.springframework.ldap.odm.typeconversion.impl
Class ConverterManagerFactoryBean
java.lang.Object
org.springframework.ldap.odm.typeconversion.impl.ConverterManagerFactoryBean
- All Implemented Interfaces:
- FactoryBean
public final class ConverterManagerFactoryBean
- extends Object
- implements FactoryBean
A utility class to allow ConverterManagerImpl
instances to be easily configured via spring.xml
.
The following shows a typical simple example which creates two Converter
instances:
fromStringConverter
toStringConverter
Configured in an ConverterManagerImpl
to:
- Use
fromStringConverter
to convert from String
to Byte, Short,
Integer, Long, Float, Double, Boolean
- Use
toStringConverter
to convert from Byte, Short,
Integer, Long, Float, Double, Boolean
to String
<bean id="converterManager" class="org.springframework.ldap.odm.typeconversion.impl.ConverterManagerFactoryBean">
<property name="converterConfig">
<set>
<bean class="org.springframework.ldap.odm.typeconversion.impl.ConverterManagerFactoryBean$ConverterConfig">
<property name="fromClasses">
<set>
<value>java.lang.String</value>
</set>
</property>
<property name="toClasses">
<set>
<value>java.lang.Byte</value>
<value>java.lang.Short</value>
<value>java.lang.Integer</value>
<value>java.lang.Long</value>
<value>java.lang.Float</value>
<value>java.lang.Double</value>
<value>java.lang.Boolean</value>
</set>
</property>
<property name="converter" ref="fromStringConverter" />
</bean>
<bean class="org.springframework.ldap.odm.typeconversion.impl.ConverterManagerFactoryBean$ConverterConfig">
<property name="fromClasses">
<set>
<value>java.lang.Byte</value>
<value>java.lang.Short</value>
<value>java.lang.Integer</value>
<value>java.lang.Long</value>
<value>java.lang.Float</value>
<value>java.lang.Double</value>
<value>java.lang.Boolean</value>
</set>
</property>
<property name="toClasses">
<set>
<value>java.lang.String</value>
</set>
</property>
<property name="converter" ref="toStringConverter" />
</bean>
</set>
</property>
</bean>
ConverterManagerFactoryBean.ConverterConfig
has a second constructor which takes an additional parameter to allow
an LDAP syntax to be defined.
- Author:
- Paul Harvey <paul.at.pauls-place.me.uk>
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ConverterManagerFactoryBean
public ConverterManagerFactoryBean()
setConverterConfig
public void setConverterConfig(Set<ConverterManagerFactoryBean.ConverterConfig> converterConfigList)
- Parameters:
converterConfigList
-
getObject
public Object getObject()
throws Exception
- Creates a ConverterManagerImpl populating it with Converter instances from the converterConfigList property.
- Specified by:
getObject
in interface FactoryBean
- Returns:
- The newly created
ConverterManager
.
- Throws:
ClassNotFoundException
- Thrown if any of the classes to be converted to or from cannot be found.
Exception
- See Also:
FactoryBean.getObject()
getObjectType
public Class<?> getObjectType()
- Specified by:
getObjectType
in interface FactoryBean
isSingleton
public boolean isSingleton()
- Specified by:
isSingleton
in interface FactoryBean