[Logo] Terracotta Discussion Forums (LEGACY READ-ONLY ARCHIVE)
  [Search] Search   [Recent Topics] Recent Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
Loading the Spring Config Files Dynamically  XML
Forum Index -> Terracotta for Spring
Author Message


Joined: 11/29/2006 07:02:51
Messages: 1


In our application we will be loading new ApplicationContexts on the Fly when we get a new Message..

How can i handle this scenario with Terrracotta ?? As one needs to specify the Spring-bean config Files in the Terracotta Config Files..Can we change the Terracotta config files at run time??




Joined: 08/04/2006 07:58:08
Messages: 17
Location: Terracotta, Inc.

Hi Sateesh,

It actually depends how you have coded the context loading. For instance, if your code looked something like this

new ClassPathXmlApplicationContext({ "config/foo.xml",
"config/bar.xml" });

and your config looked something like:


or this


that code should work. However, paths in the config are used for matching
only, but the name for the implicit context root in DSO is derived from the actual resource names. So, if you used the second configuartion, and you were to load those same contexts again, but use foo2.xml and bar2.xml, you will have two distinct DSO roots and beans won't be shared between these two contexts.

Also, as the call stack is used to calcuate the root name, you can only see that two app contexts are clustered if that new ClassPathXmlApplicationContext(..) call happens in the same call stack.

I would suggest loading the Spring contexts on init, store in them some kind of map, and then retrieve specific context instance using a key from their messages. Is this workable in your application?



Gordon Rose
Sr. Systems Engineer
Terracotta, Inc.


Joined: 01/05/2010 20:52:24
Messages: 223

Thanks for sharing !

Forum Index -> Terracotta for Spring
Go to:   
Powered by JForum 2.1.7 © JForum Team