0% found this document useful (0 votes)
25 views47 pages

7) Development of Enterprise Application

Chapter 7 of the document focuses on the development of enterprise applications using Java EE architecture, including the design of web components, Java Beans, and JDBC connectivity. It discusses various design patterns such as Singleton, Template Method, DAO, MVC, Front Controller, and Session Façade, which help in structuring enterprise applications effectively. The chapter also outlines the packaging of Java EE modules and provides an example of an MVC application using servlets and JSP.

Uploaded by

magicahbang119
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views47 pages

7) Development of Enterprise Application

Chapter 7 of the document focuses on the development of enterprise applications using Java EE architecture, including the design of web components, Java Beans, and JDBC connectivity. It discusses various design patterns such as Singleton, Template Method, DAO, MVC, Front Controller, and Session Façade, which help in structuring enterprise applications effectively. The chapter also outlines the packaging of Java EE modules and provides an example of an MVC application using servlets and JSP.

Uploaded by

magicahbang119
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 47

CSC584 Enterprise

Programming
Chapter 7 – Development of Enterprise Application
MARSHIMA MOHD ROSLI
DEPT COMPUTER SCIENCE
Development of Enterprise Application
❑Choose the Java EE Architecture and
Java EE pattern
Chapter 7 ❑Design the Web components - HTML
Outline and JSP
❑Develop Java Beans and Servlets
❑Construct the JDBC connectivity with
the enterprise application
Recap….

Java EE architecture ? Web components?


Java EE Architecture - General
Before….
Minimum
Distributed
Systems
Next….
Highly
Distributed
Systems
Java EE
Distributed
Multitiered
Application
Java EE Architecture
Java EE Server and Containers

Java EE server: The runtime Enterprise JavaBeans (EJB)


portion of a Java EE product. container: Manages the
A Java EE server provides EJB execution of enterprise beans
and web containers. for Java EE applications.

Application client container:


Web container: Manages the
Manages the execution of
execution of JSP, Servlet, and
application client
Java Server Faces.
components.
Web-Tier overview
Business-Tier overview
Java Web Application Request Handling
Packaging applications
Packaging applications

❖ A Java EE module
✓ One or more Java EE components for the same container type
✓ One component deployment descriptor of that type
❖ Java EE modules
✓ EJB modules, which contain class files for enterprise beans
and an EJB deployment descriptor. EJB modules are packaged
as JAR files with a .jar extension.
✓ Web modules, which contain servlet class files, JSP files,
supporting class files, GIF and HTML files, and a web application
deployment descriptor. Web modules are packaged as JAR files
with a .war (Web ARchive) extension.
A design pattern is a general reusable
solution to a commonly occurring problem in
software design. A design pattern is not a
finished design that can be transformed
directly into code.

It is a description or template for how to


solve a problem that can be used in many
Design
different situations.
pattern
Object-oriented design patterns typically
show relationships and interactions between
classes or objects, without specifying the final
application classes or objects that are
involved.
UML class diagram recall
Interface
ClassName Abstract
field list Concrete
method list
# private
* protected Package
+ public Class1
Class2
Base static
Aggregatee ClassN
# private()
* protected()
Derived + public()
Product
abstract()
static() code
derived base name(Type1, Type2) :
RetType
aggregator aggregatee
creator product
caller/user callee/used 18
Simple Design
Patterns

19
Singleton
Ensure a class has only one instance, and provide a global point of access
to it.

public class Singleton {


private Singleton() {}
private static Singleton _instance = null;
public static Singleton getInstance () {
if (_instance == null) _instance = new Singleton();
return _instance;
}
...
}

Lazy instantiation
Tactic of delaying the creation of an Singleton
object, the calculation of a value, or # _instance : Singleton
some other expensive process until
# Singleton()
the first time it is needed.
+ getInstance() : Singleton

return _instance; 20
Template Method
Define the skeleton of an algorithm in an operation, deferring some steps
to subclasses. Template Method lets subclasses redefine certain steps of
an algorithm without changing the algorithm's structure.

Generic ...
operation1();
+ TemplateMethod() ...
# operation1()
# operation2() operation2();
… ...
# operationN() operationN();
...

