-->
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.  [ 4 posts ] 
Author Message
 Post subject: Spring vs Struts & some questions about Spring......
PostPosted: Tue Nov 25, 2003 8:05 am 
Newbie

Joined: Tue Nov 25, 2003 7:51 am
Posts: 2
I want to use Spring and Hibernate to deal with the data access layer.

But I'm not sure which can act as the view layer .

Struts is good,I used it in my projects,it works but not so flexible,I want

a more flexible way ,anyone can give some advice?


Another thing boring me ,The sessionFactory is configured through an Xml

file,Does it instantiated once or everytime when use it?


beg for your reply.............thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 25, 2003 9:28 am 
Senior
Senior

Joined: Wed Aug 27, 2003 6:04 am
Posts: 161
Location: Linz, Austria
Well, with a middle tier based on Spring and Hibernate, you can basically put any web MVC framework on top. The web controllers just need access to your Spring-managed business objects, which is easy enough if the controllers have access to the ServletContext.

Of course, I consider Spring's own web MVC division as a clean and elegant implementation of web MVC, more flexible and less intrusive than Struts. But I'm biased, I guess ;-) We also have people using Tapestry and WebWork2 with a Spring-managed middle tier.

A Hibernate SessionFactory just gets instantiated once for each application. In a Spring-managed middle tier, there is typically a LocalSessionFactoryBean definition with singleton status. All data access objects then just reference the SessionFactory that this bean exposes.

Have a look at the docs at the Spring website (http://www.springframework.org/documentation.html), in particular the article "Web MVC with the Spring Framework", for an overview of web tier options with Spring.

Juergen


Top
 Profile  
 
 Post subject: Re: Spring vs Struts & some questions about Spring......
PostPosted: Tue Nov 25, 2003 11:01 am 
Regular
Regular

Joined: Fri Sep 05, 2003 12:01 am
Posts: 80
Location: Bogot
jameli wrote:

Another thing boring me ,The sessionFactory is configured through an Xml

file,Does it instantiated once or everytime when use it?


beg for your reply.............thanks.


If you use struts then you would be calling the spring application context from your struts Actions:

Code:
  /**
     *Initialize beans and their daos from the springframework web context
     * This method doesnt initialize the spring framework context, just get
     * properly initialized DAO's from the spring context
     **/
    protected void initBeans(){
       
        context=WebApplicationContextUtils.getWebApplicationContext(
        this.getServlet().getServletContext()
        );
        projectDAO= (ProjectDAO)context.getBean("ProjectDAO");
        packageDAO= (PackageDAO)context.getBean("PackageDAO");
        contractorDAO= (IContractorDAO)context.getBean("ContractorDAO");
       
    }
   


You dont want to initialize your spring context all the time, because it would create the hibernate sessionfactory.

_________________
Mauricio Hern


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 27, 2003 1:52 am 
Newbie

Joined: Tue Nov 25, 2003 7:51 am
Posts: 2
Quote:
Thanks;:)


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

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.