Results 1 to 4 of 4

Thread: Basic Spring Question

Hybrid View

  1. #1
    Join Date
    Aug 2005
    Location
    Sydney,Australia
    Posts
    11

    Default Basic Spring Question

    Dear Springgers,

    I am a newbie to Spring and trying to achieve this , given below are spring config file and piece of code :-

    -------------------
    springFocus.xml
    -------------------

    <beans>

    <bean id="cniP" class="cnie.util.CNIEParamReader" >
    <property name="cnieApplicationFileName"><value>src/cnie/bo/xml/cniNumberKeyValue.xml </value></property>
    </bean>

    <bean id="cniR" class="cnie.util.CNIEParameterReader">
    <property name="cnieApplicationFileName"> <value>src/cnie/bo/xml/keyvalue.xml</value></property>
    </bean>

    <bean id="getCNI" class="cnie.service.CNINumberHandler">

    <property name="focusSpringFile">
    <value>src/cnie/bo/xml/springFocus.xml</value>
    </property>

    <property name="focusPropertySource">
    <value> cniP </value>
    </property>
    </bean>

    <bean id="createCrime" class=cnie.service.CrimeRecordHandler">

    <property name="focusSpringFile">
    <value>src/cnie/bo/xml/springFocus.xml</value>
    </property>

    <property name="focusPropertySource">
    <value>cniR</value>
    </property>
    </bean>

    </beans>


    ----------------
    Piece of Code
    ----------------

    public abstract Class X {

    /**
    * Setter
    */
    public void setfocusSpringFile(String focusSpringFile) {

    this.focusSpringFile = focusSpringFile
    }

    /**
    * Getter
    */
    public String getfocusSpringFile() {

    return springFocusFile;
    }
    /**
    * Setter
    */
    public void setfocusPropertySource(String focusPropertySource)
    {
    this.focusPropetySource = focusPropertySource
    }

    /**
    * Getter
    */
    public String getfocusPropertySource() {

    return focusPropertySource
    }

    /**
    * setup for Spring reading of config file
    */
    public void setUp()
    {

    Resource is = new FileSystemResource( want to use getfocusPropertySpringFile() method as param instead of hardcoding the fileName i.e springFocus.xml)

    XmlBeanFactory factory = new XmlBeanFactory(is);

    CnieParameterReader cnieParamReader = (CNIEParameterReader)factory.getBean( want to use getfocusPropertySource() method instead of harddoding the beanId i.e. either cniP or cniR);

    }

    }

    Can we do this ? its a property within a property , I havent seen any example like what I am trying to do if i am not wrong.

    Expecting reply from Springgers

    Cheers
    Abhijeet Rai
    Abhijeet Rai
    Java Analyst Programmer

  2. #2
    Join Date
    Aug 2005
    Location
    Sydney,Australia
    Posts
    11

    Default

    Any replies please.
    Abhijeet Rai
    Java Analyst Programmer

  3. #3
    Join Date
    Aug 2005
    Location
    Sydney,Australia
    Posts
    11

    Default

    Ok springgers it works.

    Cheers
    Abhijeet
    Abhijeet Rai
    Java Analyst Programmer

  4. #4
    Join Date
    Aug 2004
    Posts
    1,905

    Default

    One thing you need to be aware of is that the java bean convention states accessors must be capitalized, i.e. if the property is called "name" then the accessors would be getName() and setName(String name)

Similar Threads

  1. Replies: 3
    Last Post: Sep 29th, 2005, 03:30 PM
  2. Newbie Question - The Ideal Spring Solution
    By conorp in forum Architecture
    Replies: 3
    Last Post: Aug 23rd, 2005, 03:22 AM
  3. Spring debugging question : IoC
    By etienno in forum Architecture
    Replies: 7
    Last Post: Apr 13th, 2005, 08:26 AM
  4. Replies: 14
    Last Post: Feb 21st, 2005, 05:41 PM
  5. Basic question about the usage of Spring
    By sganzman in forum Container
    Replies: 1
    Last Post: Aug 24th, 2004, 10:34 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
  •