ï»??xml version="1.0" encoding="utf-8" standalone="yes"?>成r视频免费观看在线播放,猫咪在线永久网站,亚洲成在人线免费观看http://www.aygfsteel.com/GavinMiao/category/49352.html我在仰望åQŒjava之上zh-cnFri, 13 Sep 2019 16:51:02 GMTFri, 13 Sep 2019 16:51:02 GMT60¾~–码至高法则-高内聚低耦合http://www.aygfsteel.com/GavinMiao/archive/2019/09/11/434613.htmlGavinMiaoGavinMiaoWed, 11 Sep 2019 07:59:00 GMThttp://www.aygfsteel.com/GavinMiao/archive/2019/09/11/434613.htmlhttp://www.aygfsteel.com/GavinMiao/comments/434613.htmlhttp://www.aygfsteel.com/GavinMiao/archive/2019/09/11/434613.html#Feedback0http://www.aygfsteel.com/GavinMiao/comments/commentRss/434613.htmlhttp://www.aygfsteel.com/GavinMiao/services/trackbacks/434613.html阅读全文

GavinMiao 2019-09-11 15:59 发表评论
]]>
公司口碑及待遇评ä»ïLš„¾|‘ç«™http://www.aygfsteel.com/GavinMiao/archive/2012/03/27/372859.htmlGavinMiaoGavinMiaoTue, 27 Mar 2012 15:13:00 GMThttp://www.aygfsteel.com/GavinMiao/archive/2012/03/27/372859.htmlhttp://www.aygfsteel.com/GavinMiao/comments/372859.htmlhttp://www.aygfsteel.com/GavinMiao/archive/2012/03/27/372859.html#Feedback1http://www.aygfsteel.com/GavinMiao/comments/commentRss/372859.htmlhttp://www.aygfsteel.com/GavinMiao/services/trackbacks/372859.htmlhttp://www.b1.tooyard.com/
2.分智¾|‘:http://www.fenzhi.com/  
3.我评itåQ?a >http://wopingit.com/   
4.企业点评¾|‘:http://www.71dp.com/   
5.中国企业评ä­h¾|‘: http://www.ceea.net.cn/  
6.公司点评¾|‘:http://www.gsdpw.com/  
7.企业付费邀请面试:http://www.tradecv.com/

GavinMiao 2012-03-27 23:13 发表评论
]]>
window下dos½H—口中文ä¹Þq è§£å†³åŠžæ³•http://www.aygfsteel.com/GavinMiao/archive/2012/03/20/372258.htmlGavinMiaoGavinMiaoTue, 20 Mar 2012 03:16:00 GMThttp://www.aygfsteel.com/GavinMiao/archive/2012/03/20/372258.htmlhttp://www.aygfsteel.com/GavinMiao/comments/372258.htmlhttp://www.aygfsteel.com/GavinMiao/archive/2012/03/20/372258.html#Feedback0http://www.aygfsteel.com/GavinMiao/comments/commentRss/372258.htmlhttp://www.aygfsteel.com/GavinMiao/services/trackbacks/372258.html˜q›å…¥æ³¨å†Œè¡¨ï¼š
HKEY_CURRENT_USER\Console\%SystemRoot%_system32_cmd.exe
新徏DWORDå€û|¼Œç„¶åŽé‡å‘½åäØ“åQšCodePageåQŒä¿®æ”¹å…¶å€égؓ十进制的936

GavinMiao 2012-03-20 11:16 发表评论
]]>
POI学习http://www.aygfsteel.com/GavinMiao/archive/2012/02/22/370488.htmlGavinMiaoGavinMiaoWed, 22 Feb 2012 02:01:00 GMThttp://www.aygfsteel.com/GavinMiao/archive/2012/02/22/370488.htmlhttp://www.aygfsteel.com/GavinMiao/comments/370488.htmlhttp://www.aygfsteel.com/GavinMiao/archive/2012/02/22/370488.html#Feedback0http://www.aygfsteel.com/GavinMiao/comments/commentRss/370488.htmlhttp://www.aygfsteel.com/GavinMiao/services/trackbacks/370488.htmlPOI所有组ä»Óž¼š




GavinMiao 2012-02-22 10:01 发表评论
]]>
MyEclipse修改™å¹ç›®åç§°http://www.aygfsteel.com/GavinMiao/archive/2011/12/03/365484.htmlGavinMiaoGavinMiaoSat, 03 Dec 2011 15:37:00 GMThttp://www.aygfsteel.com/GavinMiao/archive/2011/12/03/365484.htmlhttp://www.aygfsteel.com/GavinMiao/comments/365484.htmlhttp://www.aygfsteel.com/GavinMiao/archive/2011/12/03/365484.html#Feedback1http://www.aygfsteel.com/GavinMiao/comments/commentRss/365484.htmlhttp://www.aygfsteel.com/GavinMiao/services/trackbacks/365484.html™å¹ç›®ä¸Šå³å‡»é¼ æ ?->Properties-->MyEclipse-->Web-->Content Root-->Web content-root-->æ”ÒŽˆä½ æƒ³è¦çš„™å¹ç›®å?卛_¯

