Announcement Announcement Module
Collapse
No announcement yet.
Must using WebApplicationContextUtils? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Must using WebApplicationContextUtils?

    Hi,I have a web app based on Spring.

    a example Spring configuration file:

    <bean id="messagehandlerDAO" class="org.x.MessageHandlerDAO">
    <property name="initial"><ref local="in"/></property>
    </bean>

    <bean id="ds" class="org.xx.y.Y" destroy-method="close">
    </bean>

    MessageHandlerDAO,listenering message from JMS Server.But the web application have no clients except messages from JMS Server.

    Now,if my app have to access "ds" instance and no ServletContext,How to perform this?

    thx.

  • #2
    If you are deploying this into a Spring web application then you will have ServletContext available. Although you wont be able to access the ServletContext in your classes you can have the Spring ContextLoaderListener configure your beans and wire them automatically for you.

    Check out the reference manual for more details on how ContextLoaderListener works.

    Essentially you need a class that starts the listener and then you either implement InitializingBean for this class or use the init-method attribute of the <bean> tag.

    Next you configure ContextLoaderListener to load your application context automatically and it will invoke any initialization methods for you and start your listener.

    Rob

    Comment

    Working...
    X