Download presentation
Presentation is loading. Please wait.
Published byDávid Gulyás Modified over 5 years ago
1
CS4961 Software Design Laboratory Understand Aquila Backend
Chengyu Sun California State University, Los Angeles
2
Traditional Web Application
Example: aquila-servlet Database POJO Servlet JSP
3
The MVC Architecture HTTP Request Browser Controller Model request
View HTTP Response Server Client
4
Problem with Traditional Web Application
The server is responsible for producing “view” (e.g. combining data and JSP to produce an HTML page) Not taking advantage of improved client hardware and software Unnecessary trip to the server Bad for performance and scalability
5
Modern Web Application …
Based on the idea of Service Oriented Architecture (SOA) Off-load view generation and other UI functions to client-side applications, e.g. Angular SPA
6
… Modern Web Application
HTTP Request Controller Client-Side Application HTTP Response Model Browser Server Client
7
The Need for a Common Data Exchange Format
JSP understands Java objects, but client-side applications (usually written in JavaScript) do not. Use JSON and/or XML as the data exchange format
8
JSON (JavaScript Object Notation) Example
{ “make”: “Honda”, “model”: “Civic”, “year”: 2001, “owner”: { “name”: “Chengyu” }
9
REST A RESTful Web Service or a web application that provides a REST API is simply a web application that produces data in JSON and/or XML format Example: aquila-server For more on this subject, please see
10
REST API Conventions Map HTTP Request Methods to CRUD operations POST
GET PUT DELETE Create Retrieve Update Delete
11
Understand Aquila Backend
See Create a REST API Using Spring Boot Three important tools used in the project Maven Hibernate / JPA Spring / Spring Boot
12
Maven A build tool for Java
Preprocessing, compilation, packaging, deployment … No need to know too much about Maven except coordinates, dependency management and directory structure
13
Maven Coordinates groupId artifactId version packaging, default: jar
Name of the company, organization, team etc., usually using the reverse URL naming convention artifactId A unique name for the project under groupId version packaging, default: jar classifier Maven coordinates uniquely identifies a project.
14
Dependency Management
A dependency of a project is a library that the project depends on Adding a dependency to a project is as simple as adding the coordinates of the library to pom.xml Maven automatically downloads the library from an online repository and store it locally for future use
15
Default Directory Structure
src/main/java src/main/resources for files that should be placed under classpath src/main/webapp for web applications src/test/java target
16
Hibernate An Object-Relational Mapping (ORM) library that implements the Java Persistence API (JPA) You DO need to know quite a bit of Hibernate and JPA, particularly the object-relational mapping annotations and data access API
17
Basic Object-Relational Mapping
Class-level annotations @Entity Id field @Id Fields of simple types @Basic (can be omitted) Fields of class types @ManyToOne,
18
Some EntityManager Methods
find( entityClass, primaryKey ) createQuery( query ) createQuery( query, resultClass ) persist( entity ) merge( entity ) getTransaction()
19
More on Hibernate and JPA
ORM with Hibernate and JPA (I) - ORM with Hibernate and JPA (II) -
20
Spring and Spring Boot Spring Framework is the “glue” that put various parts of an application together Spring Boot is kind of a “packaging” of Spring to make it easier to use Understand three basic things about Spring: beans, dependency injection, and request mapping
21
Spring Bean Any class @Repository, is called a Spring bean When a Spring application is started, the framework automatically creates an instance of each bean
22
Spring Beans in Aquila Server
UserDaoImpl UserController
23
Dependency Injection Dependency here means an object relying on another object (i.e. not the library dependency in Maven) The framework passes an object to other objects that need it, a.k.a. wiring UserController UserDaoImpl
24
Dependency Injection Annotations
@Autowired – by type (default) @PersistenceContext – a special annotation that injects an entity manager For more on dependency injection, see
25
Request Mapping @RequestMapping Map a request to a controller method
value is the URL or URL pattern method is the request method, e.g. GET, POST, etc.
26
What’s Next Hibernate and JPA Spring Mapping annotations HQL/JPQL
Controllers
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.