| <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| <html lang="en-us" xml:lang="en-us"> |
| <head> |
| <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> |
| <meta name="copyright" content="Copyright (c) 2000, 2011 IBM Corporation and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at https://www.eclipse.org/legal/epl-2.0/. Contributors: IBM Corporation - initial API and implementation" /> |
| <meta name="DC.rights.owner" content="(C) Copyright 2000, 2011" /> |
| <meta content="public" name="security" /> |
| <meta content="index,follow" name="Robots" /> |
| <meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' /> |
| <meta content="concept" name="DC.Type" /> |
| <meta name="DC.Title" content="Plain old Java objects" /> |
| <meta name="abstract" content="Although POJOs existed before, they play a more important role in the programming methodology of Java EE 5. Now, you can now create EJB applications with persistence capabilities by using enterprise beans and entities created from POJOs." /> |
| <meta name="description" content="Although POJOs existed before, they play a more important role in the programming methodology of Java EE 5. Now, you can now create EJB applications with persistence capabilities by using enterprise beans and entities created from POJOs." /> |
| <meta content="Enterprise JavaBeans 3.0" name="DC.subject" /> |
| <meta content="Enterprise JavaBeans 3.0" name="keywords" /> |
| <meta scheme="URI" name="DC.Relation" content="../topics/ejbarch.html" /> |
| <meta content="XHTML" name="DC.Format" /> |
| <meta content="cejb3" name="DC.Identifier" /> |
| <meta content="en-us" name="DC.Language" /> |
| <link href="../../org.eclipse.wst.doc.user/common.css" type="text/css" rel="stylesheet" /> |
| <title>Plain old Java objects (POJOs) in Java EE 5 EJB 3.0 applications</title> |
| </head> |
| <body id="cejb3"><a name="cejb3"><!-- --></a> |
| |
| |
| <h1 class="topictitle1">Plain old Java objects</h1> |
| |
| |
| |
| |
| <div><p>Although POJOs existed before, they play a more important role |
| in the programming methodology of Java™ EE 5. Now, you can now create EJB applications |
| with persistence capabilities by using enterprise beans and entities created |
| from POJOs.</p> |
| |
| <p>The complexity of the Java 2 Enterprise Edition framework used |
| to present a major hurdle for adoption previously. The Java EE |
| 5 specification sought a simpler development experience by making POJOs the |
| basis of its design paradigm. The POJO programming model enables you to unit |
| test outside of the application server, making the whole programming experience |
| smoother.</p> |
| |
| <div class="example"><h4 class="sectiontitle">A simple POJO</h4><p>The following code is an example of |
| a simple POJO. Note that there are no references to any interfaces. To use |
| this POJO as the basis for an EJB 2.1 application requires additional framework |
| classes to support it and the class itself would have to implement additional |
| interfaces.</p> |
| <pre>public class Test { |
| |
| String name; |
| |
| /** |
| * This is a constructor for a Test Object. |
| **/ |
| public Test(){ |
| |
| name = "Jane"; |
| |
| } |
| |
| }</pre> |
| <p>To create an EJB 3.0 bean, inject a component defining annotation |
| at the class level. The following example turns a POJO into a stateless session |
| bean by adding the @Stateless annotation.</p> |
| <pre>@Stateless |
| |
| String class Test { |
| |
| String name; |
| |
| /** |
| * This is a constructor for a Test Object. |
| **/ |
| public Test () { |
| |
| name = "jane"; |
| |
| } |
| |
| }</pre> |
| </div> |
| |
| <div class="example">In a real application, the POJO needs additional business logic. |
| The fundamental idea of using POJOs in the context of the Java EE |
| specification is to associate Metadata about your component to be associated |
| directly in your POJO. This approach reduces the number of artifacts you need |
| to deal with and makes it easier to ensure the integrity of your Metadata.</div> |
| |
| <div class="example">The new POJO-based programming model also shifts your concentration |
| to working on your Java EE 5 components in your Java editor |
| as opposed to writing business logic in XML. By working with this application |
| development software, you can take advantage of features that can even further |
| simplify the process of developing Java EE 5 applications (such as as-you-type |
| validation, content assist, and refactoring). </div> |
| |
| </div> |
| |
| <div> |
| <div class="familylinks"> |
| <div class="parentlink"><strong>Parent topic:</strong> <a href="../topics/ejbarch.html" title="This topic provides a high-level overview of the distributed component architecture defined in the Sun Microsystems Enterprise JavaBeans (EJB) version 3.0 architecture specification.">EJB 3.0 and EJB 3.1 architecture</a></div> |
| </div> |
| </div> |
| |
| </body> |
| </html> |