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

<beans>

	<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
		<property name="location" value="/WEB-INF/jdbc.properties"/>
	</bean>

	<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
		<property name="driverClassName"><value>${jdbc.driverClassName}</value></property>
		<property name="url"><value>${jdbc.url}</value></property>
		<property name="username"><value>${jdbc.username}</value></property>
		<property name="password"><value>${jdbc.password}</value></property>
	</bean>
	
	<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
		<property name="dataSource" ref="dataSource"/>
		<property name="mappingResources">
	      <list>
	        <value>com/ntsky/bbs/domain/Help.hbm.xml</value>
	        <value>com/ntsky/bbs/domain/Forum.hbm.xml</value>
	        <value>com/ntsky/bbs/domain/Announcement.hbm.xml</value>
	        <value>com/ntsky/bbs/domain/ActLog.hbm.xml</value>
	        <value>com/ntsky/bbs/domain/Stat.hbm.xml</value>
	        <value>com/ntsky/bbs/domain/Admin.hbm.xml</value>
	        <value>com/ntsky/bbs/domain/Attachment.hbm.xml</value>
	        <value>com/ntsky/bbs/domain/Link.hbm.xml</value>
	        <value>com/ntsky/bbs/domain/User.hbm.xml</value>
	        <value>com/ntsky/bbs/domain/UserFace.hbm.xml</value>
	        <value>com/ntsky/bbs/domain/Message.hbm.xml</value>
	        <value>com/ntsky/bbs/domain/Topic.hbm.xml</value>
	        <value>com/ntsky/bbs/domain/Post.hbm.xml</value>
	        <value>com/ntsky/bbs/domain/Role.hbm.xml</value>
	        <value>com/ntsky/bbs/domain/Favorite.hbm.xml</value>
	        <value>com/ntsky/bbs/domain/Category.hbm.xml</value>
	        <value>com/ntsky/bbs/domain/Poll.hbm.xml</value>
	        <value>com/ntsky/bbs/domain/PollResult.hbm.xml</value>
	        <value>com/ntsky/bbs/domain/PollVoter.hbm.xml</value>
	        <value>com/ntsky/bbs/domain/Common.hbm.xml</value>
	      </list>
		</property>
		<property name="hibernateProperties">
			  <props>
				<prop key="hibernate.dialect">${hibernate.dialect}</prop>
				<prop key="hibernate.query.factory_class">org.hibernate.hql.ast.ASTQueryTranslatorFactory</prop>
				<prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
				<prop key="hibernate.cache.use_query_cache">true</prop>
				<prop key="hibernate.show_sql">true</prop>
				<prop key="hibernate.format_sql">true</prop>
				<prop key="hibernate.use_sql_comments">true</prop>
				<prop key="hibernate.jdbc.fetch_size">50</prop>
				<prop key="hibernate.jdbc.batch_size">50</prop>
				<prop key="hibernate.use_outer_join">true</prop> 				
			</props> 
		</property>
	</bean>

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

    <bean id="transactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor">
        <property name="transactionManager" ref="transactionManager"/>
		 <property name="transactionAttributes">
			<props>
				<prop key="*">PROPAGATION_REQUIRED</prop>
				<prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
			</props>
		</property>
		<!-- <property name="transactionAttributeSource">
		  <value>
			com.ntsky.bbs.service.ActLogService.create*=PROPAGATION_REQUIRED
		  </value>
		</property>	-->
    </bean>

    <bean class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
        <property name="beanNames">
            <value>*Service,*Manager</value>
        </property>
        <property name="interceptorNames">
            <list>
                <value>transactionInterceptor</value>
            </list>
        </property>
    </bean>

    <bean class="org.springframework.transaction.interceptor.TransactionAttributeSourceAdvisor">
        <property name="transactionInterceptor" ref="transactionInterceptor"/>
    </bean>
  
 	<bean id="baseDAO" class="com.ntsky.bbs.dao.hibernate.BaseDAOHibernateImpl">
    	<property name="sessionFactory"><ref local="sessionFactory"/></property>
    </bean>  
    
	<!--   ActLog	-->
 	<bean id="actLogDAO" class="com.ntsky.bbs.dao.hibernate.ActLogDAOHibernateImpl">
    	<property name="sessionFactory"><ref local="sessionFactory"/></property>
    </bean>

    <bean id="actLogService"  class="com.ntsky.bbs.service.impl.ActLogServiceImpl">
        <property name="actLogDAO"><ref local="actLogDAO"/></property>
    </bean>			
	<!--   ActLog	-->

	<!--   ActLog	-->
 	<bean id="commonDAO" class="com.ntsky.bbs.dao.hibernate.CommonDAOHibernateImpl">
    	<property name="sessionFactory"><ref local="sessionFactory"/></property>
    </bean>

    <bean id="commonService"  class="com.ntsky.bbs.service.impl.CommonServiceImpl">
        <property name="commonDAO"><ref local="commonDAO"/></property>
    	<property name="helpDAO"><ref local="helpDAO"/></property>
    	<property name="userFaceDAO"><ref local="userFaceDAO"/></property>
    </bean>			
	<!--   ActLog	-->

	<!--   Admin begin	-->	
 	<bean id="adminDAO" class="com.ntsky.bbs.dao.hibernate.AdminDAOHibernateImpl">
    	<property name="sessionFactory"><ref local="sessionFactory"/></property>
    </bean>
    
    <bean id="adminService"  class="com.ntsky.bbs.service.impl.AdminServiceImpl">
        <property name="adminDAO"><ref local="adminDAO"/></property>
    </bean>		
	<!--   Admin end	-->

	<!--   Role begin	-->	
 	<bean id="roleDAO" class="com.ntsky.bbs.dao.hibernate.RoleDAOHibernateImpl">
    	<property name="sessionFactory"><ref local="sessionFactory"/></property>
    </bean>
    
    <bean id="roleService"  class="com.ntsky.bbs.service.impl.RoleServiceImpl">
        <property name="roleDAO"><ref local="roleDAO"/></property>
        <property name="userDAO"><ref local="userDAO"/></property>
    </bean>		
	<!--   Role end	-->

	<!--   Stat	-->	
 	<bean id="statDAO" class="com.ntsky.bbs.dao.hibernate.StatDAOHibernateImpl">
    	<property name="sessionFactory"><ref local="sessionFactory"/></property>
    </bean>
    
    <bean id="statService"  class="com.ntsky.bbs.service.impl.StatServiceImpl">
        <property name="statDAO"><ref local="statDAO"/></property>
    </bean>		
	<!--   Stat	-->

	<!--  Favorite	-->	
 	<bean id="favoriteDAO" class="com.ntsky.bbs.dao.hibernate.FavortieDAOHibernateImpl">
    	<property name="sessionFactory"><ref local="sessionFactory"/></property>
    </bean>
    
    <bean id="favoriteService"  class="com.ntsky.bbs.service.impl.FavoriteServiceImpl">
    	<property name="topicDAO"><ref local="topicDAO"/></property>
       	<property name="favoriteDAO"><ref local="favoriteDAO"/></property>
     </bean>		
	<!--   Favorite	-->

	<!--  Poll	-->	
 	<bean id="pollDAO" class="com.ntsky.bbs.dao.hibernate.PollDAOHibernateImpl">
    	<property name="sessionFactory"><ref local="sessionFactory"/></property>
    </bean>
    
    <bean id="pollService"  class="com.ntsky.bbs.service.impl.PollServiceImpl">
       	<property name="pollDAO"><ref local="pollDAO"/></property>
     </bean>		
	<!--  Poll	-->

	<!--  PollResult  -->	
 	<bean id="pollResultDAO" class="com.ntsky.bbs.dao.hibernate.PollResultDAOHibernateImpl">
    	<property name="sessionFactory"><ref local="sessionFactory"/></property>
    </bean>
    
    <bean id="pollResultService"  class="com.ntsky.bbs.service.impl.PollResultServiceImpl">
       	<property name="pollVoterDAO"><ref local="pollVoterDAO"/></property>
    	<property name="pollResultDAO"><ref local="pollResultDAO"/></property>
    </bean>
	<!--  PollResult  -->

	<!--  PollVoter  -->	
 	<bean id="pollVoterDAO" class="com.ntsky.bbs.dao.hibernate.PollVoterDAOHibernateImpl">
    	<property name="sessionFactory"><ref local="sessionFactory"/></property>
    </bean>
    <!--  PollVoter  -->	

	<!--  Category	-->	
 	<bean id="categoryDAO" class="com.ntsky.bbs.dao.hibernate.CategoryDAOHibernateImpl">
    	<property name="sessionFactory"><ref local="sessionFactory"/></property>
    </bean>
    
    <bean id="categoryService"  class="com.ntsky.bbs.service.impl.CategoryServiceImpl">
    	<property name="categoryDAO"><ref local="categoryDAO"/></property>
     </bean>		
	<!--   Category	-->

	<!--   Help	-->	
 	<bean id="helpDAO" class="com.ntsky.bbs.dao.hibernate.HelpDAOHibernateImpl">
    	<property name="sessionFactory"><ref local="sessionFactory"/></property>
    </bean>
    
    <bean id="helpService"  class="com.ntsky.bbs.service.impl.HelpServiceImpl">
        <property name="helpDAO"><ref local="helpDAO"/></property>
    </bean>		
	<!--  Help	-->

	<!--  Annoucement	-->	
 	<bean id="announcementDAO" class="com.ntsky.bbs.dao.hibernate.AnnouncementDAOHibernateImpl">
    	<property name="sessionFactory"><ref local="sessionFactory"/></property>
    </bean>
    
    <bean id="announcementService"  class="com.ntsky.bbs.service.impl.AnnouncementServiceImpl">
        <property name="announcementDAO"><ref local="announcementDAO"/></property>
    </bean>		
	<!--  Annoucement	-->

	<!--  User	-->	
 	<bean id="userDAO" class="com.ntsky.bbs.dao.hibernate.UserDAOHibernateImpl">
    	<property name="sessionFactory"><ref local="sessionFactory"/></property>
    </bean>
    
    <bean id="userService"  class="com.ntsky.bbs.service.impl.UserServiceImpl">
        <property name="userDAO"><ref local="userDAO"/></property>
    </bean>		
	<!--  User	-->

	<!--  UserFace	-->	
 	<bean id="userFaceDAO" class="com.ntsky.bbs.dao.hibernate.UserFaceDAOHibernateImpl">
    	<property name="sessionFactory"><ref local="sessionFactory"/></property>
    </bean>
    
    <bean id="userFaceService"  class="com.ntsky.bbs.service.impl.UserFaceServiceImpl">
        <property name="userFaceDAO"><ref local="userFaceDAO"/></property>
    </bean>		
	<!--  UserFace	-->

	<!--  Attachment	-->	
 	<bean id="attachmentDAO" class="com.ntsky.bbs.dao.hibernate.AttachmentDAOHibernateImpl">
    	<property name="sessionFactory"><ref local="sessionFactory"/></property>
    </bean>
    
    <bean id="attachmentService"  class="com.ntsky.bbs.service.impl.AttachmentServiceImpl">
        <property name="attachmentDAO"><ref local="attachmentDAO"/></property>
    </bean>		
	<!--  Attachment	-->

	<!--  Link	-->	
 	<bean id="linkDAO" class="com.ntsky.bbs.dao.hibernate.LinkDAOHibernateImpl">
    	<property name="sessionFactory"><ref local="sessionFactory"/></property>
    </bean>
    
    <bean id="linkService"  class="com.ntsky.bbs.service.impl.LinkServiceImpl">
        <property name="linkDAO"><ref local="linkDAO"/></property>
    </bean>		
	<!--  Link	-->

	<!--  Message	-->	
 	<bean id="messageDAO" class="com.ntsky.bbs.dao.hibernate.MessageDAOHibernateImpl">
    	<property name="sessionFactory"><ref local="sessionFactory"/></property>
    </bean>
    
    <bean id="messageService"  class="com.ntsky.bbs.service.impl.MessageServiceImpl">
        <property name="messageDAO"><ref local="messageDAO"/></property>
    </bean>		
	<!--  Message	-->

	<!--  Forum	-->	
 	<bean id="forumDAO" class="com.ntsky.bbs.dao.hibernate.ForumDAOHibernateImpl">
    	<property name="sessionFactory"><ref local="sessionFactory"/></property>
    </bean>
    
    <bean id="forumService"  class="com.ntsky.bbs.service.impl.ForumServiceImpl">
        <property name="forumDAO"><ref local="forumDAO"/></property>
        <property name="topicDAO"><ref local="topicDAO"/></property>
        <property name="postDAO"><ref local="postDAO"/></property>
        <property name="userDAO"><ref local="userDAO"/></property>
        <property name="categoryDAO"><ref local="categoryDAO"/></property>
    </bean>		
	<!--  Forum	-->

	<!--  Topic	-->	
 	<bean id="topicDAO" class="com.ntsky.bbs.dao.hibernate.TopicDAOHibernateImpl">
    	<property name="sessionFactory"><ref local="sessionFactory"/></property>
    </bean>
    
    <bean id="topicService"  class="com.ntsky.bbs.service.impl.TopicServiceImpl">
        <property name="topicDAO"><ref local="topicDAO"/></property>
        <property name="postDAO"><ref local="postDAO"/></property>
        <property name="userDAO"><ref local="userDAO"/></property>
        <property name="roleDAO"><ref local="roleDAO"/></property>
        <property name="pollDAO"><ref local="pollDAO"/></property>
        <property name="pollResultDAO"><ref local="pollResultDAO"/></property>
    </bean>		
	<!--  Topic	-->

	<!--  Post	-->	
 	<bean id="postDAO" class="com.ntsky.bbs.dao.hibernate.PostDAOHibernateImpl">
    	<property name="sessionFactory"><ref local="sessionFactory"/></property>
    </bean>
    
    <bean id="postService"  class="com.ntsky.bbs.service.impl.PostServiceImpl">
        <property name="postDAO"><ref local="postDAO"/></property>
  		<property name="topicDAO"><ref local="topicDAO"/></property>
  		<property name="userDAO"><ref local="userDAO"/></property>
    </bean>		
	<!--  Post	-->
		
	<bean id="xmlDataService"  class="com.ntsky.bbs.service.impl.XmlDataServiceImpl"/>	
		
	<!-- 
    <bean id="txProxyTemplate" abstract="true"
        class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
        <property name="transactionManager" ref="transactionManager"/>
        <property name="transactionAttributes">
            <props>
                <prop key="save*">PROPAGATION_REQUIRED</prop>
                <prop key="remove*">PROPAGATION_REQUIRED</prop>
                <prop key="*">PROPAGATION_REQUIRED,readOnly</prop>
            </props>
        </property>
    </bean>	
	
	<bean id="actLogDAO" class="com.ntsky.bbs.dao.hibernate.ActLogDAOHibernateImpl">
    	<property name="sessionFactory"><ref local="sessionFactory"/></property>
    </bean>   

	<bean id="actLogService" parent="txProxyTemplate">
    	<property name="target">
            <bean class="com.ntsky.bbs.service.impl.ActLogServiceImpl">
                <property name="actLogDAO" ref="actLogDAO"/>
            </bean>
        </property>
    </bean>   
    -->
    
    <!--  <bean id="actLogDAO" class="com.ntsky.bbs.dao.hibernate.ActLogDAOHibernateImpl">
    	<property name="sessionFactory"><ref local="sessionFactory"/></property>
    </bean>

    <bean id="actLogServiceTarget"  class="com.ntsky.bbs.service.impl.ActLogServiceImpl">
        <property name="actLogDAO"><ref local="actLogDAO"/></property>
    </bean>		
    
    <bean id="actLogService" 
        class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
        <property name="transactionManager"><ref local="transactionManager"/></property>
        <property name="target"><ref local="actLogServiceTarget"/></property>
        <property name="transactionAttributes">
            <props>
                <prop key="save*">PROPAGATION_REQUIRED</prop>
            </props>
        </property>
    </bean> -->	
    
</beans>
