23
INTRODUCTION TO ENTERPRISE JAVA BEAN(EJB) ENTERPRISE JAVA BEAN ARCHITECTURE IS THE COMPONENT ARCHITECTURE FOR THE DEVELOPMENT AND DEPLOYMENT OF ROBUST, WORLD CLASS COMPONENT-BASED DISTRIBUTED APPLICATION USING THE JAVA LANGUAGE. EJB IS A COMPLEX TOPIC AND REQUIRES A LOT OF EFFORT TO MASTER IT. Tips and tools for creating and presenting wide format slides

Introduction to ejb and struts framework

  • Upload
    s4alcom

  • View
    79

  • Download
    2

Embed Size (px)

Citation preview

Page 1: Introduction to ejb and struts framework

INTRODUCTION TO ENTERPRISE JAVA BEAN(EJB)

ENTERPRISE JAVA BEAN ARCHITECTURE IS THE COMPONENT ARCHITECTURE FOR THE DEVELOPMENT AND DEPLOYMENT OF ROBUST, WORLD CLASS COMPONENT-BASED DISTRIBUTED APPLICATION USING THE JAVA LANGUAGE. EJB IS A COMPLEX TOPIC AND REQUIRES A LOT OF EFFORT TO MASTER IT. 

Tips and tools for creating and presenting wide format slides

Page 2: Introduction to ejb and struts framework

Prerequisites: To understand this course you must have

hands-on Java programming language experience.  Understanding of object-oriented programming, distributed computing and component technology helpful. Prior knowledge of Servlets, JSP and JDBC programming are highly recommended.

Page 3: Introduction to ejb and struts framework

Course Content: Introduction to Distributed Applications and Components Introduction to J2EE architecture. Enterprise Java Beans (EJB) - An Introduction Why Enterprise Java Beans (EJB)? Application Servers Available in the market. Downloading and Installing the WebLogic 6.0 server. Introduction to Enterprise Java Beans and developing yo

u first web component. Developing Hello World Session Bean Writing Deployment Descriptor and Client Code for State

less Session Bean Deploying Hello World Session Bean on WebLogic Server

Page 5: Introduction to ejb and struts framework

Two-tier application:

In the past two-tier applications were used. Two-tier applications are also know as client/server applications. In most of the cases these architecture were providing only the database functionality and all the business logic and presentation of the data logic were installed on the client machine. This architecture was very difficult to maintain.

Problems of Two-tier Architecture Easy to install, but very difficult to maintain. Problem of installing and upgrading data access software on each client

machine. It is very difficult to reuse the business and presentation logic. These two-tier applications are not very scalable and therefore not well

suited to the Internet and Intranet Applications.

Page 6: Introduction to ejb and struts framework

Multi tiered J2EE Architecture Sun's J2EE architecture is multi tiered architecture and it

eliminates all the problems of two-tier architecture. It also eliminates the need of writing thin-client multithread applications, which were earlier used to write distributed transactional applications for the enterprise. Thin-client multi tiered applications are very fast, secure and reliable. But writing the thin-client multi tiered applications are not easy and it involves many lines of intricate code to handle transaction and state management, multithreading, resource pooling and other complex low-level details.

Page 7: Introduction to ejb and struts framework

In the Java TM 2 Platform, Enterprise Edition (J2EE tm), low-level details are separated from the business logic. Now the developers will more concentrate on the business logic rather than the low-level details. Low-level details are managed by the application container of the application server.

Page 8: Introduction to ejb and struts framework

J2EETM Architecture consists of following technologies:

Java Database Connectivity (JDBC)  Java Naming and Directory Interface

(JNDI) Enterprise Java Beans (EJB) Java Server Pages (JSP) Java Servlets

Page 9: Introduction to ejb and struts framework

1. Java Database Connectivity or JDBC for short

The JDBC API allows the java programs to access the database.

Page 10: Introduction to ejb and struts framework

2. Java Naming and Directory Interface (JNDI) Sun's JNDI API is a standard extension to the JavaTM

platform and it allows the java applications to access naming and directory services. With the help of JNDI java application can seamlessly access the heterogeneous enterprise naming and directory services like DNS, LDAP, local file system, or objects in an application server.

Page 11: Introduction to ejb and struts framework

