-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Tomcat Cross Context Sharing of SessionFactory
PostPosted: Tue Dec 22, 2009 5:14 pm 
Newbie

Joined: Sun Nov 18, 2007 11:41 pm
Posts: 1
I am working on a solution for this problem: we have multiple web-apps that build a large number of Session Factories (up to 30) with large class maps which are taking up a large amount of space - we have the potential to soon run into memory usage issues if we keep doing this.

Overview:
We have at least 3 contexts which connect to the same database. Each currently has its own mapping configurations (though we can move to a single mapping configuration) - we did this to help constrain the number of classes we map in each context to help save memory. We have multiple customers, each of which has its own schema in our database and therefore each have their own session factory.

We want to move to an implementation where we create a single set of session factories which may be shared by each of our web apps (basically cutting the number of session factories we have to create by 1/3).

Proposed Solution:
Create a new mapping configuration that is an intersection of all contexts mapping configurations.
Create a new context (named "SessionFactory") that will be responsible for building the session factories.
Set this new context as: crossContext="true"
This new context will have an initialization servlet which will create all needed session factories (using new mapping) and map them to its ServletContext; all other contexts can access as follows:
Code:
ServletContext ctx = getServletContext().getContext("SessionFactory");
SessionFactory sf = ctx.getAttribute("<Session Factory ID>");


We are not using Spring, or any other Beans/J2EE frameworks -- just basic web-apps with servlets -- and do not want to (yet)

I have not found any discussions on the proper or accepted way to handle this situation, so I am looking for any known alternatives that would allow our contexts to share session factories between them.

Any insight, potential issues with this solution or alternate (proper) ways to implement this would be greatly appreciated!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.