Java简单工厂模式
在阎宏博士的《JAVA与模式》一书中开头是这样描述简单工厂模式的:简单工厂模式是类的创建模式,又叫做静态工厂方法(Static Factory Method)模式。简单工厂模式是由一个工厂对象决定创建出哪一种产品类的实例。
那么简单工厂模式是在什么场景下使用呢,下面就以本人的理解举例说明:
就拿登录功能来说,假如应用系统需要支持多种登录方式如:口令认证、域认证(口令认证通常是去数据库中验证用户,而域认证则是需要到微软的域中验证用户)。那么自然的做法就是建立一个各种登录方式都适用的接口,如下图所示:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAdIAAAEGCAIAAABerYNYAAAcUklEQVR4nO3dLWzjyt7HcV/Wyw6sLiqxVFh4gaUbeGDNFlYyOeyudA0iHVBkLSyxtNKSAIMuWxkVGi6xVFgZlblwQUChH/B/OjsdO27i+G2c7wdUaV7syXjml8l4kjgVAGBEztQFAIDTQuwCwKiIXQAYFbELAKMidgFgVMQuAIyK2AWAURG7ADAqYhcARjV97D4/P2cAMJjn5+epc+6diWP36enJAYCBPTw8TJt1uoljN8syx3Gur69vAWAANzc3juNsNptps043i9idVY0AWJIZhgyxC2DJZhgyxC6AJZthyBC7+EBZllMXYdaon5mbYcgQu2iTJEmSJI03BUGg/1sUheu6aZqOUq4GRVFEUZSmaRAEeZ73vn3j+SotVYQ5mGHIELvYaf/MFb7vF0Wx//a32+12u+1YuBrP8+RCFEW+7/e1WR3Ja6MZhgyxi2aHZm4HWZb1NSzN81zF7qBIXuvMMGSIXTTolrkHZeh2u/U879DY3TWaHi12K5LXNjMMGWIXpg6ZG0VRFEWu6xrb8TwvjuMgCOSNf5Zl6ia5fxiG8lhja3EcZ1kWhqHk7Ha7jaIoCALP84qiCMMwDEPJWbkpDEPXdWVTai9VVYVhmKZpnudhGBpPSnadZZkxNyJlk4fsmqomeS0yw5AhdvFOlmVGCCofzi0YsVtVled5YRjK5TzPjSnXxtFuGIYqN8uy1MewMqSV4m23W7Xlasdo1wh0vXh6CutzwWma6g/xPG/XQoWWVyA99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VN0gsaEbtDKcvyRNrQQaw4dlawoibpBY2IXYyKY9cXatJexC5GxbHrCzVpL2IXo+LY9YWatBexi1Fx7PpCTdqL2MWoOHZ9oSbtZXHsrtfrDLa5u7sjLHqR0QusNXQvGCR2f/786cBm9/f3QzSMk0IvsN1wvWCQ2K2q6uvXr7ew093d3evr60AN46TQC+w1aC8YKnYBAI2IXQAYFbELAKMidgFgVMQuAIyK2AWAUf0fQ6M6tSspTV0AAAAASUVORK5CYII=" alt="" />
public interface Login {
//登录验证
public boolean verify(String name , String password);
}
public class DomainLogin implements Login { @Override
public boolean verify(String name, String password) {
// TODO Auto-generated method stub
/**
* 业务逻辑
*/
return true;
} }
public class PasswordLogin implements Login { @Override
public boolean verify(String name, String password) {
// TODO Auto-generated method stub
/**
* 业务逻辑
*/
return true;
} }
我们还需要一个工厂类LoginManager,根据调用者不同的要求,创建出不同的登录对象并返回。而如果碰到不合法的要求,会返回一个Runtime异常。
public class LoginManager {
public static Login factory(String type){
if(type.equals("password")){ return new PasswordLogin(); }else if(type.equals("passcode")){ return new DomainLogin(); }else{
/**
* 这里抛出一个自定义异常会更恰当
*/
throw new RuntimeException("没有找到登录类型");
}
}
}
测试类:
public class Test {
public static void main(String[] args) {
// TODO Auto-generated method stub
String loginType = "password";
String name = "name";
String password = "password";
Login login = LoginManager.factory(loginType);
boolean bool = login.verify(name, password);
if (bool) {
/**
* 业务逻辑
*/
} else {
/**
* 业务逻辑
*/
}
}
}
简单工厂模式的结构如下图:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAATEAAABwCAIAAAD5dNBCAAAgAElEQVR4nO2deVwTx/vHJySEQMIR7iNc4dRaBQWUWKGIHKIFFb6gSBVarYpFBYHWg3AUWgo1+qqVclgElVKLwBeoYkUrKiJUixSsgCiHVI4gIhEknPv7Y17uL19QiCVIrPP+g9ezs8/Ozi757Mw8MzsLMAQCIU6AmS4AAoH4H5AmEQjxAmkSgRAvkCYRCPECaRKBEC+QJhEI8QJpEoEQ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DSasrJyRETE5s2b8UQ3N7cFCxbQaLRFixbBCQMAAGFWV/gHvHmaRIghly9f9vPzKywsvHPnTkJCQlxcXFRUVH5+fkJCwkcffeTr63v9+nVYrfn5+UGDzWZ7eXlFR0fDRDw9ISHBy8vLxMQkISEhMDDQxcXF29s7ISHBxcWFyWR+8cUXfn5+TCaTwWCYmJhYW1vDCnnr1q379+9nMplKSkrM52hoaDAYDGhra2tLS0tDW09PT1lZGdoqKioKCgrwKA0NDQCAjo6Onp6egoIChUKB6YqKirD1pKmpqaSkRCQSSSQSk8m8fPnydNxMpEmE2DE4ONjY2AjthoaGFzZJenp6Xjj8Bt+fhLS3t+MhfR6Ph0toeHgY7wA3NTVVV1fD95s7Ojqys7P7+/sHBwerq6uLi4thbjU1NdnZ2UVFRRUVFXfv3i0oKBgzTiNakCYRCPECaRKBEC+QJhEI8QJpEoEQL5AmEQjxAmkSgRAvkCYRCPECaRKBEC+QJhEI8eL/ABL/TeXM9v5JAAAAAElFTkSuQmCC" alt="" />
我们可以设想一下真实的场景,如果把上面的Test当做一个servlet的话,当客户端发起登录请求——>请求交给服务端的Servlet——>Servlet根据客户端传递的loginType调用工厂类LoginManager的factory()方法——>factory()方法根据参数loginType创建相应的登录验证类(DomainLogin或PasswordLogin)并返回——>登录验证类调用方法verify()验证用户名密码是否正确
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAjcAAAFwCAIAAADL/82wAAAgAElEQVR4nO3dL4zbWtrH8WjuLdqVJtpLVuXDCgIHGAQVVjWrdMFdyaSwwGDZrHRlFS6xVDjAYODIqNCwxNLAkdEUubAgoNAvONvz+jqOJ3Gck/M8/n5AlaYej/08Pv7VfxIvGgAAfLU49wIAALATKQUA8NfOlFqtVgvssFqtXDYJAGZrZ0otFhxm7URxAMANUmoMigMAbpBSY1AcAHCDlBqD4gCAG6TUGBQHANwgpcagOADgBik1BsUBADdIqTEoDgC4QUqNQXEAwA1SagyKAwBukFJjUBwAcIOUGoPiAIAbpNQYFA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DVopnY4O/h+499/JevnpUAAAAABJRU5ErkJggg==" alt="" />
假如不使用简单工厂模式则验证登录Servlet代码如下(假设Test为一个Servlet,变量loginType、name、password表示从客户端传递过来的参数):
public class Test {
public static void main(String[] args) {
// TODO Auto-generated method stub String loginType = "password";
String name = "name";
String password = "password";
//处理口令认证
if(loginType.equals("password")){
PasswordLogin passwordLogin = new PasswordLogin();
boolean bool = passwordLogin.verify(name, password);
if (bool) {
/**
* 业务逻辑
*/
} else {
/**
* 业务逻辑
*/
}
}
//处理域认证
else if(loginType.equals("passcode")){
DomainLogin domainLogin = new DomainLogin();
boolean bool = domainLogin.verify(name, password);
if (bool) {
/**
* 业务逻辑
*/
} else {
/**
* 业务逻辑
*/
}
}else{
/**
* 业务逻辑
*/
}
}
}
上面的代码会不会很蛋疼啊。。。呵呵
《JAVA与模式》一书中使用java.text.DataFormat类作为简单工厂模式的典型例子叙述。
简单工厂模式的优点
模式的核心是工厂类。这个类含有必要的逻辑判断,可以决定在什么时候创建哪一个登录验证类的实例,而调用者则可以免除直接创建对象的责任。简单工厂模式通过这种做法实现了对责任的分割,当系统引入新的登录方式的时候无需修改调用者。
简单工厂模式的缺点
这个工厂类集中了所以的创建逻辑,当有复杂的多层次等级结构时,所有的业务逻辑都在这个工厂类中实现。什么时候它不能工作了,整个系统都会受到影响。