GavinMiao 2011-12-03 23:37 发表评论
]]>
转蝲åQštomcat各种配置及编码设¾|?/title><link>http://www.aygfsteel.com/GavinMiao/archive/2011/12/01/365266.html</link><dc:creator>GavinMiao</dc:creator><author>GavinMiao</author><pubDate>Thu, 01 Dec 2011 02:49:00 GMT</pubDate><guid>http://www.aygfsteel.com/GavinMiao/archive/2011/12/01/365266.html</guid><wfw:comment>http://www.aygfsteel.com/GavinMiao/comments/365266.html</wfw:comment><comments>http://www.aygfsteel.com/GavinMiao/archive/2011/12/01/365266.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/GavinMiao/comments/commentRss/365266.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/GavinMiao/services/trackbacks/365266.html</trackback:ping><description><![CDATA[    åªæœ‰æ³¨å†Œç”¨æˆ·ç™Õd½•后才能阅读该文ã€?a href='http://www.aygfsteel.com/GavinMiao/archive/2011/12/01/365266.html'>阅读全文</a><img src ="http://www.aygfsteel.com/GavinMiao/aggbug/365266.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/GavinMiao/" target="_blank">GavinMiao</a> 2011-12-01 10:49 <a href="http://www.aygfsteel.com/GavinMiao/archive/2011/12/01/365266.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>XP 用命令查看和杀死进½E?/title><link>http://www.aygfsteel.com/GavinMiao/archive/2011/11/28/364996.html</link><dc:creator>GavinMiao</dc:creator><author>GavinMiao</author><pubDate>Mon, 28 Nov 2011 07:28:00 GMT</pubDate><guid>http://www.aygfsteel.com/GavinMiao/archive/2011/11/28/364996.html</guid><wfw:comment>http://www.aygfsteel.com/GavinMiao/comments/364996.html</wfw:comment><comments>http://www.aygfsteel.com/GavinMiao/archive/2011/11/28/364996.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/GavinMiao/comments/commentRss/364996.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/GavinMiao/services/trackbacks/364996.html</trackback:ping><description><![CDATA[<span id="wmqeeuq" class="Apple-style-span" style="font-family: 宋体, Arial; background-color: #fffcf3; ">1åQšæŸ¥çœ?080端口占用情况åQ?br />C:\Documents and Settings\Administrator>netstat -aon | findstr "8080"<br />  TCP    0.0.0.0:<strong><font color="#008000" style="line-height: 1.5; ">8080</font></strong>           0.0.0.0:0              LISTENING       <font color="#F00000" style="line-height: 1.5; "><strong>3608<br /><br /></strong></font></span>2<span id="wmqeeuq" class="Apple-style-span" style="font-family: 宋体, Arial; background-color: #fffcf3; ">åQšæŸ¥çœ‹è¿›½E?br /><br />C:\Documents and Settings\Administrator>tasklist | findstr "3608"<br /><font color="#0000F0" style="line-height: 1.5; "><strong>javaw.exe</strong></font>                   3608 Console                 0     69,484 K<br /><br />3.杀˜q›ç¨‹åQ?br /><div>tskill 3608</div></span><img src ="http://www.aygfsteel.com/GavinMiao/aggbug/364996.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/GavinMiao/" target="_blank">GavinMiao</a> 2011-11-28 15:28 <a href="http://www.aygfsteel.com/GavinMiao/archive/2011/11/28/364996.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>MyEclipse + Tomcat™å¹ç›®é‡å‘½å?/title><link>http://www.aygfsteel.com/GavinMiao/archive/2011/11/15/363844.html</link><dc:creator>GavinMiao</dc:creator><author>GavinMiao</author><pubDate>Tue, 15 Nov 2011 07:09:00 GMT</pubDate><guid>http://www.aygfsteel.com/GavinMiao/archive/2011/11/15/363844.html</guid><wfw:comment>http://www.aygfsteel.com/GavinMiao/comments/363844.html</wfw:comment><comments>http://www.aygfsteel.com/GavinMiao/archive/2011/11/15/363844.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/GavinMiao/comments/commentRss/363844.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/GavinMiao/services/trackbacks/363844.html</trackback:ping><description><![CDATA[<span style="color: #2e2e2e; font-family: 宋体; font-size: 15px; line-height: 24px; background-color: #f2f9ff; ">文章来源åQ?br />问题描述åQ?br />原来™å¹ç›®åç§°æ˜¯shoppingåQŒéƒ¨¾|²åˆ°tomcat后直接输入地址端口后加™å¹ç›®åhttp://localhost:8080/shoppingž®±å¯ä»¥æµè§ˆä¸»™åµäº†åQŒåŽæ¥æˆ‘把项目名æ”ÒŽˆshoppingCaråQŒé‡æ–°éƒ¨¾|²åˆ°tomcat后发现部¾|²è¿‡åŽÈš„™å¹ç›®˜q˜æ˜¯shopping而不是shoppingCar<br />解决æ–ÒŽ¡ˆåQ?br />在MyEclipse里面只把™å¹ç›®é‡å‘½åæ˜¯ä¸è¡Œçš„,˜q˜è¦ä¿®æ”¹ä»¥ä¸‹å†…容åQ?br />™å¹ç›®→properties→MyEclipse→Web下修改Web Context-rootçš„åå­—äØ“é‡å‘½åä¹‹åŽçš„åå­—å›_¯ã€?/span><img src ="http://www.aygfsteel.com/GavinMiao/aggbug/363844.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/GavinMiao/" target="_blank">GavinMiao</a> 2011-11-15 15:09 <a href="http://www.aygfsteel.com/GavinMiao/archive/2011/11/15/363844.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>转蝲åQšåœ¨™å¹ç›®ä¸­ä‹É用多个数据源åQå¤šsessionFactoryæ–ÒŽ¡ˆhttp://www.aygfsteel.com/GavinMiao/archive/2011/11/14/363689.htmlGavinMiaoGavinMiaoMon, 14 Nov 2011 08:11:00 GMThttp://www.aygfsteel.com/GavinMiao/archive/2011/11/14/363689.htmlhttp://www.aygfsteel.com/GavinMiao/comments/363689.htmlhttp://www.aygfsteel.com/GavinMiao/archive/2011/11/14/363689.html#Feedback0http://www.aygfsteel.com/GavinMiao/comments/commentRss/363689.htmlhttp://www.aygfsteel.com/GavinMiao/services/trackbacks/363689.html

适用范围åQšé€‚合SSH架构讉K—®å¤šä¸ªæ•°æ®åº“,数据库的¾cÕdž‹å’Œè¡¨¾l“构不必相同åQŒä¸”没有跨库事务的情况(跨库事务最好用分布式事务处理)ã€?/p>

文章来源åQ?a >http://apps.hi.baidu.com/share/detail/15756344

实现方式åQ?font color="#ff0000">我们可以在spring的配¾|®æ–‡ä»¶ä¸­é…ç½®å¤šä¸ªsessionFactory,如:
<bean id="aDataSource"
   class="org.apache.commons.dbcp.BasicDataSource"
   destroy-method="close">
   <property name="driverClassName">
    <value>${adriver}</value>
   </property>
   <property name="url">
    <value>${aurl}</value>
   </property>
   <property name="username">
    <value>${ausername}</value>
   </property>
   <property name="password">
    <value>${apassword}</value>
   </property>
</bean>
<bean id="bDataSource"
   class="org.apache.commons.dbcp.BasicDataSource"
   destroy-method="close">
   <property name="driverClassName">
    <value>${bdriver}</value>
   </property>
   <property name="url">
    <value>${burl}</value>
   </property>
   <property name="username">
    <value>${busername}</value>
   </property>
   <property name="password">
    <value>${bpassword}</value>
   </property>
</bean>
<bean id="cDataSource"
   class="org.apache.commons.dbcp.BasicDataSource"
   destroy-method="close">
   <property name="driverClassName">
    <value>${cdriver}</value>
   </property>
   <property name="url">
    <value>${curl}</value>
   </property>
   <property name="username">
    <value>${cusername}</value>
   </property>
   <property name="password">
    <value>${cpassword}</value>
   </property>
