You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@tuscany.apache.org by Gopi Lokavarapu <go...@gmail.com> on 2013/09/03 13:35:09 UTC

Could you pleas help me how to resolve the following issue: one composite file with multiple components and one spring-context.xml file with all service as spring beans

Below is the scenario what i have faced the problem
<composite>
 <component name="component1">
   <implementation.spring="/
somLocation/spring-conentx.xml" />
    <service name="component1Service">
      <tuscany:binding.rest uri="http://localhost:8085/hell0"/> //here can
i give like this uri="/hello' (if it is tomcat server)
   </service>
</component>
<component name="component2">
<implementation.spring="/
somLocation/spring-conentx.xml" />
    <service name="component2Service">
      <tuscany:binding.rest uri="http://localhost:8085/hell01"/> //here can
i give like this uri="/hello1' (if it is tomcat server)
   </service>
</component>

.................
.................
.................
<component name="component5'>
<implementation.spring="/
somLocation/spring-conentx.xml" />
    <service name="component5Service">
      <tuscany:binding.rest
uri="http://localhost:8085/hell05<http://localhost:8085/hell0N>"/>

   </service>
</component>

</composite>

Problem:From the above scenario spring-context.xml contains all services as
beans,whenever i start the server it at that time tuscanyServletFilter
loads the composite file,at the same time it also loading
spring-context.xml.But here is my problem ,I thought that this problem is
due to implementation.spring ,it is loaded spring-context.xml file
everytime ,when tuscanyfilter verifying the composite file,and identifying
every service defined in spring-context file at that time it creating
objects every time at the time of loading itself(before giving request)
<beans>
<bean id="mySessionFactroy" class="LocalSessionFactoryBean"/>
  <sca:service name="Component1Service" target="bean1"/>
  <sca:service name="Component2Service" target="bean2"/>
..................................................
..................................................
  <sca:service name="Component5Service" target="bean5"/>
<bean id="bean1" class="class1"/>
<bean id="bean2" class="class2"/>
....................
................
<bean id="bean3" class="classN"/>
</beans>

In the above scenario whenever i run the application with tomcat7 with
apache-wink runtime ,how many components are there in composite file
corresponding times spring-context file is loading,at that time it is
creating objects for each and every beans even though objects are already
instantiated.
i.e
whenever loading composite file
for every implementaion.spring all beans instantiation is takesplace
component1---->implementation.spring------>bean id="bean1"
component2----->implementaion.spring------->bean id="bean1' bean id="bean2'
---------------------------------------
---------------------------------------
component5------->
implementaion.spring------>bean id="bean1" bean id="bean2"...........bean5

FAQ:1)Is it good to define all components in same component file and define
all service beans in same spring-context.xml file?
2) If FAQ1 is possible why every time applicationContext instantiating
already initialized beans
3) can I use spring annotations in services directly?

Could you please help me how to resolve this issue


Thank you