Spring General Interview Question
- Bean "a" has singleton scope and with a reference to
a bean prototype scope, then how spring handle this situtation?
singleton-scoped bean to acquire a new instance of the
prototype-scoped bean repeatedly at runtime. You cannot
dependency-inject a prototype-scoped bean into your singleton bean,
because that injection occurs only once, when the Spring container is
instantiating the singleton bean and resolving and injecting its
Lookup method injection is the ability of the container to override
methods on container managed beans, to return the lookup result for
another named bean in the container. The lookup typically involves a
prototype bean as in the scenario described in the preceding section.
The Spring Framework implements this method injection by using
bytecode generation from the CGLIB library to generate dynamically a
subclass that overrides the method.
What is in JSR 303?
JSR 303 (Bean Validation) is
the specification of the Java API for JavaBean validation in Java EE
and Java SE. Before 303 have needed a bunch of if-else statements to
achieve Validation. It require validation-api-X.jar in project. e.g.
@NotNull, @Pattern, @Past, @Min, @Max, @NotBlank, @Email etc
What is Spring Batch Framework?
Spring Batch is
an open-source framework for batch processing(execution of a series
of jobs). Spring Batch provides classes and APIs to read/write
resources, transaction management, job processing statistics, job
restart and partitioning techniques to process high volume data.
What is Tasklet?
The Tasklet is a simple
interface with one method to execute. A tasklet can be used to
perform single tasks like running queries, deleting files etc. In
Spring Batch, tasklet can be used to perform unique tasks like clean
or set up resources before or after any step execution.
What is a Chunk?
Spring Batch uses a
'Chunk-oriented' processing style within its most common
implementation. Chunk oriented processing refers to reading the data
one at a time and creating 'chunks' that are written out within a
transaction boundary. One item is read in from an ItemReader, handed
to an ItemProcessor and aggregated.
What are the differences in Netty vs Apache Tomcat?
- Netty as "Asynchronous event-driven network application framework".
Netty is a NIO client server framework which enables quick and easy
development of network applications such as protocol servers and
clients. It greatly simplifies and streamlines network programming
such as TCP and UDP socket server. On the other hand, Apache Tomcat
"An open source software implementation of the Java Servlet and
JavaServer Pages technologies".
- Apache Tomcat powers numerous large-scale, mission-critical
web applications across a diverse range of industries and
organizations. Netty belongs to "Concurrency Frameworks" category of
the tech stack, while Apache Tomcat can be primarily classified under
- Netty - "High Performance", Apache Tomcat -"Easy".
-Netty and Apache Tomcat are both open source tools.
-GitHub forks has more adoption for Netty compair to Apace
-Apache Tomcat has broader StackShare community and developer
compair to Netty.