deps: Refactor dependencies (#3224)

* remove spring dep
move junit, logging, mockito under dep mgmt

* upgrade anti-corruption-layer deps

* async method invocation

* balking, bloc

* bridge to bytecode

* caching

* callback - cqrs

* component - health check

* hexagonal - metadata mapping

* rest of the patterns

* remove checkstyle, take spotless into use
This commit is contained in:
Ilkka Seppälä authored and GitHub committed 2025-03-29 19:34:27 +02:00
1 parent 371439aeaa
commit 0ca162a55c
1863 files changed
+14403 -17632

No files matched your search

@@ -31,9 +31,7 @@ package com.iluwatar.servicelocator;
* necessary to perform a certain task.
*
* <p>In this example we use the Service locator pattern to lookup JNDI-services and cache them for
* subsequent requests.
* <br>
*
* subsequent requests. <br>
*/
public class App {
@@ -29,7 +29,6 @@ import lombok.extern.slf4j.Slf4j;
/**
* For JNDI lookup of services from the web.xml. Will match name of the service name that is being
* requested and return a newly created service object with the name
*
*/
@Slf4j
public class InitContext {
@@ -26,9 +26,13 @@ package com.iluwatar.servicelocator;
/**
* This is going to be the parent service interface which we will use to create our services. All
* services will have a <ul><li>service name</li> <li>unique id</li> <li>execution work
* flow</li></ul>
* services will have a
*
* <ul>
* <li>service name
* <li>unique id
* <li>execution work flow
* </ul>
*/
public interface Service {
@@ -33,7 +33,6 @@ import lombok.extern.slf4j.Slf4j;
* the cache will be empty and thus any service that is being requested, will be created fresh and
* then placed into the cache map. On next hit, if same service name will be requested, it will be
* returned from the cache
*
*/
@Slf4j
public class ServiceCache {
@@ -30,7 +30,6 @@ import lombok.extern.slf4j.Slf4j;
* This is a single service implementation of a sample service. This is the actual service that will
* process the request. The reference for this service is to be looked upon in the JNDI server that
* can be set in the web.xml deployment descriptor
*
*/
@Slf4j
public class ServiceImpl implements Service {
@@ -38,9 +37,7 @@ public class ServiceImpl implements Service {
private final String serviceName;
private final int id;
/**
* Constructor.
*/
/** Constructor. */
public ServiceImpl(String serviceName) {
// set the service name
this.serviceName = serviceName;
@@ -27,14 +27,12 @@ package com.iluwatar.servicelocator;
/**
* The service locator module. Will fetch service from cache, otherwise creates a fresh service and
* update cache
*
*/
public final class ServiceLocator {
private static final ServiceCache serviceCache = new ServiceCache();
private ServiceLocator() {
}
private ServiceLocator() {}
/**
* Fetch the service with the name param from the cache first, if no service is found, lookup the
@@ -24,17 +24,15 @@
*/
package com.iluwatar.servicelocator;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
/**
* Application test
*/
import org.junit.jupiter.api.Test;
/** Application test */
class AppTest {
@Test
void shouldExecuteWithoutException() {
assertDoesNotThrow(() -> App.main(new String[]{}));
assertDoesNotThrow(() -> App.main(new String[] {}));
}
}
@@ -33,24 +33,17 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.List;
import org.junit.jupiter.api.Test;
/**
* ServiceLocatorTest
*
*/
/** ServiceLocatorTest */
class ServiceLocatorTest {
/**
* Verify if we just receive 'null' when requesting a non-existing service
*/
/** Verify if we just receive 'null' when requesting a non-existing service */
@Test
void testGetNonExistentService() {
assertNull(ServiceLocator.getService("fantastic/unicorn/service"));
assertNull(ServiceLocator.getService("another/fantastic/unicorn/service"));
}
/**
* Verify if we get the same cached instance when requesting the same service twice
*/
/** Verify if we get the same cached instance when requesting the same service twice */
@Test
void testServiceCache() {
final var serviceNames = List.of("jndi/serviceA", "jndi/serviceB");
@@ -62,7 +55,5 @@ class ServiceLocatorTest {
assertTrue(service.getId() > 0); // The id is generated randomly, but the minimum value is '1'
assertSame(service, ServiceLocator.getService(serviceName));
}
}
}
}