OJO (Plain Old Java Object) The name used to emphasize that it is a normal java object , rather than a specific object.
November 2005 when , "POJO" is mainly used to refer to those useless comply with specific Java object model , agreement or frameworks such as EJB Java objects.
Ideally speaking, a POJO is a Java object without any restrictions ( in addition to the Java Language Specification ) . For example, should not be a POJO
- expansion scheduled classes, such as public class Foo extends javax.servlet.http.HttpServlet {...
- achieve the intended interfaces, such as public class Bar implements javax.ejb.EntityBean {...
- contains predefined annotation , such as @ javax.ejb.Entity public class Baz {...
Then , because of technical difficulties and other reasons, many software products compatible POJO style or frame in fact still requires using a predetermined dimension , such as more convenient for persistence .
Written in JAVA language JavaBean is a reusable component . Its method naming , structure and behavior must conform to certain conventions :
- The class must have a public default constructor.
- properties of this class to access using getter and setter , other methods to comply with standard naming conventions.
- This class should be serializable.
Because these requirements mainly by convention rather than by implementing the interface , so many developers as to comply with the specific JavaBean naming conventions POJO.
In short , when a Pojo serializable , there is a no-argument constructor , use getter and setter methods to access the property, he is a JavaBean.
没有评论:
发表评论