Plain old Java object: Difference between revisions

Content deleted Content added
fixed POCO link.
m Task 70: Update syntaxhighlight tags - remove use of deprecated <source> tags
Line 14:
==Definition==
Ideally speaking, a POJO is a Java object not bound by any restriction other than those forced by the Java Language Specification; i.e. a POJO '''should not''' have to
#Extend prespecified classes, as in<sourcesyntaxhighlight lang="java">public class Foo extends javax.servlet.http.HttpServlet { ...</sourcesyntaxhighlight>
#Implement prespecified interfaces, as in<sourcesyntaxhighlight lang="java">public class Bar implements javax.ejb.EntityBean { ...</sourcesyntaxhighlight>
#Contain prespecified [[Java annotation|annotations]], as in<sourcesyntaxhighlight lang="java">@javax.persistence.Entity public class Baz { ...</sourcesyntaxhighlight>
However, due to technical difficulties and other reasons, many software products or frameworks described as POJO-compliant actually still require the use of prespecified annotations for features such as persistence to work properly.
The idea is that if the object (actually class) were a POJO before any annotations were added, and would return to POJO status if the annotations are removed then it can still be considered a POJO. Then the basic object remains a POJO in that it has no special characteristics (such as an implemented interface) that makes it a "Specialized Java Object" (SJO or (sic) SoJO).