enterprise javabeans ejb n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
DALILA BURHAN 142568 NAZIRAH SHARIFUDDIN 142554 PowerPoint Presentation
Download Presentation
DALILA BURHAN 142568 NAZIRAH SHARIFUDDIN 142554

Loading in 2 Seconds...

play fullscreen
1 / 25

DALILA BURHAN 142568 NAZIRAH SHARIFUDDIN 142554 - PowerPoint PPT Presentation


  • 121 Views
  • Uploaded on

ENTERPRISE JAVABEANS (EJB). DALILA BURHAN 142568 NAZIRAH SHARIFUDDIN 142554. Introduction.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'DALILA BURHAN 142568 NAZIRAH SHARIFUDDIN 142554' - kynan


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
introduction
Introduction
  • The Enterprise JavaBeans architecture is a component architecture for the development and deployment of component-based distributed business applications. Applications written using the Enterprise JavaBeans architecture are scalable, transactional, and multi-user secure. These applications may be written once, and then deployed on any server platform that supports the Enterprise JavaBeans specification.
context three tier architectures
Context: Three-tier Architectures

First Tier

Middle Tier

Third Tier

Presentation

Business Logic

Backend

Database

Database

implementing distributed objects using stubs and skeletons
Implementing Distributed Objects using Stubs and Skeletons

Client

Server

2. Communicate

method invoked

SKELETON

1. Client invokes

a method

Object

Server

STUB

NETWORK

3. Invoke on server

5. Return result

4. Communicate

return value

Distributed object architectures are based on a network communication layer. Essentially, there are three parts to this architecture: the object server, the skeleton, and the stub.

The object server is the business object that resides on the middle tier.

The stub and the skeleton are responsible for making the object server, which lives on the middle tier, look like if it is running locally on the client machine. This is accomplished through some kind of remote method invocation protocol.

The stub acts as the object server’s surrogate on the client. This means from the outside that the stub must look like the Object server which means the stub implements the same interface. However it doesn’t contain any business logic, it only implements the networking operations that are required to forward the request to the object server and receive the results.

different types within business logic
Different Types Within Business Logic

Stateless

Stateful

A bean implements business logic:

Business process SessionBean

Business data EntityBean

Remote Interface

Home Interface

Primary Key

Entity bean might represent a customer, a piece of equipment, an item in inventory, or even a place. In othter words, entity beans model real-world objects; these objects are usually persistent records in some kind of database.

Session beans are an extension of the client application and are responsible for managing processes or tasks (making a reservation, …). A session bean doesn’t represent something in a database. Obviously, session beans have lots of side effects on the database.

The remote interface for an enterprise bean defines the bean’s business methods: the methods a bean presents to the outside world to do its work. The methods in this interface can be used by the client and the methods are implemented by the bean class.

The home interface defines the bean’s life cycle methods: methods for creating new beans, removing beans and finding beans

message driven beans
Message Driven Beans
  • Message listener interface that act in the business interface
  • No requirement to implement on other interface
  • can process JMS messages or other kinds of messages.
  • Message-driven beans have the following characteristics:
    • They execute upon receipt of a single client message.
    • They are invoked asynchronously.
    • They do not represent directly shared data in the database, but they can access and update this data.
    • They can be transaction-aware.
    • They are stateless.
enterprise javabeans architecture
Enterprise JavaBeans Architecture

EJB Server

Client

Client code

EJB Container

EJB home

Home interface

EJB object

Remote interface

Bean class

Red: define your self

Yellow: automatically generated

bean deployment
Bean Deployment
  • Beans are deployed using JAR (Java ARchive) files.

JAR file

Class files

Deployment descriptor

resource management
Resource Management

Session beans reduce network traffic and thin down clients

  • Client using only Entity beans
  • Logic is in client
  • Clients does lots of small updates on entity beans
  • Client using Session beans
  • Logic is in the session beans
  • Client only gives small number of commands to Session beans

EJB SERVER

conclusion ejb is about hiding
Conclusion EJB is About Hiding
  • EJB hides a lot of things for the developer. Such that the developer can focus on the business logic of the application.
  • EJB hides:
    • Distribution of objects
    • Resource Management
    • Transactions
    • Security
    • Concurrency
sun java system application server 9 1
Sun Java System Application Server 9.1
  • targeted as the build and runtime environment .
  • to build, deploy, and run the program
starting and stopping the application server
Starting and Stopping the Application Server

To start the Application Server

asadmin start-domain --verbose domain1

  • When completed :

Domain domain1 started.

To stop the Application Server

asadmin stop-domain domain1

  • When the server has stopped :

Domain domain1 stopped.

starting the admin console
Starting the Admin Console
  • To administer the Application Server and manage users, resources, and Java EE applications
  • The Application Server must be running before invoke the Admin Console.
  • To start, open a browser at

http://localhost:4848/asadmin/

starting and stopping the java db database server
Starting and Stopping the Java DB Database Server
  • The App Server includes Java Database Server
  • To start :

asadmin start-database

  • To stop

asadmin stop-database

