<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title>椰子Java</title> 
<link>http:///index.php</link> 
<description>       我从事软件行业已经9年啦，2001毕业以后一直在成都从事软件开发工作，从事过电信行业相关软件开发和航空行业相关软件开发工作，2007回到了海南，回到了我的故乡。                                                                                                                                我经历了喜欢--狂热--疲倦--坚持--深爱上我的行业，因为它最体现我的价值。我对它了解越深就越能感觉到它的奇妙性，我可以在它虚拟出来的世界里任意翱翔。。。</description> 
<language>zh-cn</language> 
<copyright>Powered by Bo-blog 2.0.2 sp1</copyright>
<item>
<link>http:///read.php?1075</link>
<title>Apache+ActiveMQ教程</title> 
<author>fubin &lt;yonghe169@163.com&gt;</author>
<category>Java理论及专业研究</category>
<pubDate>Mon, 15 Feb 2010 14:14:16 +0000</pubDate> 
<guid>http:///read.php?1075</guid> 
<description>
<![CDATA[ 
	这个文件只能在登入之后下载。请先 <a href="login.php?job=register">注册</a> 或 <a href="login.php">登入</a>
  ]]> 
</description>
</item><item>
<link>http:///read.php?990</link>
<title>Java的Json taglib</title> 
<author>fubin &lt;yonghe169@163.com&gt;</author>
<category>Java理论及专业研究</category>
<pubDate>Thu, 19 Mar 2009 04:46:05 +0000</pubDate> 
<guid>http:///read.php?990</guid> 
<description>
<![CDATA[ 
	<a href="attachment/200903/1237524432_0.rar">点击这里下载文件</a>
  ]]> 
</description>
</item><item>
<link>http:///read.php?874</link>
<title>Vector 还是ArrayList――哪一个更好，为什么？(转载于JavaWord)</title> 
<author>fubin &lt;yonghe169@163.com&gt;</author>
<category>Java理论及专业研究</category>
<pubDate>Wed, 27 Aug 2008 01:11:56 +0000</pubDate> 
<guid>http:///read.php?874</guid> 
<description>
<![CDATA[ 
	<br/>要回答这个问题不能一概而论，有时候使用Vector比较好；有时是ArrayList，有时候这两个都不是最好的选择。你别指望能够获得一个简单肯定答案，因为这要看你用它们干什么。下面有4个要考虑的因素：<br/>l &nbsp; &nbsp; &nbsp; &nbsp;API<br/>l &nbsp; &nbsp; &nbsp; &nbsp;同步处理<br/>l &nbsp; &nbsp; &nbsp; &nbsp;数据增长性<br/>l &nbsp; &nbsp; &nbsp; &nbsp;使用模式<br/>下面针对这4个方面进行一一探讨<br/>API <br/>在由Ken Arnold等编著的《Java Programming Language》(Addison-Wesley, June 2000)一书中有这样的描述，Vector类似于ArrayList.。所有从API的角度来看这两个类非常相似。但他们之间也还是有一些主要的区别的。<br/><br/>[b]同步性<br/>Vector是同步的。这个类中的一些方法保证了Vector中的对象是线程安全的。而ArrayList则是异步的，因此ArrayList中的对象并不是线程安全的。因为同步的要求会影响执行的效率，所以如果你不需要线程安全的集合那么使用ArrayList是一个很好的选择，这样可以避免由于同步带来的不必要的性能开销。<br/>数据增长<br/>从内部实现机制来讲ArrayList和Vector都是使用数组(Array)来控制集合中的对象。当你向这两种类型中增加元素的时候，如果元素的数目超出了内部数组目前的长度它们都需要扩展内部数组的长度，Vector缺省情况下自动增长原来一倍的数组长度，ArrayList是原来的50%,所以最后你获得的这个集合所占的空间总是比你实际需要的要大。所以如果你要在集合中保存大量的数据那么使用Vector有一些优势，因为你可以通过设置集合的初始化大小来避免不必要的资源开销。<br/>使用模式<br/>在ArrayList和Vector中，从一个指定的位置（通过索引）查找数据或是在集合的末尾增加、移除一个元素所花费的时间是一样的，这个时间我们用O(1)表示。但是，如果在集合的其他位置增加或移除元素那么花费的时间会呈线形增长：O(n-i)，其中n代表集合中元素的个数，i代表元素增加或移除元素的索引位置。为什么会这样呢？以为在进行上述操作的时候集合中第i和第i个元素之后的所有元素都要执行位移的操作。这一切意味着什么呢？<br/>这意味着，你只是查找特定位置的元素或只在集合的末端增加、移除元素，那么使用Vector或ArrayList都可以。如果是其他操作，你最好选择其他的集合操作类。比如，LinkList集合类在增加或移除集合中任何位置的元素所花费的时间都是一样的—O(1)，但它在索引一个元素的使用缺比较慢－O(i),其中i是索引的位置.使用ArrayList也很容易，因为你可以简单的使用索引来代替创建iterator对象的操作。LinkList也会为每个插入的元素创建对象，所有你要明白它也会带来额外的开销。<br/>最后，在《Practical Java》一书中Peter Haggar建议使用一个简单的数组（Array）来代替Vector或ArrayList。尤其是对于执行效率要求高的程序更应如此。因为使用数组(Array)避免了同步、额外的方法调用和不必要的重新分配空间的操作。
  ]]> 
