Sie sind auf Seite 1von 39

A Project Report

on

Web development using Spring Framework

Submitted for the partial fulfillment of the requirement

for the award of the Degree of

BACHELOR OF TECHNOLOGY

In

COMPUTER SCIENCE & ENGINEERING

by

Mohak Mahajan

Under the Supervision of Under the Supervision of

Mr. Ajay Singh Mr. Satheesha B Nanjappa

DIT UNIVERSITY, DEHRADUN, INDIA

(State Private University through State Legislature Act No 10 of 2013 of Uttrakhand


and approved by UGC)

Mussoorie Diversion Road, Dehradun, Uttrakhand-248009, India

2019-2020
DECLARATION

This is to certify that the Project entitled “Web development using Spring Framework” in
partial fulfillment of the requirement for the award of the Degree of Bachelor of
Technology in Computer Science & Engineering, submitted to DIT University,
Dehradun, Uttarakhand, India, is an authentic record of my own work carried out during
the period (month) 2018 to (month) 2018, under the supervision of Mr. Satheesha B
Nanjappa.

The matter embodied in this Project has not been submitted for the award of any other
degree or diploma to any University/Institution.

Signature

Name of Candidate
Mohak Mahajan
Roll No:
160113022
Date:
11 April 2020
Place: Dehradun

-2-
-3-
ACKNOWLEDGEMENT

This has been the light of the day due to invaluable contribution of certain individuals whose
constant guidance, support and encouragement resulted in the realization of our project. I
would like to take this opportunity to thank the Head of Department of Computer Science
and Engineering, Dr. Vishal Bharti, HOD CSE, DIT University for making the industrial
training a part of the Curriculum and possible for the students.
The summer internship at Infosys is a golden opportunity for learning and self- development.
I consider myself very lucky and honoured to be able to be a part of it and have so many
wonderful and experienced people lead me through the completion of this project. It gives me
immense pleasure and a sense of satisfaction to have an opportunity to acknowledge and to
express gratitude to those who were associated with me during my internship.

I would also like to state that without their endless support, kind and understanding spirit
during my case presentation. The University Management and the Dean, scope for giving us
an opportunity to carry out my studies at the University.

Finally, I would thank my parents for imparting me moral support and


motivation during this project.

Name: Mohak Mahajan


Roll No: 160113022

-4-
ABSTRACT

The Spring Framework provides a comprehensive programming and configuration model for
modern Java-based enterprise applications - on any kind of deployment platform. A key
element of Spring is infrastructural support at the application level: Spring focuses on the
"plumbing" of enterprise applications so that teams can focus on application-level business
logic, without unnecessary ties to specific deployment environments.

The core features of the Spring Framework can be used in developing any Java application,
but there are extensions for building web applications on top of the Java EE platform. Spring
framework targets to make J2EE development easier to use and promotes good programming
practices by enabling a POJO-based programming model.

Apache Maven is a software project management and comprehension tool. Based on the
concept of a project object model (POM), Maven can manage a project's build, reporting and
documentation from a central piece of information.

Servlet technology is used to create a web application (resides at server side and generates a
dynamic web page).
JSP technology is used to create web application just like Servlet technology. It can be
thought of as an extension to Servlet because it provides more functionality than servlet such
as expression language, JSTL, etc.
JDBC stands for Java Database Connectivity. JDBC is a Java API to connect and execute the
query with the database.

-5-
LIST OF FIGURES

FIGURE NAME PAGE


1. Java course 1 20
2. Java course 2 20
3. Eclipse IDE 21
4. Eclipse SQL Explorer 22
5. POM XML file 23
6. POM tags 23
7. Maven in lex 24
8. Data persistence 25
9. Data persistence medium 25
10. JDBC IN lex 26
11. Spring features 27
12. Logging in SpringBoot 30
13. JPA 31
14. Presentation Layer 32
15. Spring MVC 33
16. Web API Layer 34
17. RESTful web services 35
18. CORS 36

-6-
TABLE OF CONTENTS

CHAPTER PAGE
Chapter 1 -- Organization Overview 8
1.1. Introduction 8
1.2. Services provided by company 9

Chapter 2 –Introduction to Project 10


2.1. Project Prospective 10
2.2. Skill Set of Students Before Training 11
2.3. Knowledge acquired from the projects undertaken in training 14
Chapter 3- Generic training 19
Chapter 4 – Stream training 23
Chapter 5 – Conclusion 37
Chapter 6 – Future scope 38
References 39

