????ServcieFramework????????????????????????Java MVC ????????????????????????????ü????????80%??????

??????????????????????????????????У????????????????????????????????????????????????????????????????????????

??????????????????!

???????? WilliamZhu?????@PrinceCharmingJ??Java???????4???????飬2010????????????й????????Rails????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????

????ServcieFramework ?????

????ServcieFramework????????????????ORM ?? Controller?????? surprize ?????? Java MVC ???????????ú??????????????????????????????(???????е?????oh yeah~~~)

????ServcieFramework ????????

????ORM ?????????????????? ActiveRecord ????

????????????????????????servlet api??????????????Servlet?淶??????????????????Java????http??????????е??????顣

??????????????????controller?????????????????????в????

????????????????????????

?????????????????????Javaд????????????Web API????????Spring??????????????nutz???????????????nutz?к??????????磬?????response status?????????????????????????в???????nutz???????е?????????????????????????????д???????????? RESTFul???????????????????????ServcieFramework???????????????????????????С?

????????Ч????Rails????????????????????

????????? clone ServiceFramework??????????????????????????????????????????????С?????

???????????????????????ServiceFramewok???????????????????????????????????????

????????????????????????????????????????????????

?????????????

????[sql] view plaincopy--?????

????CREATE TABLE `tag` (

????`id` int(11) NOT NULL AUTO_INCREMENT??

????`name` varchar(255) DEFAULT NULL??

????`tag_synonym_id` int(11) DEFAULT NULL??

????`weight` int(11) DEFAULT NULL??

????PRIMARY KEY (`id`)

????) ENGINE=InnoDB DEFAULT CHARSET=utf8;

????--????顣????????????????????顣?????????????????

????CREATE TABLE `tag_group` (

????`id` int(11) NOT NULL AUTO_INCREMENT??

????`name` varchar(32) DEFAULT NULL??

????PRIMARY KEY (`id`)??

????UNIQUE KEY `id` (`id`)

????) ENGINE=InnoDB DEFAULT CHARSET=utf8;

??????????????

????[java] view plaincopypublic class Tag extends Model {

????@Validate

????private final static Map $name = map(

????presence?? map("message"?? "{}??β??????")??

????uniqueness?? map("message"?? "{}??β??????")

????);

????@ManyToMany

????private List tag_groups = list();

????}

????public class TagGroup extends Model {

????@ManyToMany

????private List tags = list();

????}

????Ok?????????????? д???controller??

????[java] view plaincopypublic class TagController extends ApplicationController {

????@BeforeFilter

????private final static Map $check_params = map(only?? list("save"));

????@At(path = "/blog"?? types = POST)

????public void save() {

????if(!Tag.save(params())){

????render(HTTP_400??tag.validateResults);

????}

????render(ok());

????}

????private void check_params(){

????if(isEmpty(param("tag")))render(HTTP_400??"????????????????name???");

????}

????}

?????????????????????????????????Arel????????????磺

????[java] view plaincopyList orders = Order.where("status=:status"??map("status"??Order.Status.NEW)).joins("details").fetch();

????ServiceFramewok???????????????棺

??????ORM?????????????Rails ??ActiveRecord??ORM????????ServiceFramework??ORM????????????????

???????????Controller?е? filter(interceptor)??????before filter??around filter ??????Ч???????á????????????????filter????á?

?????淶????????????????μ?????????????????????????????????????????????ServiceFramework???????????????????

??????????????????Rails??Java?????????????Щ??????

??????????????????javassist??cglib?????????PlayFramework??

????AOP ???????????????????????????????????????????????????????????? Spring ROO??

?????????????IDE???????????????Щ???????????????????