Practice What You Preach
This post is actually part II of my Annotation Inheritance blog. Based on some of recent rants, I'm finally fleshing out my own framework with some of the new features in J2SE 5.
The framework is another MVC framework, but don't leave yet... it's goal is to be completely configureless-- no XML files to manage along side your code. My hope is that when it's finished, I can look at rolling back some of the features into a future addon to JavaServerFaces. Some of the goals I have:
Lightweight constructor-injection factory-- and I don't mean container. The factory has the same goals as Picocontainer, but doesn't manage lifecycles at all at creation. Instead, it uses what's called "wormholing" to provide state and additional developer features like named bindings at higher layers. The way this works is that a company can create their own Container object and provide it an instance of my factory implementation. When a certain type is requested, the container is passed as a parameter, and then used in the construction of the instance. This is the wormhole, where top level objects are passed to the lower level objects in order to allow things such as lifecycle managment or proxying to occur.
The view and navigation should be maintained by the view if possible-- allowing not only form data to be submitted in the post, but also your "action forwards".
Annotation driven configuration. This means that contextual data such as converters or validators are declared right with the property on the object. This allows configuration data to be strongly typed and does not require "runtime" type checking of configuration data. Granted I'm anti-AOP, but I believe this solution runs more in line with straight-talking OOP principals. I can have a User object with all of its properties, then simply create a UserForm that extends User with all of the annotations you want to use for the web framework-- or simply apply them to User itself. The reason why declaring annotations like this is safer than AspectJ, is that the annotations aren't going to affect anyone unless they are specifically looking for them-- a reversal of roles you could say.
An example would be taking something like a "first name" property on a bean and declaring (on the setter) annotations like "@ValidateNotNull" and "@ValidateLength(16)". My hope is to have the validation processors abstract enough that they can be easily used outside of the MVC realm.
The reason why I'm finally posting some of my ideas is that they are now actually working. The generics and annotations in J2SE make everything seem so clean and exact in what you are doing-- no guessing games anymore in trying to make flexible frameworks. After I got home from work, I was able to put together a working example of a validator annotation with pseudo inheritance. Also, I was able to stack various validators on a single method or class in order to work like Common's Validator, but in probably a tiny fraction of the code and without the configuration files.
Here's an example of what a developer would have to add to their POJO "backing" bean for a web form (no implements or extends required).
public class NewUserAction {
protected String firstName;
protected int age;
protected UserDao dao;
public NewUserAction(UserDao dao) {
this.dao = dao;
}
public String commit() {
dao.add(new User(firstName, age));
return "pass";
}
public String getFirstName() {
return firstName;
}
@ValidateNotNull
@ValidateLength(16)
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public int getAge() {
return age;
}
@ValidateIntegerRange(min=1,max=100)
public void setAge(int age) {
this.age = age;
}
}
Hopefully I will have the framework ready by the end of the year. I was going to post the working validator source code with annotation processing, but I would like to wait and publish an actual framework or article, not just bits and pieces.

1 Comments:
情趣用品,情趣用品,情趣用品,情趣用品,情趣用品,情趣用品,情趣用品,情趣用品,情趣,情趣,情趣,情趣,情趣,情趣,情趣,情趣,A片,視訊聊天室,聊天室,視訊,視訊聊天室,080苗栗人聊天室,上班族聊天室,成人聊天室,中部人聊天室,一夜情聊天室,情色聊天室,視訊交友網a片,a片
免費A片,AV女優,美女視訊,情色交友,免費AV,色情網站,辣妹視訊,美女交友,色情影片,成人影片,成人網站,A片,H漫,18成人,成人圖片,成人漫畫,情色網,日本A片,免費A片下載,性愛
A片,色情,成人,做愛,情色文學,A片下載,色情遊戲,色情影片,色情聊天室,情色電影,免費視訊,免費視訊聊天,免費視訊聊天室,一葉情貼圖片區,情色,情色視訊,免費成人影片,視訊交友,視訊聊天,視訊聊天室,言情小說,愛情小說,AIO,AV片,A漫,avdvd,聊天室,自拍,情色論壇,視訊美女,AV成人網,色情A片,SEX,成人論壇
情趣用品,A片,免費A片,AV女優,美女視訊,情色交友,色情網站,免費AV,辣妹視訊,美女交友,色情影片,成人網站,H漫,18成人,成人圖片,成人漫畫,成人影片,情色網
情趣用品,A片,免費A片,日本A片,A片下載,線上A片,成人電影,嘟嘟成人網,成人,成人貼圖,成人交友,成人圖片,18成人,成人小說,成人圖片區,微風成人區,成人文章,成人影城,情色,情色貼圖,色情聊天室,情色視訊,情色文學,色情小說,情色小說,臺灣情色網,色情,情色電影,色情遊戲,嘟嘟情人色網,麗的色遊戲,情色論壇,色情網站,一葉情貼圖片區,做愛,性愛,美女視訊,辣妹視訊,視訊聊天室,視訊交友網,免費視訊聊天,美女交友,做愛影片
av,情趣用品,a片,成人電影,微風成人,嘟嘟成人網,成人,成人貼圖,成人交友,成人圖片,18成人,成人小說,成人圖片區,成人文章,成人影城,愛情公寓,情色,情色貼圖,色情聊天室,情色視訊,情色文學,色情小說,情色小說,色情,寄情築園小遊戲,情色電影,aio,av女優,AV,免費A片,日本a片,美女視訊,辣妹視訊,聊天室,美女交友,成人光碟
情趣用品.A片,情色,情色貼圖,色情聊天室,情色視訊,情色文學,色情小說,情色小說,色情,寄情築園小遊戲,情色電影,色情遊戲,色情網站,聊天室,ut聊天室,豆豆聊天室,美女視訊,辣妹視訊,視訊聊天室,視訊交友網,免費視訊聊天,免費A片,日本a片,a片下載,線上a片,av女優,av,成人電影,成人,成人貼圖,成人交友,成人圖片,18成人,成人小說,成人圖片區,成人文章,成人影城,成人網站,自拍,尋夢園聊天室
By
sexy, at 7:22 AM
Post a Comment
<< Home