Spring Core and Context Flashcards
Concepts of Spring DI framework
Which interface is used to create spring IOC container?
ApplicationContext. There are multiple implementations of ApplicationContext. One needs to choose based on their requirement.
Which are common implementations of ApplicationContext
ClasspathXMLApplicationContext, FileSystemXmlApplicationContext, AnnoationConfigApplicationContext, XmlWebApplicationContext, AnnotationConfigWebApplicationContext.
What are POJO objects called in Spring?
Beans
Which are mandatory properties for defining a bean in spring xml?
Bean id or name, bean class are mandatory properties.
Which xml tag is used to inject a dependency in spring bean?
is used to inject a bean.
Which xml tag is used to inject dependency using constructor?
tag is used.
What happens if there are two beans of same type and a class wants an instance of that bean?
Then spring will fail as it will get confused as to which bean needs to be injected. Then we need @Qualifier annotation.
Which xml configuration needs to be enabled to start autowiring using annotation?
enables autowiring using annotation.
@Autowired, @PostConstruct, @PreDestroy,
@PersistanceContext (if avaiable, like hibernate), @PersistanceUnit (if available)
Which ways are used to do some post processing once all dependencies have been injected?
@PostConstruct annotation or using InitializingBean interface or init-method property of tag in xml.
Which ways are used to do some pre processing before the context is destroyed and bean is destroyed?
@PreDestroy annotation, DisposableBean interface or destroy-method property of tag in xml.
When is pre destroy call made?
When the application context is closed.
How many types of autowiring is supported?
ByType, ByName or Constructor
Which is default autowiring type?
Default mode in java based autowiring is byType.
Which is the super class of Spring ApplicationContext?
BeanFactory is super of ApplicationContext.
What additional features of ApplicationContext?
It adds enterprise level features like Internationalization, etc.
Which is default autowiring type?
Default mode in java based autowiring is byType.
Which is the super class of Spring ApplicationContext?
BeanFactory is super of ApplicationContext