Announcement Announcement Module
Collapse
No announcement yet.
Configure bean with variable Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Configure bean with variable

    Hi,

    I got a bean configured in the Spring configuration XML as shown below:

    PHP Code:
      <bean id="getAllGroupsCommand"
     
    class="de.tfhberlin.eclipsophone.server.webapp.commands.GetAllGroupsCommand">
          <
    constructor-arg><ref bean="groupDAO"/></constructor-arg>
      </
    bean
    It needs a DAO object to get results from a database.

    Now I'm facing problems with a bean that needs a DAO object and further on a parameter representing a user id (as Integer).

    I don't know how to configure the bean for this, because at runtime I have to be able to change this second parameter.

    My question: What to put into the XML configuration file and how to set the parameter at runtime?

    PHP Code:
      <bean id="getUserGroupsCommand" 
    class="de.tfhberlin.eclipsophone.server.webapp.commands.GetUserGroupsCommand">
          <
    constructor-arg><ref bean="groupDAO"/></constructor-arg>
                   <!-- 
    What else ??? -->
      </
    bean

  • #2
    It is not directly supported to specify configuration parameters at runtime. Would it be possible to just retrieve the bean and pass in the user-id into a method to execute?

    Regards,
    Andreas

    Comment


    • #3
      Originally posted by Andreas Senft View Post
      It is not directly supported to specify configuration parameters at runtime. Would it be possible to just retrieve the bean and pass in the user-id into a method to execute?

      Regards,
      Andreas
      That would be against my specification of the interface that is implemented by all Command classes. I wrote something like a Command-Pattern. The ICommand-interface has an "execute" method without parameters.

      But I could specify a parameter representing an Object[]. So its content can be empty.

      Thank you, I will consider this.

      Comment

      Working...
      X