Upload
alvin-reyes
View
226
Download
0
Embed Size (px)
Citation preview
8/6/2019 Lab - Session Beans - Stateless
1/23
Creating Stateless Session Beans
8/6/2019 Lab - Session Beans - Stateless
2/23
Agenda
Install Pre-requisite Softwares and DB
Connection
Develop a simple Stateless Session Bean Call
8/6/2019 Lab - Session Beans - Stateless
3/23
Pre-requisites
Eclipse IDE (Bundled with JBoss 6)
Jboss Server
(http://sourceforge.net/projects/jboss/files/JBoss/JBoss-6.0.0.Final/)
8/6/2019 Lab - Session Beans - Stateless
4/23
Eclipse IDE
http://www.eclipse.org/
http://www.jboss.org/tools/download/
Eclipse IDE Download
Jboss Eclipse Plugin
8/6/2019 Lab - Session Beans - Stateless
5/23
JBoss Server
Download the Application Server:
http://sourceforge.net/projects/jboss/files/JBo
s/JBoss-6.0.0.Final/
8/6/2019 Lab - Session Beans - Stateless
6/23
JBoss Server Installation
Install Jboss Server on your Eclipse IDE.
Step 1: Go to New > Server > Server
Step 2: Choose Jboss AS 6.0
Step 3: Define the Location of the Jboss AS
8/6/2019 Lab - Session Beans - Stateless
7/23
JBoss Server
Define the Home directory
of JBoss AS and click Finish.
8/6/2019 Lab - Session Beans - Stateless
8/23
Project Overview
For this session:
Well create a simple Stateless Session Bean.
8/6/2019 Lab - Session Beans - Stateless
9/23
Create Enterprise Java Bean Project
Go to > New > EJB > EJB Project
Name: ejbsampleproject_
Target: JBoss 6.
Create EAR Project
Create Client Project Click Next to Finish
8/6/2019 Lab - Session Beans - Stateless
10/23
EJB Project Stateless Session Bean
Generated:
EJB Project
Client Project
EAR
8/6/2019 Lab - Session Beans - Stateless
11/23
EJB Project Stateless Session Bean
Make sure that:
Jboss Library is included on the Build
Path of EJB and Client.
8/6/2019 Lab - Session Beans - Stateless
12/23
Create new Session BeanJava Package: com.gradu.ejb.samplebeans
Class name: SampleStatelessBean
State Type: Stateless
Create Remote and Local Interfaces
EJB Project: Develop the Bean
8/6/2019 Lab - Session Beans - Stateless
13/23
Create new Session Bean
Click Finish
EJB Project: Develop the Bean
8/6/2019 Lab - Session Beans - Stateless
14/23
Create new Session Bean
The Wizard Generated the following:
1. Session Bean named SampleStatelessBean
2. Remote Interface named SampleStatelessBeanRemote
3. Local Interface name SampleStatelessBeanLocal
EJB Project: Develop the Bean
8/6/2019 Lab - Session Beans - Stateless
15/23
Create new Session Bean
Generated Session Bean:
EJB Project: Develop the Bean
8/6/2019 Lab - Session Beans - Stateless
16/23
Create new Session Bean
Add a mappedName attribute to the bean. This will serve as the JNDI name of the Bean.
EJB Project: Develop the Bean
8/6/2019 Lab - Session Beans - Stateless
17/23
Modify Local and Remote Interface
Edit the Local and Remote Interface to implement the method.
EJB Project: Develop the Bean
Note: Remote and Local Interface served as the clients reference of the bean.
8/6/2019 Lab - Session Beans - Stateless
18/23
Implement Interface Methods
We need to implement the methods we just added and try returning a String value .
EJB Project: Develop the Bean
8/6/2019 Lab - Session Beans - Stateless
19/23
Create a new Client Class
Create a new class on the client project. This
client will be the one calling our Session Bean
from the Application Server.
EJB Project: Develop the Client
Java Package: com.gradu.ejb.client
Class name: SampleClient
8/6/2019 Lab - Session Beans - Stateless
20/23
Modify the Client Class to Call our Bean
Create a new class on the client project. This client will be the one calling our
Session Bean from the Application Server.
EJB Project: Develop the Client
8/6/2019 Lab - Session Beans - Stateless
21/23
Deploy the Session Bean
We need to deploy the session bean first before executing the Sample Client.
EJB Project: Develop the Client
Run the EAR file on the server to deploy the EJB Components.
8/6/2019 Lab - Session Beans - Stateless
22/23
Verify Deployment from Console
After running the EAR file (deployment), we need to verify if the Application Server
Indeed deployed our beans.
EJB Project: Develop the Client
If the above lines are shown on the Console, then the Session Bean was successfully
deployed.
8/6/2019 Lab - Session Beans - Stateless
23/23
Test the Session Bean using the Client ClassRun the Client Class.
EJB Project: Testing the Bean
If you were able to see the value thrown from the Session Bean, that means you
have successfully called the Bean from the Application Server.