??xml version="1.0" encoding="utf-8" standalone="yes"?>性欧美大战久久久久久久久,91麻豆精品久久久久蜜臀 ,久久只精品国产http://www.aygfsteel.com/dingfirst/Qn the QԌadzh-cnSun, 18 May 2025 14:47:25 GMTSun, 18 May 2025 14:47:25 GMT60q图治http://www.aygfsteel.com/dingfirst/archive/2007/09/11/144286.htmldingfirstdingfirstTue, 11 Sep 2007 08:29:00 GMThttp://www.aygfsteel.com/dingfirst/archive/2007/09/11/144286.htmlhttp://www.aygfsteel.com/dingfirst/comments/144286.htmlhttp://www.aygfsteel.com/dingfirst/archive/2007/09/11/144286.html#Feedback0http://www.aygfsteel.com/dingfirst/comments/commentRss/144286.htmlhttp://www.aygfsteel.com/dingfirst/services/trackbacks/144286.htmlq图治

dingfirst 2007-09-11 16:29 发表评论
]]>
无题http://www.aygfsteel.com/dingfirst/archive/2007/04/25/113575.htmldingfirstdingfirstWed, 25 Apr 2007 09:13:00 GMThttp://www.aygfsteel.com/dingfirst/archive/2007/04/25/113575.htmlhttp://www.aygfsteel.com/dingfirst/comments/113575.htmlhttp://www.aygfsteel.com/dingfirst/archive/2007/04/25/113575.html#Feedback0http://www.aygfsteel.com/dingfirst/comments/commentRss/113575.htmlhttp://www.aygfsteel.com/dingfirst/services/trackbacks/113575.html现在在干啥啊Q?br>没有方向Q没有动力?br>十年之后会是什么样子呢Q?br>nnd
郁闷Q?br>极其郁闷Q!Q?br>
改变Q?br>要改变啊Q!



