package com.zuhe;
public interface Filter {
void doFilter();
}
package com.zuhe;
public class FaceFilter implements Filter{
@Override
public void doFilter() {
System.out.println("this is FaceFilter");
}
}
package com.zuhe;
public class HTMLFilter implements Filter {
@Override
public void doFilter() {
System.out.println("this is HTMLFilter");
}
}
package com.zuhe;
public class SesitiveFilter implements Filter{
@Override
public void doFilter() {
System.out.println("this is SesitiveFilter");
}
}
package com.zuhe;
import java.util.ArrayList;
public class FilterChain implements Filter {
private ArrayList<Filter> filters = new ArrayList<Filter>();
public FilterChain addFilter(Filter filter){
filters.add(filter);
return this;
}
public void doFilter(){
for(Filter filter:filters){
filter.doFilter();
}
}
}
package com.zuhe;
public class Test {
public static void main(String[] args) {
FilterChain fc1 = new FilterChain();
fc1.addFilter(new HTMLFilter());
FilterChain fc2 = new FilterChain();
fc2.addFilter(new SesitiveFilter()).addFilter(new FaceFilter());
fc2.addFilter(fc1);
fc2.doFilter();
}
}
package com.chain.web;
public interface Filter {
void doFilter(Request req,Response res,FilterChain fc);
}
package com.chain.web;
public class HTMLFilter implements Filter{
@Override
public void doFilter(Request req, Response res,FilterChain fc) {
System.out.println("HTMLFilter request...");
fc.doFilter(req, res, fc);
System.out.println("HTMLFilter response...");
}
}
package com.chain.web;
public class FaceFilter implements Filter{
@Override
public void doFilter(Request req, Response res,FilterChain fc) {
System.out.println("facefilter request...");
fc.doFilter(req, res, fc);
System.out.println("facefilter respose...");
}
}
package com.chain.web;
public class SesitiveFilter implements Filter{
@Override
public void doFilter(Request req, Response res, FilterChain fc) {
System.out.println("SesitiveFilter request...");
fc.doFilter(req, res, fc);
System.out.println("SesitiveFilter response...");
}
}
package com.chain.web;
import java.util.ArrayList;
import java.util.List;
public class FilterChain implements Filter {
private List<Filter> filters = new ArrayList<Filter>();
private int index = 0;
public FilterChain addFilter(Filter filter) {
filters.add(filter);
return this;
}
@Override
public void doFilter(Request req, Response res, FilterChain fc) {
if (index == filters.size())
return;
Filter filter = filters.get(index);
index++;
filter.doFilter(req, res, fc);
}
}
package com.chain.web;
public class Request {
}
package com.chain.web;
public class Response {
}
package com.chain.web;
public class Test {
public static void main(String[] args) {
Request req = new Request();
Response res = new Response();
FilterChain fc = new FilterChain();
FilterChain fc1 = new FilterChain();
fc1.addFilter(new SesitiveFilter());
fc.addFilter(new HTMLFilter()).addFilter(new FaceFilter())
.addFilter(fc1);
fc.doFilter(req, res, fc);
}
}
package com.bridge;
/**
*
* @ClassName: 具体的礼物
* @Description: TODO
* @author peihongpeng
* @date 2015-2-21 下午7:37:40
*
*/
public class GiftImpl {
}
package com.bridge;
public class Gift {
protected GiftImpl giftImpl;
}
package com.bridge;
public class Flower extends GiftImpl{
}
package com.bridge;
public class Ring extends GiftImpl{
}
package com.bridge;
public class WarmGift extends Gift {
}
package com.bridge;
public class WildGift extends Gift{
}
Class A{
t()
}
Class B{
A a = new A(); //慢慢淘汰
t(){
//a.t();
New A().t(); 尽量使用局部变量
}
}
持久化:内存上的数据保存在硬盘上
设计模式:用来当成样板被参考的范例。解决特定环境下重复出现的问题。
设计模式允许系统结构的某个方面的变化独立于其他方面。
框架能加快程序开发和精良的程序架构
在框架之上开发
组件和框架的区别:组件能完成一定功能的封装体,功能是在它里面独立完成的。
代码背后的思想
单例:节约资源
Java命名
AddressValueObject(AddressVO)值对象(VO),推荐实现equals hashcode
脏数据:数据被修改过
单例控制实例的数目
DAO:data access object 数据访问对象
DepDAO(大写)
AJAX:额贼克斯
Java大会
接口隔离
分层:比如用户管理模块,
Common(base)通用的