Unit 3 - Software Architecture
Unit 3 - Software Architecture
Hibernate
Node.js
Node.js is an open-source server-side runtime environment built on Chrome's V8 JavaScript engine. It
provides an event driven, non-blocking (asynchronous) I/O and cross-platform runtime environment for
building highly scalable server-side application using JavaScript.
Traditional Web Server Model
In the traditional web server model, each
request is handled by a dedicated thread from
the thread pool. If no thread is available in the
thread pool at any point of time then the
request waits till the next available thread.
Dedicated thread executes a particular
request and does not return to thread pool
until it completes the execution and returns a
response.
Hello !
Advantages of AngularJS
• Dependency Injection: Dependency Injection specifies a design pattern in which components are
given their dependencies instead of hard coding them within the component.
• Two way data binding: AngularJS creates a two way data-binding between the select element and
the orderProp model. orderProp is then used as the input for the orderBy filter.
• Testing: Angular JS is designed in a way that we can test right from the start. So, it is very easy to test
any of its components through unit testing and end-to-end testing.
• Model View Controller: In Angular JS, it is very easy to develop application in a clean MVC way. You
just have to split your application code into MVC components i.e. Model, View and the Controller.
JSP (Java Server Page)
JSP technology is used to create dynamic web applications. JSP pages are easier to maintain then a Servlet,
as servlet adds HTML code inside Java code, while JSP adds Java code inside HTML using JSP tags. Everything
a Servlet can do, a JSP page can also do it. JSP enables us to write HTML pages containing tags, inside which
we can include powerful Java programs.
Lifecycle of JSP
A JSP page is converted into Servlet in order to service requests. The translation of a JSP page to a Servlet is
called Lifecycle of JSP. JSP Lifecycle is exactly same as the Servlet Lifecycle, with one additional first step,
which is, translation of JSP code to Servlet code.
Following are the JSP Lifecycle steps:
1. Translation of JSP to Servlet code.
2. Compilation of Servlet to byte code.
3. Loading Servlet class.
4. Creating servlet instance.
5. Initialization by calling jsplnit() method.
6. Request Processing by calling jspService() method Destroying by calling jspDestroy() method.
Web Container translates JSP code into a servlet
class source(.java) file, then compiles that into a
java servlet class. In the third step, the servlet
class bytecode is loaded using classloader. The
Container then creates an instance of that
servlet class.
The initialized servlet can now service request.
For each request the Web Container call
the jspService() method. When the Container
removes the servlet instance from service, it calls
the jspDestroy() method to perform any
required clean up.
2. Expression tag: Expression tags are used for writing the java valid expressions as a part of JSP page.
Syntax: <%=java valid expression %>
Whatever the expression we write as a part of expression tags that will be given as a response to client by
the servlet container. All the expression we write in expression tag they will be placed automatically in
out.println () method and this method is available as a part of service method. Expressions in the expression
tag should not be terminated by semi-colon (;).
Example-1 <%! Int a=10, b=20 %> <%=a+b%>
The equivalent servlet code for the above expression tag is out.println (a+b); out is implicit object of
JSPWriter class.
3. scriplet tag: scriplets are basically used to write a pure java code. Whatever the java code we write as a
part of scriplet, that code will be available as a part of service () method of servlet.
Syntax: <%pure java code% >
Servlet
Servlet Technology is used to create web
applications. Servlet technology uses Java
language to create web applications. Web
applications are helper applications that
resides at web server and build dynamic web
pages. A dynamic page could be anything like a
page that randomly chooses picture to display
or even a page that displays the current time.
Figure 3.10 (d): Service method used Figure 3.10 (f): Servlet Destroy
DBC drivers are client-side adapters (installed on the client machine, not on the server) that convert requests
from Java programs to a protocol that the DBMS can understand. There are 4 types of JDBC drivers:
1. Type-1 driver or JDBC-ODBC bridge driver.
2. Type-2 driver or Native-API driver.
3. Type-3 driver or Network Protocol driver.
4. Type-4 driver or Thin driver.
Type-1 driver or JDBC-ODBC bridge driver- It uses ODBC driver to connect to the database. The JDBC-ODBC
bridge driver converts JDBC method calls into the ODBC function calls. Type-1 driver is also called Universal
driver because it can be used to connect to any of the databases.
• As a common driver is used in order to interact with different databases, the data transferred through
this driver is not so secured.
• The ODBC bridge driver is needed to be installed in individual client machines.
• Type-1 driver isn’t written in java, that’s why it isn’t a portable driver.
• This driver software is built-in with JDK so no need to install separately.
• It is a database independent driver.
Advantage
• Easy to use.
• Can be easily connected to any database.
Disadvantage
• Performance degraded because JDBC method call is converted into the ODBC function calls.
• The ODBC driver nee.ds to be installed on the client machine.
Type 2 driver or Native-API driver - The Native API driver uses the client -side libraries of the database. This
driver converts JDBC method calls into native calls of the database API. In order to interact with different
database, this driver needs their local API, that’s why data transfer is much more secure as compared to
type-1 driver.
• Driver needs to be installed separately in individual client machines.
• Type-2 driver isn’t written in java, that’s why it isn’t a portable driver.
• It is a database dependent driver.
Advantage
• Performance upgraded than JDBC-ODBC bridge driver.
Disadvantage
• The Native driver needs to be installed on the each client machine.
• The Vendor client library needs to be installed on client machine.
Type-3 driver - The Network Protocol driver uses middleware (application server) that converts JDBC calls
directly or indirectly into the vendor-specific database protocol. Here all the database connectivity drivers
are present in a single server, hence no need of individual client-side installation.
• Type-3 drivers are fully written in Java, hence they are portable drivers.
• Switch facility to switch over from one database to another database.
Advantage
• No client side library is required because of application server that can perform many tasks like
auditing, load balancing, logging etc.
Disadvantage
• Network support is required on client machine.
• Requires database-specific coding to be done in the middle tier.
Type-4 driver native protocol driver - This driver interact directly with database. It does not require any
native database library that’s why it is also known as Thin Driver.
• Does not require any native library and Middleware server, so no client-side or server-side installation.
• It is fully written in Java language, hence they are portable drivers.
Advantage
• Better performance than all other drivers.
• No software is required at client side or server side.
Disadvantage
• Drivers depend on the Database.
Connectivity - There are 5 steps to connect any java application with the database using JDBC.
• Register the Driver class.
• Create connection.
• Create statement.
• Execute queries.
• Close connection.
JNDI
JNDI provides a common-denominator interface to many existing naming services, such as LDAP (Lightweight
Directory Access Protocol) and DNS (Domain Name System). These naming services maintain a set of
bindings, which relate names to objects and provide the ability to look up objects by name. JNDI allows the
components in distributed applications to locate each other.
WebLogic Server JNDI - The WebLogic Server implementation of JNDI supplies methods that:
• Give clients access to the Web Logic Server naming services.
• Make objects available in the Web Logic namespace.
• Retrieve objects from the Web Logic namespace.
Each Web Logic Server cluster is supported by a replicated cluster wide JNDI tree that provides access to
both replicated and pinned RMI and EJB objects. While the JNDI tree representing the cluster appears to the
client as a single global tree, the tree containing the cluster-wide services is actually replicated across each
Web Logic Server instance in the cluster.
JNDI in a Clustered Environment. Other Web Logic services can use the integrated naming service provided
by Web Logic Server JNDI. For example, Web Logic RMI can bind and access remote objects by both standard
RMI methods and JNDI methods.
JMS (Java Message Service)
JMS (Java Message Service) is an API that provides the facility to create, send and read messages. It provides
loosely coupled, reliable and asynchronous communication. It is also known as a messaging service.
Messaging is a technique to communicate applications or software components. JMS is mainly used to send
and receive message from one application to another.
Requirement of JMS - Generally, user sends message to application. But, if we want to send message from
one application to another, we need to use JMS API. Consider a scenario, one application A is running in
INDIA and another application B is running in USA. To send message from A application to B, we need to use
JMS.
Advantage of JMS
• Asynchronous: To receive the message, client is not required to send request. Message will arrive
automatically to the client.
• Reliable: It provides assurance that message is delivered.
Messaging Domains - There are two types of messaging domains in JMS-
1. Point-to-Point Messaging Domain- In PTP model, one message is delivered to one receiver only.
Here, Queue is used as a message oriented middleware (MOM).The Queue is responsible to hold the
message until receiver is ready. In PTP model, there is no timing dependency between sender and receiver.