Announcement Announcement Module
Collapse
No announcement yet.
Sample usage of jndi-lookup Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Sample usage of jndi-lookup

    I need to lookup a JMS connection factory from jndi
    and inject the connection factory into another bean
    (a JMS Template).

    I can do this manually in Java; however, I'd like
    to use j2ee:jndi-lookup bean configuration support.

    I am not clear on how to use this from the Appendix
    A2.3.1 of Spring tutorial.

    This is what I have:

    Code:
      <bean 
            id="jmsFactory"
    		class="org.apache.activemq.ActiveMQConnectionFactory"
                      p:brokerURL="tcp://localhost:61616"
        />
     
        <bean 
    	id="messageDispatchTemplate"
    		class="org.springframework.jms.core.JmsTemplate"
    		   p:connectionFactory-ref="jmsFactory"
        />
    I would like to convert this to something like (I hope):

    Code:
       <jee:jndi-lookup id="jmsFactory" jndi-name="jms/AmqConnectionFactory"/>
    
       <bean 
    	id="messageDispatchTemplate"
    		class="org.springframework.jms.core.JmsTemplate"
    		   p:connectionFactory-ref="jmsFactory"
        />
    I am assuming that the syntax I have given the second snippet above
    is approximate - if this syntax would work as is, I'd be delighted;
    of course, in this case, I would like to know how Spring figures
    out the type of "jmsFactory".

    Any suggestions?

    Thanks,

    /U

  • #2
    The type is determined at injection-time, it tries to cast/convert the jmsFactory to the correct type. On the jee:jndi-lookup you can also specify an proxy-interface so then it will (also) try to check the type when doing the lookup.

    Comment


    • #3
      Hi umark

      I have updated the relevant section of the Spring reference documentation with some examples of dependency injecting the value of the 'jee:jndi-lookup' bean... hopefully it is clearer now.

      Cheers
      Rick

      Comment

      Working...
      X