</bean>

 

<!-- Hibernate SessionFactorys -->
<bean id="aSessionFactory"
   class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
   <property name="dataSource">
    <ref local="aDataSource" />
   </property>
   <property name="mappingResources">
    <list>
     <value>
      .hbm.xmlæ–‡äšg
     </value>
    </list>
   </property>
   <property name="hibernateProperties">
    <props>
     <prop key="hibernate.dialect">
      ${ahibernate.dialect}
     </prop>
     <prop key="hibernate.show_sql">true</prop>
     <prop key="format_sql">true</prop>
    </props>
   </property>
</bean>

<bean id="bSessionFactory"
   class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
   <property name="dataSource">
    <ref local="bDataSource" />
   </property>
   <property name="mappingResources">
    <list>
     <value>
      .hbm.xmlæ–‡äšg
     </value>
    </list>
   </property>
   <property name="hibernateProperties">
    <props>
     <prop key="hibernate.dialect">
      ${bhibernate.dialect}
     </prop>
     <prop key="hibernate.show_sql">true</prop>
     <prop key="format_sql">true</prop>
    </props>
   </property>
</bean>

<bean id="cSessionFactory"
   class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
   <property name="dataSource">
    <ref local="cDataSource" />
   </property>
   <property name="mappingResources">
    <list>
     <value>
       .hbm.xmlæ–‡äšg
     </value>
    </list>
   </property>
   <property name="hibernateProperties">
    <props>
     <prop key="hibernate.dialect">
      ${chibernate.dialect}
     </prop>
     <prop key="hibernate.show_sql">true</prop>
     <prop key="format_sql">true</prop>
    </props>
   </property>
</bean>

<bean id="sessionFactory" class="com.cintel.dcp.datasource.MultiSessionFactory">
   <property name="sessionFactory"><ref local="aSessionFactory"/></property>
</bean>
注意åQ?font color="#ff0000">最后一ä¸?font color="#0000ff">com.cintel.dcp.datasource.MultiSessionFactory要自己实玎ͼŒå®ƒå®žçŽîCº†SessionFactory接口和ApplicationContext接口åQŒå¦‚下:
package com.cintel.dcp.datasource;

import java.io.Serializable;
import java.sql.Connection;
import java.util.Map;
import java.util.Set;

import javax.naming.NamingException;
import javax.naming.Reference;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.HibernateException;
import org.hibernate.Interceptor;
import org.hibernate.SessionFactory;
import org.hibernate.StatelessSession;
import org.hibernate.classic.Session;
import org.hibernate.engine.FilterDefinition;
import org.hibernate.metadata.ClassMetadata;
import org.hibernate.metadata.CollectionMetadata;
import org.hibernate.stat.Statistics;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

public class MultiSessionFactory implements SessionFactory, ApplicationContextAware {
private static final long serialVersionUID = 2064557324203496378L;
private static final Log log = LogFactory.getLog(MultiSessionFactory.class);
private ApplicationContext applicationContext = null;
private SessionFactory sessionFactory = null;

public ApplicationContext getApplicationContext() {
   return applicationContext;
}

public void setApplicationContext(ApplicationContext applicationContext) {
   this.applicationContext = applicationContext;
}

public SessionFactory getSessionFactory(String sessionFactoryName) {
   log.debug("sessionFactoryName:"+sessionFactoryName);
   try{
    if(sessionFactoryName==null||sessionFactoryName.equals("")){
     return sessionFactory;
    }
    return (SessionFactory)this.getApplicationContext().getBean(sessionFactoryName);
   }catch(NoSuchBeanDefinitionException ex){
    throw new RuntimeException("There is not the sessionFactory <name:"+sessionFactoryName+"> in the applicationContext!");
   }
}

public SessionFactory getSessionFactory() {
   String sessionFactoryName = CustomerContextHolder.getCustomerType();
   return getSessionFactory(sessionFactoryName);
}

public void setSessionFactory(SessionFactory sessionFactory) {
   this.sessionFactory = sessionFactory;
}


/* (non-Javadoc)
* @see org.hibernate.SessionFactory#close()
*/
public void close() throws HibernateException {
   getSessionFactory().close();
}
/* (non-Javadoc)
* @see org.hibernate.SessionFactory#evict(java.lang.Class)
*/
public void evict(Class persistentClass) throws HibernateException {
   getSessionFactory().evict(persistentClass);
}
/* (non-Javadoc)
* @see org.hibernate.SessionFactory#evict(java.lang.Class, java.io.Serializable)
*/
public void evict(Class persistentClass, Serializable id) throws HibernateException {
   getSessionFactory().evict(persistentClass, id);
}
/* (non-Javadoc)
* @see org.hibernate.SessionFactory#evictCollection(java.lang.String)
*/
public void evictCollection(String roleName) throws HibernateException {
   getSessionFactory().evictCollection(roleName);
}
/* (non-Javadoc)
* @see org.hibernate.SessionFactory#evictCollection(java.lang.String, java.io.Serializable)
*/
public void evictCollection(String roleName, Serializable id) throws HibernateException {
   getSessionFactory().evictCollection(roleName, id);
}
/* (non-Javadoc)
* @see org.hibernate.SessionFactory#evictEntity(java.lang.String)
*/
public void evictEntity(String entityName) throws HibernateException {
   getSessionFactory().evictEntity(entityName);
}
/* (non-Javadoc)
* @see org.hibernate.SessionFactory#evictEntity(java.lang.String, java.io.Serializable)
*/
public void evictEntity(String entityName, Serializable id) throws HibernateException {
   getSessionFactory().evictEntity(entityName, id);
}
/* (non-Javadoc)
* @see org.hibernate.SessionFactory#evictQueries()
*/
public void evictQueries() throws HibernateException {
   getSessionFactory().evictQueries();
}
/* (non-Javadoc)
* @see org.hibernate.SessionFactory#evictQueries(java.lang.String)
*/
public void evictQueries(String cacheRegion) throws HibernateException {
   getSessionFactory().evictQueries(cacheRegion);
}
/* (non-Javadoc)
* @see org.hibernate.SessionFactory#getAllClassMetadata()
*/
public Map getAllClassMetadata() throws HibernateException {
   return getSessionFactory().getAllClassMetadata();
}
/* (non-Javadoc)
* @see org.hibernate.SessionFactory#getAllCollectionMetadata()
*/
public Map getAllCollectionMetadata() throws HibernateException {
   return getSessionFactory().getAllCollectionMetadata();
}
/* (non-Javadoc)
* @see org.hibernate.SessionFactory#getClassMetadata(java.lang.Class)
*/
public ClassMetadata getClassMetadata(Class persistentClass) throws HibernateException {
   return getSessionFactory().getClassMetadata(persistentClass);
}
/* (non-Javadoc)
* @see org.hibernate.SessionFactory#getClassMetadata(java.lang.String)
*/
public ClassMetadata getClassMetadata(String entityName) throws HibernateException {
   return getSessionFactory().getClassMetadata(entityName);
}
/* (non-Javadoc)
* @see org.hibernate.SessionFactory#getCollectionMetadata(java.lang.String)
*/
public CollectionMetadata getCollectionMetadata(String roleName) throws HibernateException {
   return getSessionFactory().getCollectionMetadata(roleName);
}
/* (non-Javadoc)
* @see org.hibernate.SessionFactory#getCurrentSession()
*/
public Session getCurrentSession() throws HibernateException {
   return getSessionFactory().getCurrentSession();
}
/* (non-Javadoc)
* @see org.hibernate.SessionFactory#getDefinedFilterNames()
*/
public Set getDefinedFilterNames() {
   return getSessionFactory().getDefinedFilterNames();
}
/* (non-Javadoc)
* @see org.hibernate.SessionFactory#getFilterDefinition(java.lang.String)
*/
public FilterDefinition getFilterDefinition(String filterName) throws HibernateException {
   return getSessionFactory().getFilterDefinition(filterName);
}
/* (non-Javadoc)
* @see org.hibernate.SessionFactory#getStatistics()
*/
public Statistics getStatistics() {
   return getSessionFactory().getStatistics();
}
/* (non-Javadoc)
* @see org.hibernate.SessionFactory#isClosed()
*/
public boolean isClosed() {
   return getSessionFactory().isClosed();
}
/* (non-Javadoc)
* @see org.hibernate.SessionFactory#openSession()
*/
public Session openSession() throws HibernateException {
   return getSessionFactory().openSession();
}
/* (non-Javadoc)
* @see org.hibernate.SessionFactory#openSession(java.sql.Connection)
*/
public Session openSession(Connection connection) {
   return getSessionFactory().openSession(connection);
}
/* (non-Javadoc)
* @see org.hibernate.SessionFactory#openSession(org.hibernate.Interceptor)
*/
public Session openSession(Interceptor interceptor) throws HibernateException {
   return getSessionFactory().openSession(interceptor);
}
/* (non-Javadoc)
* @see org.hibernate.SessionFactory#openSession(java.sql.Connection, org.hibernate.Interceptor)
*/
public Session openSession(Connection connection, Interceptor interceptor) {
   return getSessionFactory().openSession(connection, interceptor);
}
/* (non-Javadoc)
* @see org.hibernate.SessionFactory#openStatelessSession()
*/
public StatelessSession openStatelessSession() {
   return getSessionFactory().openStatelessSession();
}
/* (non-Javadoc)
* @see org.hibernate.SessionFactory#openStatelessSession(java.sql.Connection)
*/
public StatelessSession openStatelessSession(Connection connection) {
   return getSessionFactory().openStatelessSession(connection);
}
/* (non-Javadoc)
* @see javax.naming.Referenceable#getReference()
*/
public Reference getReference() throws NamingException {
   return getSessionFactory().getReference();
}
}


