13 Feb 2025
DZone Java Zone
How Java Servlets Work: The Backbone of Java Web Apps
I assume that if you're reading this article, you already know what Servlets are. But if you don't, let me introduce them.
In the Java world, a Servlet is a web component defined by the Jakarta Servlet Specification 6.1, which is part of Jakarta EE. Managed by a Servlet Container (I'll dive into that soon), it handles incoming requests, processes them, and sends responses back to the client (see more in the Jakarta Servlet Specification 6.1).
13 Feb 2025 7:00pm GMT
A Guide to Constructor Chaining in Java
Constructor chaining refers to the ability to call a constructor inside another constructor. You can use a constructor chain either within the same class or even with another one. For the latter, the constructor must be inherited from the superclass. In this Java programming tutorial, you will learn the three ways to implement constructor chaining.
Java Constructor Chaining in the Same Class
You can create multiple constructors in the same class, each with a different number of arguments that it accepts. To call one constructor within another (of the same class), use this()
.
13 Feb 2025 4:00pm GMT
10 Feb 2025
DZone Java Zone
Spring Data Neo4j: How to Update an Entity
After working on a new online Spring Data Neo4j course, I learned a couple more things about updating an entity. The course required a different set of scenarios than outlined in my previous SDN update blog post, so I wanted to cover those scenarios, as well.
Spring save() Method
First up is the out-of-the-box save()
method that is provided by Spring as a default. This method takes an input of the entity object you want to save to the database.
10 Feb 2025 7:00pm GMT
Designing AI Multi-Agent Systems in Java
The year 2025 is the year of AI agents. For the purposes of this article, an AI agent is a system that can leverage AI to achieve a goal by following a series of steps, possibly reasoning on its results and making corrections. In practice, the steps that an agent follows can constitute a graph.
We will build a reactive agent (meaning that it reacts to a stimulus, in our case, the input from a user) to help people find their perfect vacation. Our agent will find the best city in the specified country, considering the food, sea, and activity specified by the user.
10 Feb 2025 1:00pm GMT
07 Feb 2025
DZone Java Zone
AOP for Post-Processing REST Requests With Spring and AspectJ
Aspect-oriented programming (AOP) is a programming paradigm that enables the modularisation of concerns that cut across multiple types and objects. It provides additional behavior to existing code without modifying the code itself.
AOP can solve many problems in a graceful way that is easy to maintain. One such common problem is adding some new behavior to a controller (@Controller
) so that it works "outside" the main logic of the controller. In this article, we will look at how to use AOP to add logic when an application returns a successful response (HTTP 200). An entity should be deleted after it is returned to a client.
07 Feb 2025 9:00pm GMT
05 Feb 2025
DZone Java Zone
Demystifying Sorting Assertions With AssertJ
There are times when a new feature containing sorting is introduced. Obviously, we want to verify that the implemented sorting works correctly. AssertJ framework provides first-class support for such tasks. This article shows how to write such tests.
In this article, you will learn the following:
05 Feb 2025 8:00pm GMT
Detecting Patterns in Event Streams With FlinkCEP
We call this an event when a button is pressed; a sensor detects a temperature change, or a transaction flows through. An event is an action or state change that is important to an application.
Event stream processing (ESP) refers to a method or technique to stream the data in real-time as it passes through a system. The main objective of ESP is to focus on the key goal of taking action on the data as it arrives. This enables real-time analytics and action, which is important in scenarios where low-latency response is a prerequisite, e.g., fraud detection, monitoring, and automated decision-making systems. Patterns play a big role in ESP as they help spot important sequences or behaviors in data that keep flowing non-stop.
05 Feb 2025 7:00pm GMT
03 Feb 2025
DZone Java Zone
Java Stream API: 3 Things Every Developer Should Know About
Time flies! I remember the time when Java 8 was such a reference, and everybody was talking about it like something new and revolutionary. Frankly speaking, it was new and revolutionary. But now, projects using Java 8 might be labeled "legacy." If Java 8 itself became a legacy, the features introduced in that version would still be actual. And let's talk today about one of them - Stream API.
In case you don't know, Java Stream API is a powerful tool that allows programmers to write Java code in a functional programming style. Introduced long ago, it makes working with collections easier by enabling filtering, transformation, and aggregation.
03 Feb 2025 8:00pm GMT
MuleSoft OAuth 2.0 Provider: Password Grant Type
OAuth 2.0 is a widely used authorization framework that allows third-party applications to access user resources on a resource server without sharing the user's credentials.
The Password Grant type, also known as Resource Owner Password Credentials Grant, is a specific authorization grant defined in the OAuth 2.0 specification. It's particularly useful in scenarios where the client application is highly trusted and has a direct relationship with the user (e.g., a native mobile app or a first-party web application). This grant type allows the client to request an access token by directly providing the user's username and password to the authorization server. While convenient, it's crucial to implement this grant type securely, as it involves handling sensitive user credentials.
03 Feb 2025 5:00pm GMT
29 Jan 2025
DZone Java Zone
How to Split PDF Files into Separate Documents Using Java
Asking our Java file-processing applications to manipulate PDF documents can only increase their value in the long run. PDF is by far the most popular, widely used file type in the world today, and that's unlikely to change any time soon.
Introduction
In this article, we'll specifically learn how to divide PDF files into a series of separate PDF documents in Java - resulting in exactly one new PDF per page of the original file - and we'll discuss open-source and third-party web API options to facilitate implementing that programmatic workflow into our code. We'll start with a high-level overview of how PDF files are structured to make this type of workflow possible.
29 Jan 2025 9:00pm GMT
The Energy Efficiency of JVMs and the Role of GraalVM
As the world becomes increasingly conscious of energy consumption and its environmental impact, software development is joining the movement to go green. Surprisingly, even the choice of runtime environments and how code is executed can affect energy consumption. This brings us to the world of Java Virtual Machines (JVMs), an integral part of running Java applications, and the rising star in the JVM world, GraalVM.
In this article, we will explore how code performance and energy efficiency intersect in the JVM ecosystem and why GraalVM stands out in this domain.
29 Jan 2025 12:00pm GMT
28 Jan 2025
DZone Java Zone
Using Spring AI to Generate Images With OpenAI's DALL-E 3
Hi, community!
This is my first article in a series of introductions to Spring AI. Today, we will see how we can easily generate pictures using text prompts. To achieve this, we will leverage the OpenAI API and the DALL-E 3 model.
28 Jan 2025 6:00pm GMT
How Apache Flink and Apache Paimon Influence Data Streaming
Apache Paimon is made to function well with constantly flowing data, which is typical of contemporary systems like financial markets, e-commerce sites, and Internet of Things devices. It is a data storage system made to effectively manage massive volumes of data, particularly for systems that deal to analyze data continuously such as streaming data or with changes over time like database updates or deletions.
To put it briefly, Apache Paimon functions similarly to a sophisticated librarian for our data. Whether we are operating a large online business or a little website, it keeps everything organized, updates it as necessary, and ensures that it is always available for use. An essential component of Apache Paimon's ecosystem, Apache Flink is a real-time stream processing framework that significantly expands its capabilities. Let's investigate how well Apache Paimon and Apache Flink work with each other so effectively.
28 Jan 2025 2:00pm GMT
27 Jan 2025
DZone Java Zone
Integrating AI With Spring Boot: A Beginner’s Guide
Do you need to integrate artificial intelligence into your Spring Boot application? Spring AI reduces complexity using abstractions you are used to apply within Spring Boot. Let's dive into the basics in this blog post. Enjoy!
Introduction
Artificial intelligence is not a Python-only party anymore. LangChain4j basically opened the Java toolbox for integrating with AI. Spring AI is the Spring solution for AI integration. It tries to reduce the complexity of integrating AI within a Java application, just like LangChain4j is doing. The difference is that you can use the same abstractions as you are used to apply within Spring Boot.
27 Jan 2025 2:00pm GMT
24 Jan 2025
DZone Java Zone
Multi-Tenancy and Its Improved Support in Hibernate 6.3.0
Multi-tenancy has become an important feature for modern enterprise applications that need to serve multiple clients (tenants) from a single application instance. While an earlier version of Hibernate had support for multi-tenancy, its implementation required significant manual configuration and custom strategies to handle tenant isolation, which resulted in higher complexity and slower processes, especially for applications with a number of tenants.
The latest version of Hibernate 6.3.0, which was released on December 15, 2024, addressed the above limitations with enhanced multi-tenancy support through better tools for tenant identification, schema resolution, and enhanced performance for handling tenant-specific operations. This article talks about how Hibernate 6.3.0 enhanced the traditional multi-tenancy implementation significantly.
24 Jan 2025 12:00pm GMT
23 Jan 2025
DZone Java Zone
Multi-Tenant Data Isolation and Row Level Security
Over the past one and a half years, I was involved in designing and developing a multi-tenant treasury management system. In this article, I will share our approaches to the data isolation aspect of our multi-tenant solution and the learnings from it.
Background and Problem Regarding Data Isolation
Before going into the problem that I will focus on today, I must first give some background into our architecture for storage and data in our system. When it comes to data partitioning for SaaS systems, at the extreme far right end, we have the approach of using dedicated databases for each tenant (silo model), and on the other side of the spectrum is the shared database model (pool model).
23 Jan 2025 6:00pm GMT