上一页 1 ··· 13 14 15 16 17 18 19 20 21 ··· 26 下一页
摘要: import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.Proxy; import java.net.URL; import org.apache.log4j.Logger; im.. 阅读全文
posted @ 2012-06-01 10:54 zhwj184 阅读(746) 评论(0) 推荐(0) 编辑
摘要: import java.util.ArrayList; import java.util.List; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; import org.apache.log4j.Logger; public c... 阅读全文
posted @ 2012-06-01 10:54 zhwj184 阅读(322) 评论(0) 推荐(0) 编辑
摘要: 一个对象实例占用了多少字节,消耗了多少内存?这样的问题在c或c++里使用sizeof()方法就可以得到明确答案,在java里好像没有这样的方法(java一样可以实现),不过通过jmap工具倒是可以查看出一个对象的占用内存的大小,这里介绍一种通过分析java代码计算内存使用情况的方法。注意,一下讨论的情况都是基于32位机,不适用用64位机,JVM是sun的HotSpot,不同的虚拟机实现可能会不同规则一:每个对象被按照8bytes粒度对齐(数组除外)在jvm中每个对象(数组除外)都有一个头,这个头有两个字,第一个字存储的时对象的一些标志位信息,例如:锁标志位、经历了几次gc等信息,第二个字是一个 阅读全文
posted @ 2012-06-01 10:53 zhwj184 阅读(479) 评论(0) 推荐(0) 编辑
摘要: 很实用的要点,每次重构都要重新看看这些要点,真正用到平时的日常工作中。代码坏味道: 1.duplicate code 重复代码 2.long method 长方法 3.large class 过大的类 4.long parameter list 过长参数列 5.divergent change 发散式变化 6.shotgun surgery 散弹式变化 7 feture envy 依恋情结 8.data clumps 数据泥团 9.primitive obsession 基本类型偏执 10.switch statument switch惊悚现身 11.parallel inheritance 阅读全文
posted @ 2012-06-01 10:53 zhwj184 阅读(189) 评论(0) 推荐(0) 编辑
摘要: CGLIB动态代理类import java.lang.reflect.Method; import net.sf.cglib.proxy.Enhancer; import net.sf.cglib.proxy.MethodInterceptor; import net.sf.cglib.proxy.MethodProxy; public class CglibProxy implements MethodInterceptor { private Object target; /** * 创建代理对象 * * @param... 阅读全文
posted @ 2012-06-01 10:52 zhwj184 阅读(355) 评论(0) 推荐(0) 编辑
摘要: /** * Spring有三种注入方法: * <ul> * <li>通过明确的bean definition声明来注入对象,缺点是无法注入 * <code>ConfigurableListableBeanFactory.registerResolvableDependency()</code> * 中注册的对象,如<code>HttpServletRequest</code>。</li> * <li>通过autowire * byConstructor来注入对象,可以注入包括resolvableDe 阅读全文
posted @ 2012-06-01 10:51 zhwj184 阅读(144) 评论(0) 推荐(0) 编辑
摘要: Caused by: org.springframework.jdbc.UncategorizedSQLException: SqlMapClient operation; uncategorized SQLException for SQL []; SQL state [null]; error code [0]; 列名无效; nested exception is java.sql.SQLException: 列名无效 at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(. 阅读全文
posted @ 2012-06-01 10:50 zhwj184 阅读(535) 评论(0) 推荐(0) 编辑
摘要: java使用jpcap抓包工具获得本机发送的所有tcp请求,根据tcp请求的内容可以调试某个应用启动后对外发送的相关http请求或者sql连接请求,这样可以很好的调试我们的程序。很不错的一种应用无侵入性的调试本机发送的http接口,sql连接接口等。import java.io.UnsupportedEncodingException; import java.net.InetAddress; import jpcap.*; import jpcap.packet.EthernetPacket; import jpcap.packet.Packet; import jpcap.packet.. 阅读全文
posted @ 2012-06-01 10:49 zhwj184 阅读(866) 评论(0) 推荐(0) 编辑
摘要: /** * Internal private hashing method. * * This is the original hashing algorithm from other clients. * Found to be slow and have poor distribution. * * @param key String to hash * @return hashCode for this string using our own hashing algorithm */ private static long origCompatH... 阅读全文
posted @ 2012-06-01 10:48 zhwj184 阅读(155) 评论(0) 推荐(0) 编辑
摘要: 其中fixup和fixdown就是堆排序的使用。 /** * This class represents a timer task queue: a priority queue of TimerTasks, * ordered on nextExecutionTime. Each Timer object has one of these, which it * shares with its TimerThread. Internally this class uses a heap, which * offers log(n) performance for the add,... 阅读全文
posted @ 2012-05-31 13:54 zhwj184 阅读(327) 评论(0) 推荐(0) 编辑
上一页 1 ··· 13 14 15 16 17 18 19 20 21 ··· 26 下一页