Announcement Announcement Module
Collapse
No announcement yet.
How to setup a String[]in spring context ? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to setup a String[]in spring context ?

    I've to set an environment map (to set JMX connector credentials) as a bean property. This map must include a String[2] entry.

    Is they're a Spring way to setup a String[] in bean context ?

  • #2
    This is not tested, and I think it's rather cumbersome at that. I'm sure there are better ways (like writing your own factory bean), but I can't think of any of them now...

    Code:
    <bean id="arrayList" class="org.springframework.beans.factory.config.ListFactoryBean">
      <property name="sourceList">
        <list>
          <value>value 1</value>
          <value>value 2</value>
        </list>
      </property>
    </bean>
    
    <bean id="someBean" class="foo">
      <property name="someMap">
        <map>
          <entry>
            <key><value>theKey</value></key>
            <bean factory-bean="arrayList" factory-method="toArray"/>
          </entry>
        </map>
      </property>
    </bean>

    Comment


    • #3
      I had already tested this, but it builds on Object[] array, not String[].

      I will have to create a factoryBean for this.

      Thanks you for suggestion anyway.

      Comment


      • #4
        String[] property example:

        Code:
        <property name="pages"><value>page1,page2,page3</value></property>

        Comment


        • #5
          [solved] How to setup a String[]in spring context ?

          It works, I just had to add
          Code:
          <value type="java.lang.String&#91;&#93;">
          Thanks.

          Comment

          Working...
          X