- 浏览: 67527 次
- 性别:
- 来自: 上海
-
最新评论
-
lirong1978:
好长的文章
海量数据处理汇总
文章列表
public class Singleton {
private static class SingletonHandler{
static final Singleton singleton =new Singleton();
}
private Singleton (){}
public static Singleton getInstance(){
...
- 2009-03-02 15:01
- 浏览 941
- 评论(0)
Interceptor的实现
- 博客分类:
- J2SE
public interface Action {
public String execute() throws Exception;
}
public class TestAction implements Action {
public String execute() throws Exception {
System.out.println("action exe");
return "success";
}
}
public interface I ...
- 2009-03-01 21:26
- 浏览 816
- 评论(0)
Spring声明式事务让我们从复杂的事务处理中得到解脱。使得我们再也无需要去处理获得连接、关闭连接、事务提交和回滚等这些操作。再也无需要我们在与事务相关的方法中处理大量的try…catch…finally代码。
我们在使用Spring ...
- 2009-02-28 22:32
- 浏览 1094
- 评论(0)
取得地址栏完整请求信息
- 博客分类:
- J2EE
public static String getCompleteURL(HttpServletRequest request) {
return new StringBuilder(getCurrentHttpURL(request))
.append(request.getServletPath()).append("?")
.append(request.getQueryString()).toString();
}
/**
* 取得当前http地址
* @pa ...
- 2009-02-17 12:06
- 浏览 774
- 评论(0)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh-cn">
<head>
<meta http-equiv="Content-Type" con ...
- 2009-02-16 16:33
- 浏览 1025
- 评论(0)
CronTrigger配置格式:
格式: [秒] [分] [小时] [日] [月] [周] [年]
序号 说明
是否必填 允许填写的值 允许的通配符
1 秒 是 0-59 , - * /
2 分 是 0-59
, - * /
3 小时 是 0-23 , - * /
4 日 是 1-31 , - * ? ...
- 2009-02-15 15:12
- 浏览 1006
- 评论(0)
import java.util.ArrayList;
interface Builder{
public void buildPartA();
public void buildPartB();
public void buildPartC();
public Product getProduct();
}
class Product{
private ArrayList<String> parts=new ArrayList<String>();
public void add(String part){
part ...
- 2009-02-12 17:59
- 浏览 883
- 评论(0)
Java代码
1. public class Invoker {
2. private Command command;
3.
4. public void setOrder(Command command) {
5. this.command = command;
6. }
7. public void ExecuteCommand() {
8. command.ExecuteCommand();
9. } ...
- 2009-01-22 11:09
- 浏览 855
- 评论(0)
1. //先来一个状态:
2. package State;
3.
4. public abstract class State
5. {
6.
7. /** *//** Creates a new instance of State */
8. public State() {
9. }
10.
11. public abstract void opration(Context context);
12. ...
- 2009-01-22 10:42
- 浏览 641
- 评论(0)
JVM在运行时会产生三个ClassLoader,Bootstrap ClassLoader、Extension ClassLoader和AppClassLoader.其中,Bootstrap是用C++编写的,我们在Java中看不到它,是null。它用来加载核心类库,在JVM源代码中这样写道:
static const char classpathFormat[] =
"%/lib/rt.jar:"
"%/lib/i18n.jar:"
"%/lib/sunrsasign.jar:"
"%/lib/jsse.jar:& ...
- 2009-01-21 13:24
- 浏览 812
- 评论(0)
import java.util.ArrayList;
import java.util.Collection;
interface Visitor{
public void visitElementA(ConcreteElementA elementA);//针对具体元素A的新方法
public void visitElementB(ConcreteElementB elementB);//针对具体元素B的新方法
}
interface Element{
public void accept(Visitor visitor);
}
class ConcreteVis ...
- 2009-01-13 21:42
- 浏览 737
- 评论(0)
/**
* 回调接口
* @author KOOK
*
*/
public interface CallBack {
/**
* 执行回调方法
* @param objects 将处理后的结果作为参数返回给回调方法
*/
public void execute(Object... objects );
}
/**
* 简单本地发送异步消息的类
* @author KOOK
*
*/
public class Loc ...
- 2009-01-06 22:03
- 浏览 823
- 评论(0)
<?xml version="1.0" encoding="UTF-8"?>
<mybeans >
<bean id="first" name="first" implement="com.my.ioc.testpackage.MybeanOneImpl"></bean>
</mybeans>
public class XmlToBean {
public Mybean ...
- 2009-01-05 21:59
- 浏览 1192
- 评论(0)
下面是一个 线程相互等待,都到达某一点后,继续开始执行任务的例子(测试CyclicBarrier)。
这里模拟了这样一个场景: 3个玩家同时进行通关游戏,当他们都到达或通过某一关后,才可继续往下过关。比如张三、李四、王五,他们通过每一关的时间都不相同,但是他们都必须都通关了第一关后,才能开始玩第二关;都通过了第二关,才能玩第三关... ...
写了3个类来验证这种情况,只在windows下做了测试。
1.1、GameBarrier.java 游戏关卡
1.2、GameBarrierTask.java 通关任务
1.3、Game ...
- 2008-12-28 23:57
- 浏览 2397
- 评论(0)
java.util.concurrent.Callable与java.util.concurrent.Future类可以协助您完成Future模式。Future模式在请求发生时,会先产生一个Future对象给发出请求的客户。它的作用类似于代理(Proxy)对象,而同时所代理的真正目标对象的生成是由一个新的线程持续进行。真正的目标对象生成之后,将之设置到Future之中,而当客户端真正需要目标对象时,目标对象也已经准备好,可以让客户提取使用。
public class PrimeCallable implements Callable<int[]> {
private ...
- 2008-12-28 23:10
- 浏览 1806
- 评论(0)