ITeye博客

Zetta Java

DavyJones2010 · 共 146 篇文章

错误收集

1. Debug无法开启: ERROR:transport error 202: gethostbyname: unknown host A configuration error occurred during startup. Please verify the preference field with the prompt: ERROR: transport error 202: gethostbyname: unknown host ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510) J…

2016-07-21 10:34 · JavaSE · 评论(0)

Tomcat 5.0.18 ClassLoader source code insight

All the functionality of ClassLoader is nested in org.apache.catalina.loader.WebappClassLoader 1) Structure of WebappClassLoader public class WebappClassLoader extends URLClassLoader implements Lifecycle{ /** * The cache of ResourceEntry for classes and resources we have loaded, * keyed by resource…

2015-07-13 21:38 · JavaWeb · 评论(0)

Guice Webapp Insight

guice web dataflow: Basic Design Concept: 1) HttpRequest/HttpResponse will always be created by WebContainer(jetty/tomcat) and Guice will reuse/wrap them. 2) For Servlet that match the url pattern in ServletModule, they will be created by Guice instead, their service() will called by guice filterin…

2015-07-01 19:29 · SpringFramework · 评论(0)

2014 Year in Review

The passed 2014 is a really tough and struggling year for me. During the course of previous 12 months, I wrote a dozens of tec blogs, read a handful books, practiced listening and speaking English, broke up with my beloved ex-girlfriend and then fall in love with the girl who loves me so much. I've…

2015-01-13 10:27 · Miscellanies · 评论(0)

Java Dynamic Proxy

1) Act as a simple log interceptor: public class DynamicProxy { private static final Logger logger = Logger.getLogger(DynamicProxy.class); @SuppressWarnings("unchecked") @Test public void useProxyTest() { String str = "Hello world"; LoggingInvocationHandler handler = new LoggingInvocationHandler(st…

2015-01-06 15:09 · JavaSE · 评论(0)

SCJP

1> Wrapper 1) Boxing, ==, and equals() public class WrapperTest { @Test public void integerEqualsTest() { assertFalse(new Integer(127) == new Integer(127)); assertTrue((new Integer(127)).equals(new Integer(127))); Integer i = 127; Integer j = 127; assertTrue(i == j); assertTrue(i.equals(j)); i = 12…

2014-12-26 09:58 · JavaSE · 评论(0)

Linux: Frequently used command

1. List disk space usage: df -hl // "l" means "local", limit listing to local file systems // "h" means "human-readable", print sizes in human readable format du -cks *|sort -rn|head // recurisive sort file size under current folder 2. Sort file by size: ls -hlS // "h": "human-readable", print size…

2014-11-03 17:05 · Linux · 评论(0)

Java Algorithm: Sorting

1. Insertion Sort 1> Straight Insertion Sort: O(n^2), if the records are already sorted, then O(n). 2> Binary Insertion Sort (Reduced comparison count) 3> 2-Way Insertion Sort (Reduced comparison count and move record time) 4> Shell's Sort 2. Swap Sort 1> Bubble Sort: O(n^2) 2> Quick Sort: O(n*lgn)…

2014-09-27 18:07 · Data Structure & Algorithm · 评论(0)

A simple implementation of "Input Method" in Java

package edu.xmu.guava.jcip; import java.util.Map; public interface Traversable { public void addWord(String word, int index); public Traversable getNext(Character c); public Map<Character, ? extends Traversable> getChildren(); } package edu.xmu.guava.jcip; import java.util.Map; import java.util.Sca…

2014-09-26 19:49 · Miscellanies · 评论(0)

Java Concurrency: Cancellation and Shutdown

Dealing well with failure, shutdown, and cancellation is one of the characteristics that distinguishes a well-behaved application from one that merely works. 1> Task Cancellation: An activity is cancellable if external code can move it to completion before its normal completion. There are a number …

2014-09-21 21:54 · JavaSE · 评论(0)

Java Concurrency: Java Memory Model

1. Happen Before Operation: 1) Each action in a thread happens before every action in that thread that comes later in the program's order. 2) An unlock on a monitor happens before every subsequent lock on that same monitor. 3) A write to a volatile field happens before every subsequent read of the …

2014-09-20 20:51 · JavaSE · 评论(0)

Java SE: Effective Java Notes "Concurrency"

Use the Advanced Concurrent Tools instead of the legacy wait() and notify(). Java Advanced Concurrent Tools: 1> Executor Framework: ExecutorService, Callable, Executors ... 2> Concurrent Collection: ConcurrentMap, BlockingQueue ... (Is there any ConcurrentSet*(1) and ConcurrentList*(2) ?) 3> Synchr…

2014-09-12 15:33 · JavaSE · 评论(0)

Java POI: Convert Excel to CSV by XSSFReader

1. public String convertExcelToCsv(File uploadedFile, String reportType) throws InvalidFormatException, IOException, InterruptedException { logger.info(String .format("Start convertExcelToCsv, uploadedFile.name: [%s], reportTYpe: [%s]", uploadedFile.getName(), reportType)); String csvFileName = Str…

2014-09-12 09:47 · Java POI · 评论(0)

Java Concurrency: JCIP Notes

1. Risks of Threads: 1> Safety Hazards We can add annotation: @NotThreadSafe, @ThreadSafe, @Immutable 2> Liveness Hazards Deadlock, Starvation, Livelock Bugs that cause liveness failures can be elusive because they depend on the relative timing of events in different threads. and therefore do not a…

2014-09-12 09:31 · JavaSE · 评论(0)

Java Concurrency: Latches & Barriers

Latches: A latch is a synchronizer that can delay the process of threads until it reaches its terminal state. A latch acts as a gate: until the latch reaches the terminal state the gate is closed and no thread can pass, and in the terminal state the gate opens, allowing all threads to pass. Once th…

2014-09-03 22:45 · JavaSE · 评论(0)