然后我用一个常量类来标识sessionFactory
public class DynamicDataSourceType {
public static final String A= "aSessionFactory";
public static final String B= "bSessionFactory";
public static final String C= "cSessionFactory";
}

最后一个关键类åQšç”¨æ¥å­˜æ”‘Ö½“前正在ä‹É用的sessionFactory
public class CustomerContextHolder {

private static final ThreadLocal contextHolder = new ThreadLocal();

public static void setCustomerType(String customerType) {
   Assert.notNull(customerType, "customerType cannot be null");
   contextHolder.set(customerType);
}

public static String getCustomerType() {
   return (String) contextHolder.get();
}

public static void clearCustomerType() {
   contextHolder.remove();
}
}

可以在action、service、dao中进行数据库切换åQŒåˆ‡æ¢æ–¹å¼ï¼š
CustomerContextHolder.setCustomerType(DynamicDataSourceType.A);

以上思èµ\来自javaEye论坛的一个高手,在此标识感谢



GavinMiao 2011-11-14 16:11 发表评论
]]>
转蝲åQšåŠ¨æ€åˆ‡æ¢æ•°æ®æº(spring+hibernate)http://www.aygfsteel.com/GavinMiao/archive/2011/11/14/363685.htmlGavinMiaoGavinMiaoMon, 14 Nov 2011 07:37:00 GMThttp://www.aygfsteel.com/GavinMiao/archive/2011/11/14/363685.htmlhttp://www.aygfsteel.com/GavinMiao/comments/363685.htmlhttp://www.aygfsteel.com/GavinMiao/archive/2011/11/14/363685.html#Feedback0http://www.aygfsteel.com/GavinMiao/comments/commentRss/363685.htmlhttp://www.aygfsteel.com/GavinMiao/services/trackbacks/363685.html

文章来源åQ?/strong>

èµ·å› åQšåœ¨å½“前我手上的一个项目中需要多个数据源,òq¶ä¸”来自于不同类型的数据åº?.. å› äØ“å¾ˆå¤šåŽ†å²åŽŸå› .˜q™ä¸ª™å¹ç›®çš„住数据源是MySQL,整个¾pȝ»Ÿçš„CURD都是操作的这个数据库.

但是˜q˜æœ‰å¦å¤–两个用于数据采集的数据库: MSSQL,ACCESS.˜q˜å¥½åªæ˜¯ç”¨äºŽæ•°æ®é‡‡é›†åQŒåœ¨äº‹åŠ¡ä¸Šå¯ä»¥ä¸è¦è·¨æ•°æ®åº“äº†åQŒè¿™ä¸€ç‚¹èŠ‚çœäº†å¥½å¤šçš„å·¥ä½œé‡.环境åQšæˆ‘æ­å¾çš„æµ‹è¯•çŽ¯å¢ƒæ˜¯ spring2.5.6+hibernate3.2
思èµ\åQšåŠ¨æ€åˆ‡æ¢æ•°æ®æº¼‹®åˆ‡çš„æ¥è¯´æ˜¯åœ¨åŒä¸€¾cÕdž‹æ•°æ®åº“的情况下的。意思就是说 , 在系¾lŸä¸­çš„ä‹É用的数据库分布在多台数据库服务器或者在同台服务器上的多个数据库. 在运行时期间æ ÒŽ®æŸç§æ ‡è¯†½W¦æ¥åŠ¨æ€çš„é€‰æ‹©å½“å‰æ“ä½œçš„æ•°æ®åº“.     1.数据源是相同¾cÕdž‹çš„æ•°æ®åº“: 一个SessionFactory+动态数据源+一个事务管理器     2.数据源是不同¾cÕdž‹çš„æ•°æ®åº“: æ ÒŽ®¾cÕdž‹ 配置多套SessionFactory模拟åQšä¸¤ä¸ªmysql数据æº?一个Access数据æº?/span>
实现åQ?/span>
1.切换数据源需要标识符,标识½W¦æ˜¯Object¾cÕdž‹
package lhp.example.context;
public enum DBType {
dataSource1, dataSource2;
}

