struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ren sky <byzh...@gmail.com>
Subject struts2+spring+hibernate, objects instantiate order?
Date Thu, 14 May 2009 02:03:16 GMT
hello everyone,
i am new to struts2.
i use struts2, spring2.5 and hibernate 3.3.1 to build a simple website.
and have some questions about the order of the objects instantiate.
here is my config file for spring:

-------------------------------------applicationContext.xml------------------------------------------------
    <bean id="Login" class="sshdemo.func001.action.LoginAction"
scope="prototype">
        <property name="personService" ref="personService" />
    </bean>

    <bean id="personService" class="sshdemo.func001.service.PersonServiceImpl">
        <property name="personDAO" ref="PersonDAO" />
    </bean>

    <bean id="PersonDAO" class="sshdemo.func001.dao.PersonDAOImpl">
        <property name="sessionFactory" ref="sessionFactory" />
    </bean>

    <bean id="sessionFactory"
        class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <property name="dataSource" ref="dataSource" />
        .......
        .......
    </bean>

    <bean id="dataSource"
        class="org.apache.commons.dbcp.BasicDataSource">
        ........
        ........
    </bean>
-------------------------------------applicationContext.xml------------------------------------------------

and when i start the tomcat, before running my project,
i get the logs like this:

-----------------------------------------------log
contents------------------------------------------------
Loaded 6 bean definitions from location pattern
[/WEB-INF/applicationContext.xml]
......
6 beans defined in
org.springframework.web.context.support.XmlWebApplicationContext@179dce4:
display name [Root WebApplicationContext]; startup date [Thu May 14
08:44:00 CST 2009]; root of context hierarchy
......
Pre-instantiating singletons in
org.springframework.beans.factory.support.DefaultListableBeanFactory@6210fb:
defining beans [Login,personService,PersonDAO,sessionFactory,dataSource,ChartAction];
root of factory hierarchy
Creating shared instance of singleton bean 'personService'
Creating instance of bean 'personService'
Eagerly caching bean 'personService' to allow for resolving potential
circular references
Creating shared instance of singleton bean 'PersonDAO'
Creating instance of bean 'PersonDAO'
Eagerly caching bean 'PersonDAO' to allow for resolving potential
circular references
Creating shared instance of singleton bean 'sessionFactory'
Creating instance of bean 'sessionFactory'
Eagerly caching bean 'sessionFactory' to allow for resolving potential
circular references
Creating shared instance of singleton bean 'dataSource'
Creating instance of bean 'dataSource'
Eagerly caching bean 'dataSource' to allow for resolving potential
circular references
........
 -----------------------------------------------log
contents------------------------------------------------

does that mean
1) before running my project, spring has already instantiate all the
object defined in the applicationContext.xml?
   such as LoginAction,PersonServiceImpl and sessionFactory?
2) the action  used in struts2 is instantiated before a request comes
in? or is instantiated  when a real request comes in?
3) with spring,what is the role of struts2 ? it seems that the
responsibility of instantiate object is changed to spring, not
struts2.

thanks.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message