Dec 10

Static constants can be used in your Spring wiring using either FieldRetrievingFactoryBean, or the newer util schema.

(2.0+) util schema


<bean id="myBean" class="au.com.objects.MyBean">
   <property name="dayOfWeek">
      <util:constant static-field="java.util.Calendar.MONDAY"/>
   </property>
</bean>

(Pre-2.0) FieldRetrievingFactoryBean


<bean id="myBean" class="au.com.objects.MyBean">
   <property name="dayOfWeek">
      <bean id="java.util.Calendar.MONDAY"
         class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean"/>
   </property>
</bean>

written by objects \\ tags: , , , ,