aspose file tools*
The moose likes Other Application Frameworks and the fly likes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark ""Many WARs in one EAR" or "Code organization with Spring/Hibernate"" Watch ""Many WARs in one EAR" or "Code organization with Spring/Hibernate"" New topic
Author

"Many WARs in one EAR" or "Code organization with Spring/Hibernate"

Olexiy Prokhorenko
Ranch Hand

Joined: Jul 11, 2004
Posts: 97
Hi there!

I wonder, what is the proper code organization with Spring, when I have one EAR with numerous WARs inside, and all these WARs suppose to use Hibernate, and any of WARs can use any of Hibernate's mapping POJOs.
So it looks like in this EAR we need to have one "business logic", which all WARs will use.
How this should looks like? What are the best practicies?

I saw different example when using Spring+Hibernate for one Web Application (WAR), but not for numerous WARs in one EAR.

To clarify a bit more -- I am interested where Spring, Hibernate's files need to be placed. How Spring need to be "called" (with one WAR we just put everything into it's WEB-INF)... and all these things.
Any help or advice, or even link - appreciated, thank you!


<a href="http://www.BossTalks.com" target="_blank" rel="nofollow">http://www.BossTalks.com</a><br />Free advices and help for entrepreneurs: from Idea to IPO<br />Software and IT Project Management forum
Chris Berthold
Greenhorn

Joined: Jul 20, 2005
Posts: 1
I've not jumped onto the Spring bandwagon yet(only out of lack of time to get comfy in a new architecture), but heres my theory. Spring uses IoC(Inversion of Control), or the "let me create the objects, so you don't have to" theory. From my understanding of what i've read in the past, Spring can use two different types of factories to manage those beans, Prototype and Singleton. Doing some lookups on Google, I see that Springs default is to create Singleton objects(one per JVM). Just by using the defaults, Spring will create one SessionFactory for you which will be used by all the different threads. The only thing you need to worry about would be thread safety on all the other objects that you have designed yourself. Spring is just a cultivated product of best use cases(I probably need to bite the bullet and catch up).

Chris
Olexiy Prokhorenko
Ranch Hand

Joined: Jul 11, 2004
Posts: 97
Honestly speaking, my question was primary of how to organize the code. Where to place Spring's config, etc.
At the moment I found a solution of putting everything in JAR (Spring+Hibernate configs), libraries directly into EAR, and all my WARs in this EAR are able to work with Spring/Hibernate, however, this will require to force Ant to generate proper Class-Path for their manifests.

This is what I see. May be there is more elegant solution - but I was not able to find it yet.

What also I noticed, is that once each of WARs will start they both will use Springs config from JAR and this will force to create one Hibernate Session Factories for each of WAR! As I can understand it happens because each of WARs are started in separated JVM. Not sure how JBoss/Tomcat is doing this. But while I can keep only ONE copy of all configs in a one place I do not care if each of WARs will require it's own session factory. Besides, this makes sense.
[ July 20, 2005: Message edited by: Olexiy Prokhorenko ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: "Many WARs in one EAR" or "Code organization with Spring/Hibernate"