spring Flashcards

1
Q

Lifecycle of a bean

——– : The bean is created or instantiated using a constructor or a factory method.

—————- : The bean’s dependencies are injected, either through constructor injection or setter injection.

—————-: The bean is initialized using its init method or by implementing the InitializingBean interface.

———-: The bean is now ready to be used, and it performs its designated function.

—————–: The bean is destroyed when it is no longer needed, either through a call to its destroy method or by implementing the DisposableBean interface.

A

Instantiation

Dependency Injection

Initialization

In Use

Destruction

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

—————- is a fully AOP framework that SpringAOP uses under the hood. However, it requires extensive XML configuration to function, which SpringAOP abstracts away from us.

A

AspectJ

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

The —————- method takes an “Authentication” object as its parameter and returns an “—————–” object on successful authentication of the user or else we can have an exception thrown indicating that the user is not authenticated.

A

authenticate

Authentication

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Eagerly instantiates beans (When the application starts, all the beans are ready)
Provides support for annotations

A

ApplicationContext:

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Older
Lazily instantiates beans.

A

BeanFactory:

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

———— is an object that creates (instantiates) and holds your Spring Beans, then injects them wherever they’re being called in the application”

A

A Spring Container

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

how many instances of a Bean are/can be created and where they are used

A

“Bean Scope

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

(Bean scopes)
———-There will only ever be one instance of the Bean with the Bean’s class at one time.

A

Singleton (default):

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

(Bean scopes) : A new Bean (with potentially new values) is instantiated every time a Bean is called for.

A

Prototype

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

how we connect our beans as dependencies of one another”

Why do we connect beans as dependencies in the first place? Sometimes you need access to other Classes to run their methods etc. (like the Author Class in a Book Class, or a DAO Class in a Service Class.) We can use dependency injection to accomplish this!

A

Bean Wiring

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

sets dependencies using a Class’s constructor so that the injection happens at the same time as Class instantiation.

A

Constructor Injection

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

uses the setter method of a Class to add the dependencies slightly after instantiation (so after the constructor is invoked)

A

Setter Injection

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

