7) Development of Enterprise Application
7) Development of Enterprise Application
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….
❖ 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.
19
Singleton
Ensure a class has only one instance, and provide a global point of access
to it.
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();
...
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.
State change
Change notification
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)