I want to call a method after creating the bean using spring, for example I create Factory and schema but I want to call the same method of Factory before creating a schema bean
<!-- schemaFactory-->
<bean id="schemaFact" class="javax.xml.validation.SchemaFactory"
factory-method="newInstance">
<constructor-arg value="http://www.w3.org/2001/XMLSchema" />
</bean>
<!-- schema -->
<bean id="schema" class="javax.xml.validation.Schema"
factory-bean="schemaFact" factory-method="newSchema">
<constructor-arg value="3DSecure.xsd" />
</bean>
If you are using Spring 3.0/3.1 you can take advantage of Java configuration:
But which method on
SchemaFactorydo you want to call?Seems like all of them are either getters or setters, so you can use normal XML injection…Alternatively create your ownFactoryBean:And use it like this (no
factory-methodneeded):