————— is the data being sent back (often, we’re sending objects from our models back and forth

————- is what the user sees. They send requests to the server, and things change on their webpage. So they sends requests which updates their view

————— is just our controller classes that take in requests and facilitate sending responses back.

A

The Model

The View

The Controller

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

lets us handle HTTP Requests, and provides tools for using the Model-View-Controller design pattern.

A

Spring MVC

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Classes that have other Classes as dependencies

A

Dependency Injection

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

are used to configure and customize the behavior of Spring’s dependency injection

A

Annotations

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

uses the Java Persistence API (JPA) standard, which provides a set of annotations and APIs for managing relational data. provides a simplified and standardized way of working with data access, allowing developers to write less boilerplate code.

A

Spring JPA

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

a standalone Object-Relational Mapping (ORM) framework that provides a way of mapping Java objects to relational databases. mature and widely used technology, providing advanced features such as caching, lazy loading, and optimistic locking.

A

Hibernate,

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

————– provides a higher level of abstraction and simplifies database access,
——— provides more control and fine-grained configuration options.

A

Spring JPA

Hibernate

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Can you use Spring JPA by itself?

A

yes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

three ways to define spring beans :

—– Configuration via the <bean> tag in our applicationContext.xml
------ Java Class (@Configuration, @Bean, @Scope) (Won’t show)
------- Driven (stereotype annotations)</bean>

A

XML
Configuration
Annotation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

aotomagically determine the dependencies for you, and then provide them. it abstracts away the dependency injection that it does for you. So to us, it looks automatic and magical.

A

Autowiring

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

pieces of the Spring Framework

A

Spring Modules

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

Required Modules of spring framework

A

core
bean
context

25
----------------- This module contains the core functionality of Spring. Contains the BeanFactory interface which is one of the IoC containers (read below) you can choose from.
Core
26
--------- Contains Bean configuration and functionality
Bean
27
---------- Provides the ApplicationContext interface which is another, newer IoC container. This is the one we use nowadays, and it is a child of BeanFactory
Context
28
a Spring Project used to create standalone Spring-based applications that you can just run
Spring Boot
29
spring Boot has the mindset of --------------------- This means that it’s designed to work with the standard industry conventions, and as long as you want to follow those conventions, it can abstract all of that setup away from you.
Convention over Configuration
30
Benefits and Features of Spring Boot... 1.)------------Tomcat Server 2.)Provides “---------” dependencies 3.)Spring Boot ---------------: 4.)Spring Boot ------------
embedded starter Actuator DevTools
31
--------------- - This means that each Spring Boot app has its own server that it calls instead of us having to host some server on your local machine. Javalin does something similar with a Jetty Server.
Embedded Tomcat Server
32
Provides ------------ dependencies - This allows us to simply choose our dependencies from a list when we create our projects
“starter”
33
Spring Boot ------------- This provides endpoints for us to monitor metrics and project information for our running applications.
Actuator
34
Spring Boot -------------: Provides additional tools for setting up a development environment easily. For instance, this is what automatically restarts your server when you save changes, so you don’t have to manually restart it anymore.
DevTools
35
This is SpringMVC’s Front Controller. (Think like how the main method with javalin handlers used to be our front controller)
DispatcherServlet
36
any technology or entity that sits at the FRONT of the server and CONTROLS where requests go.
front controller
37
This is an Interface that is responsible for sending requests to the proper controller.
HandlerMapping
38
Stereotype annotation (makes a class a bean) BUT it has a few more functionalities with Spring MVC. With Spring MVC, it indicates that the class will handle HTTP requests from the DispatcherServlet
@Controller
39
object that lets us use to send back responses to the client. It lets us do things like set status code and the body of the response.
ResponseEntity
40
This automates the creation of our ApplicationContext for us so that our application and its server can “just run”.
ContextLoaderListener
41
built on Spring modules and provide solutions to issues faced by industry level applications. So basically think of them as add-ons that make our lives easier as developers.”
Spring Projects
42
Two modules that will handle the application’s ORM (Object Relational Mapping) and the database connection.
SpringORM
43
where we get the annotations that map our model classes to DB tables.
spring JPA
44
spring jpa uses It uses the ------------- Interface to create, read, update and delete (crud) DB entities (tables) and their data in the database.
EntityManager
45
uses annotations from the JPA to directly map our Java models to Database tables”. So our DB tables get created by our Java models!
Spring Data
46
A ------------ is a group of one or more SQL statements (typically DML statements) that execute together, under a certain set of properties (ACID properties)...important for data integrity, or when you need a group of SQL statements to succeed together or fail together - no in between.
transaction
47
The entire transaction happens in one go, or it doesn’t happen at all. Every SQL statement in the transaction must complete successfully, or we undo everything the previous statements did.
Atomicity
48
Transactions must be consistent with the rules you set in your DB The database has constraints… (PK/FK, unique, not null, check, etc.) While transactions are executing, we never enter a state where the constraints are untrue or disregarded.
Consistency
49
In an enterprise scale database, many transactions will be running concurrently (at the same time) Each individual transaction runs as if it was the only one running. This avoids collision of transaction’s SQL statements. Transactions can’t interfere with each other! The database implements this for us
Isolation
50
If the transaction successfully completes, all of the data is saved to the database. The data won’t be lost after a transaction completes. It’s saved forever! Just like a normal SQL statement.
Durability
51
used in SpringMVC to receive JSON information from an external Restful API (a different server). This allows our Java server to send requests
RestTemplate
52
Breaks down programming logic into distinct Cross Cutting Concerns (CCC).
SpringAOP
53
AOP stands for ------------ used for organizing a project (or part of a project) into ASPECTS as opposed to OBJECTS.
Aspect Oriented programming
54
parts of the program that affect or rely on many other parts of the program. They form the basis for development of aspects. CCC don’t fit cleanly into the object-oriented paradigm.
Cross Cutting Concerns
55
A Class responsible for the Cross Cutting Concern that you’re addressing (an aspect is typically one class.) We’ll see a LoggingAspect today, which will hold all our logging code.
Aspect:
56
The action you are taking. What code you’re injecting to address the Cross Cutting Concern. The methods in the aspect are typically all advices
57
A point/place in the application that you can inject advice into.
JoinPoint
58
The specific JoinPoint that you will inject advice into. You will list criteria that will match certain JoinPoints to determine your
PointCut