building using netbeans ide
Building Using NetBeans IDE
  • Register your Application Server installation as a NetBeans Server Instance :
  • Select Tools→Server Manager to open the Server Manager dialog.
  • Click Add Server.
  • Under Platform Location, enter the location of your Application Server installation.
  • Select Register Local Default Domain and click Next.
  • Under Admin Username and Admin Password, enter the admin name and password created when you installed the Application Server.
  • Click Finish.
getting started with enterprise beans
Getting Started with Enterprise Beans
  • The purpose of converter is to calculate currency conversions between Japanese yen and Eurodollars.
    • Create the enterprise bean: ConverterBean.
    • Create the application client: ConverterClient.
    • Create the web client in converter-war.
    • Deploy converter onto the server.
    • Run the application client.
    • Using a browser, run the web client.
coding the business interface
Coding the Business Interface

package com.sun.tutorial.javaee.ejb;

 import java.math.BigDecimal;

import javax.ejb.Remote; 

@Remote

public interface Converter {

public BigDecimaldollarToYen(BigDecimal dollars);

public BigDecimalyenToEuro(BigDecimal yen);

}

coding the enterprise bean class
Coding the Enterprise Bean Class

package com.sun.tutorial.javaee.ejb;

import java.math.BigDecimal;

import javax.ejb.*;

@Stateless

public class ConverterBean implements Converter {

private BigDecimalyenRate = new BigDecimal("115.3100");

private BigDecimaleuroRate = new BigDecimal("0.0071");

public BigDecimaldollarToYen(BigDecimal dollars) {

BigDecimal result = dollars.multiply(yenRate);

return result.setScale(2, BigDecimal.ROUND_UP);}

public BigDecimalyenToEuro(BigDecimal yen) {

BigDecimal result = yen.multiply(euroRate);

return result.setScale(2, BigDecimal.ROUND_UP);}

}

compiling and packaging in netbeans ide
Compiling and Packaging in NetBeans IDE
  • In NetBeans IDE, select File→OpenProject.
  • In the Open Project dialog, navigate to tut-install/javaeetutorial5/examples/ejb/.
  • Select the converter folder.
  • Select the Open as Main Project and Open Required Projects check boxes.
  • Click Open Project.
  • In the Projects tab, right-click the converter project and select Build. You will see the output in the Output tab.
creating application client
Creating Application Client

public void doConversion() {

try {

BigDecimal param = new BigDecimal("100.00");

BigDecimal yenAmount = converter.dollarToYen(param); 

System.out.println("$" + param + " is " + yenAmount + " Yen.");

BigDecimal euroAmount = converter.yenToEuro(yenAmount); System.out.println(yenAmount + " Yen is " + euroAmount + " Euro."); 

System.exit(0);

}

catch (Exception ex) {

System.err.println("Caught an unexpected exception!"); ex.printStackTrace(); }

}

}

package com.sun.tutorial.javaee.ejb; 

import java.math.BigDecimal;

import javax.ejb.EJB;

public class ConverterClient {

@EJB

private static Converter converter;

public ConverterClient(String[] args) {

public static void main(String[] args) {

ConverterClient client = new ConverterClient(args);

client.doConversion();

Compiling -The application client files are compiled at the same time as the enterprise bean files.

creating web client
Creating Web Client

public void jspDestroy() {

converter = null;

}%>

<html>

<head>

<title>Converter</title>

</head> 

<body bgcolor="white">

<h1>Converter</h1>

<hr>

<p>Enter an amount to convert:</p>

<form method="get">

<input type="text" name="amount" size="25">

<br>

<p>

<input type="submit" value="Submit">

<input type="reset" value="Reset">

</form>

<%@ page import="converter.ejb.Converter, java.math.*, javax.naming.*"%> 

<%!

private Converter converter = null;

public void jspInit() {

try {

InitialContext ic = new InitialContext();

converter = (Converter) ic.lookup(Converter.class.getName()); }

catch (Exception ex) {

System.out.println("Couldn’t create converter bean."+ ex.getMessage());

}

slide22

<%

String amount = request.getParameter("amount");

if ( amount != null && amount.length() > 0 ) {

BigDecimal d = new BigDecimal(amount); 

BigDecimal yenAmount = converter.dollarToYen(d);

%>

<p>

<%= amount %> dollars are <%= yenAmount %> Yen.

<p>

<%

BigDecimal euroAmount = converter.yenToEuro(yenAmount);

%>

<%= amount %> Yen are <%= euroAmount %> Euro. <%

}

%>

</body>

</html>

Compiling - The Application Server automatically compiles web clients

deploying in netbeans ide
Deploying in NetBeans IDE
  • In NetBeans IDE, make sure the converter application is open.
  • In the Projects tab, right-click the converter project and select Undeploy and Deploy. You will see the output in the Output tab.
running application server in netbeans ide
Running Application Server in NetBeans IDE
  • In NetBeans IDE, make sure the converter application is open.
  • In the Projects tab, right-click the converter project and select Run. You will see the following output in the Output tab:

...

$100.00 is 11258.00 Yen.

11258.00 Yen is 78.81 Euro.

...

running web client
Running Web Client
  • To run the web client, point your browser at the following URL. Replace host with the name of the host running the Application Server. If your browser is running on the same host as the Application Server, you can replace host with localhost.
    • http://host:8080/converter
    • After entering 100 in the input field and clicking Submit, you should see the screen shown in