<?xml version="1.0" encoding="gb2312"?>

<!-- RSS generated by oioj.net on 4/16/2004 ; 感谢LeXRus提供 RSS 2.0 文档; 此文件可自由使用，但请保留此行信息 --> 
<!-- Source download URL: http://blogger.org.cn/blog/rss2.asp       -->
<rss version="2.0">

<channel>
<title>Open your thoughts</title>
<link>http://blogger.org.cn/blog/blog.asp?name=java2guru</link>
<description>Nurhachi.Zhang的博客</description>
<copyright>blogger.org.cn</copyright>
<generator>W3CHINA Blog</generator>
<webMaster>webmaster@blogger.org.cn</webMaster>
<item>
<title><![CDATA[好久没有更新这个blog，发现自己基本半年多换一次]]></title>
<link>http://blogger.org.cn/blog/more.asp?name=java2guru&amp;id=22667</link>
<author>java2guru</author>
<pubDate>2007-2-10 20:10:36</pubDate>
<description><![CDATA[从第一次开始，到现在，常用的前后大概换了4、5个了]]></description>
</item><item>
<title><![CDATA[英文版《八荣八耻》]]></title>
<link>http://blogger.org.cn/blog/more.asp?name=java2guru&amp;id=17674</link>
<author>java2guru</author>
<pubDate>2006-8-19 22:47:51</pubDate>
<description><![CDATA[<A>弘扬传统文化，你我皆有责任<BR/><BR/>著作权声明：此英文版《八荣八耻》版权归 北京外文局 所有 <BR/><BR/><BR/><BR/>Eight-honor and Eight-shame （八荣八耻） <BR/><BR/><BR/><BR/>Honor to those who love the motherland, <BR/><BR/>and shame on those who harm the motherland. <BR/><BR/>以热爱祖国为荣、以危害祖国为耻 <BR/><BR/><BR/><BR/>Honor to those who serve the people, <BR/><BR/>and shame on those who betray the people. <BR/><BR/>以服务人民为荣、以背离人民为耻 <BR/><BR/><BR/><BR/>Honor to those who quest for science, <BR/><BR/>and shame on those who refuse to be educated. <BR/><BR/>以崇尚科学为荣、以愚昧无知为耻 <BR/><BR/><BR/><BR/>Honor to those who are hardworking, <BR/><BR/>and shame on those who indulge in comfort and hate work. <BR/><BR/>以辛勤劳动为荣、以好逸恶劳为耻 <BR/><BR/><BR/><BR/>Honor to those who help each other, <BR/><BR/>and shame on those who seek gains at the expense of others. <BR/><BR/>以团结互助为荣、以损人利己为耻 <BR/><BR/><BR/><BR/>Honor to those who are trustworthy, <BR/><BR/>and shame on those who trade integrity for profits. <BR/><BR/>以诚实守信为荣、以见利忘义为耻 <BR/><BR/><BR/><BR/>Honor to those who abide by law and discipline, <BR/><BR/>and shame on those who break laws and discipline. <BR/><BR/>以遵纪守法为荣、以违法乱纪为耻 <BR/><BR/><BR/><BR/>Honor to those who uphold plain living and hard struggle, <BR/><BR/>and shame on those who wallow in extravagance and pleasures. <BR/><BR/>以艰苦奋斗为荣、以骄奢淫逸为耻<BR/><BR/>]]></description>
</item><item>
<title><![CDATA[try Rational Application Developer]]></title>
<link>http://blogger.org.cn/blog/more.asp?name=java2guru&amp;id=17518</link>
<author>java2guru</author>
<pubDate>2006-8-14 11:35:52</pubDate>
<description><![CDATA[今天安装了一套IBM的RAD工具]]></description>
</item><item>
<title><![CDATA[mac上视频聊天]]></title>
<link>http://blogger.org.cn/blog/more.asp?name=java2guru&amp;id=17497</link>
<author>java2guru</author>
<pubDate>2006-8-13 17:43:41</pubDate>
<description><![CDATA[现在skype有版本支持mac上视频，而且，有一个开源项目macam提供了摄像头的驱动程序，支持不少摄像头]]></description>
</item><item>
<title><![CDATA[求自然数n以内的质数]]></title>
<link>http://blogger.org.cn/blog/more.asp?name=java2guru&amp;id=17483</link>
<author>java2guru</author>
<pubDate>2006-8-12 17:52:25</pubDate>
<description><![CDATA[今天遇到这样一道题目：求自然数n以内的质数<BR/>经过观察以后，我觉得可以以下方式来求解：<BR/>将已求解的质数放入结果数组，判断下一个数是否是质数，只要将它除以质数结果数组，如果都不能被整除，那么这个数也是一个质数，放入结果数组中。<BR/><BR/>/*<BR/> * PrimeNumber.java<BR/> *<BR/> * Created on 2006年8月12日, 下午6:05<BR/> *<BR/> * This class is under Gnu GPL.<BR/> */<BR/><BR/>package primenumber;<BR/><BR/>import java.io.IOException;<BR/><BR/>/**<BR/> * Get prime numbers.<BR/> *<BR/> * @author &lt;a href="guangquanzhang@gmail.com"&gt;guangquanzhang&lt;/a&gt;<BR/> */<BR/>public class PrimeNumber {<BR/> <BR/>       &#160;&#160;&#160;&#160;/** Creates a new instance of PrimeNumber */<BR/>    &#160;&#160;&#160;&#160;public PrimeNumber() {<BR/>    &#160;&#160;&#160;&#160;}<BR/> <BR/>       &#160;&#160;&#160;&#160;/**<BR/>     &#160;&#160;&#160;&#160;&#160;&#160;* @param n natural number, 1-n<BR/>     &#160;&#160;&#160;&#160;&#160;&#160;* @return all prime numbers between 1 and n.<BR/>     &#160;&#160;&#160;&#160;&#160;&#160;*/<BR/>    &#160;&#160;&#160;&#160;public static void getPrime(int n) {<BR/>        &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;int[] primes = new int[n];<BR/>        &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;int primesSize = 0;<BR/><BR/>        &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;// its apparent that 1, 2 is prime numbers<BR/>        &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;primes[0] = 1;<BR/>        &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;primes[1] = 2;<BR/>        &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;primesSize = 2;<BR/><BR/>        &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;for(int i=3; i&lt;n; i++) {<BR/>            &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;int j = 1;<BR/>            &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;for (; j &lt; primesSize; j++) {<BR/>                &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if(i%primes[j] == 0) {<BR/>                    &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;break;<BR/>                &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}<BR/>            &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}<BR/>            &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if(j == primesSize) {<BR/>                &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;primes[primesSize] = i;<BR/>                &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;primesSize++;<BR/>            &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}<BR/>        &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}<BR/> <BR/>               &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;// print all prime numbers<BR/>        &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;for(int k = 0; k &lt; primesSize; k++) {<BR/>            &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;System.out.println(k + " : " + primes[k]);<BR/>        &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}<BR/>    &#160;&#160;&#160;&#160;}<BR/> <BR/>       &#160;&#160;&#160;&#160;public static void main(String[] args) {<BR/>        &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;PrimeNumber.getPrime(24);<BR/>    &#160;&#160;&#160;&#160;}<BR/>}<BR/><BR/><BR/>]]></description>
</item><item>
<title><![CDATA[配置ubuntu server]]></title>
<link>http://blogger.org.cn/blog/more.asp?name=java2guru&amp;id=17227</link>
<author>java2guru</author>
<pubDate>2006-8-5 18:34:00</pubDate>
<description><![CDATA[&#160;&#160;&#160;&#160;在使用apt-get update的时候，发现有temporary resolving failture，遂怀疑是dns有问题。在我这里dhcp是没问题的，放到同学那里使用的是静态ip，dns没有做相应更改。在resolv.conf中将dns重新设置，问题便解决了。<BR/>&#160;&#160;&#160;&#160;这次在配置服务器的时候，发现ubuntu 源竟然提供了这么完美的工具，比如java，tomcat，mysql，apache2，以及apache2与tomcat连接的模块都提供了，你要做的只是apt-get。<BR/>]]></description>
</item><item>
<title><![CDATA[一些基础]]></title>
<link>http://blogger.org.cn/blog/more.asp?name=java2guru&amp;id=16784</link>
<author>java2guru</author>
<pubDate>2006-7-20 22:17:44</pubDate>
<description><![CDATA[<a>1.</a>public interface Inf {
}<br>&nbsp; public class Parent {
}<br>&nbsp; public class Child extends Parent implements Inf {
}<br><br>&nbsp; Inf i = new Child();<br>&nbsp; Parent p = new Child();<br><br>2.public class Sample {}<br>&nbsp; public abstract class SampleA extends Sample {}<br><br>3.静态内部类可以出现在一个接口中<br><br>4.初始化顺序：从基类开始的所有类层次中的静态域（按顺序全部初始化）－&gt;从基类开始，按层次顺序初始化每个类的变量域和构造函数。<br>public class Sample{<br>&nbsp; public Sample(String s) {<br>&nbsp;&nbsp;&nbsp; System.out.println(s);<br>&nbsp; }<br>}<br><br>public class Test {<br>&nbsp; public static Sample s1 = new Sample("static field in Test");<br>&nbsp; public Sample s2 = new Sample("filed in Test");<br><br>&nbsp; public Test() {<br>&nbsp;&nbsp;&nbsp; System.out.println("in Test constructer");<br>&nbsp; }<br>}<br><br>public class TestA extends Test {<br>&nbsp; public static Sample sample = new Sample("static field in TestA");<br>&nbsp; public Sample s = new Sample("field in TestA");<br><br>&nbsp; public TestA() {<br>&nbsp;&nbsp;&nbsp; System.out.println("in TestA constructer");<br>&nbsp; }<br><br>&nbsp; public static void main(String[] args) {<br>&nbsp;&nbsp;&nbsp; TestA ta = new TestA();<br>&nbsp; }<br>}<br><br>public class TestB extends TestA {<br>&nbsp; public static Sample sample = new Sample("static field in TestB");<br>&nbsp; public Sample s = new Sample("field in TestB");<br><br>&nbsp; public TestB() {<br>&nbsp;&nbsp;&nbsp; System.out.println("in TestB constructer");<br>&nbsp; }<br><br>&nbsp; public static void main(String[] args) {<br>&nbsp;&nbsp;&nbsp; TestB tb = new TestB();<br>&nbsp; }<br>}<br><br>输出为：<br>static field in Test<br>static field in TestA<br>static field in TestB<br>filed in Test<br>in Test constructer<br>field in TestA<br>in TestA constructer<br>field in TestB<br>in TestB constructer<br><br>5.初始化基础类(Thinking in Java)<br>由于这儿涉及到两个类——基础类及衍生类，而不再是以前的一个，所以在想象衍生类的结果对象时，可能会产生一些迷惑。从外部看，似乎新类拥有与基础类相同的接口，而且可包含一些额外的方法和字段。但继承并非仅仅简单地复制基础类的接口了事。创建衍生类的一个对象时，它在其中包含了基础类的一个“子对象”。这个子对象就象我们根据基础类本身创建了它的一个对象。从外部看，基础类的子对象已封装到衍生类的对象里了。<br>当然，基础类子对象应该正确地初始化，而且只有一种方法能保证这一点：在构建器中执行初始化，通过调用基础类构建器，后者有足够的能力和权限来执行对基础类的初始化。在衍生类的构建器中，Java会自动插入对基础类构建器的调用。下面这个例子向大家展示了对这种三级继承的应用：<br><br>//: Cartoon.java<br>// Constructor calls during inheritance<br><br>class Art {<br>&nbsp; Art() {<br>&nbsp;&nbsp;&nbsp; System.out.println("Art constructor");<br>&nbsp; }<br>}<br><br>class Drawing extends Art {<br>&nbsp; Drawing() {<br>&nbsp;&nbsp;&nbsp; System.out.println("Drawing constructor");<br>&nbsp; }<br>}<br><br>public class Cartoon extends Drawing {<br>&nbsp; Cartoon() {<br>&nbsp;&nbsp;&nbsp; System.out.println("Cartoon constructor");<br>&nbsp; }<br>&nbsp; public static void main(String[] args) {<br>&nbsp;&nbsp;&nbsp; Cartoon x = new Cartoon();<br>&nbsp; }<br>} ///:~<br><br>该程序的输出显示了自动调用：<br><br>Art constructor<br>Drawing constructor<br>Cartoon constructor<br><br>可以看出，构建是在基础类的“外部”进行的，所以基础类会在衍生类访问它之前得到正确的初始化。<br>即使没有为Cartoon()创建一个构建器，编译器也会为我们自动合成一个默认构建器，并发出对基础类构建器的调用。<br>上述例子有自己默认的构建器；也就是说，它们不含任何自变量。编译器可以很容易地调用它们，因为不存在具体传递什么自变量的问题。如果类没有默认的自变量，或者想调用含有一个自变量的某个基础类构建器，必须明确地编写对基础类的调用代码。这是用super关键字以及适当的自变量列表实现的.在衍生类构建器中，对基础类构建器的调用是必须做的第一件事情（前提：基础类没有无参构造器）。<br><br>6.每个类都有一个Class对象与之对应，如何获取这个类的Class对象？<br>&nbsp; Class.forName(className);<br>&nbsp; className.class;<br>]]></description>
</item><item>
<title><![CDATA[jar包导致jsp输出空白页面]]></title>
<link>http://blogger.org.cn/blog/more.asp?name=java2guru&amp;id=15737</link>
<author>java2guru</author>
<pubDate>2006-6-22 10:39:06</pubDate>
<description><![CDATA[由于我在WEB-INF/lib下添加了一个叫javax.servlet.jsp.jar的包，导致jsp总是输出空白页，移去这个jar后，一切正常。这个包的具体用途在google上没有搜索到，但看起来是用于预编译jsp的。]]></description>
</item><item>
<title><![CDATA[使用axis2访问web service时抛read timed out的解决方法]]></title>
<link>http://blogger.org.cn/blog/more.asp?name=java2guru&amp;id=15410</link>
<author>java2guru</author>
<pubDate>2006-6-13 10:16:31</pubDate>
<description><![CDATA[<div style="text-align: left;">


	<title></title><meta name="GENERATOR" content="OpenOffice.org 2.0  (Linux)"><meta name="CREATED" content="20060613;9103100"><meta name="CHANGED" content="16010101;8042600">
	
	
	
	
	</div><style type="text/css">
	<!--
		@page { size: 21cm 29.7cm; margin: 2cm }
		P { margin-bottom: 0.21cm }
	-->
	</style>

<p style="margin-left: 1.27cm; margin-bottom: 0cm; text-align: left;"><font face="AR PL SungtiL GB, serif">options.setProperty(org.apache.axis2.transport.http.HTTPConstants.SO_TIMEOUT,new</font></p><div style="text-align: left;">
</div><p style="margin-left: 1.27cm; margin-bottom: 0cm; text-align: left;">                  
 <font face="AR PL SungtiL GB, serif">Integer(480000));</font></p><div style="text-align: left;">
</div><p style="margin-left: 1.27cm; margin-bottom: 0cm; text-align: left;"><font face="AR PL SungtiL GB, serif">options.setProperty(org.apache.axis2.transport.http.HTTPConstants.CONNECTION_TIMEOUT,
new Integer(480000));</font></p>
]]></description>
</item><item>
<title><![CDATA[突破封锁，访问google]]></title>
<link>http://blogger.org.cn/blog/more.asp?name=java2guru&amp;id=15195</link>
<author>java2guru</author>
<pubDate>2006-6-7 11:11:09</pubDate>
<description><![CDATA[我的系统是Linux，安装了tor 和 privoxy，然后在/etc/privoxy/config文件后加上 forward-socks4a / localhost:9050 . ，注意不要漏了后面的.号。然后把浏览器的代理设置为127.0.0.1 port 8118，这样就可以访问google网站了。<br>&nbsp; 更详细的信息请访问http://blog.anthonywong.net/2005/07/24/tor-another-way-to-get-around-the-great-firewall-of-china/]]></description>
</item><item>
<title><![CDATA[关于IOC和AOP的一点感想]]></title>
<link>http://blogger.org.cn/blog/more.asp?name=java2guru&amp;id=14725</link>
<author>java2guru</author>
<pubDate>2006-5-25 16:12:34</pubDate>
<description><![CDATA[&nbsp;&nbsp;&nbsp; 虽然有关IOC的话题最近几年炒的火热，但一直没有去看、去了解这方面的东西。前天听了别人的讲解，恍然大悟，这其实在实际工作中或多或少的使用过。理解起来不复杂，但是我们却没有将其提升至理论，可见，跟IT高水平国家的程序员相比，我们欠缺的不仅仅是技能，更多的是独立而深入的思考。<br>&nbsp;&nbsp;&nbsp; Think different ...<br>]]></description>
</item><item>
<title><![CDATA[Linux下把GBK编码的文件转化为utf-8编码的命令]]></title>
<link>http://blogger.org.cn/blog/more.asp?name=java2guru&amp;id=14724</link>
<author>java2guru</author>
<pubDate>2006-5-25 15:52:05</pubDate>
<description><![CDATA[<font size="3"><font color="#000000"><font face="MS Sans Serif">iconv -f gbk -t utf8 in_file &gt; out_file</font></font></font>]]></description>
</item><item>
<title><![CDATA[A Brief Introduction to IoC --- by Sam Newman 02/10/2004]]></title>
<link>http://blogger.org.cn/blog/more.asp?name=java2guru&amp;id=14509</link>
<author>java2guru</author>
<pubDate>2006-5-18 10:49:09</pubDate>
<description><![CDATA[This article aims to introduce the notion of Inversion Of Control
(IoC) and how it can streamline application design. We will look at the
different types
of IoC frameworks. By showing how IoC can result in simpler, more
flexible code, you'll also be able to see why IoC has attracted so much
interest of late.

<h2 id="The_Theory_of_IoC">The Theory of IoC</h2>

<p>The best way to describe what IoC is about, and what benefits it can provide, 
is to look at a simple example. The following <code>JDBCDataManger</code> class is used to 
manage our application's accessing of  the database. This application is currently 
using raw JDBC for persistence. To access the persistence store via JDBC, the <code>JDBCDataManger</code> will need a <code>DataSource</code> object. The standard approach would be to hard code this <code>DataSource</code> object into the class, like this:</p>

<pre><code>public class JDBCDataManger {<br>  public void accessData() {<br>    DataSource dataSource = new DataSource();<br>    //access data<br>    ...<br>}</code></pre>

<p>Given that <code>JDBCDataManger</code> is handling all data access for our application,
hard coding the <code>DataSource</code> isn't that bad, but we may want to further 
abstract the <code>DataSource</code>, perhaps getting it via some system-wide property 
object:</p>

<pre><code>public class JDBCDataManger {<br>  public void accessData() {<br>    DataSource dataSource = <br>      ApplciationResources.getDataSource();<br>}</code></pre>

<p>In either case, the <code>JDBCDataManger</code> has to fetch the <code>DataSource</code> itself.</p>

<p>IoC takes a different approach — with IoC, the <code>JDBCDataManger</code> would declare its need 
for a <code>DataSource</code> and have one provided to it by an IoC framework. This means that the 
component would no longer need to know how to get the dependency, resulting in cleaner, more focused, and more flexible code.</p>

<h2 id="IoC_frameworks">IoC Frameworks</h2>

<p>The ideas behind IoC aren't especially new; in fact, many have 
remarked that IoC is nothing but a new acronym for the older 
<a href="http://www.objectmentor.com/resources/articles/dip.pdf">Dependency Inversion Principle</a>
(PDF file). What is new is the interest in IoC, and the large number of
frameworks being actively developed to aid the use of IoC.
</p>

<p>IoC frameworks are the facilitators for the IoC pattern — think of a
framework's job as being the glue for connecting the components in an
IoC system. While the general principle of IoC is fairly
straightforward, there are several distinct implementations evident in
the frameworks. The developers of PicoContainer originally defined the
three types of IoC, in order to differentiate their approach
from the other frameworks around at the time. At first, these types
were simply called Types 1,2, and 3, but in Martin Fowler's recent
article, "<a href="http://www.martinfowler.com/articles/injection.html">Inversion of Control Containers and the Dependency Injection Pattern</a>," he coined some more informative terms for these three types, which we will use below.</p>

<p>In the rest of the article, we'll look briefly at <a href="http://avalon.apache.org/framework/" title="The Avalon Project">Avalon</a>, and in more depth at the two most popular IoC frameworks, <a href="http://www.springframework.org/">Spring</a> and <a href="http://picocontainer.org/">PicoContainer</a>, and the types of IoC they provide.</p>

<h5 id="Interface_Injection">Interface Injection (Type 1)</h5>

<p>With Interface Injection IoC, components implement specific
interfaces provided by their containers in order to be configured.
Let's look at a refactor of our <code>JDBCDataManager</code> that uses the Avalon framework:</p>

<pre><code>import org.apache.avalon.framework.*;<br><br>  public class JDBCDataManger implements Serviceable {<br>    DataSource dataSource;<br>    public void service (ServiceManager sm) <br>          throws ServiceException {<br>      dataSource = (DataSource)sm.lookup("dataSource");<br>    }<br>    <br>    public void getData() {<br>      //use dataSource for something<br>    }<br>}</code></pre>

<p>This form of IoC has been around for longer than the term IoC has
been in use — many of you might have used such a form of IoC when using
the EJB framework, for example. Here, your components extend and
implement specified interfaces, which then get called by the framework
itself.</p>

<p>The fact that the Avalon framework has been providing an IoC
framework for several years now, without generating nearly as much
interest in the idea as either Spring or PicoContainer, is probably due
to the downsides of this approach. The requirement to implement
specific interfaces can give code a "bloated" feel, while at the same
time coupling your application code to the underlying framework. The
benefits provided by the other two forms of IoC we will look at next
far outweigh those provided by this form of IoC.</p>

<h5 id="Setter_Injection">Setter Injection (Type 2)</h5>

<p>With Setter Injection IoC, some external metadata is used to resolve
dependencies. In Spring, this metadata takes the form of an XML
configuration file. With this form of IoC, the <code>JDBCDataManager</code> class looks like a normal bean:</p>

<pre><code>public class JDBCDataManger {<br>  private DataSource dataSource;<br>  <br>  public void setDataManager(DataSource dataSource {<br>    this.dataSource = dataSource;<br>  }<br>  <br>  public void getData() {<br>      //use dataSource for something<br>  }<br>}</code></pre>

<p>Our <code>JDBCDataManger</code> component exposes its <code>dataSource</code> property to allow Spring to set it. 
Spring does this using its XML configuration. First we define a data source bean (which can be reused by multiple components):</p>

<pre><code>&lt;bean id="myDataSource" <br>  class="org.apache.commons.dbcp.BasicDataSource" &gt;<br>  &lt;property name="driverClassName"&gt;<br>    &lt;value&gt;com.mydb.jdbc.Driver&lt;/value&gt;<br>  &lt;/property&gt;<br>  &lt;property name="url"&gt;<br>    &lt;value&gt;jdbc:mydb://server:port/mydb&lt;/value&gt;<br>  &lt;/property&gt;<br>  &lt;property name="username"&gt;<br>    &lt;value&gt;root&lt;/value&gt;<br>  &lt;/property&gt;<br>&lt;/bean&gt;</code></pre>

<p>Next, we define an instance of our manager and pass in a reference to the data source:</p>

<pre><code>&lt;bean id="dataManager" <br>  class="example.JDBCDataManger"&gt;<br>  &lt;property name="dataSource"&gt;<br>    &lt;ref bean="myDataSource"/&gt;<br>  &lt;/property&gt;<br>&lt;/bean&gt;</code></pre>

<p>At runtime, a <code>JDBCDataManger</code> class will be instantiated with the correct <code>DataSource</code>
dependency resolved, and we will be able to access the bean via the Spring framework itself.</p>

<p>The definition of dependencies in this way makes unit testing a
breeze: simply define an XML file for your mock objects, replacing your
normal XML file, and away you go.</p>

<p>Perhaps the main advantage of Setter Injection is that application
code is not tied to the container in any way, but this is also a
downside — it's not immediately clear how this <code>JDBCDataManger</code> component relates to everything else. It almost seems as though the <code>DataSource</code> is being magically passed to the <code>JDBCDataManger</code>,
as the dependency management is being done outside of the Java code.
Another disadvantage is that Spring requires getters and setters for
its dependency resolution. You have to expose properties that you might
perhaps not otherwise expose, potentially breaking data encapsulation
rules and, at best, making a class' interface more complex than is
needed. With Spring's metadata being described in XML, it cannot be
validated at compile time during normal Java compilation, meaning
issues with broken dependencies can only be spotted at runtime.
</p>

<h5 id="Constructor_Injection">Constructor Injection (Type 3)</h5>

<p>Constructor Injection is based around this principle of the "Good
Citizen." The Good Citizen pattern was introduced by Joshua Bloch, to
describe objects that, upon creation, are fully set up and valid to
use. In practice, this means that
objects should not need additional methods to be called on them after
instantiation in order to make them useable. The result is that you can
sure that once you've created such an object, it's fit to use. This
radically simplifies your code and reduces the need for defensive
coding checks, while at the same time making your code more defensive
as a whole. Such code is also very easy to test.</p>

<p>With Constructor Injection, you register an object with the
framework, specify the parameters to use (which can in turn be created
by the framework itself) and then just request an instance. The
components being registered just have to implement a constructor, which
can be used to inject the dependencies. Recently, Spring has introduced
support for this form of IoC, but we'll look instead at PicoContainer,
which has been built around this principle. Let's look at our <code>JDBCDataManger</code>, now recoded for use with a Constructor Injection framework:</p>

<pre><code>public class JDBCDataManger {<br>  private DataSource dataSource;<br>  <br>  public JDBCDataManger(DataSource dataSource) {<br>    this.dataSource = dataSource;<br>  }<br>  <br>  public void getData() {<br>      //use dataSource for something<br>  }<br>}</code></pre>

<p>Rather than using a configuration file, PicoContainer uses some good old-fashioned Java to glue everything 
together:</p>

<pre><code>//create a datasource bean<br>BasicDataSource dataSource = new BasicDataSource();<br>dataSource.setDriverClassName("com.mydb.jdbc.Driver");<br>dataSource.setUrl("jdbc:mysql://localhost:3306/mydb");<br>dataSource.setUsername("Bob");<br><br>//create the container<br>MutablePicoContainer pico = new DefaultPicoContainer();<br><br>//register components with container<br>ConstantParameter dataSourceParam =<br>    new ConstantParameter(dataSource);<br>String key = "DataManager";<br>Parameter[] params = {dataSourceParam};<br><br>/*<br> * Now each request for a DataManager will instantiate<br> * a JDBCDataManager object with our defined<br> * dataSource object<br> */<br>pico.registerComponentImplementation (key,<br>    JDBCDataManger.class,params);</code></pre>

<p>To get instances of the <code>JDBCDataManager</code> object, we just have to reference the class by its key:</p>

<pre><code>JDBCDataManger dm =<br>    (JDBCDataManger)pico.getComponentInstance(key);</code></pre>

<p>Like Setter Injection IoC, our application code (apart from the
Pico-specific configuration) is independent of the framework itself,
and also gives you the advantages inherited from the use of the Good
Citizen pattern. In addition, given that PicoContainer only requires a
constructor, we have to make much less provisioning for the use
of an IoC framework than with Setter Injection IoC.</p>

<p>Potential downsides with this approach are that using constructors to maintain the dependencies can become
more complex when using inheritance, and it can cause issues if you use your constructors for purposes other than 
simply initializing the object. (Which some do!)</p>

<h2 id="IoC_in_action">IoC in Action: The Data Access Object Pattern</h2>

<p>Currently, our <code>JDBCDataManger</code> class is using SQL to access our data. What if we wanted to access data 
via Hibernate, or JDO? We could replace the uses of <code>JDBCDataManger</code>
with a new class, but a more elegant solution would be to use the Data
Access Object (DAO) pattern. In brief, the DAO pattern defines a method
by which normal value objects are used to set and retrieve data (think
normal JavaBeans), and this access is done via an abstract Data Access
Object. (For those of you wishing to learn more on the DAO pattern,
Sun's <a href="http://java.sun.com/blueprints/corej2eepatterns/Patterns/DataAccessObject.html">Pattern Catalog</a> 
is a good place to start.) </p>

<p>Our existing <code>JDBCDataManger</code> will remain unchanged. We will add an <code>Interface</code> called <code>DataManager</code>, which will implement our data access methods. For the sake of argument, we'll also add a Hibernate implementation, <code>HibernateDataManager</code>. Both <code>JDBCDataManger</code> and 
<code>HibernateDataManager</code> become Data Access Objects.  </p>

<p>Assuming we were already using IoC, changing which DAO to use is a
breeze. Assuming we use Spring with the code above, we can use
Hibernate instead of JDBC by simply changing the XML config to resolve
to the <code>HibernateDataManager</code> rather than the <code>JDBCDataManger</code> class. Likewise for PicoContainer: we just register the <code>HibernateDataManager</code> class instead of the <code>JDBCDataManger</code>.
When switching between DAO implementations, our application code will remain unchanged, assuming they are just 
expecting the <code>DataManager</code> interface rather than the <code>JDBCDataManger</code> implementation. </p>

<p>By using a DAO interface with two implementations, we are combining the DAO pattern with the 
<a href="http://www.developer.com/java/other/article.php/626001">Abstract Factory pattern</a>.
In effect, the IoC frameworks are undertaking the role of the factory
itself. Using such a pattern during development makes moving to another
persistence mechanism very easy indeed, and can be of great use if your
development environment uses a slightly different setup than your
release environment. Both implementations of the <code>DataManager</code> can be in the same codebase, and switching between them is trivial.</p>

<h2 id="Spring_vs_PicoContainer">Spring Vs. PicoContainer</h2>

<p>PicoContainer and Spring differ little in the amount of work required to 
set up your IoC bindings. Spring can be configured either by an XML configuration 
file or directly in Java, whereas PicoContainer requires a Java binding
(although the PicoExtras project does provide XML configuration support). I am rapidly 
coming to the conclusion that XML configuration files are becoming overused 
(and as someone has recently noted, all of these different configuration files are 
almost becoming new languages in their own right), although which approach is better is very much a matter of
personal taste. Given that you may require multiple configurations 
(say, one for development, another for release), an XML-based system may
be preferable, if only for configuration management issues.</p>

<p>Both are fairly "light" frameworks — they work well with other
frameworks and have the added advantage of not tying you to them.
PicoContainer is by far the smaller of the two; it sticks to the job of
being an IoC framework and
doesn't provide many supporting classes for working with external
products
like Hibernate. It is also worth noting that Spring is not just an IoC
framework: it also provides web application and AOP frameworks, as well
as some general support classes, which adds significantly to the size
of the library. Personally, I found Spring's web application framework
very flexible. However, it does seem to require more in the way of
configuration than a framework such as Struts, and yet doesn't have as
rich a set of supporting classes.
In addition, the AOP features are still being developed, and you may
not find it as fully featured as "pure" AOP frameworks such as
AspectWerkz or AspectJ.</p>

<p>If you are going to use the additional supporting classes provided by Spring, then 
you'll find it a good choice. If, however, you are happy to implement these 
yourself (or rely on external projects to provide them) then Pico's small footprint 
might be a deciding factor. Both support Constructor Injection IoC, but only Spring supports
Setter Injection -- if you prefer setter injection to constructor injection, then Spring is the obvious choice.</p>

<h2 id="Conclusion">Conclusion</h2>

<p>Hopefully, I have shown that by using IoC in your application that you can end 
up with neater, more flexible code. Both Spring and PicoContainer can be 
easily introduced into existing projects as part of ongoing refactoring work, and
their introduction can further aid future refactoring work. Those adopting IoC from
project inception will find their application code has better defined inter-component
relationships, and will be more flexible and easier to test.</p>

<p><em><a href="http://today.java.net/pub/au/85">Sam Newman</a> is a Java programmer.  Check out his blog at <a href="http://www.magpiebrain.com/">magpiebrain.com</a>.</em></p>]]></description>
</item><item>
<title><![CDATA[使用J2SE API读取Properties文件的六种方法]]></title>
<link>http://blogger.org.cn/blog/more.asp?name=java2guru&amp;id=14271</link>
<author>java2guru</author>
<pubDate>2006-5-11 13:56:56</pubDate>
<description><![CDATA[<a>来源: </a><a href="http://tech.163.com/06/0407/09/2E3J5B150009159T.html#" target="_blank">赛迪博客</a><a><br><br>1。使用java.util.Properties类的load()方法 <br>示例： <br><code>InputStream in = lnew BufferedInputStream(new FileInputStream(name)); <br>Properties p = new Properties(); <br>p.load(in); <br></code><br>2。使用java.util.ResourceBundle类的getBundle()方法 <br>示例：<br><code>ResourceBundle rb = ResourceBundle.getBundle(name, Locale.getDefault()); <br></code><br>3。使用java.util.PropertyResourceBundle类的构造函数 <br>示例： <br><code>InputStream in = new BufferedInputStream(new FileInputStream(name)); <br>ResourceBundle rb = new PropertyResourceBundle(in); <br></code><br>4。使用class变量的getResourceAsStream()方法 <br>示例： <br><code>InputStream in = JProperties.class.getResourceAsStream(name); <br>Properties p = new Properties(); <br>p.load(in); <br></code><br>5。使用class.getClassLoader()所得到的java.lang.ClassLoader的getResourceAsStream()方法 <br>示例： <br><code>InputStream in = JProperties.class.getClassLoader().getResourceAsStream(name); <br>Properties p = new Properties(); <br>p.load(in); <br></code><br>6。使用java.lang.ClassLoader类的getSystemResourceAsStream()静态方法 <br>示例： <br><code>InputStream in = ClassLoader.getSystemResourceAsStream(name); <br>Properties p = new Properties(); <br>p.load(in); <br></code><br>补充 <br><br>Servlet中可以使用javax.servlet.ServletContext的getResourceAsStream()方法 <br>示例：<br><code>InputStream in = context.getResourceAsStream(path); <br>Properties p = new Properties(); <br>p.load(in); <br></code></a>]]></description>
</item><item>
<title><![CDATA[Installation/PowerPC]]></title>
<link>http://blogger.org.cn/blog/more.asp?name=java2guru&amp;id=14238</link>
<author>java2guru</author>
<pubDate>2006-5-10 13:42:08</pubDate>
<description><![CDATA[<a>原文出处：</a><a class="https" href="https://wiki.ubuntu.com/Installation/PowerPC">UbuntuWiki</a> <span class="anchor" id="line-8"></span><span class="anchor" id="line-9"></span><p class="line879">原文作者：<a class="nonexistent nonexistent" href="http://wiki.ubuntu.org.cn/UbuntuWiki">UbuntuWiki</a> <span class="anchor" id="line-10"></span></p><span class="anchor" id="line-11"></span><p class="line886">授权许可：GNU General Public License <span class="anchor" id="line-12"></span></p><span class="anchor" id="line-13"></span><p class="line879">翻译／修改人员：<a href="http://wiki.ubuntu.org.cn/MillenniumDark">MillenniumDark</a> <span class="anchor" id="line-14"></span></p><span class="anchor" id="line-15"></span><p class="line886">校对人员： <span class="anchor" id="line-16"></span></p><span class="anchor" id="line-17"></span><p class="line886">适用版本：Ubuntu 5.10 <span class="anchor" id="line-18"></span></p><span class="anchor" id="line-19"></span><p class="line886">文章状态：完成。 <span class="anchor" id="line-20"></span></p><hr><p class="line886"> <span class="anchor" id="line-21"></span></p><span class="anchor" id="line-22"></span>
<h1 id="head-e1b4e3437e670e8ab723d1c45afe07b89b09f631">原文</h1>
<span class="anchor" id="line-23"></span><span class="anchor" id="line-24"></span><p class="line879">注意： 以下内容可能已经过时，并经过修改，请访问<a class="https" href="https://wiki.ubuntu.com/Installation/PowerPC">UbuntuWiki</a>获取最新的原文。 <span class="anchor" id="line-25"></span></p><span class="anchor" id="line-26"></span><p class="line903"><strong>This
document describes how to install Ubuntu 5.10 "Breezy Badger" for the
IBM/Motorola PowerPC and Apple Power Mac ("powerpc"). </strong> <span class="anchor" id="line-27"></span></p><span class="anchor" id="line-28"></span><p class="line903"><strong>本文档描述了如何在IBM/Motorola PowerPC和Apple Power Mac ("powerpc")上安装Ubuntu 5.10 "Breezy Badger"。</strong> <span class="anchor" id="line-29"></span></p><span class="anchor" id="line-30"></span><p class="line886">This How To is free; you may redistribute it and/or modify it under the terms of the GNU General Public License. <span class="anchor" id="line-31"></span></p><span class="anchor" id="line-32"></span><p class="line886">本指南是自由的；你可以再分发或修改它，但要遵循GNU公共许可证（GNU General Public License）。 <span class="anchor" id="line-33"></span></p><span class="anchor" id="line-34"></span>
<h2 id="head-0738366d93288320647706bea052d09f99efd83e">1. Booting the installer</h2>
<span class="anchor" id="line-35"></span><span class="anchor" id="line-36"></span>
<h2 id="head-174532e2d9dcc48e003643d0783c12a8e7575be5">2. 引导安装程序</h2>
<span class="anchor" id="line-37"></span><span class="anchor" id="line-38"></span><ul><li><p class="line879">Download the CD image from <a class="http" href="http://www.ubuntulinux.org/download/">http://www.ubuntulinux.org/download/</a>
and burn it to a CD. Use the Disk Utility (or similar CD burner) to
burn the CD - don't just open up the .iso file into the Finder and burn
from there as this won't work! <span class="anchor" id="line-39"></span></p><span class="anchor" id="line-40"></span></li><li class="gap"><p class="line886">从http://www.ubuntulinux.org/download/下载CD镜像并烧录CD。 使用Disk Utility（或类似的CD烧录程序）烧录CD －－不要仅仅在Finder打开.iso文件并在里面烧录，这样不管用！ <span class="anchor" id="line-41"></span></p><span class="anchor" id="line-42"></span></li></ul><p class="line886">PowerPC <span class="anchor" id="line-43"></span></p><span class="anchor" id="line-44"></span><ul><li><p class="line879">To boot the CD on "<a href="http://wiki.ubuntu.org.cn/NewWorld">NewWorld</a>"
Power Macs (from the blue-and-white G3 onwards), hold down the c key
when booting your computer, or else Command-Option-Shift-Delete. "<a class="nonexistent nonexistent" href="http://wiki.ubuntu.org.cn/OldWorld">OldWorld</a>" Power Macs (beige G3 and older) will not boot from CD and are not currently supported by Ubuntu. <span class="anchor" id="line-45"></span></p><span class="anchor" id="line-46"></span></li></ul><p class="line886">PowerPC <span class="anchor" id="line-47"></span></p><span class="anchor" id="line-48"></span><ul><li><p class="line879">当启动你的电脑时，按住c键，或者Command-Option-Shift-Delete，以便在"<a href="http://wiki.ubuntu.org.cn/NewWorld">NewWorld</a>" Power Mac（从蓝白色的G3机往后的机子）引导CD，"<a class="nonexistent nonexistent" href="http://wiki.ubuntu.org.cn/OldWorld">OldWorld</a>" Power Mac（beige G3及更早的机子）无法从CD引导，目前不被Ubuntu支持。 <span class="anchor" id="line-49"></span></p><span class="anchor" id="line-50"></span></li></ul><p class="line886">A netboot install is also available, but for now it is outside the scope of this document. <span class="anchor" id="line-51"></span></p><span class="anchor" id="line-52"></span><p class="line886">网络引导安装是可用的，但是，就目前而言，这在本文档的范围之外。 <span class="anchor" id="line-53"></span></p><span class="anchor" id="line-54"></span><ul><li><p class="line886">Once the installer starts, you will be greeted with a simple boot menu.  <span class="anchor" id="line-55"></span></p><span class="anchor" id="line-56"></span></li><li class="gap"><p class="line886">一旦安装程序启动，你将见到一个简单的引导菜单。 <span class="anchor" id="line-57"></span></p><span class="anchor" id="line-58"></span></li><li class="gap"><p class="line886">Press Enter to boot, or use one of the other boot methods described on this screen. <span class="anchor" id="line-59"></span></p><span class="anchor" id="line-60"></span></li><li class="gap"><p class="line886">按下Enter来进行引导，或者使用屏幕上描述的其他引导方法。 <span class="anchor" id="line-61"></span></p><span class="anchor" id="line-62"></span></li></ul>
<h2 id="head-8ab9bafc5460aff33542cc696229ed37519eb555">3. First stage of installation</h2>
<span class="anchor" id="line-63"></span><span class="anchor" id="line-64"></span>
<h2 id="head-dc1a3704ffd9f504277a58836eee2164426130ea">4. 安装的第一阶段</h2>
<span class="anchor" id="line-65"></span><span class="anchor" id="line-66"></span><p class="line886">After a few moments, you will be asked to select your language. <span class="anchor" id="line-67"></span></p><span class="anchor" id="line-68"></span><p class="line886">过了一段时间，会让你选择语言。 <span class="anchor" id="line-69"></span></p><span class="anchor" id="line-70"></span><ul><li><p class="line886">Use the arrow keys to pick a language and press Enter to continue. <span class="anchor" id="line-71"></span></p><span class="anchor" id="line-72"></span></li><li class="gap"><p class="line886">使用箭头箭选择一种语言，按Enter继续。 <span class="anchor" id="line-73"></span></p><span class="anchor" id="line-74"></span></li><li class="gap"><p class="line886">Next
you'll be asked to select a country, with the choices including
countries where your language is spoken. If it's not on the short list,
choose "other" to see a list of all the countries in the world. <span class="anchor" id="line-75"></span></p><span class="anchor" id="line-76"></span></li><li class="gap"><p class="line886">接着会让你选择国家，提供的选项是使用你的语言的国家。如果其中没有你的国家，选择other（其他），你将会看到包含世界上所有国家的列表。 <span class="anchor" id="line-77"></span></p><span class="anchor" id="line-78"></span></li><li class="gap"><p class="line886">You will be asked to choose your keyboard layout. <span class="anchor" id="line-79"></span></p><span class="anchor" id="line-80"></span></li><li class="gap"><p class="line886">将让你选择键盘布局。 <span class="anchor" id="line-81"></span></p><span class="anchor" id="line-82"></span></li><li class="gap"><p class="line886">Now sit back while the installer detects some of your hardware, and loads the rest of itself from the CD. <span class="anchor" id="line-83"></span></p><span class="anchor" id="line-84"></span></li><li class="gap"><p class="line886">现在你可以休息一下，安装程序将探测你的一些硬件，并从CD装载它的剩余部分。 <span class="anchor" id="line-85"></span></p><span class="anchor" id="line-86"></span></li><li class="gap"><p class="line886">Next
the installer will try to detect your network hardware and set up
networking by DHCP. If you are not on a network or do not have DHCP,
you will be given the opportunity to configure the network manually. <span class="anchor" id="line-87"></span></p><span class="anchor" id="line-88"></span></li><li class="gap"><p class="line886">接着安装程序将尝试探测你的网络硬件并通过DHCP设置网络。如果你未联网或没有DHCP，你需要手动配置网络。 <span class="anchor" id="line-89"></span></p><span class="anchor" id="line-90"></span></li></ul>
<h3 id="head-c6b01f11190fca1b9de2ff10686accd74d5e77f5">4.1. Partition your disk</h3>
<span class="anchor" id="line-91"></span><span class="anchor" id="line-92"></span>
<h3 id="head-c6ff186a0ab2684f1076583db6303558aa965d24">4.2. 分区</h3>
<span class="anchor" id="line-93"></span><span class="anchor" id="line-94"></span><ul><li><p class="line886">First
you will be given the opportunity to erase and automatically partition
an entire disk. This is recommended for new users, but if you have any
valuable data on the disk, be sure to back it up first, as it will be
erased! <span class="anchor" id="line-95"></span></p><span class="anchor" id="line-96"></span></li><li class="gap"><p class="line886">第一个选项是擦除整个硬盘，然后自动分区。建议新手选这一项。不过，如果你的硬盘上有有价值的数据，一定要先备份，因为它们会被擦去。 <span class="anchor" id="line-97"></span></p><span class="anchor" id="line-98"></span></li><li class="gap"><p class="line886">If
you are dual booting with Mac OSX and Ubuntu, you should already have
Mac OSX installed. This way the yaboot configuration will see the OSX
install and automatically add it to the boot map options when you
startup. To change the default OS see /etc/yaboot.conf. <span class="anchor" id="line-99"></span></p><span class="anchor" id="line-100"></span></li><li class="gap"><p class="line879">如果你打算Mac OSX和Ubuntu双启动，你应该已经安装了Mac OSX。这样的话，<a href="http://wiki.ubuntu.org.cn/yaboot">yaboot</a>配置程序会检测到OSX安装，并自动将其加入boot map的选项里。要改变默认的操作，看看/etc/yaboot.conf。 <span class="anchor" id="line-101"></span></p><span class="anchor" id="line-102"></span></li><li class="gap"><p class="line886">If
you do not want to edit the partition table manually, and you are dual
booting, select "use the largest continous free space."(Given that this
is where you want ubuntu to be installed.) This will automatically
partition the drive for you leaving your other OS untouched. (This also
assumes you have your alternate OS already installed, and a large area
of free space in which to install Ubuntu. <span class="anchor" id="line-103"></span></p><span class="anchor" id="line-104"></span></li><li class="gap"><p class="line886">若
不想手工修改分区表，同时希望双启动，选择use the largest continous free
space（使用最大的连续空闲空间），（前提是你想把Ubuntu装在这儿。）这将自动分区，不会影响其他操作系统。（这里同样假设你调整了已经安装的
操作系统，空出一大块空闲空间安装Ubuntu。） <span class="anchor" id="line-105"></span></p><span class="anchor" id="line-106"></span></li><li class="gap"><p class="line886">If
you do not want to erase an entire disk, or if you want to customize
the partition layout, choose "Manually edit partition table" from the
menu, and the next screen will show you your partition table, how the
partitions will be formatted, and where they will be mounted. <span class="anchor" id="line-107"></span></p><span class="anchor" id="line-108"></span></li><li class="gap"><p class="line886">如不想擦除整块硬盘，或打算定制分区布局，在菜单中选择Manually edit partition table（手工编辑分区表）。 <span class="anchor" id="line-109"></span></p><span class="anchor" id="line-110"></span><span class="anchor" id="line-111"></span></li></ul><p class="line886">接下的安装过程和在x86系统上的安装基本相同，请参考在x86系统上安装Ubuntu的文档。 <span class="anchor" id="line-112"></span></p><span class="anchor" id="bottom"></span><p id="pageinfo" class="info" dir="ltr" lang="en">UbuntuChina Wiki: UbuntuOnPPC  (last edited 2006-05-03 16:47:13 by <span title="MillenniumDark @ 221.6.72.21[221.6.72.21]"><a href="http://wiki.ubuntu.org.cn/MillenniumDark" title="MillenniumDark @ 221.6.72.21[221.6.72.21]">MillenniumDark</a></span>)</p>]]></description>
</item><item>
<title><![CDATA[ubuntu英文环境下激活中文输入法 - 作者： huihoo-Allen]]></title>
<link>http://blogger.org.cn/blog/more.asp?name=java2guru&amp;id=13254</link>
<author>java2guru</author>
<pubDate>2006-4-7 9:19:18</pubDate>
<description><![CDATA[<a>我安装配置ubuntu是按照 www.ubuntu.org.cn 里的“快速设置指南”来的。<br>
按照它的方法配置的中文支持和fcitx。<br>
<br>
想实现英文环境中文输入时遇到了困难。后来经过很多次尝试发现问题出现在LC_ALL=**上。<br>
现在说一下我实现的方法：<br>
<br>
如果你全部按照“快速设置指南”的话完成后是中文界面。<br>
然后进行以下修改：<br>
<br>
1: sudo dpkg-reconfigure locales<br>
改默认locale为en_US.UTF-8，这个时候注销重启x的话应该还是中文界面。<br>
<br>
2: sudo gedit /etc/environment<br>
<br>
将其改为如下：<br>
LC_CTYPE="zh_CN.UTF-8"<br>
LC_NUMERIC="en_US.UTF-8"<br>
LC_TIME="en_US.UTF-8"<br>
LC_COLLATE="en_US.UTF-8"<br>
LC_MONETARY="en_US.UTF-8"<br>
LC_MESSAGES="en_US.UTF-8"<br>
LC_PAPER="en_US.UTF-8"<br>
LC_NAME="en_US.UTF-8"<br>
LC_ADDRESS="en_US.UTF-8"<br>
LC_TELEPHONE="en_US.UTF-8"<br>
LC_MEASUREMENT="en_US.UTF-8"<br>
LC_IDENTIFICATION="en_US.UTF-8"<br>
LC_ALL=<br>
LANGUAGE="zh_CN:zh:en_US:en"<br>
GST_ID3_TAG_ENCODING=GBK<br>
LANG=zh_CN.UTF-8<br>
<br>
很长，没办法，不能LC_ALL定义只能一个个来。<br>
<br>
3： 注销，重新登陆，登陆时选择language为en_US。并设为default。<br>
<br>
这样应该可以了。<br>
<br>
from linuxsir.org</a>]]></description>
</item><item>
<title><![CDATA[ReactOS - windows-like operation system]]></title>
<link>http://blogger.org.cn/blog/more.asp?name=java2guru&amp;id=12992</link>
<author>java2guru</author>
<pubDate>2006-3-29 9:18:18</pubDate>
<description><![CDATA[<a href="http://www.reactos.org">ReactOS</a>目标是做一个与windows兼容的免费OS，最新版本是0.29<br><br>]]></description>
</item><item>
<title><![CDATA[前些天看完了petstore的代码，最近研究roller]]></title>
<link>http://blogger.org.cn/blog/more.asp?name=java2guru&amp;id=12881</link>
<author>java2guru</author>
<pubDate>2006-3-24 19:05:38</pubDate>
<description><![CDATA[roller是一个开源的blog项目，象jroller及weblog.java.net都使用roller。但是，它的缓存似乎有些问题。]]></description>
</item><item>
<title><![CDATA[本年度的学习计划]]></title>
<link>http://blogger.org.cn/blog/more.asp?name=java2guru&amp;id=12197</link>
<author>java2guru</author>
<pubDate>2006-3-3 18:37:26</pubDate>
<description><![CDATA[1。数据结构和算法<br>2。设计模式<br>3。架构设计]]></description>
</item><item>
<title><![CDATA[自动挂载 windows 分区 --- http://www.ubuntu.org.cn]]></title>
<link>http://blogger.org.cn/blog/more.asp?name=java2guru&amp;id=12007</link>
<author>java2guru</author>
<pubDate>2006-2-24 19:43:02</pubDate>
<description><![CDATA[<div class="documentDescription">自动挂载 windows 分区</div>


    执行下列命令， 编辑挂载脚本 autowinfs.<br>

<br>

<pre class="terminal">sudo gedit /usr/sbin/autowinfs</pre>
 <br>
<br>
复制粘贴以下引用的内容，<br>
<br>
保存文件, 退出。<br>


<pre class="file">#!/bin/sh<br>#<br>#autowinfs    auto mount windows disks<br>#<br># Copyright (c) 2005   Jiahua Huang &lt;jhuangjiahua@gmail.com&gt;<br>#License: GPLv2<br><br>#<br>#  /usr/bin/sutowinfs<br>#  用来自动挂载机器上的 Windows 分区 ， 并写入 /etc/fstab<br>#   五  2月 18 14:06:12 CST 2005<br><br>mkdir  -p  /windows/<br>rmdir   /windows/*   1&gt; /dev/null<br>grep  -v  '/windows/'  /etc/fstab  &gt;  /etc/fstab.swp<br><br><br>#  本脚本用于 UTF-8 的 Locale 下 <br>#  单独的 fdisk  -l  不能列出分区的情况很少了 ， 所以把  /dev/[hs]d[a-z]  去掉<br>## fdisk  -l  /dev/[hs]d[a-z]  |  grep   -E  'FAT|NTFS'  | cut -d' ' -f1    |   cut -d/ -f3  |   while read WDISKS<br># 查找 NTFS 分区  ， 新内核的 auto 好像有点问题 ， 所以现在把  NTFS 和 VFST 分开来<br><br>fdisk  -l /dev/[hs]d[a-z]  |  grep     'NTFS'  | cut -d' ' -f1    |   cut -d/ -f3  |   while read WDISKS<br>     do echo  "/dev/$WDISKS  /windows/$WDISKS  ntfs  auto,user,nls=utf8,umask=0   0 0"    &gt;&gt;  /etc/fstab.swp<br>     mkdir  "/windows/$WDISKS"<br>done<br><br>fdisk  -l /dev/[hs]d[a-z]  |  grep     'FAT'  | cut -d' ' -f1    |   cut -d/ -f3  |   while read WDISKS<br>     do echo  "/dev/$WDISKS  /windows/$WDISKS  vfat  auto,user,utf8,umask=0   0 0"    &gt;&gt;  /etc/fstab.swp<br>     mkdir  "/windows/$WDISKS"<br>done<br><br>mv   /etc/fstab.swp    /etc/fstab<br>mount   -a<br>exit  0<br></pre>


再运行命令:<br>

<pre class="terminal">sudo chmod +x /usr/sbin/autowinfs<br>sudo /usr/sbin/autowinfs<br></pre>

就可以了，Windows分区将挂载在 /windows/ 下<br>
<br>

]]></description>
</item>
</channel>
</rss>