blob: 2f0e331b8cf64d594860e2e6f7e3db6c0cefd27a [file] [log] [blame]
<?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, 2008 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, 2008" />
<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="task" name="DC.Type" />
<meta name="DC.Title" content="Creating EJB Session Beans" />
<meta name="abstract" content="You can use a wizard to create a session bean and add it to your project." />
<meta name="description" content="You can use a wizard to create a session bean and add it to your project." />
<meta content="session beans, creating" name="DC.subject" />
<meta content="session beans, creating" name="keywords" />
<meta scheme="URI" name="DC.Relation" content="../topics/ceover.html" />
<meta scheme="URI" name="DC.Relation" content="../topics/sessb.html" />
<meta content="XHTML" name="DC.Format" />
<meta content="sessbwiz" 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>Creating EJB Session Beans</title>
</head>
<body id="sessbwiz"><a name="sessbwiz"><!-- --></a>
<h1 class="topictitle1">Creating EJB Session Beans</h1>
<div><p>You can use a wizard to create a session bean and add it to your
project.</p>
<div class="section"><p>The session bean wizard helps you create an Enterprise session
bean by walking you through the creation process and by providing you with
output files that you can use or that you can modify for use with your application.</p>
<p>To
create a session bean, complete the following steps:</p>
</div>
<ol>
<li class="stepexpand"><span>From the Java™ EE perspective, expand your EJB project
in the Project Explorer view.</span></li>
<li class="stepexpand"><span>Right click on the <strong>Session Bean</strong> icon, and select <span class="menucascade">
<span class="uicontrol">New</span> &gt; <span class="uicontrol">Session Bean</span></span> from
the pop-up menu.</span> The <span class="uicontrol">Create Session Bean</span> wizard
appears.</li>
<li class="stepexpand"><span>Follow the project wizard prompts.</span></li>
</ol>
<div class="section"><p><strong>General Information</strong></p>
<dl>
<dt class="dlterm">State type</dt>
<dd>There are three types of session beans: stateless, stateful and singleton. <dl>
<dt class="dlterm">Stateless session beans</dt>
<dd>A stateless session bean is a collection of related services, each represented
by a method; the bean maintains no state from one method invocation to the
next. When you invoke a method on a stateless session bean, it executes the
method and returns the result without knowing or caring what other requests
have gone before or might follow. Stateless session beans have longer lives
because they do not maintain any conversational state.</dd>
<dt class="dlterm">Stateful session beans</dt>
<dd>A stateful session bean performs tasks on behalf of a client and maintains
state related to that client. This state is called conversational state because
it represents a continuing conversation between the stateful session bean
and the client. Methods invoked on a stateful session bean can write and read
data to and from this conversational state, which is shared among all methods
in the bean. Stateful session beans have timeout periods.</dd>
<dt class="dlterm">Singleton session beans</dt>
<dd>A Singleton session bean is a session bean component that is instantiated
once per application. In cases where the container is distributed over many virtual
machines, each application will have one bean instance of the Singleton for each JVM.
Once instantiated, a Singleton session bean instance lives for the duration of the
application in which it is created. It maintains its state between client invocations
but that state is not required to survive container shutdown or crash. A Singleton
session bean is intended to be shared and supports concurrent access.</dd>
</dl>
</dd>
</dl>
<dl>
<dt class="dlterm">Business interface</dt>
<dd>A business interface of a session bean is an ordinary Java interface
that contains the business methods for the bean. A reference to a session
bean's business interface can be passed as a parameter or as a return value
of a business interface method. It contains methods to initialize a session
bean's state and to notify the EJB container when the reference is no more
needed and can be removed. There are several options available:<dl>
<dt class="dlterm">Remote business interface:</dt>
<dd>The client can run on a different machine or different Java virtual
machine than the enterprise bean it accesses and the location of the bean
is transparent.</dd>
<dt class="dlterm">Local business interface:</dt>
<dd>The client must run on the same Java virtual machine as the bean it accesses
and the location of the enterprise bean is not transparent.</dd>
<dt class="dlterm">No-interface:</dt>
<dd>This is a variation of the Local view that exposes the public methods of the
bean class without the use of a separate business interface.</dd>
</dl>
</dd>
</dl>
<dl>
<dt class="dlterm">Mapped name</dt>
<dd>Specifies the bean's global JNDI name. The use of mappedName attribute
allows you to assign names which you can use to search the EJB bean through
the remote client.</dd>
</dl>
<dl>
<dt class="dlterm">Transaction type</dt>
<dd>The <strong>Transaction type</strong> field is used to specify whether the transaction
is handled by the <strong>Container</strong> or the <strong>Bean</strong>.</dd>
</dl>
<dl>
<dt class="dlterm">Home and Components Interfaces</dt>
<dd>Home and component interfaces are used only for EJB 2.x session beans.<dl>
<dt class="dlterm">Home interface:</dt>
<dd>The home interface allows a client to create, remove and find existing
instances of enterprise beans.</dd>
<dt class="dlterm">Component interface:</dt>
<dd>The component interface allows a client to access the business methods
of the enterprise bean.</dd>
</dl>
</dd>
</dl>
</div>
</div>
<div>
<ul class="ullinks">
<li class="ulchildlink"><strong><a href="../topics/sessb.html">Session Beans</a></strong><br />
</li>
</ul>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="../topics/ceover.html" title="The workbench provides a specialized environment that you can use to develop and test enterprise beans that conform to the distributed component architecture defined in the Sun Microsystems Enterprise JavaBeans (EJB) version specification. This product supports the Enterprise JavaBeans 1.1, 2.0, 2.1, and 3.0 specification levels.">EJB 2.x application development</a></div>
</div>
</div>
</body>
</html>