Java 版 (精华区)

发信人: thering (没完没了), 信区: Java
标  题: struts源码分析=====ActionForwards
发信站: 哈工大紫丁香 (2003年05月17日18:28:50 星期六), 站内信件

www.javasoft.cn出品

package org.apache.struts.action;

ActionForwards

2003-5-17日

package org.apache.struts.action;

import java.io.Serializable;
import org.apache.commons.collections.FastHashMap;

大家看看这个类,觉得唯一值得说的就是FastHashMap了
public class ActionForwards implements Serializable {

    //存放ActionForward实例的地方了,为什么是FastHashMap?什么是FastHashMap?  
    
    private FastHashMap forwards = new FastHashMap();


    public boolean getFast() {
        return (forwards.getFast());
    }

    public void setFast(boolean fast) {
        forwards.setFast(fast);
    }

    public void addForward(ActionForward forward) {
    forwards.put(forward.getName(), forward);
    }

    public ActionForward findForward(String name) {
    return ((ActionForward) forwards.get(name));
    }

    public String[] findForwards() {
        return ((String[]) forwards.keySet().toArray(new 
String[forwards.size()]));
    }

    public void removeForward(ActionForward forward) {
    forwards.remove(forward.getName());
    }
}

总结:这是个集中存放ActionForward的类,其中提到了FastHashMap,就是org.apache.str
uts.util.FastHashMap,
为什么不用HashMap呢?原因就是他不是线程同步的,而FastHashMap就不一样了,他是为
了适应多线程、并且
对HashMap的访问大部分是只读的特殊环境的需要。当你调用setFast(false)方法将
他设置为slow模式,这时对他(FastHashMap)的访问是线程同步的,高速模式下他与普通的h
ashmap就没有太大区别了。
真不知道现在讲的是FastHashMap还是ActionForwards。
 

※ 来源:·哈工大紫丁香 bbs.hit.edu.cn·[FROM: 202.118.228.151]
[百宝箱] [返回首页] [上级目录] [根目录] [返回顶部] [刷新] [返回]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:2.117毫秒