</description>
</item><item>
<link>http:///read.php?844</link>
<title>propedit4.8.2</title> 
<author>fubin &lt;yonghe169@163.com&gt;</author>
<category>Java理论及专业研究</category>
<pubDate>Thu, 03 Jul 2008 03:47:12 +0000</pubDate> 
<guid>http:///read.php?844</guid> 
<description>
<![CDATA[ 
	这个文件只能在登入之后下载。请先 <a href="login.php?job=register">注册</a> 或 <a href="login.php">登入</a><br/><br/><br/><br/>Eclipse属性文件编辑插件。<br/><br/>修改：D:&#92;Program Files&#92;MyEclipse 5.5 GA&#92;eclipse&#92;links&#92;com.genuitec.eclipse.MyEclipse.link文件<br/><br/>假如配置路径（注意windows目录是双&#92;&#92;）：path=d:&#92;&#92;Program Files&#92;&#92;MyEclipse 5.5 GA&#92;&#92;propedit4.8.2
  ]]> 
</description>
</item><item>
<link>http:///read.php?767</link>
<title>开源的异步处理模块（Beans Binding）</title> 
<author>fubin &lt;yonghe169@163.com&gt;</author>
<category>Java理论及专业研究</category>
<pubDate>Wed, 26 Mar 2008 15:54:58 +0000</pubDate> 
<guid>http:///read.php?767</guid> 
<description>
<![CDATA[ 
	Beans Binding，这是一个异步处理模块的处理模块，效率很高，也很安全。<br/><br/>开源工程地址：https://beansbinding.dev.java.net/<br/><br/>我把用源代码做了一个测试工程，相关的文档请阅读<br/>http://today.java.net/pub/a/2008/03/20/synchronizing-properties-with-beans-binding.html<br/><br/>这个文件只能在登入之后下载。请先 <a href="login.php?job=register">注册</a> 或 <a href="login.php">登入</a><br/>
  ]]> 
