`
lizhengfa
  • 浏览: 44897 次
  • 来自: ...
社区版块
存档分类
最新评论

webwork+hibernate+spring 速度慢

阅读更多

<!---->

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

<beans>
 <import resource="cacheContext.xml"/> 
 <bean id="propertyConfigurer"  
  class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" >  
  <property name="locations">  
   <list>  
   <value>/jdbc.properties</value>  
   </list>  
  </property>  
 </bean>
 
 <bean id="mydataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
  <property name="driverClassName">
   <value>${jdbc.driver}</value>
  </property>
  <property name="url">
   <value>${jdbc.url}</value>
  </property>
  <property name="username">
   <value>${jdbc.user}</value>
  </property>
  <property name="password">
   <!-- value>ossserver</value-->
   <value>${jdbc.password}</value>
  </property>
  <property name="maxActive">
   <value>${jdbc.maxActive}</value>
  </property>
  <property name="maxIdle">
   <value>${jdbc.maxIdle}</value>
  </property>
  <property name="maxWait">
   <value>${jdbc.maxWait}</value>
  </property>
 </bean>
 
    <!-- 不用事务的调用方法 -->
 <bean id="mySessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean" >
  <property name="dataSource">
   <ref bean="mydataSource"/>
  </property>
  <property name="mappingResources">
   <list>    
    <value>com/eom/acl/bo/EomOrgan.hbm.xml</value> 
    <value>com/eom/acl/bo/EomSystemFunc.hbm.xml</value> 
   </list>
  </property>
 
  <property name="hibernateProperties">
   <props>
      <prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop>
            <prop key="hibernate.show_sql">false</prop>
            <prop key="hibernate.generate_statistics">true</prop>
            <prop key="hibernate.jdbc.fetch_size">50</prop>
            <prop key="hibernate.jdbc.batch_size">30</prop>
   <!-- 解决weblogic抛出的ClassNotFoundException: org.hibernate.hql.ast.HqlToken异常-->
   <prop key="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</prop>
   </props>
  </property>

   </bean>
  
   <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
       <property name="sessionFactory"><ref bean="mySessionFactory"/></property>
    </bean>
    
 
 <!-- 定义业务对象-->
    <bean id="EomOrganDAO"
   class="com.eom.acl.daoimpl.EomOrganDAOImpl" >
   <property name="sessionFactory">
    <ref bean="mySessionFactory"/>
   </property>
 </bean> 
    

  
 <bean id="EomSystemFuncDAO"
   class="com.eom.acl.daoimpl.EomSystemFuncDAOImpl">
   <property name="sessionFactory">
    <ref bean="mySessionFactory"/>
   </property>
 </bean> 

 
</beans>

下面是取的两个类

 

package com.eom.common.context;

import java.util.Date;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class AllContext {
 
 private static AllContext instance;   
 private  static ApplicationContext appContext;
 
 private static final Object key = new Object();   
   
    private AllContext()   
    {   
     if (appContext == null) {
      appContext = new ClassPathXmlApplicationContext("/applicationContext.xml");
     }
    }   
  
    public static AllContext getInstance()   
    {   
        if (instance == null)   
        {   
            synchronized (key)   
            {   
                if (instance == null)   
                {   
                    instance = new AllContext();   
                }   
            }   
        }   
        return instance;   
    }   
   
    public ApplicationContext getAppContext() {
  return appContext;
 }
}

 

package com.eom.common.context;

public class AppContext {
 
 /**
  *  组织机构DAO
  * @return
  */
 public static EomOrganDAO getEomOrganDAO(){
  
  return (EomOrganDAO) AllContext.getInstance().getAppContext().getBean("EomOrganDAO");
 }

}

 

不知道这样取行不行???

 

 

终于知道原因了,原来webwork 里面自带ajax 部分会影响速度

分享到:
评论
1 楼 rasonyang 2007-08-30  
看看这个http://www.opensymphony.com/webwork/wikidocs/Spring.html

直接通过new ClassPathXmlApplicationContext这种方式,并不是WebWork2推荐的方式。还有通过WebLogic,最好使用JTA事务,如下:
<bean id="transactionManager" class="org.springframework.transaction.jta.WebLogicJtaTransactionManager"> <property name="transactionManagerName" value="javax.transaction.TransactionManager"/>
</bean>

相关推荐

Global site tag (gtag.js) - Google Analytics