dingfirst 2007-04-25 17:13 发表评论
]]>
web文g下蝲时文件名q长D截断的问?/title><link>http://www.aygfsteel.com/dingfirst/archive/2006/11/27/83859.html</link><dc:creator>dingfirst</dc:creator><author>dingfirst</author><pubDate>Mon, 27 Nov 2006 10:59:00 GMT</pubDate><guid>http://www.aygfsteel.com/dingfirst/archive/2006/11/27/83859.html</guid><wfw:comment>http://www.aygfsteel.com/dingfirst/comments/83859.html</wfw:comment><comments>http://www.aygfsteel.com/dingfirst/archive/2006/11/27/83859.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/dingfirst/comments/commentRss/83859.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/dingfirst/services/trackbacks/83859.html</trackback:ping><description><![CDATA[问题Q?br />      直接用URLEncoder.encode(fileName,"UTF-8")Q得到的文g名长度会被截断?br /><br />解决Ҏ是:<br />      文g名先用“GB2312”编码,然后用?span style="COLOR: #000000">ISO8859_1</span>”解码。当然也可以在将文g名保存到数据库之前用“GB2312”编码?br /><br />代码如下Q?br /><br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #008080"> 1</span><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><span style="COLOR: #000000">conn </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> DBUtil.getConnection();<br /></span><span style="COLOR: #008080"> 2</span><span style="COLOR: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />            ps </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> conn.prepareStatement(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">SELECT FILE_NAME, CONTENT_TYPE, CONTENT FROM PUB_JOB_ATTACHMENTS WHERE ATTACHID = ?</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br /></span><span style="COLOR: #008080"> 3</span><span style="COLOR: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />            ps.setString(</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">,getAttachId());<br /></span><span style="COLOR: #008080"> 4</span><span style="COLOR: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />            rs </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> ps.executeQuery();<br /></span><span style="COLOR: #008080"> 5</span><span style="COLOR: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />            </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(rs.next())<br /></span><span style="COLOR: #008080"> 6</span><span style="COLOR: #000000"><img id="Codehighlighter1_275_1150_Open_Image" onclick="this.style.display='none'; Codehighlighter1_275_1150_Open_Text.style.display='none'; Codehighlighter1_275_1150_Closed_Image.style.display='inline'; Codehighlighter1_275_1150_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_275_1150_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_275_1150_Closed_Text.style.display='none'; Codehighlighter1_275_1150_Open_Image.style.display='inline'; Codehighlighter1_275_1150_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedBlock.gif" align="top" />            </span><span id="Codehighlighter1_275_1150_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.aygfsteel.com/images/dot.gif" /></span><span id="Codehighlighter1_275_1150_Open_Text"><span style="COLOR: #000000">{<br /></span><span style="COLOR: #008080"> 7</span><span style="COLOR: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />                </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">java.net.URLEncoder.encode(rs.getString("FILE_NAME"), "UTF-8")</span><span style="COLOR: #008000"><br /></span><span style="COLOR: #008080"> 8</span><span style="COLOR: #008000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" /></span><span style="COLOR: #000000">                response.setContentType(rs.getString(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">CONTENT_TYPE</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">));<br /></span><span style="COLOR: #008080"> 9</span><span style="COLOR: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />                String fileName</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">rs.getString(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">FILE_NAME</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br /></span><span style="COLOR: #008080">10</span><span style="COLOR: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />                fileName</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">URLEncoder.encode(fileName,</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">GB2312</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br /></span><span style="COLOR: #008080">11</span><span style="COLOR: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />                fileName</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">URLDecoder.decode(fileName, </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">ISO8859_1</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br /></span><span style="COLOR: #008080">12</span><span style="COLOR: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />                response.addHeader(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">Content-Disposition</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">, </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">attachment; filename=\</span><span style="COLOR: #000000">""</span><span style="COLOR: #000000"> + fileName + </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">\</span><span style="COLOR: #000000">""</span><span style="COLOR: #000000">);<br /></span><span style="COLOR: #008080">13</span><span style="COLOR: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />                Blob content </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> rs.getBlob(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">CONTENT</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br /></span><span style="COLOR: #008080">14</span><span style="COLOR: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />                InputStream ins </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> content.getBinaryStream();<br /></span><span style="COLOR: #008080">15</span><span style="COLOR: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />                </span><span style="COLOR: #0000ff">byte</span><span style="COLOR: #000000"> buffer[] </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">byte</span><span style="COLOR: #000000">[</span><span style="COLOR: #000000">1024</span><span style="COLOR: #000000">];<br /></span><span style="COLOR: #008080">16</span><span style="COLOR: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />                </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> length </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">;<br /></span><span style="COLOR: #008080">17</span><span style="COLOR: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />                outs </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> response.getOutputStream();<br /></span><span style="COLOR: #008080">18</span><span style="COLOR: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />                </span><span style="COLOR: #0000ff">while</span><span style="COLOR: #000000">((length </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> ins.read(buffer)) </span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">)<br /></span><span style="COLOR: #008080">19</span><span style="COLOR: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />                    outs.write(buffer, </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">, length);<br /></span><span style="COLOR: #008080">20</span><span style="COLOR: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />                ins.close();<br /></span><span style="COLOR: #008080">21</span><span style="COLOR: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />                outs.flush();<br /></span><span style="COLOR: #008080">22</span><span style="COLOR: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />            }</span></span></div><br /><img src ="http://www.aygfsteel.com/dingfirst/aggbug/83859.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/dingfirst/" target="_blank">dingfirst</a> 2006-11-27 18:59 <a href="http://www.aygfsteel.com/dingfirst/archive/2006/11/27/83859.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>也看Dynamic Proxyhttp://www.aygfsteel.com/dingfirst/archive/2006/07/26/60215.htmldingfirstdingfirstWed, 26 Jul 2006 09:48:00 GMThttp://www.aygfsteel.com/dingfirst/archive/2006/07/26/60215.htmlhttp://www.aygfsteel.com/dingfirst/comments/60215.htmlhttp://www.aygfsteel.com/dingfirst/archive/2006/07/26/60215.html#Feedback0http://www.aygfsteel.com/dingfirst/comments/commentRss/60215.htmlhttp://www.aygfsteel.com/dingfirst/services/trackbacks/60215.html先看一下Proxy的两U用法:

