Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

Overview

{span:style=
Span
Wiki Markup
style
float:
right;
margin-left:
20px;
} {

HTML

}



<object width="400" height="250"><param name="movie" value="http://www.youtube.com/v/aLx2jta96xU?fs=1&amp;hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/aLx2jta96xU?fs=1&amp;hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="400" height="250"></embed></object>


{html}


{span}

Div

This example shows how to create a Stateless session EJB using annotations. As stated in the "JSR 220: Enterprise JavaBeansTM,Version 3.0 - EJB Core Contracts and Requirements",

Panel

"Stateless session beans are session beans whose instances have no conversational state. This means that all bean instances are equivalent when they are not involved in servicing a client-invoked method. The term 'stateless' signifies that an instance has no state for a specific client."

What this means is quite simply that stateless beans are shared. They do in fact have state as you can assign values to the variables, etc. in the bean instance. The only catch is there are a pool of identical instances and you are not guaranteed to get the exact same instance on every call. For each call, you get whatever instance happens to be available. This is identical to checking out a book from the library or renting a movie from the video store. You are essentially checking out or renting a new bean instance on each method call.

With EJB 3.0, it's now possible to write stateless session bean without specifying a deployment descriptor; you basically have to write just a remote or local business interface, which is a

Wiki Markup
{div} This example shows how to create a Stateless session EJB using annotations. As stated in the "JSR 220: Enterprise JavaBeansTM,Version 3.0 - EJB Core Contracts and Requirements", {panel} "Stateless session beans are session beans whose instances have no conversational state. This means that all bean instances are equivalent when they are not involved in servicing a client-invoked method. The term 'stateless' signifies that an instance has no state for a specific client." {panel} What this means is quite simply that stateless beans are *shared*. They do in fact have state as you can assign values to the variables, etc. in the bean instance. The only catch is there are a *pool* of identical instances and you are not guaranteed to get the exact same instance on every call. For each call, you get whatever instance happens to be available. This is identical to checking out a book from the library or renting a movie from the video store. You are essentially checking out or renting a new bean instance on each method call. With EJB 3.0, it's now possible to write stateless session bean without specifying a deployment descriptor; you basically have to write just a remote or local business interface, which is a

plain-old-java-interface,

annotated

with

the

@Remote

or

@Local

annotation

the

stateless

session

bean

implementation,

a

plain-old-java-object

which

implements

the

remote

or

the

local

business

interface

and

is

annotated

with

the

@Stateless

annotation

_

This

example

is

the

"simple-stateless"

example

located

in

the

[

openejb-examples.zip

|OPENEJB:Download]

available

on

the

download

page.

_ {

}{div:style=}{div}
Div
Wiki Markup
style
clear:both;

The Code

In this example we develop a simple EJB 3 Stateless session EJB. Every stateless session bean implementation must be annotated using the annotation @Stateless or marked that way in the ejb-jar.xml file.

...