Thursday, February 16, 2012

Constants in Spring Context

Found an easy way to include a constant declared in some random Java file into the context file.

http://www.unicon.net/node/601

<bean id="Context" class="javax.naming.InitialContext"> 
    <constructor-arg> 
        <util:map id="jmsProperties" map-class="java.util.Hashtable"> 
            <entry> 
                <key><util:constant static-field="javax.naming.Context.INITIAL_CONTEXT_FACTORY"/></key> 
                <value>org.apache.activemq.jndi.ActiveMQInitialContextFactory</value> 
            </entry> 
            <entry> 
                <key><util:constant static-field="javax.naming.Context.PROVIDER_URL"/></key> 
                <value>tcp://localhost:61616</value> 
            </entry> 
        </util:map> 
    </constructor-arg> 
</bean>

1 comment:

  1. Use $ for accessing inner classes

    path.MyClass$InnerClass.VALUE

    ReplyDelete