Results 1 to 5 of 5

Thread: How to setup a String[]in spring context ?

  1. #1
    Join Date
    Jan 2005
    Posts
    144

    Default 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. #2
    Join Date
    Oct 2004
    Location
    Herndon, VA, US
    Posts
    648

    Default

    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>
    --Jing Xue

  3. #3
    Join Date
    Jan 2005
    Posts
    144

    Default

    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.

  4. #4
    Join Date
    Sep 2004
    Posts
    1

    Default

    String[] property example:

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

  5. #5
    Join Date
    Jan 2005
    Posts
    144

    Default [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.

Similar Threads

  1. Loosing my SecureContext
    By sklakken in forum Security
    Replies: 3
    Last Post: Jul 21st, 2005, 01:44 PM
  2. Spring http invoker: retrieving the application context...?
    By gvl@foundation.be in forum Remoting
    Replies: 1
    Last Post: Jun 21st, 2005, 12:59 AM
  3. Replies: 2
    Last Post: Jun 6th, 2005, 10:00 AM
  4. Replies: 14
    Last Post: Feb 21st, 2005, 05:41 PM
  5. Replies: 2
    Last Post: Jan 21st, 2005, 04:17 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •