Tuesday, September 06, 2011

Retrieving static constants with Spring

In a Spring configuration it is possible to inject constant values defined in some class (or interface). For this you don't need to know the actual value of the constant, but can instruct Spring to retrieve it. For instance for an IBM MQ TransportType:
<property name="transportType">
    <bean id="com.ibm.mq.jms.JMSC.MQJMS_TP_CLIENT_MQ_TCPIP" 
          class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean" />
</property>