Results 1 to 5 of 5

Thread: Setting bean property question

  1. #1
    Join Date
    Sep 2004
    Posts
    5

    Default Setting bean property question

    Hi,
    I'm really very new to spring. Infact I'm writing my first program in spring.
    I have to set a bean property in bean configuration xml file with a value that is defined in as a public static final member of an interface. In java program I write the code as
    Code:
    setTransportType(com.ibm.mq.jms.JMSC.MQJMS_TP_CLIENT_MQ_TCPIP);
    How do I write the same in bean xml file. BTW com.ibm.mq.jms.JMSC.MQJMS_TP_CLIENT_MQ_TCPIP is of type int.
    Thanks

  2. #2
    Join Date
    Sep 2004
    Posts
    5

    Default

    I guess this is not a place to ask newbie questions. Can someone please tell me where I can direct newbie questions?
    Thanks

  3. #3
    Join Date
    Sep 2004
    Location
    San Diego, CA
    Posts
    49

    Default

    Perhaps someone else can confirm whether this works, but have you looked at "org.springframework.beans.factory.config.FieldRet rievingFactoryBean"...

    The documentation indicates "FactoryBean which retrieves a static or non-static field value. Typically used for retrieving public static final constants."

    Not sure if you can use it with primitive types?

    Tim

  4. #4
    Join Date
    Aug 2004
    Location
    Montréal, Canada
    Posts
    845

    Default

    You can use either
    Code:
       <bean id="const" class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean">
         <property name="targetClass">
          <value>com.ibm.mq.jms.JMSC</value>
         </property>
         <property name="targetField">
          <value>MQJMS_TP_CLIENT_MQ_TCPIP</value>
         </property>
       </bean>
    or
    Code:
       <bean id="const" class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean">
        <property name="staticField">
          <value>com.ibm.mq.jms.JMSC.MQJMS_TP_CLIENT_MQ_TCPIP</value>
        </property>
       </bean>
    HTH
    Omar Irbouh

    Spring Modules Team
    http://irbouh.blogspot.com/

  5. #5
    Join Date
    Sep 2004
    Posts
    5

    Default

    Thanks a lot Tim and Omar. Worked fine for me indeed with org.springframework.beans.factory.config.FieldRetr ievingFactoryBean.
    I confirm that it does work with primitives too not just objects. Thanks again.

Similar Threads

  1. Order of Bean definitions matters?
    By cfuser in forum Container
    Replies: 2
    Last Post: Oct 21st, 2005, 10:29 AM
  2. Spring container fails with no exception
    By naor in forum Container
    Replies: 9
    Last Post: Oct 1st, 2005, 03:39 PM
  3. EHCaching Hibernate
    By dencamel in forum Data
    Replies: 3
    Last Post: Sep 6th, 2005, 09:03 PM
  4. could not satisfy dependencies
    By springuser in forum Container
    Replies: 4
    Last Post: Apr 26th, 2005, 01:15 PM
  5. Replies: 1
    Last Post: Apr 25th, 2005, 07:37 PM

Posting Permissions

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