Home » Java (page 3)

Java

Guidance for Building a Control Plane for Envoy Part 2 – Identify Components

java-interview-questions-answers

This is part 2 of a series that explores building a control plane for Envoy Proxy. In this blog series, we’ll take a look at the following areas: Adopting a mechanism to dynamically update Envoy’s routing, service discovery, and other configurationIdentifying what components make up your control plane, including backing stores, service discovery APIs, security components, et. al. (this entry)Establishing ...

Read More »

New life of old Visitor design pattern

Introduction Visitor [1, 2] is a widely known classical design pattern. There are a lot of resources that explain it in details. Without digging into the implementation I will briefly remind the idea of the pattern, will explain its benefits and downsides and will suggest some improvements that can be easily applied to it using Java programming language.  Classical Visitor [Visitor] ...

Read More »

Centralized Authorization with OAuth2 & Opaque Tokens using Spring Boot 2

java-interview-questions-answers

If you are looking for JWT implementation please follow this link This guide walks through the process to create a centralized authentication and authorization server with Spring Boot 2, a demo resource server will also be provided. If you’re not familiar with OAuth2 I recommend this read. Pre-req JDK 1.8Text editor or your favorite IDEMaven 3.0+ Implementation Overview For this project we’ll ...

Read More »

How to put Java application behind Apache HTTP server

In the “old days” it was very common thing to put Apache HTTP server in front of your Java application server, or Java application it self. Reason behind it was very simple, caching could be added in easy way, also load balancing could be added, and on top of this static content could be served by Apache HTTP while all ...

Read More »

Two ways to extend enum functionality

Preface In my previous article I explained how and why to use enums instead of switch/case control structure in Java code. Here I will show how to extend functionality of existing enums. Introduction Java enum is a kind of a compiler magic. In the byte code anyenum is represented as a class that extends abstract class java.lang.Enum and has several ...

Read More »

Var and Language Design

What is var in Java The var predefined type introduced in Java 10 lets you declared local variables without specifying the type of the variable when you assign a value to the variable. When you assign a value to a variable the type of the expression already defines the type of the variable, thus there is no reason to type ...

Read More »

Featured enum instead of switch

Problem and  its solution Switch/case is the common control structure implemented in most imperative programming languages. Switch is considered more readable than series of if/else. Here is a simple example: // Switch with int literal switch (c) { case 1: one(); break; case 2: two(); break; case 3: three(); break; default: throw new UnsupportedOperationException(String.format("Operation %d is not supported", c)); } ...

Read More »

Removing elements from a Map in Java

Very short and simple post on removing elements from a Map in Java. We will be focusing on removing multiple elements and ignore the fact you can remove a single element using Map.remove. The Map below will be used for this post: Map<Integer, String> map = new HashMap<>(); map.put(1, "value 1"); map.put(2, "value 2"); map.put(3, "value 3"); map.put(4, "value 4"); ...

Read More »