public   interface  Foo  {
    
int  doSomthing();
}
   一个基本的实现Q?br />
public class FooImpl implements Foo {
    
public FooImpl() {
    }


    
public int doSomthing() {
        System.out.println(
"FooImpl doSomthing");
        
return 10;
    }

    
}
   调用处理c,q也是aop的一U实现方式,呵呵?br />
public class MyInvocationHandler implements InvocationHandler{
    Object proxyObject;
    
    
public MyInvocationHandler(Object _proxyObject) {
        
this.proxyObject=_proxyObject;
    }


    
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println(
"in proxy instance");
        
return method.invoke(proxyObject,args);
    }

}
   两种实现方式Q?br />
public class ProxyUse {
    
public ProxyUse() {
    }


    
public void useProxy1() throws SecurityException, NoSuchMethodException, InvocationTargetException,
            IllegalArgumentException, IllegalAccessException, InstantiationException 
{
        FooImpl obj 
= new FooImpl();
        InvocationHandler handler 
= new MyInvocationHandler(obj);
        Class proxyClass 
= Proxy.getProxyClass(
                Foo.
class.getClassLoader(), new Class[] {Foo.class});
        Foo f 
= (Foo) proxyClass.
                getConstructor(
new Class[] {InvocationHandler.class}).
                newInstance(
new Object[] {handler});
        System.out.println(f.doSomthing());
    }

    
    
public void useProxy2() throws SecurityException, NoSuchMethodException, InvocationTargetException,
            IllegalArgumentException, IllegalAccessException, InstantiationException 
{
        FooImpl obj 
= new FooImpl();
        InvocationHandler handler 
= new MyInvocationHandler(obj);
        Foo f 
= (Foo) Proxy.newProxyInstance(
            Foo.
class.getClassLoader(),
            
new Class[] { Foo.class },
            handler
            );
        System.out.println(f.doSomthing());
    }

    
    
public static void main(String [] args){
        ProxyUse use
=new ProxyUse();
        
try{
            use.useProxy1();
            use.useProxy2();
        }
catch(Exception ex){
            ex.printStackTrace();
        }

    }


}

看一下java api doc

static InvocationHandlergetInvocationHandler(Object proxy)
          q回指定代理实例的调用处理程序?/td>
static Class<?>getProxyClass(ClassLoader loader, Class<?>... interfaces)
          q回代理cȝ java.lang.Class 对象Qƈ向其提供cd载器和接口数l?/td>
static booleanisProxyClass(Class<?> cl)
          当且仅当指定的类通过 getProxyClass Ҏ?newProxyInstance Ҏ动态生成ؓ代理cLQ返?true?/td>
static ObjectnewProxyInstance(ClassLoader loader, Class<?>[] interfaces, InvocationHandler h)
          q回一个指定接口的代理cd例,该接口可以将Ҏ调用指派到指定的调用处理E序?/td>

没时间了Q先q样吧?br />


 



