Announcement Announcement Module
Collapse
No announcement yet.
How to set many independent Business Logic Bean in a single applicationContext.xml? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to set many independent Business Logic Bean in a single applicationContext.xml?

    I know there is a many Business Logic Bean in applicationContext.xml,like follows:
    <property name="mappingResources">
    <list>
    <value>com/lxx/flypig/bean/User.hbm.xml</value>
    <value>com/lxx/flypig/bean/Depment.hbm.xml</value>
    <value>com/lxx/flypig/bean/Czdyb.hbm.xml</value>
    <value>com/lxx/flypig/bean/Jsdmdyb.hbm.xml</value>
    <value>com/lxx/flypig/bean/Jsqxdyb.hbm.xml</value>
    <value>com/lxx/flypig/bean/Modeldyb.hbm.xml</value>
    </list>
    </property>
    ...

    <!-- Business Logic Bean -->
    <bean id="userService1" parent="baseProxy">
    <property name="target"><ref local="userServiceImpl1" /></property>
    </bean>
    <bean id="userServiceImpl1" class="com.service.impl.UserServiceImpl1" autowire="byName" />
    <bean id="userService2" parent="baseProxy">
    <property name="target"><ref local="userServiceImpl2" /></property>
    </bean>
    <bean id="userServiceImpl2" class="com.service.impl.UserServiceImpl2" autowire="byName" />
    ....

    If there are many Business Logic Bean in this file,such as 100 Business Logic Bean in applicationContext.xml,it looks applicationContext.xml file is bigger and don't easily to maintenance,is there a method to include these Business Logic Bean in independent file,like follows:
    <property name="mappingResources">
    <list>
    <value>com/lxx/flypig/bean/User.hbm.xml</value>
    <value>com/lxx/flypig/bean/Depment.hbm.xml</value>
    <value>com/lxx/flypig/bean/Czdyb.hbm.xml</value>
    <value>com/lxx/flypig/bean/Jsdmdyb.hbm.xml</value>
    <value>com/lxx/flypig/bean/Jsqxdyb.hbm.xml</value>
    <value>com/lxx/flypig/bean/Modeldyb.hbm.xml</value>
    </list>
    </property>

    Thanks in advance

  • #2
    Sorry, I'm not sure that I understood your question properly,
    but, if so, you have at least 2 solution
    1. Construnct you application contelt xml from sevelar files in your programm. Almost any ApplicationContext variation has constructor that accepts multiply file names, e.g. new ClasspathXmlapplicationcontext("file1.xmk,file2.xm l,file3.xml");
    2. Use import directive in your applicationContext.xml file, e. g. <import resource="businessBeans.xml"/>. It should reside before bean definitions.

    Should point that this topic is quite good covered in the Spring Reference Manual, chapter 3.2.2.1. Composing XML-based configuration metadata.
    It recommends first approach, whil myself prefers second one.

    Regards,
    Oleksandr

    Comment


    • #3
      Couldn't you use wild cards or set the directory instead?
      http://www.springframework.org/docs/...esource&#91;])
      Last edited by karldmoore; Aug 27th, 2007, 04:02 PM.

      Comment

      Working...
      X