[jboss-cvs] JBossAS SVN: r82609 - in projects/ejb3/trunk/docs/tutorial/guide/en: modules and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Jan 5 09:44:23 EST 2009
Author: jaikiran
Date: 2009-01-05 09:44:23 -0500 (Mon, 05 Jan 2009)
New Revision: 82609
Added:
projects/ejb3/trunk/docs/tutorial/guide/en/modules/relationships.xml
projects/ejb3/trunk/docs/tutorial/guide/en/modules/secondary.xml
projects/ejb3/trunk/docs/tutorial/guide/en/modules/security.xml
projects/ejb3/trunk/docs/tutorial/guide/en/modules/singleinheritance.xml
projects/ejb3/trunk/docs/tutorial/guide/en/modules/stateful_deployment_descriptor.xml
projects/ejb3/trunk/docs/tutorial/guide/en/modules/stateless_deployment_descriptor.xml
Modified:
projects/ejb3/trunk/docs/tutorial/guide/en/master.xml
Log:
More tutorials added to the guide
Modified: projects/ejb3/trunk/docs/tutorial/guide/en/master.xml
===================================================================
--- projects/ejb3/trunk/docs/tutorial/guide/en/master.xml 2009-01-05 10:53:19 UTC (rev 82608)
+++ projects/ejb3/trunk/docs/tutorial/guide/en/master.xml 2009-01-05 14:44:23 UTC (rev 82609)
@@ -15,6 +15,12 @@
<!ENTITY mdb SYSTEM "modules/mdb.xml">
<!ENTITY mdb_deployment_descriptor SYSTEM "modules/mdb_deployment_descriptor.xml">
<!ENTITY merge SYSTEM "modules/merge.xml">
+<!ENTITY relationships SYSTEM "modules/relationships.xml">
+<!ENTITY secondary SYSTEM "modules/secondary.xml">
+<!ENTITY security SYSTEM "modules/security.xml">
+<!ENTITY singleinheritance SYSTEM "modules/singleinheritance.xml">
+<!ENTITY stateful_deployment_descriptor SYSTEM "modules/stateful_deployment_descriptor.xml">
+<!ENTITY stateless_deployment_descriptor SYSTEM "modules/stateless_deployment_descriptor.xml">
<!ENTITY todo SYSTEM "modules/todo.xml">
]>
<book lang="en">
@@ -28,5 +34,5 @@
<title>Target Audience</title>
<para>This tutorial is meant for EJB3 application developers on JBoss Application Server. The tutorial walks you through the EJB 3.0 features and how they deploy to JBoss. Please check the <xref linkend="Installation">install guide</xref> for system requirements.</para>
</preface>
-&installing;&stateless;&stateful;&blob;&callbacks;&composite;&embeddable;&entity;&extended_pc;&injection;&interceptor;&jndibinding;&mdb;&mdb_deployment_descriptor;&merge;&todo;
+&installing;&stateless;&stateful;&blob;&callbacks;&composite;&embeddable;&entity;&extended_pc;&injection;&interceptor;&jndibinding;&mdb;&mdb_deployment_descriptor;&merge;&relationships;&secondary;&security;&singleinheritance;&stateful_deployment_descriptor;&stateless_deployment_descriptor;&todo;
</book>
Added: projects/ejb3/trunk/docs/tutorial/guide/en/modules/relationships.xml
===================================================================
--- projects/ejb3/trunk/docs/tutorial/guide/en/modules/relationships.xml (rev 0)
+++ projects/ejb3/trunk/docs/tutorial/guide/en/modules/relationships.xml 2009-01-05 14:44:23 UTC (rev 82609)
@@ -0,0 +1,139 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<chapter id="EJB3 Entity Relationships">
+ <title>Introduction to relationships between EJB3 entities</title>
+ <para>
+ The "entity" tutorial only showed one-to-many and many-to-one relationships.
+ This tutorial will show you one-to-one and many-to-many relationships.
+ </para>
+
+ <sect5>
+ One-to-One :
+ <para>
+ There is a unidirectional one-to-one relationship defined between the <literal>org.jboss.tutorial.relationships.bean.Customer</literal>
+ and <literal>org.jboss.tutorial.relationships.bean.Address</literal>. Customer defines the uni-directional relationship.
+ </para>
+ <programlisting>
+ <![CDATA[
+ at OneToOne(cascade = {CascadeType.ALL})
+ at JoinColumn(name = "ADDRESS_ID")
+public Address getAddress()
+{
+ return address;
+}
+
+ ]]>
+ </programlisting>
+ <para>
+ <literal>CascadeType.ALL</literal> specifies that when a Customer is created, if there is any
+ Address association, then that Address will be created as well(<literal>CascadeType.PERSIST</literal>).
+ If the Customer is deleted from persistence storage, the Address will be deleted(<literal>CascadeType.REMOVE</literal>).
+ If a Customer instance is re-attached to persistence storage, any changes to the Address collection will be merged with
+ persistence storage (<literal>CascadeType.MERGE</literal>).
+ </para>
+ </sect5>
+
+ <sect5>
+ Many-To-Many :
+ <para>
+ There is a many-to-many relationship between <literal>org.jboss.tutorial.relationships.bean.Customer</literal>
+ and <literal>org.jboss.tutorial.relationships.bean.Flight</literal>. In order to have a many-to-many relationship
+ there needs to be a distinct join table that maps the many-to-many relationship. This is called an association table.
+ You can have JBoss automatically generate the association table for you, or you can use the <literal>@JoinTable</literal>
+ annotation to define it yourself. If you use <literal>@JoinTable</literal> it must be defined on both sides of the
+ bi-directional relationship. Let's look at the Customer side of the relationship:
+ <programlisting>
+ <![CDATA[
+ at ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.EAGER, mappedBy="customers")
+ ]]>
+ </programlisting>
+ <para>
+ The <literal>mappedBy</literal> attribute states that the <literal>Flight.customers</literal> property is responsible
+ for mapping and managing the relationship. The spec allows for multiple join and inverse join columns.
+ See the "Composite Primary Key" tutorial for more information.
+ </para>
+ Let's look at the other side of the relationship in Flight.
+ <programlisting>
+ <![CDATA[
+ at ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.EAGER)
+ at JoinTable(table = @Table(name = "flight_customer_table"),
+ joinColumns = {@JoinColumn(name = "FLIGHT_ID")},
+ inverseJoinColumns = {@JoinColumn(name = "CUSTOMER_ID")})
+public Set<Customer> getCustomers()
+{
+ return customers;
+}
+
+ ]]>
+ </programlisting>
+ The database associate table will look like this:
+
+ <programlisting>
+ <![CDATA[
+create table FLIGHT_CUSTOMER_TABLE (
+ CUSTOMER_ID integer,
+ FLIGHT_ID integer
+ );
+ ]]>
+ </programlisting>
+ </para>
+
+ </sect5>
+
+ <sect5>
+
+Building and Running
+ <para>
+ <note>
+ <para>
+ To build and run the example, make sure you have installed JBoss 5.x.
+ See the <xref linkend="JBossAS5">installation section</xref> for details.
+ </para>
+ </note>
+
+ <sect5>
+ Ant Users:
+ </sect5>
+ <para>
+ Make sure your JBossAS-5.x is running
+ </para>
+ <programlisting>
+ <![CDATA[
+$ ant
+$ ant run
+
+run:
+ [java] Air France customers
+ [java] Bill
+ [java] Monica
+ [java] USAir customers
+ [java] Molly
+
+
+
+ ]]>
+ </programlisting>
+
+ <sect5>
+ Maven Users: <xref linkend="Maven_Users_TODO">TODO</xref>
+ </sect5>
+
+ <programlisting>
+$ mvn clean install
+ </programlisting>
+
+ </para>
+ </sect5>
+
+ <sect5>
+ View the tables and rows:
+
+ <para>
+ You can view the tables created by JBoss by going to the
+ <ulink url="http://localhost:8080/jmx-console/HtmlAdaptor?action=inspectMBean&name=jboss%3Aservice%3DHypersonic%2Cdatabase%3DlocalDB">Hypersonic Service</ulink>,
+ scrolling down to the <literal>startDatabaseManager</literal> button and clicking it.
+ A Hypersonic SQL window will be minimized, but you can open it up to look at the tables and do queries.
+
+ </para>
+ </sect5>
+
+</chapter>
Added: projects/ejb3/trunk/docs/tutorial/guide/en/modules/secondary.xml
===================================================================
--- projects/ejb3/trunk/docs/tutorial/guide/en/modules/secondary.xml (rev 0)
+++ projects/ejb3/trunk/docs/tutorial/guide/en/modules/secondary.xml 2009-01-05 14:44:23 UTC (rev 82609)
@@ -0,0 +1,91 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<chapter id="Secondary Tables for EJB3 Entities">
+ <title>Introduction to Secondary tables for EJB3 entities</title>
+ <para>
+ The EJB specification allows you to map an entity bean to multiple tables. You do this by using the <literal>@SecondaryTable</literal>
+ annotation.
+ </para>
+ <para>
+ The <literal>org.jboss.tutorial.secondary.bean.Customer</literal> entity maps its address properties to a
+ separate ADDRESS table. The first thing it does is define the secondary table.
+ <programlisting>
+ <![CDATA[
+ at Entity
+ at Table(name = "CUSTOMER")
+ at SecondaryTable(name = "EMBEDDED_ADDRESS", join = {@JoinColumn(name = "ADDRESS_ID")})
+public class Customer implements java.io.Serializable
+{
+}
+ ]]>
+ </programlisting>
+ The <literal>@JoinColumn</literal> of the secondary table must match the value of the Customer's primary key. To map
+ individual properties to a secondary table you use the <literal>secondaryTable</literal> member value of <literal>@Column</literal>.
+ <programlisting>
+ <![CDATA[
+ at Column(name = "STREET", secondaryTable = "EMBEDDED_ADDRESS")
+public String getStreet()
+{
+ return street;
+}
+
+ ]]>
+ </programlisting>
+ </para>
+
+ <sect5>
+
+Building and Running
+ <para>
+ <note>
+ <para>
+ To build and run the example, make sure you have installed JBoss 5.x.
+ See the <xref linkend="JBossAS5">installation section</xref> for details.
+ </para>
+ </note>
+
+ <sect5>
+ Ant Users:
+ </sect5>
+ <para>
+ Make sure your JBossAS-5.x is running
+ </para>
+ <programlisting>
+ <![CDATA[
+$ ant
+$ ant run
+
+run:
+ [java] Create Bill Burke and Monica Smith
+ [java] Bill and Monica get married
+ [java] Get all the Burkes
+ [java] There are now 2 Burkes
+
+
+
+ ]]>
+ </programlisting>
+
+ <sect5>
+ Maven Users: <xref linkend="Maven_Users_TODO">TODO</xref>
+ </sect5>
+
+ <programlisting>
+$ mvn clean install
+ </programlisting>
+
+ </para>
+ </sect5>
+
+ <sect5>
+ View the tables and rows:
+
+ <para>
+ You can view the tables created by JBoss by going to the
+ <ulink url="http://localhost:8080/jmx-console/HtmlAdaptor?action=inspectMBean&name=jboss%3Aservice%3DHypersonic%2Cdatabase%3DlocalDB">Hypersonic Service</ulink>,
+ scrolling down to the <literal>startDatabaseManager</literal> button and clicking it.
+ A Hypersonic SQL window will be minimized, but you can open it up to look at the tables and do queries.
+
+ </para>
+ </sect5>
+
+</chapter>
\ No newline at end of file
Added: projects/ejb3/trunk/docs/tutorial/guide/en/modules/security.xml
===================================================================
--- projects/ejb3/trunk/docs/tutorial/guide/en/modules/security.xml (rev 0)
+++ projects/ejb3/trunk/docs/tutorial/guide/en/modules/security.xml 2009-01-05 14:44:23 UTC (rev 82609)
@@ -0,0 +1,124 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<chapter id="Security and Transactions in EJB3">
+ <title>Introduction to Security and Transactions in EJB3</title>
+
+ <para>
+ The EJB 3.0 specification has made the XML deployment descriptors optional. This tutorial goes over how to
+ use the transaction and security annotations of EJB 3.0.
+
+ </para>
+ <sect5>
+ Transactions :
+ <para>
+ Using transactions is easy, just use the <listing>javax.ejb.TransactionAttribute</listing> annotation.
+ The <literal>javax.ejb.TransactionAttributeType</literal> enum has every transactional type. Here's an example
+ for using REQUIRES_NEW transaction type:
+ <programlisting>
+ <![CDATA[
+ at TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
+public int add(int x, int y)
+{
+ return x + y;
+}
+
+ ]]>
+ </programlisting>
+
+ </para>
+ </sect5>
+
+ <sect5>
+ Security :
+ <para>
+ Take a look at <listing>org.jboss.tutorial.security.bean.CalculatorBean</listing>. The <literal>@javax.annotation.security.RolesAllowed</literal>
+ and <literal>@javax.annotation.security.PermitAll</literal> are the EJB 3.0 security annotations. You can attach a method permission to any method
+ and define which roles are allowed to invoke on that method. The <literal>javax.ejb.RunAs</literal> annotation can also be applied at the class
+ level. There is also an additional JBoss specific annotation that you must supply at the class level <literal>@org.jboss.ejb3.annotation.SecurityDomain</literal>.
+ The <literal>@SecurityDomain</literal> specifies the JAAS application-policy name which will be used by JBoss to authenticate and authorize.
+ See the JBoss Application Server documentation for more details. In this particular example, the "other" domain is used.
+ The "other" domain corresponds to a users.properties and roles.properties files that contain cleartext user, password, and user/role associations.
+ If you open the tutorial jar file you will see these two files in there.
+
+ </para>
+ </sect5>
+
+ <sect5>
+ Client :
+ <para>
+ Open up <literal>org.jboss.tutorial.security.client.Client</literal>. You'll see that it looks up the stateless bean.
+ Also notice that there is no Home interface and you can begin executing on the stateless bean right away.
+ The client uses a JBoss's SecurityClient class to pass the user name and password:
+ <programlisting>
+ <![CDATA[
+import org.jboss.security.client.SecurityClient;
+import org.jboss.security.client.SecurityClientFactory;
+
+SecurityClient securityClient = SecurityClientFactory.getSecurityClient();
+securityClient.setSimple("kabir", "invalidpassword");
+securityClient.login();
+ ]]>
+ </programlisting>
+ <note>
+ <para>See the documentation of org.jboss.security.client.SecurityClient for more options</para>
+ </note>
+ </para>
+ </sect5>
+
+ <sect5>
+
+Building and Running
+ <para>
+ <note>
+ <para>
+ To build and run the example, make sure you have installed JBoss 5.x.
+ See the <xref linkend="JBossAS5">installation section</xref> for details.
+ </para>
+ </note>
+
+ <sect5>
+ Ant Users:
+ </sect5>
+ <para>
+ Make sure your JBossAS-5.x is running
+ </para>
+ <programlisting>
+ <![CDATA[
+$ ant
+$ ant run
+
+run:
+ [java] Kabir is a student.
+ [java] Kabir types in the wrong password
+ [java] Authentication exception, principal=kabir
+ [java] Kabir types in correct password.
+ [java] Kabir does unchecked addition.
+ [java] 1 + 1 = 2
+ [java] Kabir is not a teacher so he cannot do division
+ [java] Insufficient method permissions, principal=kabir, interface=org.jboss.ejb3.EJBContainerInvocation, requiredRoles=[teacher], principalRoles=[student]
+ [java] Students are allowed to do subtraction
+ [java] 1 - 1 = 0
+
+ ]]>
+ </programlisting>
+
+ <sect5>
+ Maven Users: <xref linkend="Maven_Users_TODO">TODO</xref>
+ </sect5>
+
+ <programlisting>
+$ mvn clean install
+ </programlisting>
+
+ </para>
+ <note>
+ <para>
+ If you want to change the roles for the user, through the roles.properties, you will have to
+ restart the server, for the role changes to take effect. This is because by default JBoss caches the roles for a
+ user and until the cache is flushed, either through this <ulink url="http://www.jboss.org/community/docs/DOC-9246">configuration</ulink>
+ or through server restart, the changes won't take effect.
+ </para>
+ </note>
+ </sect5>
+
+
+</chapter>
Added: projects/ejb3/trunk/docs/tutorial/guide/en/modules/singleinheritance.xml
===================================================================
--- projects/ejb3/trunk/docs/tutorial/guide/en/modules/singleinheritance.xml (rev 0)
+++ projects/ejb3/trunk/docs/tutorial/guide/en/modules/singleinheritance.xml 2009-01-05 14:44:23 UTC (rev 82609)
@@ -0,0 +1,135 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<chapter id="Single Inheritance in EJB3 Entities">
+ <title>Introduction Single Inheritance in EJB3 Entities</title>
+
+ <para>
+ The EJB specification allows you to define entities that inherit from one another. The inheritance relationships can be reflected in
+ queries as well. So, if you queried based on the base class, the query is polymorphic.
+ </para>
+
+ <para>
+ The tutorial example uses the single table strategy to map an inheritance relationship of <literal>org.jboss.tutorial.singleinheritance.bean.Pet</literal>,
+ which is the base class for <literal>org.jboss.tutorial.singleinheritance.bean.Cat</literal> and <literal>org.jboss.tutorial.singleinheritance.bean.Dog</literal>.
+ With the single table strategy, the entire class hierarchy is persisted in one big single table. A discriminator column is required to
+ differentiate between which class type is persisted in a particular row. This is what the annotations look like for Pet.
+
+ <programlisting>
+ <![CDATA[
+ at Entity
+ at Inheritance(strategy = InheritanceType.SINGLE_TABLE)
+ at DiscriminatorColumn(name = "ANIMAL_TYPE", discriminatorType = DiscriminatorType.STRING)
+public class Pet implements java.io.Serializable
+{
+}
+ ]]>
+ </programlisting>
+
+ The <literal>@DiscriminatorColumn</literal> specifies the column that will hold the type of the persisted entity.
+ For subclasses, they must define the value of the discriminator column that will identify the class.
+
+ <para>
+ Here's the Dog entity which extends Pet:
+ <programlisting>
+ <![CDATA[
+ at Entity
+ at Inheritance(strategy = InheritanceType.SINGLE_TABLE)
+ at DiscriminatorColumn(discriminatorType = DiscriminatorType.STRING)
+ at DiscriminatorValue("DOG")
+public class Dog extends Pet
+{
+}
+ ]]>
+ </programlisting>
+ </para>
+
+ </para>
+
+ <sect5>
+ Polymorphic queries:
+ <para>
+ <literal>org.jboss.tutorial.singleinheritance.bean.PetDAOBean</literal> stateless EJB wraps some polymorphic queries.
+ <programlisting>
+ <![CDATA[
+public List findByWeight(double weight)
+{
+ return manager.createQuery("from Pet p where p.weight < :weight").setParameter("weight", weight).getResultList();
+}
+
+ ]]>
+ </programlisting>
+ </para>
+ Even though the <listing>findByWeight</listing> method queries on Pet, either Dog or Cat instances can be returned.
+ </sect5>
+
+ <sect5>
+ Table Mapping :
+ <para>
+ The table mapping for this example looks like this:
+ <programlisting>
+ <![CDATA[
+create table PET (
+ ID integer primary key,
+ ANIMAL_TYPE varchar,
+ NAME varchar,
+ WEIGHT double,
+ LIVES int,
+ NUMBONES int
+);
+
+ ]]>
+ </programlisting>
+ </para>
+ </sect5>
+
+ <sect5>
+
+Building and Running
+ <para>
+ <note>
+ <para>
+ To build and run the example, make sure you have installed JBoss 5.x.
+ See the <xref linkend="JBossAS5">installation section</xref> for details.
+ </para>
+ </note>
+
+ <sect5>
+ Ant Users:
+ </sect5>
+ <para>
+ Make sure your JBossAS-5.x is running
+ </para>
+ <programlisting>
+ <![CDATA[
+$ ant
+$ ant run
+
+run:
+ [java] Sox
+ [java] Junior
+
+ ]]>
+ </programlisting>
+
+ <sect5>
+ Maven Users: <xref linkend="Maven_Users_TODO">TODO</xref>
+ </sect5>
+
+ <programlisting>
+$ mvn clean install
+ </programlisting>
+
+ </para>
+ </sect5>
+
+ <sect5>
+ View the tables and rows:
+
+ <para>
+ You can view the tables created by JBoss by going to the
+ <ulink url="http://localhost:8080/jmx-console/HtmlAdaptor?action=inspectMBean&name=jboss%3Aservice%3DHypersonic%2Cdatabase%3DlocalDB">Hypersonic Service</ulink>,
+ scrolling down to the <literal>startDatabaseManager</literal> button and clicking it.
+ A Hypersonic SQL window will be minimized, but you can open it up to look at the tables and do queries.
+
+ </para>
+ </sect5>
+</chapter>
\ No newline at end of file
Added: projects/ejb3/trunk/docs/tutorial/guide/en/modules/stateful_deployment_descriptor.xml
===================================================================
--- projects/ejb3/trunk/docs/tutorial/guide/en/modules/stateful_deployment_descriptor.xml (rev 0)
+++ projects/ejb3/trunk/docs/tutorial/guide/en/modules/stateful_deployment_descriptor.xml 2009-01-05 14:44:23 UTC (rev 82609)
@@ -0,0 +1,126 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<chapter id="Stateful Session Beans in EJB3 with deployment descriptors">
+ <title>Configuring Stateful Session Beans with deployment descriptors in EJB3</title>
+
+ <para>
+ Take a look at the <literal>META-INF/ejb-jar.xml</literal> and <literal>org.jboss.tutorial.stateful_deployment_descriptor.bean.ShoppingCartBean</literal>.
+ You specify a stateful bean with the "session" and "session-type" tags. Note that all bean types in EJB 3.0 are homeless,
+ so there is no requirement for a "home" or "local-home" tag. The bean class is specified with the "ejb-class" tag.
+ </para>
+ <para>
+ ShoppingCartBean also implements a business-remote interface. Take a look at <literal>org.jboss.tutorial.stateful_deployment_descriptor.bean.ShoppingCart</literal>.
+ To define this as the business-remote interface of ShoppingCartBean you need to use the "business-remote" tag in the ejb-jar.xml. Here's the <literal>META-INF/ejb-jar.xml</literal>:
+
+ <programlisting>
+ <![CDATA[
+<session>
+ <ejb-name>ShoppingCart</ejb-name>
+ <business-remote>org.jboss.tutorial.stateful_deployment_descriptor.bean.ShoppingCart</business-remote>
+ <ejb-class>org.jboss.tutorial.stateful_deployment_descriptor.bean.ShoppingCartBean</ejb-class>
+ <session-type>Stateful</session-type>
+ <remove-method>
+ <bean-method>
+ <method-name>checkout</method-name>
+ </bean-method>
+ <retain-if-exception>false</retain-if-exception>
+ </remove-method>
+ <transaction-type>Container</transaction-type>
+</session>
+ ]]>
+ </programlisting>
+
+ <note>
+ <para>
+ There's a very important difference between the <literal>remote</literal> and a <literal>business-remote</literal>
+ interface. The EJB2.x remote interfaces, which extend from EJBObject, are referred through the <literal><remote></literal>
+ tag in the ejb-jar.xml. On the other hand, the EJB3 style Plain Old Java Interface which is implemented by your EJB3 style
+ POJO bean is known as the business-remote interface and is represented by the <literal>@Remote</literal> and it's
+ corresponding <literal><business-remote></literal> tag in ejb-jar.xml.
+
+ Similar is the case with <literal><local></literal> and the <literal><business-local></literal> tags in ejb-jar.xml.
+ </para>
+ </note>
+
+ </para>
+
+ <sect5>
+ @Remove :
+ <para>
+ Take another look at <literal>META-INF/ejb-jar.xml</literal>. Look for the "remove-method" tag.
+ Instead of explicitly calling EJBObject.remove() in your applications and thus polluting it further with J2EE specific code,
+ any method specified in the "remove-method" tag will cause the stateful bean instance to be removed from the container
+ at the end of the method call. This deployment descriptor behavior mimics the <literal>@Remove</literal> annotation.
+
+ </para>
+ </sect5>
+
+ <sect5>
+ JNDI Bindings through deployment descriptor :
+
+ <para>
+ The CalculatorBean will have its remote interface bound in JNDI. Take a look at <literal>META-INF/jboss.xml</literal>.
+ Note the <literal>jndi-name</literal> tag. This specifies the jndi binding for the remote interface of the bean.
+
+ </para>
+ </sect5>
+
+ <sect5>
+ Client :
+ <para>
+ Open up <literal>org.jboss.tutorial.stateful_deployment_descriptor.client.Client</literal>.
+ You'll see that it looks up the stateful bean under its jndi name. Also notice that there is no Home interface
+ and you can begin executing on the stateful bean right away. When you access the bean in JNDI, an instance of the stateful
+ bean will be created on the server. So, when you need a different instance of the stateful bean, you do an additional
+ jndi lookup to get this new reference.
+ </para>
+ </sect5>
+
+ <sect5>
+
+Building and Running
+ <para>
+ <note>
+ <para>
+ To build and run the example, make sure you have installed JBoss 5.x.
+ See the <xref linkend="JBossAS5">installation section</xref> for details.
+ </para>
+ </note>
+
+ <sect5>
+ Ant Users:
+ </sect5>
+ <para>
+ Make sure your JBossAS-5.x is running
+ </para>
+ <programlisting>
+ <![CDATA[
+$ ant
+$ ant run
+
+run:
+ [java] Buying 1 memory stick
+ [java] Buying another memory stick
+ [java] Buying a laptop
+ [java] Print cart:
+ [java] 2 Memory stick
+ [java] 1 Laptop
+ [java] Checkout
+ [java] Should throw an object not found exception by invoking on cart after @Remove method
+ [java] Successfully caught no such object exception.
+
+ ]]>
+ </programlisting>
+
+ <sect5>
+ Maven Users: <xref linkend="Maven_Users_TODO">TODO</xref>
+ </sect5>
+
+ <programlisting>
+$ mvn clean install
+ </programlisting>
+
+ </para>
+ </sect5>
+
+
+</chapter>
Added: projects/ejb3/trunk/docs/tutorial/guide/en/modules/stateless_deployment_descriptor.xml
===================================================================
--- projects/ejb3/trunk/docs/tutorial/guide/en/modules/stateless_deployment_descriptor.xml (rev 0)
+++ projects/ejb3/trunk/docs/tutorial/guide/en/modules/stateless_deployment_descriptor.xml 2009-01-05 14:44:23 UTC (rev 82609)
@@ -0,0 +1,115 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<chapter id="Stateless Session Beans in EJB3 with deployment descriptors">
+ <title>Configuring Stateless Session Beans with deployment descriptors in EJB3</title>
+
+ <para>
+ CalculatorBean is defined as a stateless session bean through the <literal><session></literal> and
+ <literal><session-type></literal> elements. This marks the class as a stateless bean and the deployer will
+ deploy that class as a stateless bean EJB container.
+ </para>
+ <para>
+ CalculatorBean also implements two interfaces. One is the business-remote interface of the EJB the other is the business-local
+ interface. Take a look at <literal>org.jboss.tutorial.stateless_deployment_descriptor.bean.CalculatorRemote</literal>. To define this
+ as the business-remote interface of Calculator bean you specify the interface with the <literal><remote></literal> tag.
+ Similarly for <literal>org.jboss.tutorial.stateless_deployment_descriptor.bean.CalculatorLocal</literal> you need to specify the
+ business-local interface with the <literal><local></literal> tag. Here's the <literal>META-INF/ejb-jar.xml</literal>:
+
+ <programlisting>
+ <![CDATA[
+<session>
+ <ejb-name>Calculator</ejb-name>
+ <business-local>org.jboss.tutorial.stateless_deployment_descriptor.bean.CalculatorLocal</business-local>
+ <business-remote>org.jboss.tutorial.stateless_deployment_descriptor.bean.CalculatorRemote</business-remote>
+ <ejb-class>org.jboss.tutorial.stateless_deployment_descriptor.bean.CalculatorBean</ejb-class>
+ <session-type>Stateless</session-type>
+ <transaction-type>Container</transaction-type>
+</session>
+ ]]>
+ </programlisting>
+
+ <note>
+ <para>
+ There's a very important difference between the <literal>remote</literal> and a <literal>business-remote</literal>
+ interface. The EJB2.x remote interfaces, which extend from EJBObject, are referred through the <literal><remote></literal>
+ tag in the ejb-jar.xml. On the other hand, the EJB3 style Plain Old Java Interface which is implemented by your EJB3 style
+ POJO bean is known as the business-remote interface and is represented by the <literal>@Remote</literal> and it's
+ corresponding <literal><business-remote></literal> tag in ejb-jar.xml.
+
+ Similar is the case with <literal><local></literal> and the <literal><business-local></literal> tags in ejb-jar.xml.
+ </para>
+ </note>
+
+ </para>
+ <sect5>
+ JNDI Bindings through deployment descriptor :
+
+ <para>
+ The Calculator bean will have two JNDI bindings for the remote and Local interface. The <literal>META-INF/jboss.xml</literal>
+ through the <literal><jndi-name></literal> and the <literal><local-jndi-name></literal> specifies the jndi-name
+ for the remote and the local interfaces, respectively:
+
+ <programlisting>
+ <![CDATA[
+<session>
+ <ejb-name>Calculator</ejb-name>
+ <jndi-name>org.jboss.tutorial.stateless_deployment_descriptor.bean.CalculatorRemote</jndi-name>
+ <local-jndi-name>org.jboss.tutorial.stateless_deployment_descriptor.bean.CalculatorLocal</local-jndi-name>
+</session>
+ ]]>
+ </programlisting>
+
+ </para>
+ </sect5>
+
+ <sect5>
+ Client :
+
+ <para>
+ Open up <literal>org.jboss.tutorial.stateless_deployment_descriptor.client.Client</literal>.
+ The client looks up the bean using the jndi-name specified in the jboss.xml. Also notice that there is no Home interface
+ and you can begin executing on the stateless bean right away.
+
+ </para>
+ </sect5>
+
+ <sect5>
+
+Building and Running
+ <para>
+ <note>
+ <para>
+ To build and run the example, make sure you have installed JBoss 5.x.
+ See the <xref linkend="JBossAS5">installation section</xref> for details.
+ </para>
+ </note>
+
+ <sect5>
+ Ant Users:
+ </sect5>
+ <para>
+ Make sure your JBossAS-5.x is running
+ </para>
+ <programlisting>
+ <![CDATA[
+$ ant
+$ ant run
+
+run:
+ [java] 1 + 1 = 2
+ [java] 1 - 1 = 0
+
+ ]]>
+ </programlisting>
+
+ <sect5>
+ Maven Users: <xref linkend="Maven_Users_TODO">TODO</xref>
+ </sect5>
+
+ <programlisting>
+$ mvn clean install
+ </programlisting>
+
+ </para>
+ </sect5>
+
+</chapter>
More information about the jboss-cvs-commits
mailing list