dingfirst 2006-07-26 17:48 发表评论
]]>
Peter Haggar对Singleton 的分?/title><link>http://www.aygfsteel.com/dingfirst/archive/2006/07/18/58834.html</link><dc:creator>dingfirst</dc:creator><author>dingfirst</author><pubDate>Tue, 18 Jul 2006 11:17:00 GMT</pubDate><guid>http://www.aygfsteel.com/dingfirst/archive/2006/07/18/58834.html</guid><wfw:comment>http://www.aygfsteel.com/dingfirst/comments/58834.html</wfw:comment><comments>http://www.aygfsteel.com/dingfirst/archive/2006/07/18/58834.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/dingfirst/comments/commentRss/58834.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/dingfirst/services/trackbacks/58834.html</trackback:ping><description><![CDATA[     摘要: 原文名称QDouble-checked locking and the Singleton pattern                            A comprehensive look at this broken programming idiom 1Q请首先看一下下面的q个c,只有W一个getInstanceQ)Ҏ是正的。其中get...  <a href='http://www.aygfsteel.com/dingfirst/archive/2006/07/18/58834.html'>阅读全文</a><img src ="http://www.aygfsteel.com/dingfirst/aggbug/58834.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/dingfirst/" target="_blank">dingfirst</a> 2006-07-18 19:17 <a href="http://www.aygfsteel.com/dingfirst/archive/2006/07/18/58834.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>多线E设计要点(转蝲)http://www.aygfsteel.com/dingfirst/archive/2006/07/14/58160.htmldingfirstdingfirstFri, 14 Jul 2006 05:06:00 GMThttp://www.aygfsteel.com/dingfirst/archive/2006/07/14/58160.htmlhttp://www.aygfsteel.com/dingfirst/comments/58160.htmlhttp://www.aygfsteel.com/dingfirst/archive/2006/07/14/58160.html#Feedback2http://www.aygfsteel.com/dingfirst/comments/commentRss/58160.htmlhttp://www.aygfsteel.com/dingfirst/services/trackbacks/58160.html 1 .多线E中有主内存和工作内存之分, 在JVM中,有一个主内存Q专门负责所有线E共享数据;而每个线E都有他自己U有的工作内存, d存和工作内存分贝在JVM的stack区和heap区?/p>

