<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Using a shared parent application context in a multi-war Spring application</title>
	<atom:link href="http://blog.springsource.org/2007/06/11/using-a-shared-parent-application-context-in-a-multi-war-spring-application/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.springsource.org/2007/06/11/using-a-shared-parent-application-context-in-a-multi-war-spring-application/</link>
	<description>The voice of SpringSource</description>
	<lastBuildDate>Wed, 08 Feb 2012 17:31:53 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.1</generator>
	<item>
		<title>By: DomV</title>
		<link>http://blog.springsource.org/2007/06/11/using-a-shared-parent-application-context-in-a-multi-war-spring-application/comment-page-3/#comment-204590</link>
		<dc:creator>DomV</dc:creator>
		<pubDate>Thu, 06 Oct 2011 16:36:59 +0000</pubDate>
		<guid isPermaLink="false">http://blog.interface21.com/main/2007/06/11/using-a-shared-parent-application-context-in-a-multi-war-spring-application/#comment-204590</guid>
		<description>Great post.   This is timely for us, as we have an EAR with 8 WARs that we are converting to Spring.    

Is it proper to move the datasource and transaction manager beans up into the EAR as well?    Seems a little strange, because I am using resource-ref=true, and resource references are defined to the WAR.</description>
		<content:encoded><![CDATA[<p>Great post.   This is timely for us, as we have an EAR with 8 WARs that we are converting to Spring.    </p>
<p>Is it proper to move the datasource and transaction manager beans up into the EAR as well?    Seems a little strange, because I am using resource-ref=true, and resource references are defined to the WAR.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joris Kuipers</title>
		<link>http://blog.springsource.org/2007/06/11/using-a-shared-parent-application-context-in-a-multi-war-spring-application/comment-page-3/#comment-198955</link>
		<dc:creator>Joris Kuipers</dc:creator>
		<pubDate>Thu, 21 Jul 2011 09:01:05 +0000</pubDate>
		<guid isPermaLink="false">http://blog.interface21.com/main/2007/06/11/using-a-shared-parent-application-context-in-a-multi-war-spring-application/#comment-198955</guid>
		<description>Hi Fellix,

that remark is there to clarify that &#039;singleton&#039; is not intended to mean the Gang of Four design pattern, but the default scope of a Spring bean definition. Spring cannot guarantee that only a single instance of a class exists, only that for a given bean definition defined in an ApplicationContext there&#039;s only going to be a single instance. 
Without a shared parent context, using a single Spring configuration file to define multiple contexts inside of a single application would mean that a separate instance would be created for every context, whereas a single shared context will ensure that only a single instance is created. That&#039;s only important if that instance holds state that you don&#039;t want to be replicated across the contexts that make up your application, or if its creation has additional side effects that should not be repeated for every context. Think about things like caches and pools: you want the entire application to share those objects, you don&#039;t want every web module (or whatever module with its own ApplicationContext you happen to be using) to define its own instances, since that would be inefficient and potentially even problematic.</description>
		<content:encoded><![CDATA[<p>Hi Fellix,</p>
<p>that remark is there to clarify that &#039;singleton&#039; is not intended to mean the Gang of Four design pattern, but the default scope of a Spring bean definition. Spring cannot guarantee that only a single instance of a class exists, only that for a given bean definition defined in an ApplicationContext there&#039;s only going to be a single instance.<br />
Without a shared parent context, using a single Spring configuration file to define multiple contexts inside of a single application would mean that a separate instance would be created for every context, whereas a single shared context will ensure that only a single instance is created. That&#039;s only important if that instance holds state that you don&#039;t want to be replicated across the contexts that make up your application, or if its creation has additional side effects that should not be repeated for every context. Think about things like caches and pools: you want the entire application to share those objects, you don&#039;t want every web module (or whatever module with its own ApplicationContext you happen to be using) to define its own instances, since that would be inefficient and potentially even problematic.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: fellix</title>
		<link>http://blog.springsource.org/2007/06/11/using-a-shared-parent-application-context-in-a-multi-war-spring-application/comment-page-3/#comment-198954</link>
		<dc:creator>fellix</dc:creator>
		<pubDate>Thu, 21 Jul 2011 08:49:09 +0000</pubDate>
		<guid isPermaLink="false">http://blog.interface21.com/main/2007/06/11/using-a-shared-parent-application-context-in-a-multi-war-spring-application/#comment-198954</guid>
		<description>Hi Joris,

Great post even for Spring3, but I have something confused about the singleton. You mentioned&quot;In general, if you have stateful beans that should really be used as a singleton (in the Spring sense, i.e. one instance per application as opposed to per JVM) you should define them in a single context accessed by the other contexts.&quot;, and is the comparison about the per application and per JVM means the clustered deployment and a non clustered one? If not, in a single server I think all the wars in an ear will be in a same JVM. Could you help explain that point in more details?</description>
		<content:encoded><![CDATA[<p>Hi Joris,</p>
<p>Great post even for Spring3, but I have something confused about the singleton. You mentioned&#034;In general, if you have stateful beans that should really be used as a singleton (in the Spring sense, i.e. one instance per application as opposed to per JVM) you should define them in a single context accessed by the other contexts.&#034;, and is the comparison about the per application and per JVM means the clustered deployment and a non clustered one? If not, in a single server I think all the wars in an ear will be in a same JVM. Could you help explain that point in more details?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joris Kuipers</title>
		<link>http://blog.springsource.org/2007/06/11/using-a-shared-parent-application-context-in-a-multi-war-spring-application/comment-page-3/#comment-195691</link>
		<dc:creator>Joris Kuipers</dc:creator>
		<pubDate>Fri, 17 Jun 2011 08:58:53 +0000</pubDate>
		<guid isPermaLink="false">http://blog.interface21.com/main/2007/06/11/using-a-shared-parent-application-context-in-a-multi-war-spring-application/#comment-195691</guid>
		<description>Hi Loek,

no, I had never anticipated that this entry would cause so much interest and feedback over the years ;)
You say &quot;prototypes&quot;, not sure what you mean: did you mean &quot;profiles&quot; perhaps? In that case it&#039;s not the same: profiles allow you to conditionally have certain beans defined depending on the profile(s) that are active when you start the ApplicationContext, this blog post talks about sharing beans from a single context across (web) modules in your application. Actually, my only other blog post which discusses environment-aware Spring applications is a way to achieve what can now be done with profiles natively in Spring 3.1.</description>
		<content:encoded><![CDATA[<p>Hi Loek,</p>
<p>no, I had never anticipated that this entry would cause so much interest and feedback over the years <img src='http://blog.springsource.org/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /><br />
You say &#034;prototypes&#034;, not sure what you mean: did you mean &#034;profiles&#034; perhaps? In that case it&#039;s not the same: profiles allow you to conditionally have certain beans defined depending on the profile(s) that are active when you start the ApplicationContext, this blog post talks about sharing beans from a single context across (web) modules in your application. Actually, my only other blog post which discusses environment-aware Spring applications is a way to achieve what can now be done with profiles natively in Spring 3.1.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loek Bergman</title>
		<link>http://blog.springsource.org/2007/06/11/using-a-shared-parent-application-context-in-a-multi-war-spring-application/comment-page-3/#comment-195689</link>
		<dc:creator>Loek Bergman</dc:creator>
		<pubDate>Fri, 17 Jun 2011 08:49:52 +0000</pubDate>
		<guid isPermaLink="false">http://blog.interface21.com/main/2007/06/11/using-a-shared-parent-application-context-in-a-multi-war-spring-application/#comment-195689</guid>
		<description>Hi Joris,


Thank you for this excellent post and answering all those questions throughout the years. Did you have that on your mind when you were writing this blog post? :-)

I wondered if this multiple context solution is equivalent to the use of prototypes in Spring 3? If correct wondering, which solution would you prefer?

With kind regards,

Loek</description>
		<content:encoded><![CDATA[<p>Hi Joris,</p>
<p>Thank you for this excellent post and answering all those questions throughout the years. Did you have that on your mind when you were writing this blog post? <img src='http://blog.springsource.org/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>I wondered if this multiple context solution is equivalent to the use of prototypes in Spring 3? If correct wondering, which solution would you prefer?</p>
<p>With kind regards,</p>
<p>Loek</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joris Kuipers</title>
		<link>http://blog.springsource.org/2007/06/11/using-a-shared-parent-application-context-in-a-multi-war-spring-application/comment-page-2/#comment-190852</link>
		<dc:creator>Joris Kuipers</dc:creator>
		<pubDate>Mon, 21 Mar 2011 09:22:18 +0000</pubDate>
		<guid isPermaLink="false">http://blog.interface21.com/main/2007/06/11/using-a-shared-parent-application-context-in-a-multi-war-spring-application/#comment-190852</guid>
		<description>Hi Jack,

frankly I can&#039;t think of a good use case for creating a new ApplicationContext for every request. That is what you&#039;re suggesting, right? What is it exactly you&#039;re trying to achieve? Maybe using session- or request-scoped beans could help you to achieve what you want; if you have dynamic requirements for their creation then using a FactoryBean or an @Bean method on an @Configuration class might suffice.</description>
		<content:encoded><![CDATA[<p>Hi Jack,</p>
<p>frankly I can&#039;t think of a good use case for creating a new ApplicationContext for every request. That is what you&#039;re suggesting, right? What is it exactly you&#039;re trying to achieve? Maybe using session- or request-scoped beans could help you to achieve what you want; if you have dynamic requirements for their creation then using a FactoryBean or an @Bean method on an @Configuration class might suffice.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jack</title>
		<link>http://blog.springsource.org/2007/06/11/using-a-shared-parent-application-context-in-a-multi-war-spring-application/comment-page-2/#comment-190632</link>
		<dc:creator>Jack</dc:creator>
		<pubDate>Fri, 18 Mar 2011 04:14:53 +0000</pubDate>
		<guid isPermaLink="false">http://blog.interface21.com/main/2007/06/11/using-a-shared-parent-application-context-in-a-multi-war-spring-application/#comment-190632</guid>
		<description>Joris,

First of all thanks for such wonderful post. I have a question related to making the same feature you are doing here session/request specific. What I am talking about is using the RequestContextListener instead of the ContextLoaderListener. Have you come across anythng like that..please guide me if you have any idea</description>
		<content:encoded><![CDATA[<p>Joris,</p>
<p>First of all thanks for such wonderful post. I have a question related to making the same feature you are doing here session/request specific. What I am talking about is using the RequestContextListener instead of the ContextLoaderListener. Have you come across anythng like that..please guide me if you have any idea</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dan carter</title>
		<link>http://blog.springsource.org/2007/06/11/using-a-shared-parent-application-context-in-a-multi-war-spring-application/comment-page-2/#comment-178938</link>
		<dc:creator>dan carter</dc:creator>
		<pubDate>Thu, 18 Nov 2010 17:29:24 +0000</pubDate>
		<guid isPermaLink="false">http://blog.interface21.com/main/2007/06/11/using-a-shared-parent-application-context-in-a-multi-war-spring-application/#comment-178938</guid>
		<description>Thanks Joris, makes sense now.</description>
		<content:encoded><![CDATA[<p>Thanks Joris, makes sense now.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dan carter</title>
		<link>http://blog.springsource.org/2007/06/11/using-a-shared-parent-application-context-in-a-multi-war-spring-application/comment-page-2/#comment-178937</link>
		<dc:creator>dan carter</dc:creator>
		<pubDate>Thu, 18 Nov 2010 17:27:50 +0000</pubDate>
		<guid isPermaLink="false">http://blog.interface21.com/main/2007/06/11/using-a-shared-parent-application-context-in-a-multi-war-spring-application/#comment-178937</guid>
		<description>Thanks Joris,

You&#039;re explaination of the extra level of nesting using spring dispatcher servlets makes it clear now.

For the benfit of anyone else using Jetty embeded and configured with spring, one piece of the puzzle is that took me a while to discover is that the context-param needed to set the parentContextKey in a web.xml translates to an init-param in the servlet API. 


ContextLoader.loadParentContext() {
[...]
  String parentContextKey = servletContext.getInitParameter(LOCATOR_FACTORY_KEY_PARAM);

Here&#039;s a full Jetty example for posterity


		
			
				
					
					
				
			
		
		
			
				
					
				
				
					
						
						
					
				
				
				
					
				
				
				
					
						
							
								
									
									
										
									
									
										
											
										
									
								
							
						
						
							
								
									
										
											/
										
									
									
								
							
						
					
				
			
		
	</description>
		<content:encoded><![CDATA[<p>Thanks Joris,</p>
<p>You&#039;re explaination of the extra level of nesting using spring dispatcher servlets makes it clear now.</p>
<p>For the benfit of anyone else using Jetty embeded and configured with spring, one piece of the puzzle is that took me a while to discover is that the context-param needed to set the parentContextKey in a web.xml translates to an init-param in the servlet API. </p>
<p>ContextLoader.loadParentContext() {<br />
[...]<br />
  String parentContextKey = servletContext.getInitParameter(LOCATOR_FACTORY_KEY_PARAM);</p>
<p>Here&#039;s a full Jetty example for posterity</p>
<p>											/</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Criminal Defense Las Vegas</title>
		<link>http://blog.springsource.org/2007/06/11/using-a-shared-parent-application-context-in-a-multi-war-spring-application/comment-page-2/#comment-178906</link>
		<dc:creator>Criminal Defense Las Vegas</dc:creator>
		<pubDate>Thu, 18 Nov 2010 04:28:04 +0000</pubDate>
		<guid isPermaLink="false">http://blog.interface21.com/main/2007/06/11/using-a-shared-parent-application-context-in-a-multi-war-spring-application/#comment-178906</guid>
		<description>Its so highly informative things are posted here. These things are the fresh and having good information are posted here, and also am seeking for this kind of information thanks for updated.</description>
		<content:encoded><![CDATA[<p>Its so highly informative things are posted here. These things are the fresh and having good information are posted here, and also am seeking for this kind of information thanks for updated.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

