Spring Class_04.2020_CORE_IoC Flashcards
What is Spring Framework?
It’s enormous amount of libraries which help build web apps
How many libraries does Spring consists?
near 250
Why spring is lightweight framework?
Because it minimizes amount of written code by developer
Basic idea behind Spring is
Simplify traditional approach to designing J2EE apps
Who is the creator of Spring?
Rod Johnson
What is Rob Johnson specialization?
enterprise java architect
Difference between library and framework
you code call LIBRARY
FRAMEWORK call your code
(* and contains library functions)
How Spring Framework reduce time of development?
Spring handles the infrastructure
so you can focus on your application
What is POJO?
plain old java object
How Spring work with POJOs?
apply enterprise services to POJO
Spring implements various design …
patterns
…, Builder, Proxy - patterns were implemented in Spring
Factory
What is IoC purpose?
compose fully disparate components into a working app
Когда невозможно использовать другие реализации зависимого класса и тестировать главный и зависимый классы раздельно?
Когда главный класс инициализирует зависимый класс в конструкторе
Как разделить главный и зависимый классы?
Создавать раздельно
Как можно связать классы при раздельном создании?
установить сеттером или передать параметр в конструктор
какие проблемы могут быть при установке сеттером
переменная до установки сеттером= null
при этом к ней могут обратиться
основные проблемы раздельного создания экземпляров классов: порядок создания, установка сеттером всех экземпляров, …
порядок параметров в конструкторе
How to automate creating of objects and their connections?
Dependency Injections
How does Dependency Injections work?
define dependencies and inject them
How to configure dependencies?
xml, annotations, java
Who can inject dependencies?
application context can make it
Which file do we use to configure objects via xml?
application-context.xml
How does tag for class called?
bean
attribute of “bean” tag for connection with other beans
id
attribute of “bean” tag for class name
class
tag inside “bean” tag for filling properties of bean
property
attribute of “property” tag to find field in bean
name
should be exactly the same as field variable in class
attribute of “property” tag for filling simple type value into field
value
attribute of “property” tag for filling reference type value into field
ref
how to fill ref attribute of “property” tag?
use id attribute of appropriate bean
how to create java class by application context (xml config)
Use an instance of ApplicationContext
to call method getBean with id of bean as parameter
how application context recognize about beans?
application-context.xml
config file is placed as constructor parameter
what is internal structure of application context?
it contains map for managed objects
key id
value reference to managed objects
The creation of the object’s relationships is managed by the container through …
Dependency Injections
How can you formulate “Hollywood principle”?
Don’t call me, I’ll call you
What is basic idea of “Hollywood principle”?
eliminate dependencies of application components from certain implementation
How “Hollywood principle” is realized in IoC?
Dependency Injection container instantiate and initialize objects and their dependencies
IoC Containers can simplify …
unit testing
IoC Containers can make code …
cleaner
IoC Containers give us facilities of …
reusing classes or components
IoC Containers provide applying changes …
without recompiling
The … is a central Ioc container into the Spring Framework
BeanFactory
Which pattern is implemented in BeanFactory?
factory pattern
Most common implementation of BeanFactory is …
XmlBeanFactory
ApplicationContext extends BeanFactory and adds …
Event handling
ApplicationContext extends BeanFactory ability to work with many languages that is called …
Internationalization
ApplicationContext works with … and messages
resources
ApplicationContext simply integrates with
Spring AOP
ApplicationContext differs from BeanFactory by …
Specific application contexts
Central point of the context module is …
Application Context interface
… are used in real life
Application Contexts
… could be used in exceptional cases
BeanFactory
possible exceptional cases when it’s possible to use BeanFactory
- Resources are critical and only IoC container is required.
- Integrating Spring with framework
(backward compatibility is necessary)
… is traditional way to configure a container
XML
Most widely used implementations of ApplicationContext are GenericXmlApplicationContext, … , FileSystemXmlApplicationContext
ClassPathXmlApplicationContext
This prefix can be added to config file’s name to say context to find out it in class path
classpath:
Spring IoC Container uses POJOs and …
Configuration Metadata