frank127的博客
frank127 · 共 9 篇文章
JPA notes 1
Creating an Entity Regular Java classes are easily transformed into entities simply by annotating them. In fact, by adding a couple of annotations, virtually any class with a no-arg constructor can become an entity. Let’s start by creating a regular Java class for an employee. Listing 2-1 shows a s…
2013-05-09 12:52 · JPA · 评论(0)
zt - 深入浅出JAVA多线程(1)-方法 JOIN
深入浅出JAVA多线程(1)-方法 JOIN Posted on 2008-08-23 23:25 advincenting 阅读(10602) 评论(8) 编辑 收藏 所属分类: JAVA基础知识 对于Java开发人员,多线程应该是必须熟练应用的知识点,特别是开发基于Java语言的产品。本文将深入浅出的表述Java多线程的知识点,在后续的系列里将侧重于Java5由Doug Lea教授提供的Concurrent并行包的设计思想以及具体实现与应用。 如何才能深入浅出呢,我的理解是带着问题,而不是泛泛的看。所以该系列基本以解决问题为主,当然我也非常希望读者能够提出更好的解决问题的方案以及提出更多…
2011-09-16 13:50 · Thread · 评论(0)
快速排序
package com.alzhang.chapter03; import java.util.Comparator; import java.util.Random; @SuppressWarnings("unchecked") public class QuickSort { public static final Random RND = new Random(); private static void swap(Object[] array, int i, int j) { Object tmp = array[i]; array[i] = array[j]; array[j] =…
2011-03-09 13:18 · 评论(0)
XML-RPC
package org.apache.xmlrpc.demo.webserver; import org.apache.xmlrpc.server.PropertyHandlerMapping; import org.apache.xmlrpc.server.XmlRpcServer; import org.apache.xmlrpc.server.XmlRpcServerConfigImpl; import org.apache.xmlrpc.webserver.WebServer; public class JavaServer { private static final int po…
2011-03-08 13:30 · 评论(2)
Singleton pattern
Singleton: Ensure a class only has one instance and provide a global point of access to it. code implementation public class Singleton { private static Singleton uniqueInstance; private Singleton() {} public static Singleton getInstance() { if (uniqueInstance==null) uniqueInstance=new Singleton(); …
2010-06-20 11:26 · 评论(0)
factory pattern
let's say you have a pizza shop. you might end up writing some code like this: Pizza orderPizza() { Pizza pizza = new Pizza(); pizza.prepare(); pizza.bake(); pizza.cut(); pizza.box(); return pizza; When you need more than one type of pizza Pizza orderPizza(String type) { Pizza pizza; if (type.equal…
2010-06-06 08:53 · 评论(1)
decorator pattern
Decorator Pattern: attaches additional responsibilities to an object dynamically. Decorators provide a flexible alternative to subclassing for extending functionality. Meet the decorator pattern: For example, if the customer wants a Dark Roast with Mocha and Whip, then we'll: Take a DarkRoast objec…
2010-06-06 01:15 · 评论(0)
observer pattern
Observer pattern: defines a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically. oo principles: strive for loosely coupled designs between objects that interact. How observer pattern works let's look at how newspape…
2010-06-04 23:14 · 评论(0)
strategy pattern
The strategy pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it. see SimUDuck app. for reference. below you'll find a mess of classes and interface for an action adventure game.You'll…
2010-06-04 13:07 · 评论(0)