2.然后创徏一个用于切换数据源(讄¡½®æˆ–者获得上下文)的工å…ïL±»
package lhp.example.context;

public class ContextHolder {
private static final ThreadLocal<Object> holder = new ThreadLocal<Object>();

public static void setDbType(DBType dbType) {
holder.set(dbType);
}

public static DBType getDbType() {
return (DBType) holder.get();
}

public static void clearDbType() {
holder.remove();
}
}

3.创徏动态数据源¾c?¾l§æ‰¿org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource˜q™ä¸ª¾c?
package lhp.example.context;

import java.util.logging.Logger;

import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;

public class DynamicDataSource extends AbstractRoutingDataSource {
public static final Logger logger = Logger.getLogger(DynamicDataSource.class.toString());

@Override
protected Object determineCurrentLookupKey() {
DBType key = ContextHolder.getDbType();//获得当前数据源标识符
//logger.info("当前数据�:" + key);
return key;
}

}

4.然后配置多个数据�/span>
<!-- 数据æº? åQ?mysql -->
<bean id="dataSource1" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="com.mysql.jdbc.Driver" />
<property name="jdbcUrl" value="jdbc:mysql://127.0.0.1:3306/dec" />
<property name="user" value="root" />
<property name="password" value="" />
</bean>
<!-- 数据æº? åQ?mysql -->
<bean id="dataSource2" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="com.mysql.jdbc.Driver" />
<property name="jdbcUrl" value="jdbc:mysql://127.0.0.1:3306/lms" />
<property name="user" value="root" />
<property name="password" value="" />
</bean>

<!-- 数据æº? åQ? access -->
<bean id="dataSource3" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="sun.jdbc.odbc.JdbcOdbcDriver" />
<property name="jdbcUrl" value="jdbc:odbc:accessTest" />
<property name="user" value="administrator" />
<property name="password" value="XLZX0309" />
</bean>

<!-- mysql 动态数据源讄¡½®-->
<bean id="mysqlDynamicDataSource" class="lhp.example.context.DynamicDataSource">
<property name="targetDataSources">
<!-- 标识½W¦ç±»åž?-->
<map key-type="lhp.example.context.DBType">
<entry key="dataSource1" value-ref="dataSource1" />
<entry key="dataSource2" value-ref="dataSource2" />
</map>
</property>
<property name="defaultTargetDataSource" ref="dataSource1" />
</bean>

5.配置sessionFactory
<!-- mysql sessionFactory -->
<bean id="mysqlSessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="mysqlDynamicDataSource" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop><!--create validate -->
<prop key="hibernate.query.substitutions">true 1, false 0</prop>
</props>
</property>
</bean>

<!-- access sessionFactory -->
<bean id="aceessSessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource3" />
<property name="hibernateProperties">
<props>
<!-- access 语法和MSSQLç›æ€¼¼ 所以用的MSSQL方言åQŒæˆ–者可以ä‹É用第三方方言 -->
<prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop>
<prop key="hibernate.jdbc.batch_size">30</prop>
<prop key="hibernate.jdbc.fetch_size">50</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">false</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop><!--create validate -->
<prop key="hibernate.query.substitutions">true 1, false 0</prop>
<prop key="hibernate.cglib.use_reflection_optimizer">true</prop>
<!-- <prop key="hibernate.cache.use_second_level_cache">true</prop> -->
<!-- <prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop> -->
<!-- <prop key="hibernate.cache.use_query_cache">true</prop> -->
<!-- <prop key="hibernate.generate_statistics">true</prop> -->
<!-- <prop key="hibernate.cache.provider_configuration_file_resource_path">classpath:ehcache.xml</prop> -->
</props>
</property>
</bean>

6.‹¹‹è¯•用例
package lhp.example.junit;

