Kayıtlar

Dependency Injection In Java and CDI

Dependency injection(DI) is one of the key techniques that enables a class or module to be injected into another, which also enables us to apply the principal of seperation of concerns via enabling a way of entity association and making wiring easy.

Along with Java EE 5, dependency injection was made of a part of the specification with JSR 250 (Common Annotations). For basic usages of injection, it has been a good start for Java platform especially with the annotations; @ManagedBean and @Resource.

Since Java EE 6, JSR 330 (Dependency Injection for Java) was introduced and the frequently used annotations like @Inject and @Named were made available. And ultimately, Contexts and Dependency Injection was also introduced with Java EE 6 which is built on top of JSR 330. Comparing to DI, CDI additionally provides an easy to use event mechanism, decorators and interceptors to add functionality to beans.

Since Java EE 5 with the EJB 3.0 specification, Java EE also provides injection for EJBs whic…

Java EE 8

Resim
In this article, we will focus on the following advances upcoming within Java EE 8.
For each item, i will try to write up in a seperate article or series of articles.

Servlet 4.0CDI 2.0JPA 2.2JSF 2.3JAX-RS 2.1MicroprofileBean Validation 2.0JSON Processing 1.1 (JSON-P)JSON Binding 1.0 (JSON-B)Java EE Security


MicroProfile

Resim
Eclipse MicroProfile provides a way of developing cloud-native Java microservices with the usage of a small subset of Java EE specifications.

These specifications are commonly; JAX-RS, CDI and JSON-P.
A MicroProfile microservice can be run on a supported container, such as TomEE and WildFly Swarm.

MicroProfile By Versions MicroProfile 1.0 - 2016
MicroProfile 1.1 - 2017
MicroProfile 1.2 - 2017 - aligned EE7
MicroProfile 2.0 - 2018 - aligned EE8
MicroProfile 3.0 - 2019 - aligned EE8


Referenceshttps://microprofile.io/
https://start.microprofile.io/
https://kodnito.com/category/tomee/
https://www.baeldung.com/eclipse-microprofile
https://github.com/eclipse/microprofile/releases/
https://openliberty.io/docs/ref/general/#microprofile.html
https://www.oracle.com/a/ocom/docs/corporate/java-magazine-nov-dec-2017.pdf
https://developer.ibm.com/articles/jakarta-ee-and-microprofile-getting-started/



Configuring Spring Boot Application with Maven

You can build and manage your Spring Boot applications with Maven or Gradle. In this article we will explore the basics of maven configuration for Spring Boot applications.

When we generate a Spring Boot application with Spring Initializr or Spring Boot CLI, a template Spring Boot project is generated for us having the selected dependencies. Let's examine the sections of the generated pom.xml.
1.Parent Pom In the heart of Spring Boot is inheriting the defaults from predefined configurations and that is the usage of starter pom files. A starter pom file includes convenient dependencies and versions in sync for your application; and when you import that starter you would automatically have the dependencies defined in that starter pom file.

<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.0.3.RELEASE</version> <relativePath/> </parent>
In the code bl…

Spring Boot Auto Configuration

Spring Components & Auto Scanning & Configuration

Spring managed beans are declared with the stereotype annotations specialized from @Component or with the @Component annotation itself.
When you declare a class with @Component[+derived] annotations, that bean is detected by Spring, via component scanning or explicitly wiring,
and put into the ApplicationContext.
1. Component ScanningIn a Spring application, you can declare your beans manually inside the bean configuration file,
but most probably, auto scanning of components is the preferred way of registering your beans into the application context.

You can configure auto scanning in bean configuration file or with the annotation.
1.1 Enable Auto-Scanning in Bean Configuration FileThis is available since Spring 2.5:
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframe…

Servlet

In Java EE world, Servlet simply is a web technology with which we can receive and handle the HTTP requests, create HTTP response and return that response back to the client.

Servlet technology makes a basis for other Java web technologies on top of which other frameworks put their extensions. For example JSP, JSF, Spring MVC are such technologies which are uses Servlet technology at behind. 

Servlets run on a web container such as Tomcat which provides the services on Java EE technology stack

What is a servlet ?
Servlet simply makes an object having HTTP-server functionality when its class extends HttpServlet class.

A servlet is mapped to a URL to which clients requestHTTP requests made to the URL is directed to the corresponding Servlet objectServlet implementation receives the request in the form of GET, POST, PUT or DELETEServlet implementation runs a business logic and prepares an HTTP response and sends it back to the client just an HTTP server doesLifecycle of the servlet is manag…