Announcement Announcement Module
Collapse
No announcement yet.
Basic Spring Question Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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

  • #2
    Any replies please.

    Comment


    • #3
      Ok springgers it works.

      Cheers
      Abhijeet

      Comment


      • #4
        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)

        Comment

        Working...
        X