import static org.junit.Assert.*;
import java.sql.DatabaseMetaData;
import lhp.example.context.ContextHolder;
import lhp.example.context.DBType;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.junit.Before;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class ServiceTest {
private ApplicationContext context;
//三个数据源的URL
private String dataSource1_URL = "jdbc:mysql://127.0.0.1:3306/dec";
private String dataSource2_URL = "jdbc:mysql://127.0.0.1:3306/lms";
private String dataSource3_URL = "jdbc:odbc:accessTest";
private SessionFactory mysqlSessionFactory;
private SessionFactory aceessSessionFactory;

@Before
public void setUp() throws Exception {
// 选择数据源初始化spring
ContextHolder.setDbType(DBType.dataSource1);
//
String[] xmlFiles = new String[] {
"applicationContext-dataSource.xml",
"applicationContext-hibernate.xml",
"applicationContext-spring.xml" };
//
context = new ClassPathXmlApplicationContext(xmlFiles);
//
mysqlSessionFactory = (SessionFactory) context.getBean("mysqlSessionFactory");
aceessSessionFactory = (SessionFactory) context.getBean("aceessSessionFactory");
}

@SuppressWarnings("deprecation")
@Test
public void mysqlDataSourceTest() {
try {

Session mysqlSession = mysqlSessionFactory.openSession();
// 获得数据库元数据
DatabaseMetaData meatData = mysqlSession.connection().getMetaData();

// 默认启动数据�dataSource1
//断言当前数据源URL是否是dataSource1的URL
assertEquals(dataSource1_URL, meatData.getURL());

// 切换到数据源 dataSource2
ContextHolder.setDbType(DBType.dataSource2);
mysqlSession = mysqlSessionFactory.openSession();
meatData = mysqlSession.connection().getMetaData();
//断言当前数据源URL是否是dataSource2的URL
assertEquals(dataSource2_URL, meatData.getURL());

} catch (Exception e) {
e.printStackTrace();
}
}

@SuppressWarnings("deprecation")
@Test
public void accessDataSourceTest() {
try {
Session accessSession = aceessSessionFactory.openSession();
// 获得数据库元数据
DatabaseMetaData meatData = accessSession.connection().getMetaData();
//断言当前数据源URL是否是dataSource3的URL
assertEquals(dataSource3_URL, meatData.getURL());


} catch (Exception e) {
e.printStackTrace();
}
}

}


]]>
tomcat 调内å­?/title><link>http://www.aygfsteel.com/GavinMiao/archive/2011/10/26/362065.html</link><dc:creator>GavinMiao</dc:creator><author>GavinMiao</author><pubDate>Wed, 26 Oct 2011 01:51:00 GMT</pubDate><guid>http://www.aygfsteel.com/GavinMiao/archive/2011/10/26/362065.html</guid><wfw:comment>http://www.aygfsteel.com/GavinMiao/comments/362065.html</wfw:comment><comments>http://www.aygfsteel.com/GavinMiao/archive/2011/10/26/362065.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/GavinMiao/comments/commentRss/362065.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/GavinMiao/services/trackbacks/362065.html</trackback:ping><description><![CDATA[<div>一、java.lang.OutOfMemoryError: PermGen space 错误解决办法åQ?br /><div><div>修改TOMCAT_HOME/bin/catalina.sh </div><div>åœ?#8220;echo "Using CATALINA_BASE: $CATALINA_BASE"”上面加入以下行: </div><div>JAVA_OPTS="-server -XX:PermSize=64M -XX:MaxPermSize=128m <br />二、java.lang.OutOfMemoryError: Java heap space 错误解决办法åQ?br /><div><div>解决æ–ÒŽ³•åQšæ‰‹åŠ¨è®¾¾|®Heap size </div><div>修改TOMCAT_HOME/bin/catalina.sh </div><div>åœ?#8220;echo "Using CATALINA_BASE: $CATALINA_BASE"”上面加入以下行: </div><div>JAVA_OPTS="-server -Xms800m -Xmx800m -XX:MaxNewSize=256m"<br /><br /><div>注意åQšHeap Size 最大不要超˜q‡å¯ç”¨ç‰©ç†å†…存的80åQ…,一般的要将-Xmså’?Xmx选项讄¡½®ä¸ºç›¸åŒï¼Œè€?Xmnä¸?/4çš?Xmx倹{€?nbsp;</div></div></div></div></div></div><img src ="http://www.aygfsteel.com/GavinMiao/aggbug/362065.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/GavinMiao/" target="_blank">GavinMiao</a> 2011-10-26 09:51 <a href="http://www.aygfsteel.com/GavinMiao/archive/2011/10/26/362065.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>用命令打开windows常用软äšghttp://www.aygfsteel.com/GavinMiao/archive/2011/09/28/359656.htmlGavinMiaoGavinMiaoWed, 28 Sep 2011 01:40:00 GMThttp://www.aygfsteel.com/GavinMiao/archive/2011/09/28/359656.htmlhttp://www.aygfsteel.com/GavinMiao/comments/359656.htmlhttp://www.aygfsteel.com/GavinMiao/archive/2011/09/28/359656.html#Feedback0http://www.aygfsteel.com/GavinMiao/comments/commentRss/359656.htmlhttp://www.aygfsteel.com/GavinMiao/services/trackbacks/359656.htmlmspaint ç”Õd›¾æ?nbsp;
mstsc ˜qœç¨‹æ¡Œé¢˜qžæŽ¥
notepad 打开è®îCº‹æœ?/span>
winmsd.exe 查看¾pȝ»Ÿä¿¡æ¯
Sndvol32 音量控制½E‹åº
diskmgmt.msc ¼‚ç›˜½Ž¡ç†å™?br />cleanmgr 垃圾整理
conf 启动netmeeting聊天工具
cleanmgr.exe ¼‚ç›˜æ¸…理 
calc.exe 计算�br />regedt32 注册表编辑器



]]>
电脑使用技巧:windows自带定时å…Ïxœºhttp://www.aygfsteel.com/GavinMiao/archive/2011/09/28/359654.htmlGavinMiaoGavinMiaoWed, 28 Sep 2011 01:16:00 GMThttp://www.aygfsteel.com/GavinMiao/archive/2011/09/28/359654.htmlhttp://www.aygfsteel.com/GavinMiao/comments/359654.htmlhttp://www.aygfsteel.com/GavinMiao/archive/2011/09/28/359654.html#Feedback0http://www.aygfsteel.com/GavinMiao/comments/commentRss/359654.htmlhttp://www.aygfsteel.com/GavinMiao/services/trackbacks/359654.html转蝲åQ?a >http://bbs.yhcgo.com/read.php?tid-77128.html

