框架整體介紹:http://blog.csdn.net/flyxxxxx/article/category/7055640
對此框架有興趣或想參與開發的請加QQ羣:255195191一般發送短信或郵件,均需要調用相關接口,如果接口發生變理,通常可能需要修改大量的調用代碼,而採用Prototype框架,可以做到更大程度的解耦。
@Prototype
public class TemplateBusiness {
public void business(){
...;
sendSms(user);
}
@Msg(type="sms")//這裏發短信消息
SMS sendSms(User user){
return new SMS(user.getTelephone(),template(user));//構造一個短信對象,具體如何發送與此業務類無關
}
@Template("${user.name},你好")//這裏採用jsp el語言作爲默認的模板引擎
String template1(User user){
return null;//不需要做任何實現
}
@Template(file="classpath:template1.txt",engine="js")//這裏採用javascript作爲模板引擎
String template3(User user){
return null;//不需要做任何實現
}
@Data
public static class User {
private String name;
}
}
當然,如果短信或郵件內容的模板來源於數據庫,只需要實現一個接口就可以完成對接。