</description>
</item><item>
<link>http:///read.php?718</link>
<title>ThreadLocal实现session唯一（转载）</title> 
<author>fubin &lt;yonghe169@163.com&gt;</author>
<category>Java理论及专业研究</category>
<pubDate>Tue, 15 Jan 2008 06:01:45 +0000</pubDate> 
<guid>http:///read.php?718</guid> 
<description>
<![CDATA[ 
	 &nbsp; &nbsp; 在利用Hibernate开发DAO模块时，我们和Session打的交道最多，所以如何合理的管理Session，避免Session的频繁创建和销毁，对于提高系统的性能来说是非常重要的，以往是通过eclipse的插件来自动完成这些代码的，当然效果是不错的，但是总是觉得不爽(没有读懂那些冗长的代码)，所以现在打算自己实现Session管理的代码。我们知道Session是由SessionFactory负责创建的，而SessionFactory的实现是线程安全的，多个并发的线程可以同时访问一个SessionFactory并从中获取Session实例，那么Session是否是线程安全的呢？很遗憾，答案是否定的。Session中包含了数据库操作相关的状态信息，那么说如果多个线程同时使用一个Session实例进行CRUD，就很有可能导致数据存取的混乱，你能够想像那些你根本不能预测执行顺序的线程对你的一条记录进行操作的情形吗？<br/> &nbsp; &nbsp; &nbsp;在Session的众多管理方案中，我们今天来认识一种名为ThreadLocal模式的解决方案。<br/> &nbsp; &nbsp; &nbsp;早在Java1.2推出之时，Java平台中就引入了一个新的支持：java.lang.ThreadLocal，给我们在编写多线程程序时提供了一种新的选择。ThreadLocal是什么呢？其实ThreadLocal并非是一个线程的本地实现版本，它并不是一个Thread，而是thread local variable(线程局部变量)。也许把它命名为ThreadLocalVar更加合适。线程局部变量(ThreadLocal)其实的功用非常简单，就是为每一个使用该变量的线程都提供一个变量值的副本，是每一个线程都可以独立地改变自己的副本，而不会和其它线程的副本冲突。从线程的角度看，就好像每一个线程都完全拥有一个该变量。<br/> &nbsp; &nbsp; &nbsp;ThreadLocal是如何做到为每一个线程维护变量的副本的呢？其实实现的思路很简单，在ThreadLocal类中有一个Map，用于存储每一个线程的变量的副本。比如下面的示例实现(为了简单，没有考虑集合的泛型)： <br/><br/>public class ThreadLocal { &nbsp; &nbsp;<br/>　 &nbsp; &nbsp;private Map values = Collections.synchronizedMap(new HashMap()); &nbsp; &nbsp;<br/>　 &nbsp; &nbsp;public Object get() { &nbsp; &nbsp;<br/>　　 &nbsp; &nbsp; &nbsp;Thread currentThread = Thread.currentThread(); &nbsp; &nbsp; <br/>　 &nbsp; &nbsp; 　 Object result = values.get(currentThread); &nbsp; &nbsp; <br/>　　 &nbsp; &nbsp; &nbsp;if(result == null&&!values.containsKey(currentThread)) { &nbsp; &nbsp;<br/>　　　 &nbsp; &nbsp; &nbsp; &nbsp;result = initialValue(); &nbsp; &nbsp;<br/>　　　 &nbsp; &nbsp; &nbsp; &nbsp;values.put(currentThread, result); &nbsp; &nbsp; <br/>　　 &nbsp; &nbsp; &nbsp;} &nbsp; &nbsp;<br/>　　 &nbsp; &nbsp; &nbsp;return result; &nbsp; &nbsp; <br/>　 &nbsp; &nbsp;} &nbsp; &nbsp;<br/>　 &nbsp; &nbsp;public void set(Object newValue) { &nbsp; &nbsp;<br/>　　 &nbsp; &nbsp; &nbsp;values.put(Thread.currentThread(), newValue); &nbsp; &nbsp;<br/>　 &nbsp; &nbsp;} &nbsp; &nbsp;<br/> &nbsp; 　 public Object initialValue() { &nbsp; &nbsp;<br/>　　 &nbsp; &nbsp; &nbsp;return null; &nbsp; &nbsp; <br/>　 &nbsp; &nbsp;} &nbsp; &nbsp;<br/>} &nbsp; &nbsp;<br/><br/> &nbsp; &nbsp; &nbsp;那麽具体如何利用ThreadLocal来管理Session呢？Hibernate官方文档手册的示例之中，提供了一个通过ThreadLocal维护Session的好榜样：<br/><br/>public class HibernateUtil { &nbsp; &nbsp;<br/> &nbsp; &nbsp; &nbsp; public static final SessionFactory sessionFactory; &nbsp; &nbsp;<br/> &nbsp; &nbsp; &nbsp; static { &nbsp; &nbsp;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; try { &nbsp; &nbsp;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sessionFactory = new Configuration().configure() &nbsp; &nbsp;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .buildSessionFactory(); &nbsp; &nbsp;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } catch (Throwable ex) { &nbsp; &nbsp;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;throw new ExceptionInInitializerError(ex); &nbsp; &nbsp;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp;<br/> &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp;<br/> &nbsp; &nbsp; &nbsp; public static final ThreadLocal session = &nbsp; &nbsp; <br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;new ThreadLocal(); &nbsp; &nbsp;<br/> &nbsp; &nbsp; &nbsp; public static Session currentSession() throws HibernateException { &nbsp; &nbsp;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Session s = session.get(); &nbsp; &nbsp;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(s == null) { &nbsp; &nbsp;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; s = sessionFactory.openSession(); &nbsp; &nbsp;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; session.set(s); &nbsp; &nbsp;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return s; &nbsp; &nbsp;<br/> &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp;<br/> &nbsp; &nbsp; &nbsp; public static void closeSession() throws HibernateException { &nbsp; &nbsp;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Session s = session.get(); &nbsp; &nbsp;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if(s != null) { &nbsp; &nbsp;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;s.close(); &nbsp; &nbsp;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;} &nbsp; &nbsp;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;session.set(null); &nbsp; &nbsp;<br/> &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp;<br/>} &nbsp; <br/><br/> &nbsp; &nbsp; 只要借助上面的工具类获取Session实例，我们就可以实现线程范围内的Session共享，从而避免了线程中频繁的创建和销毁Session实例。当然，不要忘记在用完后关闭Session。<br/> &nbsp; &nbsp; 写到这里，想再多说一些，也许大多数时候我们的DAO并不会涉及到多线程的情形，比如我们不会将DAO的代码写在Servlet之中，那样不是良好的设计，我自己通常会在service层的代码里访问DAO的方法。但是我还是建议采用以上的工具类来管理Session，毕竟我们不能仅仅考虑今天为自己做什么，还应该考虑明天为自己做什么！<br/>
  ]]> 
</description>
</item><item>
<link>http:///read.php?715</link>
<title>取得标准的JavaBean所有的方法属性</title> 
<author>fubin &lt;yonghe169@163.com&gt;</author>
<category>Java理论及专业研究</category>
<pubDate>Fri, 11 Jan 2008 15:58:02 +0000</pubDate> 
<guid>http:///read.php?715</guid> 
<description>
<![CDATA[ 
	&nbsp;&nbsp;public static PropertyDescriptor[] getPropertyDescriptors(Class clazz) throws AppException {<br/>&nbsp;&nbsp;&nbsp;&nbsp;BeanInfo beanInfo = null;<br/>&nbsp;&nbsp;&nbsp;&nbsp;try {<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;beanInfo = Introspector.getBeanInfo(clazz);<br/>&nbsp;&nbsp;&nbsp;&nbsp;} catch (IntrospectionException e) {<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;throw new AppException("Can not get bean info!");<br/>&nbsp;&nbsp;&nbsp;&nbsp;}<br/>&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;return beanInfo.getPropertyDescriptors();<br/>&nbsp;&nbsp;}
  ]]> 
</description>
</item><item>
<link>http:///read.php?700</link>
<title>强烈建议使用的通用第三方库Apache Commons</title> 
<author>fubin &lt;yonghe169@163.com&gt;</author>
<category>Java理论及专业研究</category>
<pubDate>Sun, 23 Dec 2007 15:01:29 +0000</pubDate> 
<guid>http:///read.php?700</guid> 
<description>
<![CDATA[ 
	这个库给我们提供了非常多的基础功能。<br/>例如随机产生指定位数的方法：<br/><br/>import org.apache.commons.lang.RandomStringUtils;<br/>/**<br/> * <br/> * @author www.cujava.com<br/> * 产生随机数的方法。<br/> *<br/> */<br/>public class Test {<br/><br/> &nbsp;public static void main(String[] args) {<br/> &nbsp; &nbsp; System.out.print("动态的四位数字：");<br/> &nbsp; &nbsp; System.out.println(RandomStringUtils.randomNumeric(4));<br/> &nbsp;}<br/>}<br/><br/>以下是公用库：commons-lang-2.1.jar<br/><br/><a href="attachment/1198422040_0.rar">点击这里下载文件</a><br/><br/>http://commons.apache.org/ &nbsp; &nbsp;这是apache commons官方网站。<br/><br/>我个人建议，应该好好学习这个第三库，它是对Java基础库的非常好的补充。<br/>
  ]]> 
</description>
</item><item>
<link>http:///read.php?687</link>
<title>DWR详细练习代码(Free DWR code)</title> 
<author>fubin &lt;yonghe169@163.com&gt;</author>
<category>Java理论及专业研究</category>
<pubDate>Fri, 07 Dec 2007 09:58:24 +0000</pubDate> 
<guid>http:///read.php?687</guid> 
<description>
<![CDATA[ 
	这是本人做的所有DWR测试代码，对刚学习的同志非常有用。<br/>这个文件只能在登入之后下载。请先 <a href="login.php?job=register">注册</a> 或 <a href="login.php">登入</a><br/><br/><br/>
  ]]> 
</description>
</item><item>
<link>http:///read.php?658</link>
<title>为什么Java程序员不重视程序效率？</title> 
<author>fubin &lt;yonghe169@163.com&gt;</author>
<category>Java理论及专业研究</category>
<pubDate>Thu, 01 Nov 2007 15:35:54 +0000</pubDate> 
<guid>http:///read.php?658</guid> 
<description>
<![CDATA[ 
	 &nbsp; &nbsp; 这几天朋友议论的话题是：Java程序员不重视程序效率？<br/><br/> &nbsp; 其实我觉得这个问题本来就是有问题的，因为我不认为Java程序员都不注重效率，至少我身边的朋友不会，我也不会。<br/><br/> &nbsp; 由于我4年前都是从Tubor C走过来的，我能体会到一些老程序员的想法。但现在Java语言都是面对对象的语言了。也就是说，现在计算机语言越来越重视从宏观上的设计而不重视专牛角尖了。如果一定要在一个平台上提高效率那我认为应该直接使用汇编，或者直接使用机器语言。然而现在由于计算机速度的不断提高，牺牲效率获取更快的开发应该是可行的，也是必然的。<br/><br/> &nbsp; 我不同意这个观点原因还有：系统运行效率固然是重要的，但是开发效率呢？开发效率不是效率吗？明显面对对象的开发显然是比面对过程的开发效率要高出很多的。<br/><br/> &nbsp; 总而言之，今是不同往日，不要老是以一些就的标准评论现在的思维。。。
  ]]> 
</description>
</item>
</channel>
</rss>