1.Windows XPçš?a target="_blank" id="url_2" style="outline-style: none; outline-width: initial; outline-color: initial; text-decoration: none; color: #0070af; ">定时å…Ïxœºå‘½ä×o是由Shutdown.exe½E‹åºæ¥æŽ§åˆ¶çš„åQŒä½äºŽWindows\System32æ–‡äšg夹中ã€?br />如果惌™®©Windows 2000也实现同æ ïLš„æ•ˆæžœåQŒå¯ä»¥æŠŠShutdown.exe复制åˆ?span id="rlt_2" style="outline-style: none; outline-width: initial; outline-color: initial; cursor: pointer; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #fa891b; ">¾pȝ»Ÿç›®å½•下ã€?/span>
¾pȝ»Ÿæ ¹ç›®å½•:C:\windows\下;
2.winows+r打开“˜qè¡Œ”输入框,然后输入以下命ä×oåQ?br />at 22:00 Shutdown -s           --->无倒计时框åQŒåˆ°
22:00ç‚ÒŽ½Cºå…³æœ?/span>
shutdown.exe -s -t 3600 -->60分钟后,�div style="display: inline-block; ">
倒计时的方式å…Ïxœº
Shutdown åQs åQt 1320 -->
指定¾pȝ»Ÿåœ?2分钟后自动关é—?/span>
3.
如果惛_–消的话,可以在运行中输入“shutdown -a”。另外输å…?#8220;shutdown -i”åQŒåˆ™å¯ä»¥æ‰“开讄¡½®è‡ªåЍå…Ïxœºå¯¹è¯æ¡†ï¼Œå¯¹è‡ªåŠ¨å…³æœø™¿›è¡Œè®¾¾|®ã€?nbsp;
4.
Shutdown.exe的参�
-råQšå…³æœºåƈ重启
-t æ—‰™—´åQšè®¾¾|®å…³æœºå€’计æ—?br />“-s”ž®Þp¡¨½Cºå…³é—­æœ¬åœ°è®¡½Ž—机
“-a”表示取消å…Ïxœºæ“ä½œ
-iåQšæ˜¾½Cºå›¾å½¢ç”¨æˆïL•Œé¢ï¼Œä½†å¿…™åÀL˜¯Shutdown的第一个选项


]]>
birt初认è¯?/title><link>http://www.aygfsteel.com/GavinMiao/archive/2011/09/22/359209.html</link><dc:creator>GavinMiao</dc:creator><author>GavinMiao</author><pubDate>Wed, 21 Sep 2011 16:01:00 GMT</pubDate><guid>http://www.aygfsteel.com/GavinMiao/archive/2011/09/22/359209.html</guid><wfw:comment>http://www.aygfsteel.com/GavinMiao/comments/359209.html</wfw:comment><comments>http://www.aygfsteel.com/GavinMiao/archive/2011/09/22/359209.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/GavinMiao/comments/commentRss/359209.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/GavinMiao/services/trackbacks/359209.html</trackback:ping><description><![CDATA[官网åQ?a >http://www.eclipse.org/birt/phoenix/</a> <br />1.<div style="display: inline-block; "></div><span id="wmqeeuq" class="Apple-style-span" style="font-family: Arial, sans-serif; font-size: 12px; line-height: 16px; background-color: #ffffff; ">BIRT是一个基于Eclipse的开源Web应用½E‹åº <br />2.主要用在åŸÞZºŽJavaå’ŒJ2EEçš„web应用½E‹åºä¸Šï¼›<br />3.使用birt可以实现åQšåˆ—è¡¨ã€å›¾æ ‡ã€æØœåˆæŠ¥è¡¨ã€äº¤å‰è¡¨åQˆäºŒ¾l´è¡¨åQ‰ï¼›<br />4.安装åQ?br /><div style="display: inline-block; "><div>本äh用的时MyEclipse6.6åQŒå¯¹åº”çš„Eclipse3.3.åQ?/div></div></span><span id="wmqeeuq" class="Apple-style-span" style="color: #333333; font-family: Arial; line-height: 26px; background-color: #ffffff; ">    <br />如果使用的是eclipse3.3版本åQŒä½ åº”该用birt-report-framework-2_2_0.zipåQ?br />地址åQšhttp://archive.eclipse.org/birt/downloads/build.php?build=R-R1-2_2_0-200706261010/birt-report-framework-2_2_0.zip <br /> <div style="display: inline-block; "><div><a >http://archive.eclipse.org/birt/downloads/build.php?build=R-R1-2_2_0-200706261010/birt-runtime-2_2_0.zip</a></div></div><br />如果使用的是eclipse3.4åQŒä½ åº”该用birt-report-framework-2_3_0.zipã€?br />5.参考文章地址åQ?br /><div><a >http://www.docin.com/p-177563530.html</a></div><div><a >http://wenku.baidu.com/view/e9414713a216147917112885.html <br /></a><div><a >http://wenku.baidu.com/view/8f996c553c1ec5da50e27093.html<br /></a><div><a href="http://www.aygfsteel.com/amigoxie/archive/2009/05/03/268684.html">http://www.aygfsteel.com/amigoxie/archive/2009/05/03/268684.html</a></div><a ><a ></a></a></div><a ></a></div></span><img src ="http://www.aygfsteel.com/GavinMiao/aggbug/359209.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/GavinMiao/" target="_blank">GavinMiao</a> 2011-09-22 00:01 <a href="http://www.aygfsteel.com/GavinMiao/archive/2011/09/22/359209.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>select count(*)æ—Óž¼ŒæŠ¥é”™java.lang.ClassCastException: java.lang.Longhttp://www.aygfsteel.com/GavinMiao/archive/2011/09/15/358708.htmlGavinMiaoGavinMiaoThu, 15 Sep 2011 07:12:00 GMThttp://www.aygfsteel.com/GavinMiao/archive/2011/09/15/358708.htmlhttp://www.aygfsteel.com/GavinMiao/comments/358708.htmlhttp://www.aygfsteel.com/GavinMiao/archive/2011/09/15/358708.html#Feedback0http://www.aygfsteel.com/GavinMiao/comments/commentRss/358708.htmlhttp://www.aygfsteel.com/GavinMiao/services/trackbacks/358708.html阅读全文

]]>
各数据库数据¾cÕdž‹æ¯”较http://www.aygfsteel.com/GavinMiao/archive/2011/09/06/358081.htmlGavinMiaoGavinMiaoTue, 06 Sep 2011 05:01:00 GMThttp://www.aygfsteel.com/GavinMiao/archive/2011/09/06/358081.htmlhttp://www.aygfsteel.com/GavinMiao/comments/358081.htmlhttp://www.aygfsteel.com/GavinMiao/archive/2011/09/06/358081.html#Feedback0http://www.aygfsteel.com/GavinMiao/comments/commentRss/358081.htmlhttp://www.aygfsteel.com/GavinMiao/services/trackbacks/358081.html

]]>
UE讄¡½®java环境http://www.aygfsteel.com/GavinMiao/archive/2011/09/05/358008.htmlGavinMiaoGavinMiaoMon, 05 Sep 2011 09:29:00 GMThttp://www.aygfsteel.com/GavinMiao/archive/2011/09/05/358008.htmlhttp://www.aygfsteel.com/GavinMiao/comments/358008.htmlhttp://www.aygfsteel.com/GavinMiao/archive/2011/09/05/358008.html#Feedback0http://www.aygfsteel.com/GavinMiao/comments/commentRss/358008.htmlhttp://www.aygfsteel.com/GavinMiao/services/trackbacks/358008.html阅读全文

]]>
ssh与设计模å¼?/title><link>http://www.aygfsteel.com/GavinMiao/archive/2011/08/29/357477.html</link><dc:creator>GavinMiao</dc:creator><author>GavinMiao</author><pubDate>Mon, 29 Aug 2011 02:42:00 GMT</pubDate><guid>http://www.aygfsteel.com/GavinMiao/archive/2011/08/29/357477.html</guid><wfw:comment>http://www.aygfsteel.com/GavinMiao/comments/357477.html</wfw:comment><comments>http://www.aygfsteel.com/GavinMiao/archive/2011/08/29/357477.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.aygfsteel.com/GavinMiao/comments/commentRss/357477.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/GavinMiao/services/trackbacks/357477.html</trackback:ping><description><![CDATA[参考文章来源:<br /><div><a >http://www.docin.com/p-87219490.html</a>  <br /><a >http://kaixuan489577823.iteye.com/blog/662864</a>  <br /><div></div>一、struts1主要用到的设计模式:<br />1.Straegy½{–略模式<br />2.singletom单例模式<br />3.command命ä×o模式<br />4.Facade外观模式<br />5.composite view¾l„成模式<br />6.decorator装饰模式<br />7.MVC模式<br />二、spring主要用到的设计模式:<br />1.½Ž€å•工厂即静态工厂模式Static Factory Method<br />2.工厂模式Factory Method<br />3.单例模式Singleton<br />4.适配器Adapter<br />5.装饰器Decorator<br />6.代理Proxy<br />7.观察者Observer<br />8.½{–ç•¥Strategy<br />9.模板æ–ÒŽ³•Template Method<br />三、struts2主要用到的模式:<br />1.MVC模式<br />2.command命ä×o模式<br />3.代理Proxy<br />4.适配器Adapter<br />5.单例模式Singleton<br />6. <span id="wmqeeuq" class="Apple-style-span" style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; ">职责链模å¼?Chain of Responsibility </span><br /><br /><div><span style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; ">GoF设计模式的分¾c»ï¼š <br />æ ÒŽ®ç›®çš„准则分类åQ?nbsp;<br />1åQ?创徏型:creational 与对象的创徏有关ã€?nbsp;<br />2åQ?¾l“构型:Structural 处理¾cÀLˆ–对象之间的组合ã€?nbsp;<br />3åQ?è¡ŒäØ“åž‹ï¼šbehavioral 描述¾cÀLˆ–对象如何交互及如何分配职责ã€?br /><br /><br />创徏型模å¼?br /><br />1.抽象工厂模式 AbstractFactory <br />2.建造者模å¼?Builder <br />3.工厂æ–ÒŽ³•模式 Factory Method <br />4.原型模式 Prototype <br />5.单例模式 Singleton <br /><br />¾l“构型模å¼?nbsp;<br /><br />1.适配器模å¼?Adapter <br />2.桥接模式 Bridge <br />3.¾l„合模式 Composite <br />4.装饰模式 Decorator <br />5.外观模式 Facade <br />6.享元模式 Flyweight <br />7.代理模式 Proxy <br /><br />è¡ŒäØ“æ¨¡å¼ <br /><br />1.职责链模å¼?Chain of Responsibility <br />2.命ä×o模式 Command <br />3.解释器模å¼?Interpreter <br />4.˜q­ä»£å™¨æ¨¡å¼?Iterator <br />5.中介者模å¼?Mediator <br />6.备忘录模å¼?Memento <br />7.观察者模å¼?Observer <br />8.状态模å¼?State <br />9.½{–略模式 Strategy <br />10.模板æ–ÒŽ³•模式 Template Method <br />11.讉K—®è€…模å¼?Visitor</span></div></div><img src ="http://www.aygfsteel.com/GavinMiao/aggbug/357477.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/GavinMiao/" target="_blank">GavinMiao</a> 2011-08-29 10:42 <a href="http://www.aygfsteel.com/GavinMiao/archive/2011/08/29/357477.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>瞎聊http://www.aygfsteel.com/GavinMiao/archive/2011/08/23/357151.htmlGavinMiaoGavinMiaoTue, 23 Aug 2011 15:26:00 GMThttp://www.aygfsteel.com/GavinMiao/archive/2011/08/23/357151.htmlhttp://www.aygfsteel.com/GavinMiao/comments/357151.htmlhttp://www.aygfsteel.com/GavinMiao/archive/2011/08/23/357151.html#Feedback0http://www.aygfsteel.com/GavinMiao/comments/commentRss/357151.htmlhttp://www.aygfsteel.com/GavinMiao/services/trackbacks/357151.html事务å…ähœ‰å››ä¸ªç‰¹å¾åQšåŽŸå­æ€§ï¼ˆ Atomicity åQ‰ã€ä¸€è‡´æ€§ï¼ˆ Consistency åQ‰ã€é𔼛ÀL€§ï¼ˆ Isolation åQ‰å’ŒæŒä¹…性( Durability åQ‰ã€‚这四个ç‰ÒŽ€§ç®€¿UîCØ“ ACID ç‰ÒŽ€?br />事务是一¾l„原子操作单å…?br />从数据库角度è¯ß_¼Œž®±æ˜¯ä¸€¾l„SQL指ä×oåQ?br />要么全部执行成功åQŒè¦ä¹ˆæ’¤é”€ä¸æ‰§è¡Œã€?br />
ä½¿ç”¨å•æ€æ¨¡å¼çš„ç›®æ ‡æ˜¯äØ“äº†æŽ§åˆ¶å¯¹è±¡çš„åˆ›å¾åQŒå•æ€æ¨¡å¼ç»å¸æ€‹É用在控制资源的访问上。例如数据库˜qžæŽ¥æˆ–Socket˜qžæŽ¥½{‰ã€‚单态模式可以控制在某个时刻只有一个线½E‹è®¿é—®èµ„源ã€?br />


]]>
Ö÷Õ¾Ö©Öë³ØÄ£°å£º ÎäÒÄɽÊÐ| ÒËÑôÏØ| ¸ÊÂåÏØ| Õã½­Ê¡| À¶É½ÏØ| ËÕÄáÌØÓÒÆì| º×±ÚÊÐ| ¸ÊÂåÏØ| µÂ²ýÏØ| »ÆÊ¯ÊÐ| ¤Î÷ÏØ| ¹âÉ½ÏØ| ·áÏØ| ÍòÄþÊÐ| »ÆÆ½ÏØ| °ËËÞÏØ| Ûº£ÏØ| ³¤¸ðÊÐ| ¸·ÐÂÊÐ| ÇàºÓÏØ| ÌìÃÅÊÐ| ´óÐËÇø| ·À³Ç¸ÛÊÐ| Ôö³ÇÊÐ| ʯÇþÏØ| ÐÂÃÜÊÐ| »ÝË®ÏØ| ÍòÈÙÏØ| ÇàÖÝÊÐ| Ó¯½­ÏØ| ³¤É³ÊÐ| µÂ¸ñÏØ| ¸ßÐÛÊÐ| ¼ÎÏéÏØ| ¼Ó²éÏØ| ³àË®ÊÐ| ƽÌÁÏØ| ÉÛÑôÊÐ| äü¹ØÏØ| ɳÍåÏØ| ãòË®ÏØ|