Entries in the ‘设计模式’ Category:
filed in WebService和SOA, 设计模式 on Jul.29, 2008, by javafuns
原文:http://www.xml.com/pub/a/ws/2004/05/19/wsdl2.html?page=1
by Arulazi Dhesiaseelan
May 20, 2004
W3C 的 Web Services Description Working Group, Web Services Activity 的一个子组织, 已经为描述 web service 定义了一种语言, 也定义了与他们交互的可能方式. The WG 于 26 March 2004 发布了 WSDL 2.0 工作草稿. 这是 WSDL 进化史上的一个重要里程碑. 本文中, 我讨论了相对于 WSDL 1.1 规范所作出的修改以及其它对 web 服务描述语言的主要改进.
W3C WSDL 2.0 工作草稿
W3C 已经公布了下列核心工作草稿作为该工作组交付物一部分:
其它相关工作草稿包括需求和使用场景.
W3C XML Schema definition for WSDL 2.0 specification 可见于 http://www.w3.org/2003/11/wsdl/.
The editor’s copies of these documents provide updated information about the progress of these specifications.
Changes from the WSDL 1.1 Specification
WSDL 1.2 重命名为 WSDL 2.0 因为它相对 WSDL 1.1 有很大不同. 这其中的一些改变包括:
- 进一步加强了 WSDL 的语义. 这是在 WSDL 2.0 中要求 targetNamespace 是 definitions element 的一个必需属性的原因之一.
- 去掉了 message 结构.
- 不再支持操作重载.
PortTypes 重命名为 interfaces. 支持 interface 使用 extends 属性实现继承.
Ports 重命名为 endpoints.
Tags: schema, SOAP, WSDL, XML - Views: 450 - Trackback -
filed in Java, 设计模式 on May.01, 2008, by javafuns
说到排斥性过滤器,大家会一头雾水,搞不明白这其中含义。何为排斥性(exclude)过滤器呢,其实是本人自己定义出来的,呵呵。
排斥性过滤器是相对于规范所定义的Filter而言的,Java EE 规范中的过滤器是对web.xml中所列出的url进行过滤,而排斥性过滤器则恰恰相反,不对这些web.xml中列出的url执行过滤,而是对除这些url外的url进行过滤逻辑操作。
作为一个多年的Java开发人员,在实际开发中遇到这种情况,这便是有此动机的原因。
下面就讲讲这个exclude filter的原理,其实很简单。在拦截所有请求时,我们检查这些请求的url是否在url列表之内,如果在,那么就不进行过滤逻辑,直接调用chain.doFilter(xxx);否则的话,我们就执行一些过滤逻辑操作,然后再chain.doFilter(xxx)。
其中,检查url分2种方式:精确匹配(equals)和模糊匹配(contains),精确匹配优先于模糊匹配
对于代码中的URI获取,可能要根据实际情况作些更改,代码中URI只是使用request.getRequestURI(),得到的不是完整的URL,可视实际情况做出调整。
AbstractExcludeFilter 类将不该被override的方法都设置为了final,developer应该实现唯一的一个abstract method filter(),并且需要在该方法内部适当位置调用 chain.doFilter(xx)。
请看实现代码:
Tags: DesignPatterns, Java - Views: 257 - Trackback -
filed in 设计模式 on Apr.27, 2008, by javafuns
Design Principle
Identify the aspects of your application that vary and separate them
from what stays the same
意思是,要尽可能把变化的部分与不变的部分分离开.
Tags: DesignPatterns, Java - Views: 272 - Trackback -
filed in Java, 设计模式 on Mar.18, 2008, by javafuns
Spring provides all kinds of DAO layers:
- JdbcDaoSupport: you can get JdbcTemplate.
- HibernateDaoSupport:you can get hibernateTemplate and SessionFactory
- JdoDaoSupport: you can get jdoTemplate and PersistenceManagerFactory
- JpaDaoSupport: you can get jpaTemplate and EntityManagerFactory
- SqlMapDaoSupport: you can get sqlMapDaoTemplate and SqlMapClient
So, you can extend these XxxDaoSupport to expose CRUD APIs.
In spring applicationContext.xml, you should inject Datasource, SessionFactory, PersistenceManagerFactory, EntityManagerFactory, SqlMapClient bean to these XxxDaoSupport descendants respectively, so that you can get their XxxTemplate in your DAO subclasses.
Lets see these XxxTemplates:
JdbcTemplate encapsulates Jdbc operations, so that you can use it handily. The other XxxTemplates encapsulate the respective OR-Mappings.
E.g. jdbcTemplate.queryForObject(”select **** “);
Next, i will talk about how smartly the XxxTemplates are designed. They are all best practices of Template-Method. Please keep your focus on.
Tags: DAO, Java, Spring - Views: 262 - Trackback -
filed in Java, 设计模式 on May.17, 2007, by javafuns
public class Singleton {
private final static Singleton instance = new Singleton();
// Private constructor suppresses generation of a (public) default constructor
private Singleton() {}
public static Singleton getInstance() {
return instance;
}
}
public class Singleton {
private static Singleton instance;
// Private constructor suppresses generation of a (public) default constructor
private Singleton() {}
public static synchronized Singleton getInstance() {
if(instance == null) {
instance = new Singleton();
}
return instance;
}
}
public class Singleton {
// Private constructor suppresses generation of a (public) default constructor
private Singleton() {}
private static class SingletonHolder {
private static Singleton instance = new Singleton();
}
public static Singleton getInstance() {
return SingletonHolder.instance;
}
}
public class Singleton {
private volatile static Singleton instance;
// Private constructor suppresses generation of a (public) default constructor
private Singleton() {}
public static Singleton getInstance() {
if(instance == null) {
synchronized(Singleton.class) {
if(instance == null) {
instance = new Singleton();
}
}
}
return instance;
}
}
Tags: DesignPatterns, Java - Views: 293 - Trackback -
filed in Java, 设计模式 on May.16, 2007, by javafuns
Design Principle
Depend upon abstractions. Do not depend upon concrete classes.
Tags: DesignPatterns, Java - Views: 252 - Trackback -
filed in Java, 设计模式 on May.15, 2007, by javafuns
Another new OO design principle:
Design Principle
Classes should be open for extension, but closed for modification
e.g. Decorator Pattern
Tags: DesignPatterns, Java - Views: 255 - Trackback -
filed in Java, 设计模式 on May.11, 2007, by javafuns
The next principle i got is :
Design Principle:
Strive for loosely coupled designs between objects that interact
Tags: DesignPatterns, Java - Views: 238 - Trackback -
filed in Java, 设计模式 on May.08, 2007, by javafuns
书中提到的第3个设计原则是:
Design Principle
Favor composition over inheritance
这是因为我们可以为HAS-A关系中的从属个体提供多种具体实现(通过面向接口编程),而且这些具体实现也可以在运行时(runtime)动态的变换(通过setter方法注入)。
Tags: DesignPatterns, Java - Views: 241 - Trackback -
filed in Java, 设计模式 on Apr.26, 2007, by javafuns
《Head first Design Patterns》中提到的第二个编程法则:
Design Principle
Program to an interface, not an implementation
这样做的目的是有利于替换接口的具体实现
Tags: DesignPatterns, Java - Views: 257 - Trackback -