-7-
CHAPTER 1

ORGANIZATION OVERVIEW

Infosys Limited is an Indian multinational corporation that provides business consulting,


information technology and outsourcing services. It has its headquarters in Bangalore,
Karnataka, India.

Infosys is the second-largest Indian IT company after Tata Consultancy Services by 2017
revenue and 596th largest public company in the world based on revenue. On March 29,
2019, its market capitalisation was $46.52 billion. The credit rating of the company is A−
(rating by Standard & Poor's).

1.1 INTRODUCTION

Infosys was established by seven engineers in Pune, Maharashtra, India with an initial capital
of $250 in 1981. It was registered as Infosys Consultants Private Limited on 2 July 1981. In
1983, it relocated its office to Bangalore, Karnataka, India.

The company changed its name to Infosys Technologies Private Limited in April 1992 and to
Infosys Technologies Limited when it became a public limited company in June 1992. It was
later renamed to Infosys Limited in June 2011.

Its shares were listed on NASDAQ in 1999 through ADR route. The share price surged to
₹8,100 (equivalent to ₹28,000 or US$390 in 2019) by 1999 making it the costliest share on
the market at the time. At that time, Infosys was among the 20 biggest companies by market
capitalization on the NASDAQ. The ADR listing was shifted from NASDAQ to NYSE
Euronext to give its European investors better access to its stock.

-8-
1.2 SERVICES PROVIDED BY COMPANY

Infosys provides software development, maintenance and independent validation services to


companies in finance, insurance, manufacturing and other domains.

One of its known products is Finacle which is a universal banking solution with various
modules for retail & corporate banking.

Its key products and services are:

• NIA – Next Generation Integrated AI Platform (formerly known as Mana)

• Infosys Consulting – a global management consulting service

• Infosys Information Platform (IIP) – Analytics platform

• EdgeVerve Systems which includes Finacle, a global banking platform

• Panaya Cloud Suite

• Skava

-9-
CHAPTER 2

INTRODUCTION TO THE PROJECT

2.1 PROJECT PROSPECTIVE

A web application is a software application that runs on a remote server. In most cases, Web
browsers are used to access Web applications, over a network, such as the Internet. Some
web applications are used in intranets, in companies and schools, for example. Web
applications are different from other applications because they do not need to be installed.

Some example web applications are: Facebook (social networking), Flickr (photo sharing),
Mibbit (chatting), and Wikipedia.

Web applications are popular because most computer operating systems have web browsers.
Programmers can easily change a web application. Users do not need to install any new
software to see these changes.

Spring is an enterprise Java framework. It was designed to simplify Java EE development


and make developers more productive. Spring makes use of Inversion of Control and
Dependency Injection to promote good software coding practices and speed up development
time.

React.js is an open-source JavaScript library that is used for building user interfaces
specifically for single-page applications. It's used for handling the view layer for web and
mobile apps. React also allows us to create reusable UI components.

Backend is server side of the website. It stores and arranges data, and also makes sure
everything on the client-side of the website works fine. Java is one of the most popular and
widely used programming language and platform.

- 10 -
2.2 SKILL SET OF STUDENTS BEFORE TRAINING

My skillset before the internship was limited to the subjects, I had undertaken under the
curriculum in DIT University. I had completed several courses that helped me to get a strong
theoretical and practical base to implement the project at the facility. The skillset I acquired
from the curriculum at DIT is as follows:

Internet and Web Programming:

This course taught me the basic concepts of web programming and internet. I learned about
the internet protocols, the use of scripting languages and appreciate their limitations. I
learned to develop web applications using basic PHP, HTML and CSS.

Database Management System:

This course imparted the knowledge of design, implement, and use database management
systems to me. It highlighted the significant functions of database management system. I
helped me to learn and explore about advantages of using a DBMS rather than a file system,
designing an Entity-Relationship model for a real-life application, optimizing a query, basic
concepts on transaction processing, concurrency control and recovery and storage of
databases and techniques to access them using various algorithms. As an outcome of this
course I was able to determine the role of a database management system in an organization,
construct database queries using Structured Query Language (SQL), design and implement a
database project depending on the business requirements, considering various design issues
and implement the concept of a database transaction and related database facilities, including
concurrency control, backup and recovery.

- 11 -
Operating System:

Through the knowledge acquired from this course I was able to understand and evaluate
trade-offs between conflicting objectives in large scale system design. I was able to
understand the internal structure of the Linux and Windows operating systems and also
learned to retrieve essential system information via basic system commands. I was able to
understand about the issues related to security in the operating system. I have a clear
understanding of the subject related concepts and of contemporary issues, an ability to design
and conduct experiments, as well as to analyze and interpret data and an ability to use
techniques, skills and modern engineering tools necessary for engineering practice

Networks and Communication:

This course enabled me to build an understanding of the fundamental concepts of computer


networking, protocols, architectures, and applications, gain expertise in design, implement
and analyze performance perspective of various architectures and deal with the major issues
of the layers of the model. As a result of the course, I learned to identify the architecture of
the network, deploy minions in the slave nodes, describe the layered structure of a typical
networked architecture, identify and analyze the different types of network topologies,
switching, error and flow control mechanisms, transport crucial information in any network,
establish a secure network, design subnetting and enhance the performance of routing
mechanisms and identify various Application layer protocols for specific applications.

Software Engineering:

This course introduced me to the essential software engineering concepts involved in


developing software products and components and imparted skills in the design and
implementation of efficient software systems across disciplines and also ensure engineering

- 12 -
practices and standards. On completion of this course, I was able to explain the principles of
the engineering processes in software development, implement the software development
processes activities from requirements to validation and verification, manage software
projects through activities of estimations, scheduling, quality and software maintenance.

Machine Learning:

Machine learning is an application of artificial intelligence (AI) that provides systems the
ability to automatically learn and improve from experience without being explicitly
programmed. Machine learning focuses on the development of computer programs that can
access data and use it learn for themselves.

The process of learning begins with observations or data, such as examples, direct
experience, or instruction, in order to look for patterns in data and make better decisions in
the future based on the examples that we provide. The primary aim is to allow the computers
learn automatically without human intervention or assistance and adjust actions accordingly.

Data Science:

Data science is a multi-disciplinary field that uses scientific methods, processes, algorithms
and systems to extract knowledge and insights from structured and unstructured data.[1][2]
Data science is the same concept as data mining and big data: "use the most powerful
hardware, the most powerful programming systems, and the most efficient algorithms to
solve problems".

I had learned many more subjects and courses since my admission, the above mentioned are
some of those.

- 13 -
2.3 KNOWLEDGE ACQUIRED FROM THE PROJECTS
UNDERTAKEN IN TRAINING

Servlet: Servlet technology is used to create a web application (resides at server side and
generates a dynamic web page). Servlet is a class that extends the capabilities of the servers
and responds to the incoming requests. It can respond to any requests. Servlet is a web
component that is deployed on the server to create a dynamic web page.

Servlet technology is robust and scalable because of java language. Before Servlet, CGI
(Common Gateway Interface) scripting language was common as a server-side programming
language.

Applications of Servlet:

• Read the explicit data sent by the clients (browsers). This includes an HTML form on
a Web page or it could also come from an applet or a custom HTTP client program.

• Read the implicit HTTP request data sent by the clients (browsers). This includes
cookies, media types and compression schemes the browser understands, and so forth.

• Process the data and generate the results. This process may require talking to a
database, executing an RMI or CORBA call, invoking a Web service, or computing
the response directly.

JSP: JSP technology is used to create web application just like Servlet technology. It can be
thought of as an extension to Servlet because it provides more functionality than servlet such
as expression language, JSTL, etc.

A JSP page consists of HTML tags and JSP tags. The JSP pages are easier to maintain than
Servlet because we can separate designing and development. It provides some additional
features such as Expression Language, Custom Tags, etc.

- 14 -
JSP technology is the extension to Servlet technology. We can use all the features of the
Servlet in JSP. In addition to, we can use implicit objects, predefined tags, expression
language and Custom tags in JSP, that makes JSP development easy.

• The JSP pages follow these phases:

• Translation of JSP Page

• Compilation of JSP Page

• Classloading (the classloader loads class file)

• Instantiation (Object of the Generated Servlet is created).

• Initialization ( the container invokes jspInit() method).

• Request processing ( the container invokes _jspService() method).

• Destroy ( the container invokes jspDestroy() method).

JDBC: JDBC stands for Java Database Connectivity. JDBC is a Java API to connect and
execute the query with the database. It is a part of JavaSE (Java Standard Edition). JDBC
API uses JDBC drivers to connect with the database. There are four types of JDBC drivers:

• JDBC-ODBC Bridge Driver,

• Native Driver,

• Network Protocol Driver, and

• Thin Driver

The JDBC API uses a driver manager and database-specific drivers to provide transparent
connectivity to heterogeneous databases.

The JDBC driver manager ensures that the correct driver is used to access each data source.
The driver manager is capable of supporting multiple concurrent drivers connected to
multiple heterogeneous databases.
- 15 -
Maven: Apache Maven is a software project management and comprehension tool. Based on
the concept of a project object model (POM), Maven can manage a project's build, reporting
and documentation from a central piece of information. Using maven we can build and
manage any Java based project.

In case of multiple development teams environment, Maven can set-up the way to work as
per standards in a very short time. As most of the project setups are simple and reusable,
Maven makes life of developer easy while creating reports, checks, build and testing
automation setups.

Maven uses Convention over Configuration, which means developers are not required to
create build process themselves. Developers do not have to mention each and every
configuration detail. Maven provides sensible default behavior for projects. When a Maven
project is created, Maven creates default project structure. Developer is only required to place
files accordingly and he/she need not to define any configuration in pom.xml.

In order to build the project, Maven provides developers with options to mention life-cycle
goals and project dependencies (that rely on Maven plugin capabilities and on its default
conventions). Much of the project management and build related tasks are maintained by
Maven plugins.

Microsoft SQL Server: It is a relational database management system developed by


Microsoft. As a database server, it is a software product with the primary function of storing
and retrieving data as requested by other software applications—which may run either on the
same computer or on another computer across a network (including the Internet).

Microsoft markets at least a dozen different editions of Microsoft SQL Server, aimed at
different audiences and for workloads ranging from small single-machine applications to
large Internet-facing applications with many concurrent users.

- 16 -
SQL: SQL or Structured Query Language is a domain-specific language used in
programming and designed for managing data held in a relational database management
system (RDBMS), or for stream processing in a relational data stream management system
(RDSMS). It is particularly useful in handling structured data where there are relations
between different entities/variables of the data. SQL offers two main advantages over older
read/write APIs like ISAM or VSAM. First, it introduced the concept of accessing many
records with one single command; and second, it eliminates the need to specify how to reach
a record, e.g. with or without an index.

Originally based upon relational algebra and tuple relational calculus, SQL consists of many
types of statements, which may be informally classed as sublanguages, commonly: a data
query language (DQL), a data definition language (DDL), a data control language (DCL),
and a data manipulation language (DML). The scope of SQL includes data query, data
manipulation (insert, update and delete), data definition (schema creation and modification),
and data access control. Although SQL is often described as, and to a great extent is, a
declarative language (4GL), it also includes procedural elements.

SQL was one of the first commercial languages for Edgar F. Codd's relational model. The
model was described in his influential 1970 paper, "A Relational Model of Data for Large
Shared Data Banks". Despite not entirely adhering to the relational model as described by
Codd, it became the most widely used database language.

Spring: Spring is an enterprise Java framework. It was designed to simplify Java EE


development and make developers more productive. Spring makes use of Inversion of
Control and Dependency Injection to promote good software coding practices and speed up
development time. pring is a lightweight framework. It can be thought of as a framework of
frameworks because it provides support to various frameworks such as Struts, Hibernate,

- 17 -
Tapestry, EJB, JSF, etc. The framework, in broader sense, can be defined as a structure
where we find solution of the various technical problems.

The core features of the Spring Framework can be used in developing any Java application,
but there are extensions for building web applications on top of the Java EE platform. Spring
framework targets to make J2EE development easier to use and promotes good programming
practices by enabling a POJO-based programming model.

The technology that Spring is most identified with is the Dependency Injection (DI) flavor of
Inversion of Control. The Inversion of Control (IoC) is a general concept, and it can be
expressed in many different ways. Dependency Injection is merely one concrete example of
Inversion of Control.

When writing a complex Java application, application classes should be as independent as


possible of other Java classes to increase the possibility to reuse these classes and to test them
independently of other classes while unit testing. Dependency Injection helps in gluing these
classes together and at the same time keeping them independent.

SpringBoot: Spring Boot is an open source Java-based framework used to create a micro
Service. It is developed by Pivotal Team and is used to build stand-alone and production
ready spring applications.

Micro Service is an architecture that allows the developers to develop and deploy services
independently. Each service running has its own process and this achieves the lightweight
model to support business applications.

- 18 -
CHAPTER 3

GENERIC TRAINING

Java

A program is a collection of instructions that performs a specific task when executed by a


computer. A program must be written in a programming language. In this course, you will
learn to write programs using Java as a programming language.

Java is one of the most popular programming languages. Some statistics about Java are given
below:

• Java has been evolving since 1991 with different editions

• According to the TIOBE Programming Community Index, it has been one of the top 5
programming languages for the past several years

• It is being used by more than 10 million developers worldwide

• More than 15 billion devices are powered by Java technology

• More than 125 million Java-based TV devices have been deployed

• 97% of enterprise desktops run Java

• The features and strengths of Java have made it suitable for applications throughout
the history of Internet, and it continues to do so even for modern applications.

- 19 -
Fig 1: Java course 1

Fig 1: Java course 2

- 20 -
Eclipse

Eclipse is an integrated development environment (IDE) used in computer programming. It


contains a base workspace and an extensible plug-in system for customizing the environment.
Eclipse is written mostly in Java and its primary use is for developing Java applications, but
it may also be used to develop applications in other programming languages via plug-ins,
including Ada, ABAP, C, C++, C#, Clojure, COBOL, D, Erlang, Fortran, Groovy, Haskell,
JavaScript, Julia, Lua, NATURAL, Perl, PHP, Prolog, Python, R, Ruby (including Ruby on
Rails framework), Rust, Scala, and Scheme.

In addition to allowing the Eclipse Platform to be extended using other programming


languages, such as C and Python, the plug-in framework allows the Eclipse Platform to work
with typesetting languages like LaTeX and networking applications such as telnet and
database management systems. The plug-in architecture supports writing any desired
extension to the environment, such as for configuration management. Java and CVS support
is provided in the Eclipse SDK, with support for other version control systems provided by
third-party plug-ins.

Fig 3: Eclipse IDE

- 21 -
SQL

SQL or Structured Query Language is a domain-specific language used in programming and


designed for managing data held in a relational database management system (RDBMS), or
for stream processing in a relational data stream management system (RDSMS). It is
particularly useful in handling structured data where there are relations between different
entities/variables of the data. SQL offers two main advantages over older read/write APIs
like ISAM or VSAM. First, it introduced the concept of accessing many records with one
single command; and second, it eliminates the need to specify how to reach a record, e.g.
with or without an index.

The scope of SQL includes data query, data manipulation (insert, update and delete), data
definition (schema creation and modification), and data access control. Although SQL is
often described as, and to a great extent is, a declarative language (4GL), it also includes
procedural elements.

We used SQL in Eclipse IDE itself:

Fig 4: Eclipse SQL Explorer

- 22 -
CHAPTER 4

STREAM TRAINING

Project Object Model

Project Object Model is the basic unit of work in any Maven project. It is basically an XML
configuration file named pom.xml with the information about project and the necessary
configurations. It is the central configuration file of Maven.

Pom.xml is the declarative descriptor of Maven projects that should be placed in the root
folder of the project.

Fig 5: POM XML file

Fig 6: POM tags

- 23 -
Maven

Apache Maven is a software project management and comprehension tool. Based on the
concept of a project object model (POM), Maven can manage a project's build, reporting and
documentation from a central piece of information. Using maven we can build and manage
any Java based project.

In case of multiple development teams environment, Maven can set-up the way to work as
per standards in a very short time. As most of the project setups are simple and reusable,
Maven makes life of developer easy while creating reports, checks, build and testing
automation setups.

Fig 7: Maven in Lex

- 24 -
Data Persistence

Data Persistence means for an application to persist and retrieve information from the non-
volatile storage.

The persistence phenomenon contains three core components Data, Medium, Storage. It is
also necessary to know what to persist, how to persist and where to persist.

Medium is the thing that is used to transfer the data from source to destination. The data is
transferred between source and destination in the serialized manner. To transfer the data
efficiently in a serial manner, the mechanism used is called Serialization. Serialization is the
method of converting all the data/object to byte stream (0’s and 1’s) to transfer the data to the
specified storage or repository.

Fig 8: Data persistence

Fig 9: Data persistence medium

- 25 -
JDBC

JDBC stands for Java Database Connectivity. JDBC is a Java API to connect and execute the
query with the database. It is a part of JavaSE (Java Standard Edition). JDBC API uses JDBC
drivers to connect with the database. There are four types of JDBC drivers:

• JDBC-ODBC Bridge Driver,

• Native Driver,

• Network Protocol Driver, and

• Thin Driver

The JDBC API uses a driver manager and database-specific drivers to provide transparent
connectivity to heterogeneous databases.

Fig 10: JDBC in Lex

- 26 -
Spring framework

Spring Framework is an open source Java application development framework which


supports building all types of Java applications like web applications, database driven
applications, enterprise applications and many more. Java applications developed using
Spring are simple, easily testable, reusable and maintainable. It has following features:

Fig 11: Spring features

- 27 -
Spring IoC Containers

Spring framework provides a container for dependency injection. This container is called as
Spring IoC container. It creates, initializes, and injects the required objects. These objects
whose life cycle is managed by Spring are called as Spring beans or beans. The Spring
container needs information about objects of which class to create and how to wire them
together. This information is called as configuration metadata. It can be provided in
following ways:

• XML configuration

• Java-based configuration

• Java Annotation-based configuration

The Spring IoC container is represented by following interfaces:

BeanFactory interface: It represents container which provides basic functionalities. It


instantiates bean whenever asked for by the client application. Using its getBean() method
you can get instances of beans. It instantiates bean objects only when getBean() method is
called.

ApplicationContext interface: It extends BeanFactory interface and provides additional


functionalities to support enterprise application development. It instantiates all beans when
container is loaded. There are many implementations of this interface. Some commonly used
implementation classes are as follows:

ClassPathXmlApplicationContext: It is used to process XML-based configuration metadata.

AnnotationConfigApplicationContext: It is used to process Java‐based configuration


metadata.

- 28 -
SpringBoot

Spring Boot is a framework built on the top Spring framework that helps developers build
Spring-based applications quickly and easily. The main goal of Spring Boot is to quickly
create Spring-based applications without requiring developers to write the same boilerplate
configuration again and again.

But how does it work? It works because of following reasons,

1. Spring Boot is opinionated framework

Spring Boot forms opinions. It means that Spring Boot has some sensible defaults which you
can use to quickly build your application. For example, Spring Boot uses embedded Tomcat
as the default web container.

2. Spring Boot is customizable

Though Spring Boot has its defaults, you can easily customize it at any time during your
development based on your need. For example, if you prefer log4j for logging over Spring
Boot built-in logging support then you can easily make dependency change in your pom.xml
file to replace the default logger with log4j dependencies.

The main Spring Boot features are as follows:

• Starter Dependencies

• Automatic Configuration

• Spring Boot Actuator

• Easy-to-use Embedded Servlet Container Support

- 29 -
Logging in SpringBoot

Spring Boot uses SLF4J along with Logback implementations to log messages to the console
at ERROR, WARN, and INFO level. You can easily configure logging levels, logging
format, and log file location by setting logging related properties in application.properties
file.

Spring Boot by default, logs messages at ERROR, WARN, and INFO level. You can also set
the logger levels in application.properties file by setting the property logging.level.<logger-
name>=<level> where level is one of TRACE, DEBUG, INFO, WARN, ERROR, FATAL,
or OFF. The root logger can be configured by setting logging.level.root property in
application.properties file.

By default, Spring Boot logs only to the console and does not log to files. If you want to log
messages in files in addition to the console, you need to set logging.file property in
application.properties file. The value for this property can be exact location of file or relative
to the current directory.

Once configuration is done you can get the SLF4J logger and use it as follows:

Fig 12: Logging in SpringBoot

As a developer you may want to have more control over logging for debugging and
maintenance. For this you can create the logging provider specific configuration file in their
default locations, which Spring Boot will automatically use.

- 30 -
Java Persistence API

The Java Persistence API (JPA) is Java EE specification that defines how data
persistence‐related tasks are handled using object‐relational mapping (ORM) frameworks in
Java applications. It provides following features:

• Defines an API for mapping the object model with the relational model

• Defines an API for performing CRUD operations

• Standardizes ORM features and functionalities in the Java.

• Provides an object query language called Java Persistence Query Language (JPQL)
for querying database.

• Provides Criteria API to fetch data over an object graph.

There are multiple providers available in market which provides implementation of JPA
specification such as EclipseLink, OpenJPA, Hibernate, etc. as shown below:

Fig 13: JPA

- 31 -
Presentation Layer

The presentation layer of an enterprise application handles the client requests and provide
clients a visual view of the information. It also allows them to perform business functions
provided and managed by the application.

Fig 14: Presentation layer

The development of the presentation layer is a challenging task these days because of
emergence of many technologies and frameworks, such as Spring Web MVC, Java Server
Faces (JSF), Angular etc.

- 32 -
Spring MVC

Spring MVC Framework is one of the most popular framework used for developing
presentation layer of enterprise web applications. It is based on MVC and front controller
design patterns. It has following features :

• It is a subproject of Spring. So it provides all Spring's core features such as


dependency injection and annotations.

• It provides a mechanism to extract data from user request and mapping it to a model
class to construct an object which makes development easy and simple.

• It is view independent. You can use any technology for generating the view such as
JSP, Tiles, Theamleaf etc.

• It is action based framework. Every user request is an action to be performed with the
framework. This is achieved by mapping each request to an executable method. The
request parameters are also mapped to arguments of this method.

Fig 15: Spring MVC

- 33 -
Web API Layer

Web service is a standard way of communication between web applications running on


diverse platforms and frameworks. In our scenario, Google Map is exposed as web service
and consumed by different applications running on different devices. Web services are
usually enclosed in the Web Service layer or API layer, which communicates directly with
the service layer. The Web Service layer provides the logic to convert software objects into
different representations that can be sent to destination applications.

Fig 16: Web API layer

Application built using different technologies can interact with each other, for example a
Java based application can send data to a.NET application.

- 34 -
RESTful Web Services

Spring provides support for creating RESTful web services using Spring MVC starting with
version 3.0. The REST controllers are different from MVC controllers because their methods
return result which can be mapped to a representation rather than a view. For this Spring 3.0
introduced @ResponseBody annotation. It tells DispatcherServlet that the result of execution
of method need not to be mapped with a view and to automatically convert the response to a
JSON string literal.

In Spring 4.0, the @RestController annotation was introduced. This annotation is a


combination of @Controller and @ResponseBody. This annotation when used on a REST
controller class bounds all the values returned by controller methods to the response body.

Fig 17: RESTful web services

@RestController:

This annotation is used to define REST controllers. It is a combination of @Controller and


@ResponseBody annotation. @Controller annotation marks a class for discovery by
component scanning. @ResponseBody tells Spring that all handler methods in the controller
should have their return value written directly to the body of the response, rather than being
carried in the model to a view for rendering.

- 35 -
CORS - Cross-Origin Resource Sharing

For security reasons, browsers don’t allow you to make cross-origin request. Cross origin
requests are requests to those resources which resides outside the the current origin. For
example, if a document served from xyz.com makes a request to domain abc.com for some
images then this request is called as cross origin request.

To allow cross-origin requests, Cross-Origin Resource Sharing (CORS) is used. It is an


specification which provides a way to specify which cross-origin requests are permitted.
Spring MVC provides @CrossOrigin annotation for enabling CORS for REST API so that
the API clients can make calls to REST APIs.

When applied at the class level, the same @CrossOrigin configuration is applied to all the
@RequestMapping methods.

Fig 18: CORS

- 36 -
CHAPTER 5

CONCLUSION

Infosys training is considered one of the best industrial trainings across the world and to be a
part of such a training was definitely a life changing experience for me. I got a chance to
apply all the theoretical concepts which I learnt during college to practical use. It provided a
great exposure to me not only in terms of increasing my technical knowledge but also in
other aspects like communication skills, industry exposure and also giving a boost to my
professional career.

- 37 -
CHAPTER 6

FUTURE SCOPE
Due to COVID-19, our training was terminated in the middle, we could not enter the project
phase. I am, though, looking forward to working with Infosys very soon.

- 38 -
REFERENCES

• www.infosys.com

• www.tutorialspoint.com

• www.lex.infosysapps.com

• www.javatpoint.com

- 39 -

Das könnte Ihnen auch gefallen