2. U程的状态有'Ready', 'Running', 'Sleeping', 'Blocked', ?'Waiting'几个状态,
'Ready' 表示U程正在{待CPU分配允许q行的时间?/p>

3. U程q行ơ序q不是按照我们创Z们时的顺序来q行的,CPU处理U程的顺序是不确定的Q如果需要确定,那么必须手工介入Q用setPriority()Ҏ讄优先U?/p>

4. 我们无从知道一个线E什么时候运行,两个或多个线E在讉K同一个资源时Q需要synchronized

5. 每个U程会注册自己,实际某处存在着对它的引用,因此Q垃圑֛收机制对它就“束手无{”了?/p>

6. DaemonU程区别一般线E之处是Q主E序一旦结束,DaemonU程׃l束?/p>

7. 一个对象中的所有synchronizedҎ都共享一把锁Q这把锁能够防止多个Ҏ寚w用内存同时q行的写操作。synchronized staticҎ可在一个类范围内被怺间锁定v来?/p>

8. 对于讉K某个关键׃n资源的所有方法,都必L它们设ؓsynchronizedQ否则就不能正常工作?/p>

9. 假设已知一个方法不会造成冲突Q最明智的方法是不要使用synchronizedQ能提高些性能?/p>

10 . 如果一?同步"Ҏ修改了一个变量,而我们的Ҏ要用到这个变?可能是只?,最好将自己的这个方法也设ؓ synchronized?/p>

11. synchronized不能l承Q 父类的方法是synchronizedQ那么其子类重蝲Ҏ中就不会l承“同步”?/p>

12. U程堵塞Blocked有几个原因造成Q?/p>

(1)U程在等候一些IO操作
(2)U程试图调用另外一个对象的“同步”方法,但那个对象处于锁定状态,暂时无法使用?/p>

13. 原子型操?atomic), 对原始型变量(primitive)的操作是原子型的atomic. 意味着q些操作是线E安全的Q?但是大部分情况下Q我们ƈ不能正确使用Q来看看 i = i + 1 , i是int型,属于原始型变量:

(1)从主内存中读取i值到本地内存.
(2)g本地内存装蝲到线E工作拷贝中.
(3)装蝲变量1.
(4)i ?1.
(5)结果给变量i.
(6)i保存到线E本地工作拷贝中.
(7)写回d?

注意原子型操作只限于W?步到W?步的d以及W?到第7步的? i的D是可能被同时执行i=i+1的多U程中断打扰(在第4??/p>

double 和long 变量是非原子型的(non-atomic)。数l是object 非原子型?br />

14. ׃13条的原因Q我们解军_法是Q?/p>

class xxx extends Thread{

//i会被l常修改
private int i;

public synchronized int read(){ return i;}

public synchronized void update(){ i = i + 1;}

..........

}

15. Volatile变量Q?volatile变量表示保证它必L与主内存保持一_它实际是"变量的同?, 也就是说对于volatile变量的操作是原子型的Q如用在long ?double变量前?br />

16. 使用yield()会自动放弃CPUQ有时比sleep更能提升性能?/p>

17. sleep()和wait()的区别是Qwait()Ҏ被调用时会解除锁定,但是我们能用它的地方只是在一个同步的Ҏ或代码块内?/p>

18. 通过刉羃同步范_可能的实现代码块同步,wait(毫秒?可在指定的毫U数可退出waitQ对于wait()需要被notisfy()或notifyAll()t醒?/p>

19. 构造两个线E之间实旉信的方法分几步Q?br />(1). 创徏一个PipedWriter和一个PipedReader和它们之间的道;
PipedReader in = new PipedReader(new PipedWriter())
(2). 在需要发送信息的U程开始之前,外部的PipedWriter导向l其内部的Writer实例out
(3). 在需要接受信息的U程开始之前,外部的PipedReader导向l其内部的Reader实例in
(4). q样攑օout的所有东西度可从in中提取出来?/p>

20. synchronized带来的问题除性能有所下降外,最大的~点是会带来死锁DeadLockQ只有通过谨慎设计来防止死锁,其他毫无办法Q这也是U程难以驯服的一个原因。不要再使用stop() suspend() resume()和destory()Ҏ

21. 在大量线E被堵塞Ӟ最高优先的线E先q行。但是不表示低别线E不会运行,q行概率而已?/p>

22. U程l的主要优点是:使用单个命o可完成对整个U程l的操作。很需要用到线E组?/p>

23. 从以下几个方面提升多U程的性能Q?/p>

查所有可能Block的地方,可能的多的使用sleep或yield()以及wait();

可能g长sleep(毫秒?的时?

q行的线E不用超q?00个,不能太多Q?/p>

不同q_linux或windows以及不同JVMq行性能差别很大?/p>

24. 推荐几篇相关英文文章:

Use Threading Tricks to Improve Programs



原文Q多U程设计要点  板桥里h http://www.jdon.com/concurrent/thread.htm



dingfirst 2006-07-14 13:06 发表评论
]]>
XA和两阶段提交http://www.aygfsteel.com/dingfirst/archive/2006/07/11/57703.htmldingfirstdingfirstTue, 11 Jul 2006 11:44:00 GMThttp://www.aygfsteel.com/dingfirst/archive/2006/07/11/57703.htmlhttp://www.aygfsteel.com/dingfirst/comments/57703.htmlhttp://www.aygfsteel.com/dingfirst/archive/2006/07/11/57703.html#Feedback0http://www.aygfsteel.com/dingfirst/comments/commentRss/57703.htmlhttp://www.aygfsteel.com/dingfirst/services/trackbacks/57703.html    
      X/Openl织Q即现在的Open GroupQ定义了分布式事务处理模型。X/Open DTP模型Q?994Q包括应用程序(APQ、事务管理器QTMQ、资源管理器QRMQ、通信资源理器(CRMQ四部分。一般,常见的事务管理器QTMQ是交易中间Ӟ常见的资源管理器QRMQ是数据库,常见的通信资源理器(CRMQ是消息中间件。ؓ表述方便赯Q在本文中直接以其常见表现Ş式进行描q?br />


      一般情况下Q某一数据库无法知道其它数据库在做什么,因此Q在一个DTP环境中,交易中间件是必需的,由它通知和协调相x据库的提交或回滚。而一个数据库只将其自己所做的操作Q可恢复Q媄到全局事务中。?br />      
      XA是X/Open DTP定义的交易中间g与数据库之间的接口规范(x口函敎ͼQ交易中间g用它来通知数据库事务的开始、结束以及提交、回滚等。XA接口函数由数据库厂商提供?

      通常情况下,交易中间件与数据库通过XA 接口规范Q用两阶段提交来完成一个全局事务QXA规范的基是两阶段提交协议。?br />
      在第一阶段Q交易中间gh所有相x据库准备提交Q预提交Q各自的事务分支Q以认是否所有相x据库都可以提交各自的事务分支。当某一数据库收到预提交后,如果可以提交属于自己的事务分支,则将自己在该事务分支中所做的操作固定记录下来Qƈl交易中间g一个同意提交的应答Q此时数据库不能再在该事务分支中加入Q何操作,但此时数据库q没有真正提交该事务Q数据库对共享资源的操作q未释放Q处于上锁状态)。如果由于某U原因数据库无法提交属于自己的事务分支,它将回滚自己的所有操作,释放对共享资源上的锁Qƈq回l交易中间gp|应答?

  在第二阶D,交易中间件审查所有数据库q回的预提交l果Q如所有数据库都可以提交,交易中间件将要求所有数据库做正式提交,q样该全局事务被提交。而如果有M数据库预提交q回p|Q交易中间g要求所有其它数据库回滚其操作,q样该全局事务被回滚?br /> 

      摘自http://www.huihoo.com/middleware/trade_middleware.html    交易中间件与XA规范

 



dingfirst 2006-07-11 19:44 发表评论
]]>
中文排序http://www.aygfsteel.com/dingfirst/archive/2006/07/11/57654.htmldingfirstdingfirstTue, 11 Jul 2006 07:18:00 GMThttp://www.aygfsteel.com/dingfirst/archive/2006/07/11/57654.htmlhttp://www.aygfsteel.com/dingfirst/comments/57654.htmlhttp://www.aygfsteel.com/dingfirst/archive/2006/07/11/57654.html#Feedback0http://www.aygfsteel.com/dingfirst/comments/commentRss/57654.htmlhttp://www.aygfsteel.com/dingfirst/services/trackbacks/57654.html  1     public static int compare(String str1, String str2)
 2     {
 3         int result = 0;
 4         String m_s1 = null;
 5         String m_s2 = null;
 6         try
 7         {
 8             m_s1 = new String(str1.getBytes(_FromEncode_), _ToEncode_);
 9             m_s2 = new String(str2.getBytes(_FromEncode_), _ToEncode_);
10         }

11         catch(Exception e)
12         {
13             return str1.compareTo(str2);
14         }

15         result = chineseCompareTo(m_s1, m_s2);
16         return result;
17     }

18
19     public static int getCharCode(String s)
20     {
21         if(s == null && s.equals(""))
22             return -1;
23         byte b[] = s.getBytes();
24         int value = 0;
25         for(int i = 0; i < b.length && i <= 2; i++)
26             value = value * 100 + b[i];
27
28         return value;
29     }

30
31     public static int chineseCompareTo(String s1, String s2)
32     {
33         int len1 = s1.length();
34         int len2 = s2.length();
35         int n = Math.min(len1, len2);
36         for(int i = 0; i < n; i++)
37         {
38             int s1_code = getCharCode(s1.charAt(i) + "");
39             int s2_code = getCharCode(s2.charAt(i) + "");
40             if(s1_code * s2_code < 0)
41                 return Math.min(s1_code, s2_code);
42             if(s1_code != s2_code)
43                 return s1_code - s2_code;
44         }

45
46         return len1 - len2;
47     }

是比较准的了,但还是有错误Q而且性能比较差?br />
法最初是谁写的也忘了。呵呵,拿来用一?


dingfirst 2006-07-11 15:18 发表评论
]]>
վ֩ģ壺 ľ| ˺| | | ԭ| ͩ| Ʊ| | | | ƽ| ǧ| â| | ƽ| ʶ| ϻ| ǰ| | | ֺ| | | | °Ͷ| | | ȳ| | Ϫ| ݳ| | | Դ| | տ| | | | ̨ǰ| |