Announcement Announcement Module
No announcement yet.
Setting bean's property value dynamicaly (possibly not using BeanPostProcessor) Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Setting bean's property value dynamicaly (possibly not using BeanPostProcessor)

    Hello everybody!

    I thought to ask this in the "Remoting" forum since this question has Spring JMS context, but then I realized that it's more about Spring container rather then JMS.

    My application uses Spring's JMS "listener container" to listen on the queue.
    There's wonderful support for jms listener configuration in the Spring's jms namespace.

    The problem is that in my application queue name can only be known at runtime. This doesn't allow for "static" destination settings of the listener bean. Also I still have to specify something to conform to xml schema - that's why ugly "just-a-placeholder".

    I ended up with the following configuration + custom BeanPostProcessor to override DefaultMessageListenerContainer bean's destination property in postProcessBeforeInitialization() method:

    PHP Code:
    <jms:listener-container container-type="default" connection-factory="connectionFactory">
    jms:listener destination="just-a-placeholder" ref="completionHandler" method="handleMessage"/>

    Object postProcessBeforeInitialization(Object beanString beanNamethrows BeansException {
            if (
    bean instanceof DefaultMessageListenerContainer) {
    But I don't really like this solution (at least for its aesthetic). So my question is - does Spring allow for more elegant ways of solving a problem when value for certain bean's property only becomes available at runtime?
    Last edited by samolet; Nov 17th, 2010, 03:58 PM. Reason: typos