DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

How does AI transform chaos engineering from an experiment into a critical capability? Learn how to effectively operationalize the chaos.

Data quality isn't just a technical issue: It impacts an organization's compliance, operational efficiency, and customer satisfaction.

Are you a front-end or full-stack developer frustrated by front-end distractions? Learn to move forward with tooling and clear boundaries.

Developer Experience: Demand to support engineering teams has risen, and there is a shift from traditional DevOps to workflow improvements.

Core Badge
Avatar

Reza Ganji

DZone Core CORE

Software Development Manager,Software Architect,Programmer,Fighter

Dubai, AE

Joined Jan 2021

https://www.linkedin.com/in/reza-ganji-a131253a/

About

I have a master of science in IT from Iran Sharif university of tech. .....challenge lover ,computer geek ....

Stats

Reputation: 6002
Pageviews: 268.2K
Articles: 20
Comments: 12
  • Articles
  • Comments

Articles

article thumbnail
SRE Best Practices for Java Applications
Learn SRE best practices for Java applications to ensure high availability, performance, and scalability, covering monitoring, logging, security, and more.
March 12, 2025
· 8,972 Views · 10 Likes
article thumbnail
Is Spring AI Strong Enough for AI?
Explore Spring's capabilities within the AI domain, its potential integration with AI libraries, and its ability to effectively manage AI workflows.
September 27, 2024
· 13,634 Views · 15 Likes
article thumbnail
10 Things to Avoid in Domain-Driven Design (DDD)
DDD is an important strategic approach to software development. In this article, explore 10 things to avoid in DDD and examples to illustrate these pitfalls.
September 12, 2024
· 12,741 Views · 13 Likes
article thumbnail
How To Think Simple In Java
This guide aims to help you think simply in Java, emphasizing clean, readable, and maintainable code without sacrificing the power and capabilities of the language.
July 18, 2024
· 10,937 Views · 13 Likes
article thumbnail
Twenty Things Every Java Software Architect Should Know
Architects need a deep understanding of Java and its ecosystem, staying updated on the latest trends and best practices.
June 28, 2024
· 20,717 Views · 28 Likes
article thumbnail
The Magic of Quarkus With Vert.x in Reactive Programming
Explore reactive programming in Quarkus, along with detailed insights and practical examples in Java to illustrate its transformative capabilities.
June 3, 2024
· 6,887 Views · 4 Likes
article thumbnail
Comprehensive Guide to Unit Testing Spring AOP Aspects
With proper testing strategies in place, developers can confidently maintain and evolve AOP-based functionalities in their Spring app.
April 15, 2024
· 5,511 Views · 4 Likes
article thumbnail
JSON Handling With GSON in Java With OOP Essence
This guide will introduce you to GSON with practical examples and explore how OOP principles play a crucial role in the process.
January 4, 2024
· 11,106 Views · 10 Likes
article thumbnail
Simplifying Data Entities in Spring Data With Java Records
Java developers have been relying on Spring Data for efficient data access. With the Java records, the way data entities are managed has significantly changed.
October 30, 2023
· 6,583 Views · 5 Likes
article thumbnail
Creating a Deep vs. Shallow Copy of an Object in Java
There are two main ways to make copies: deep copy and shallow copy. Let’s explore these concepts and see how they work with some easy examples.
September 5, 2023
· 6,248 Views · 6 Likes
article thumbnail
Less Code With Spring Data Rest
We programmers are constantly solving various problems and always looking for a way to make life easier for others. On the other hand, we make life difficult for ourselves, because sometimes our code contains a lot of boilerplate code and modules that are not needed. For better understanding, consider a normal Spring Boot project that is only responsible for creating/reading/updating/deleting (CRUD) a client. First of all, we should create an entity called "Customer" which should be mapped to the table in the database, next, we should create a repository and the controller to call this repository and expose the service to the outside, sometimes we go one step further and add another layer to the architecture. Is all this extra work really necessary to provide multiple simple services? The answer is no, we can use "spring data rest" which can help us to provide our services directly from the data layer. Spring Data Rest With Spring Data Rest, the BL and controller layers are removed from your project. In fact, all REST services are provided by your Spring Data layer, and all you need to do is create a simple repository for your project, and Spring will do the rest. How Spring Data Rest Works everything is very simple, Spring Data Rest searches your projects and any commodity that finds the repository creates REST services for the corresponding entities related to the repository, consider the following example: Java public interface CustomerRepository extends CrudRepository {} If spring data rest finds this repository class, generates all REST APIs related to the client class. Rest APIs And Standards Spring Data Rest is based on a very simple and standard contract and creates REST APIs based on the entity type. In the example above, APIs were generated based on the entity type "customer", and the APIs followed a simple pluralized form, e.g. the first character of the entity is a lowercase letter and an "s" is simply added to the end of the entity. "/customers", you can see some generated REST for "customer" in the table below: HTTP Method URL Pattern Status Code Description GET /customers 200 get all customers GET /customers{id} 200 get customer by id POST /customers 201(created) creates new customer PUT /customers{id} 200 existing customer by id DELETE /customers{id} 200 customer by id REST APIs exposes in HATAOS format Spring Data Rest provides APIs in this format: Hypermedia as the Engine of application state(HATAOS), as you know hypermedia format can refer to any format or URL or even an image from the content, here is a simple HATAOS JSON from wiki : JSON HTTP/1.1 200 OK { "account": { "account_number": 12345, "balance": { "currency": "usd", "value": 100.00 }, "links": { "deposits": "/accounts/12345/deposits", "withdrawals": "/accounts/12345/withdrawals", "transfers": "/accounts/12345/transfers", "close-requests": "/accounts/12345/close-requests" } } } Useful and practical information about HATAOS can be found here. Also, learn more about this format in the rest of the article. Simple Case Study For better understanding, I will try to continue with a very simple example. Again, this example is not very unusual, because we are trying to create a project around the entity "customer". So let us get started. First of all, we need to add the required dependency to our pom: XML org.springframework.boot spring-boot-starter-data-rest Now it is time to create the main entity of the project, "Customer". This is a very simple entity that contains only one property: id, name, phone, and address of the customer Java package com.rgn.model; import lombok.Data; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.Table; import java.io.Serializable; @Data @Entity @Table(name = "customer") public class Customer implements Serializable { @Id @Column(name = "id") private Long id; @Column(name = "customername") private String customerName; @Column(name = "customerphonno") private Long customerPhoneNo; @Column(name = "customraddress") private String customerAddress; } Using Lombok @Data annotation helps us to prevent additional, setter, and getter in our code. the second most important part of our code is the creation of an appropriate repository for our entity customer: Java package com.rgn.repository; import com.rgn.model.Customer; import org.springframework.data.repository.CrudRepository; public interface CustomerRepository extends CrudRepository { } Also, we have a simple application class like every spring boot project: Java import org.springframework.boot.CommandLineRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; import java.util.Arrays; @SpringBootApplication public class MainApplication { public static void main(String[] args) { SpringApplication.run(MainApplication.class, args); } @Bean public CommandLineRunner commandLineRunner(ApplicationContext ctx) { return args -> { System.out.println("Let's inspect the beans provided by Spring Boot:"); String[] beanNames = ctx.getBeanDefinitionNames(); Arrays.sort(beanNames); for (String beanName : beanNames) { System.out.println(beanName); } }; } } Here is the configuration (application. properties)file of our project, we created our customer table in the Oracle database so we need to set database URL, username, and password: Shell spring.datasource.url=jdbc:oracle:thin:@localhost:1521:ORA81 spring.datasource.username=scott spring.datasource.password=tiger spring.datasource.driver-class-name=oracle.jdbc.OracleDriver # HikariCP settings spring.datasource.hikari.minimumIdle=5 spring.datasource.hikari.maximumPoolSize=20 spring.datasource.hikari.idleTimeout=30000 spring.datasource.hikari.maxLifetime=2000000 spring.datasource.hikari.connectionTimeout=30000 spring.datasource.hikari.poolName=HikariPoolBooks # JPA settings spring.jpa.database-platform=org.hibernate.dialect.Oracle12cDialect spring.jpa.hibernate.use-new-id-generator-mappings=false Note: the default address of exposed APIs is "/", for example, if you run the above project you can see the APIs at address "http://localhost:8080", unless, you should add your own address to the application.properties file with the following code : Shell spring.data.rest.basePath=/myApi By adding the above code you can see your rest in "http://localhost:8080/myApi" HAL explorer Spring also surprises developers and DevOps engineers with the capabilities it offers. There is a strong REST APIs explore that shows the APIs in HATAOS format, to use them you need to add the following dependency to your project: XML org.springframework.data spring-data-rest-hal-explorer org.springframework.boot spring-boot-starter-security In order for us to use standard annotations at both the class and method levels, the following code represents the application of class-level security roles, which means that any caller wishing to invoke any service of this class should have the "ALL" role: Java @PreAuthorize("hasRole('ALL')") public interface CustomerRepository extends CrudRepository { } If you want to create a method with different access roles, you should simply override the method and apply a different role. In the code below, "findAll()" has been overridden and applied to an "ADMIN" role: import com.rgn.model.Customer; import org.springframework.data.repository.CrudRepository; import org.springframework.security.access.prepost.PreAuthorize; @PreAuthorize("hasRole('ALL')") public interface CustomerRepository extends CrudRepository { @Override @PreAuthorize("hasRole('ADMIN')") public Iterable findAll(); } You can find detailed information about spring security and annotations and mechanism here. Performance When I decide to use new technology, after all the technical considerations and studies of that technology, before I use it, I try to compare its performance either with the older technology I am using now or with similar technologies that exist in the field. For this purpose, firstly, I search for reputable websites to know the experience of others with this technology in terms of its performance and benchmarks, and secondly, I try to make performance comparisons myself. in this part, let us compare the performance between Spring Data Rest and the regular architecture that includes the controller layer. So I have two test cases with and without spring data rest. For the performance tests, I used JMeter, with 1000000 threads and 1000 as a threshold for the graph and the regular PC. OK, here we go: Test Result With Spring Data Rest As you can see, the graph of response times has stabilized after slight fluctuations and we have a normal response time. Test Result Without Spring Data Rest Before we start this step, we should remove the dependency on spring data rest from our pom and add the following class as a controller layer to our project: Java package com.rgn.model; import com.rgn.repository.CustomerRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @RestController public class CustomerService { @Autowired CustomerRepository repository; @GetMapping("/customers") public Customer getCustomer(@RequestParam(value = "id") Long id){ return repository.findById(id.longValue()).get(); } } The result can be seen in the following figure. You can see that we get better performance when using spring data.
January 16, 2022
· 10,441 Views · 9 Likes
article thumbnail
How To Get Closer to Consistency in Microservice Architecture
Some scenarios in microservice-based architecture involve multiple microservices. Read how completion of the scenario depends on the task completion of each microservice.
October 20, 2021
· 9,371 Views · 10 Likes
article thumbnail
Choose The Right Data Structure at The Right Time and Right Place
These days we have a basket full of various data structures, that most of which have similar functions. So which one is correct for my current problem?
August 28, 2021
· 6,342 Views · 7 Likes
article thumbnail
How Kafka Can Make Microservice Planet a Better Place
In this article, we want to focus on using Kafka in the microservice architecture, and we need an important concept named Kafka Topic for that.
August 28, 2021
· 18,580 Views · 13 Likes
article thumbnail
HashiCorp Is Becoming an Important Part of Spring Cloud (Part 1)
Spring Cloud Config is the basic part of every distributed and Cloud-based architecture. Actually, it provides client-side and server-side configuration for that systems.
July 24, 2021
· 13,611 Views · 5 Likes
article thumbnail
High-Performance Batch Processing Using Apache Spark and Spring Batch
Batch processing is dealing with a large amount of data; it actually is a method of running high-volume, repetitive data jobs and each job does a specific task.
May 16, 2021
· 27,949 Views · 7 Likes
article thumbnail
The Magic of Apache Spark in Java
An experience software architect runs through the concepts behind Apache Spark and gives a tutorial on how to use Spark to better analyze your data sets.
April 13, 2021
· 42,220 Views · 21 Likes
article thumbnail
Company Internal Frameworks; Good, Bad, Boring
Software companies' internal frameworks sometimes contain the whole software development life cycle, and sometimes it just boils down to a few tools and utilities.
March 31, 2021
· 7,746 Views · 7 Likes
article thumbnail
Google Guava and Its Two Fantastic Libraries: Graph and Eventbus
The main idea behind it was to include generics introduced in JDK 1.5 into Java Collections Framework, or JCF, and enhance its capability.
March 8, 2021
· 19,170 Views · 9 Likes
article thumbnail
Native Memory May Cause Unknown Memory Leaks
Recently I came across a strange case: the memory usage of my program exceeded the maximum value intended for the heap. I found an interesting issue.
January 31, 2021
· 6,678 Views · 11 Likes