3. Enterprise JavaBeans or EJB for short

Sun Microsystem's definition of Enterprise JavaBeans is: "The Enterprise JavaBeans architecture is a component

architecture for developing and deployment of component-based distributed applications. Applications written using the Enterise JavaBeans 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."

The EJB specification defines the EJB component architecture and the interfaces between the Enterprise JavaBeans technology-enabled server and the component.

Page 12: Introduction to ejb and struts framework

There are three types of Beans: A) Stateless Session Beans: These beans do not maintain the state, and the information

stored in these beans are lost when the server crashes. b) Statefull Session Beans: These beans are also short lived and do not survive the

server crashes. These beans are used to maintain the session of a client. Shopping cart is developed using the session beans.

Page 13: Introduction to ejb and struts framework

c) Entity Beans: These beans represents the data stored

in a database. These beans survive the server crashes because it reconstruct the data from the database when server comes up. An example of an entity bean is the users information.

Page 14: Introduction to ejb and struts framework

4. Java Server Pages or JSP for short:

Java Server Pages allows the developers to embed the java code into html pages. It is a mean by which dynamic content can be generated using the static HTML pages and the data from the database.

Page 15: Introduction to ejb and struts framework

5. Java Servlets:

Java Servlets are server side components that provides a powerful mechanism for developing serverside applications.

Page 16: Introduction to ejb and struts framework

What Is the Struts Framework? The Struts Framework is a standard for developing well-architected Web

applications. It has the following features: Open source Based on the Model-View-Controller (MVC) design paradigm, distinctly

separating all three levels: Model: application state View: presentation of data (JSP, HTML) Controller: routing of the application flow

Implements the JSP Model 2 Architecture Stores application routing information and request mapping in a single core

file, struts-config.xml The Struts Framework, itself, only fills in the View and Controller layers. The

Model layer is left to the developer.

Page 17: Introduction to ejb and struts framework

Architecture Overview

Page 18: Introduction to ejb and struts framework

All incoming requests are intercepted by the Struts servlet controller. The Struts Configuration file struts-config.xmlis used by the controller to determine the routing of the flow. This flows consists of an alternation between two transitions:

From View to ActionA user clicks on a link or submits a form on an HTML or JSP page. The controller receives the request, looks up the mapping for this request, and forwards it to an action. The action in turn calls a Model layer (Business layer) service or function.From Action to ViewAfter the call to an underlying function or service returns to the action class, the action forwards to a resource in the View layer and a page is displayed in a web browser.

Page 19: Introduction to ejb and struts framework

The diagram below describes the flow in more detail:

Page 20: Introduction to ejb and struts framework

User clicks on a link in an HTML page. Servlet controller receives the request, looks up mapping information

in struts-config.xml, and routes to an action. Action makes a call to a Model layer service. Service makes a call to the Data layer (database) and the requested data

is returned. Service returns to the action. Action forwards to a View resource (JSP page) Servlet looks up the mapping for the requested resource and forwards to

the appropriate JSP page. JSP file is invoked and sent to the browser as HTML. User is presented with a new HTML page in a web browser.

Page 21: Introduction to ejb and struts framework

Struts Components

The Controller This receives all incoming requests. Its primary function is the mapping of a

request URI to an action class selecting the proper application module. It's provided by the framework.

The struts-config.xml File This file contains all of the routing and configuration information for the Struts

application. This XML file needs to be in the WEB-INF directory of the application.

Action Classes It's the developer's responsibility to create these classes. They act as bridges

between user-invoked URIs and business services. Actions process a request and return an ActionForward object that identifies the next component to invoke. They're part of the Controller layer, not the Model layer.

Page 22: Introduction to ejb and struts framework

View Resources View resources consist of Java Server Pages, HTML pages,

JavaScript and Stylesheet files, Resource bundles, JavaBeans, and Struts JSP tags.

ActionForms These greatly simplify user form validation by capturing user

data from the HTTP request. They act as a "firewall" between forms (Web pages) and the application (actions). These components allow the validation of user input before proceeding to an Action. If the input is invalid, a page with an error can be displayed.

Page 23: Introduction to ejb and struts framework

Model Components

The Struts Framework has no built-in support for the Model layer. Struts supports any model components:

JavaBeans EJB CORBA JDO any other