KEMBAR78
Introduction to ejb and struts framework | PPTX
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
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.
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 you first web
component.
 Developing Hello World Session Bean
 Writing Deployment Descriptor and Client Code for Stateless Session
Bean
 Deploying Hello World Session Bean on WebLogic Server
 Writing Calculator Session Bean and Testing on
WebLogic Server
 Understanding Stateful and Stateless Session Beans Life
cycle
 Writing Stateless Session Bean
 Introduction to the Entity Beans
 Writing your first Entity Bean
 Writing Entity Bean with Container Managed Persistence
 Writing Entity Bean with Bean Managed Persistence
 Deploying Entity Bean
 Summing up
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.
 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.
 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.
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
 1. Java Database Connectivity or JDBC for
short
The JDBC API allows the java programs to
access the database.
 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.
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.
 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.
 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.
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.
5. Java Servlets:
 Java Servlets are server side components that
provides a powerful mechanism for developing
serverside applications.
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.
Architecture Overview
 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.
The diagram below describes the
flow in more detail:
 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.
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.
 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.
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

Introduction to ejb and struts framework

  • 1.
    INTRODUCTION TO ENTERPRISEJAVA 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
  • 2.
    Prerequisites:  To understandthis 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.
  • 3.
    Course Content:  Introductionto 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 you first web component.  Developing Hello World Session Bean  Writing Deployment Descriptor and Client Code for Stateless Session Bean  Deploying Hello World Session Bean on WebLogic Server
  • 4.
     Writing CalculatorSession Bean and Testing on WebLogic Server  Understanding Stateful and Stateless Session Beans Life cycle  Writing Stateless Session Bean  Introduction to the Entity Beans  Writing your first Entity Bean  Writing Entity Bean with Container Managed Persistence  Writing Entity Bean with Bean Managed Persistence  Deploying Entity Bean  Summing up
  • 5.
    Two-tier application:  Inthe 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.
  • 6.
     Multi tieredJ2EE 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.
  • 7.
     In theJava 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.
  • 8.
    J2EETM Architecture consistsof following technologies:  Java Database Connectivity (JDBC)  Java Naming and Directory Interface (JNDI)  Enterprise Java Beans (EJB)  Java Server Pages (JSP)  Java Servlets
  • 9.
     1. JavaDatabase Connectivity or JDBC for short The JDBC API allows the java programs to access the database.
  • 10.
     2. JavaNaming 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.
  • 11.
    short  Sun Microsystem'sdefinition 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.
  • 12.
     There arethree 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.
  • 13.
     c) EntityBeans:  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.
  • 14.
    short:  Java ServerPages 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.
  • 15.
    5. Java Servlets: Java Servlets are server side components that provides a powerful mechanism for developing serverside applications.
  • 16.
    What Is theStruts 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.
  • 17.
  • 18.
     All incomingrequests 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.
  • 19.
    The diagram belowdescribes the flow in more detail:
  • 20.
     User clickson 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.
  • 21.
    Struts Components  TheController  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.
  • 22.
     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.
  • 23.
    Model Components  TheStruts Framework has no built-in support for the Model layer. Struts supports any model components:  JavaBeans  EJB  CORBA  JDO  any other