Specific1 Specific2 SpecificM


# operation1() # operation1() # operation1()
# operation2() # operation2() # operation2()
… … …
# operationN() # operationN() # operationN() 21
Java EE pattern examples
Data Access Objects (DAO)
Code that depends on specific features of data resources ties together
business logic with data access logic. This makes it difficult to replace or
modify an application's data resources.
This pattern
• separates a data resource's client interface from its data access
mechanisms;
• adapts a specific data resource's access API to a generic client interface;
• allows data access mechanisms to change independently of the code
that uses the data.

23
Data Access Objects (DAO) / 2
BusinessObject: represents the data client.
DataAccessObject: abstracts the underlying data access implementation
for the BusinessObject to enable transparent access to the data source.
DataSource: represents a data source implementation.
TransferObject: the data carrier, DAO may use it to return data to the
client.
BusinessObject DataAccessObject DataSource

+ CRUD methods

TransferObject

24
Model-View-Controller (MVC)
Application presents content to users in numerous ways containing
various data. The engineering team responsible for designing,
implementing, and maintaining the application is composed of
individuals with different skill sets.

Classic Web Mobile Rich Web Supplier


Administrator
customer customer customer B2B agent

HTML WML web RAP web JFC/Swing Web


web view view view view Service

Enterprise information system


25
Model-View-Controller / 2
Model
•Encapsulates application state
•Responds to state queries
State query •Exposes application functionality
•Notifies views of changes

State change

Change notification

View View selection Controller


•Renders the models •Defines application behavior
•Requests updates from models •Maps user actions to model updates
•Sends gestures to controller •Selects view for response
•Allows controller to select view •One for each functionality

User gestures
26
Front Controller
The presentation-tier request handling mechanism must control and
coordinate processing of each user across multiple requests. Such
control mechanisms may be managed in either a centralized or
decentralized manner.
Problems:
◦ Each view is required to provide its own system services, often resulting in
duplicate code.
◦ View navigation is left to the views. This may result in commingled view
content and view navigation.
◦ Distributed control is more difficult to maintain: changes will need to be
made in numerous places.

27
Front Controller / 2
incoming
request handle
request
Front
controller Controller
return model
response create model
delegate
return control rendering of
response
model
render
response
View
template

Web container
28
Session Façade
Enterprise beans encapsulate business logic and business data and
expose their interfaces, and thus the complexity of the distributed
services, to the client tier.
• Tight coupling, which leads to direct dependence between clients and
business objects;
• Too many method invocations between client and server, leading to
network performance problems;
• Lack of a uniform client access strategy, exposing business objects to
misuse.

29
Session Façade / 2
Client: the object which needs access to the business service. This client
can be another session bean (Session Facade) in the same business tier
or a business delegate in another tier.
SessionFacade: a session bean which manages the relationships between
numerous BusinessObjects and provides a higher level abstraction to the
client.
BusinessObject: a role object that facilitates applying different strategies,
such as session beans, entity beans and a DAO. A BusinessObject
provides data and/or some services.
Client SessionFacade BusinessObject

BusinessEntity BusinessSession

DataAccessObject

30
Design the Web components -
HTML and JSP
HTML & JSP
Develop Java Beans and Servlets
Recap: Java Bean
Java Bean: Example
Recap: Servlet
Servlet: Example
Construct the JDBC connectivity
with the enterprise application

https://netbeans.org/kb/docs/web/mysql-webapp.html
MVC APPLICATION EXAMPLE
In this example, servlet as a controller, JSP as a view
component, java bean class as a model.
Create 5 pages:
❑index.jsp : a page that gets input from the user.
❑ControllerServlet.java : a servlet that acts as a controller.
❑login-success.jsp and login-error.jsp files acts as view
components.
❑web.xml file for mapping the servlet.
index.jsp
ControllerServlet.java
loginBean.java
loginSuccess.jsp

loginError.jsp
web.xml
Output

index.jsp
index.jsp

loginSuccess.jsp
Web Project
Discussions
❑Web project
❑Storyborad : Good
❑ Project Submission dateline
❑Presentation
❑User manual
❑Project (netbeans project in a zip file)

You might also like