POJO

POJOPlain Old Java Object)这种叫法Martin FowlerRebecca ParsonsJosh MacKenzie2000年的一次演讲的时候提出来的。
 The term was coined while Rebecca Parsons, Josh MacKenzie and I were preparing for a talk at a conference in September 2000. In the talk we were pointing out the many benefits of encoding business logic into regular java objects rather than using Entity Beans. We wondered why people were so against using regular objects in their systems and concluded that it was because simple objects lacked a fancy name. So we gave them one, and it''s caught on very nicely.

基本的意思是我们要给具有业务逻辑处理的规则的Java对象(regular java objects)起了一个名字——POJO,这些Java对象不是EntityBeans(EJB的一种)。

POJO, or Plain Old Java Object, is a normal Java object class (that is, not a JavaBean, EntityBean etc.)  and does not serve any other special role nor does it implement any special interfaces of any of the Java frameworks. This term was coined by Martin Fowler, Rebbecca Parsons and Josh MacKenzie who believed that by creating the acronym POJO, such objects would have a "fancy name", thereby convincing people that they were worthy of use.
        基本意思是说POJO一个正规的Java对象(不是JavaBean,EntityBean等),也不担当任何的特殊的角色,也不实现任何Java框架指定的接口。
        我觉得上面的解释很准确,POJO应该不是我们开始认为的JavaBean,当然更不是EJB,它不应该依赖于框架即继承或实现某些框架类或接口。例如:Struts1中的Action和ActionForm当然不属于POJO了,而在Struts2中的Action由于可以不继承任何的接口,所以在这种情况下Action是POJO,但是Struts2中的Action也可以继承ActionSupport类就不再属于POJO了。POJO里面是可以包含业务逻辑处理和持久化逻辑,也可以包含类似与JavaBean属性和对属性访问的set和get方法的。
       最后,我们总结一下给一个定义把,POJO是一个简单的、正规Java对象,它包含业务逻辑处理或持久化逻辑等,但不是JavaBean、EntityBean等,不具有任何特殊角色和不继承或不实现任何其它Java框架的类或接口。

你可能感兴趣的:(java,框架,ejb)