Comments

Twenty Things Every Java Software Architect Should Know

Jul 04, 2024 · Reza Ganji

Thank you very much, Tim.

Twenty Things Every Java Software Architect Should Know

Jul 04, 2024 · Reza Ganji

Thank you very much, Lauren.

How To Get Closer to Consistency in Microservice Architecture

May 19, 2022 · Reza Ganji

It is my pleasure

How Kafka Can Make Microservice Planet a Better Place

Jan 17, 2022 · Reza Ganji

Dear kaveh, do you mean stream processor?

How To Get Closer to Consistency in Microservice Architecture

Oct 23, 2021 · Reza Ganji

Regards


Choose The Right Data Structure at The Right Time and Right Place

Sep 04, 2021 · Reza Ganji

The Magic of Apache Spark in Java

Apr 14, 2021 · Reza Ganji

Sure ,thanks

Why Java Is so Young After 25 Years: An Architect’s Point of View

Mar 25, 2021 · Dr.Magesh Kasthuri

It was great

7 Continuous Code Quality and Automated Code Review Tools

Mar 25, 2021 · Saif Sadiq

I think human code review somtimes could not be eliminated

Java 2021: What Frameworks and Trends for This New Year?

Feb 26, 2021 · Otavio Santana

you Are absolutely all right mr friend

Java 2021: What Frameworks and Trends for This New Year?

Feb 26, 2021 · Otavio Santana

I think the next years would be a jalartaEE s years

MuleSoft Operational and API Management Capabilities

Feb 26, 2021 · Jitendra Bafna

It will be very helpful if you refer a some real wold example.

User has been successfully modified

Failed to modify user

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • [email protected]

Let's be friends: