Resolves checkstyle errors for ambassador, async-method-invocation, balking, bridge, builder (#1058)

* Decreases checkstyle errors for ambassador pattern

* Reduces checkstyle errors in async-method-invocation

* Reduces checkstyle errors in balking

* Reduces checkstyle errors in bridge

* Reduces checkstyle errors in builder
This commit is contained in:
Anurag Agarwal
2019-11-10 00:33:22 +05:30
committed by Ilkka Seppälä
parent 1fa8a604eb
commit 6d1c0b1563
29 changed files with 179 additions and 225 deletions

View File

@ -24,27 +24,26 @@
package com.iluwatar.ambassador;
/**
*
* The ambassador pattern creates a helper service that sends network requests on behalf of a
* client. It is often used in cloud-based applications to offload features of a remote service.
*
* An ambassador service can be thought of as an out-of-process proxy that is co-located with
* the client. Similar to the proxy design pattern, the ambassador service provides an interface
* for another remote service. In addition to the interface, the ambassador provides extra
* functionality and features, specifically offloaded common connectivity tasks. This usually
* consists of monitoring, logging, routing, security etc. This is extremely useful in
* legacy applications where the codebase is difficult to modify and allows for improvements
* in the application's networking capabilities.
* <p>An ambassador service can be thought of as an out-of-process proxy that is co-located with
* the client. Similar to the proxy design pattern, the ambassador service provides an interface for
* another remote service. In addition to the interface, the ambassador provides extra functionality
* and features, specifically offloaded common connectivity tasks. This usually consists of
* monitoring, logging, routing, security etc. This is extremely useful in legacy applications where
* the codebase is difficult to modify and allows for improvements in the application's networking
* capabilities.
*
* In this example, we will the ({@link ServiceAmbassador}) class represents the ambassador while the
* <p>In this example, we will the ({@link ServiceAmbassador}) class represents the ambassador while
* the
* ({@link RemoteService}) class represents a remote application.
*
*/
public class App {
/**
* Entry point
*/
* Entry point.
*/
public static void main(String[] args) {
Client host1 = new Client();
Client host2 = new Client();

View File

@ -23,12 +23,11 @@
package com.iluwatar.ambassador;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.Logger;
/**
* A simple Client
* A simple Client.
*/
public class Client {

View File

@ -23,12 +23,12 @@
package com.iluwatar.ambassador;
import static java.lang.Thread.sleep;
import com.iluwatar.ambassador.util.RandomProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static java.lang.Thread.sleep;
/**
* A remote legacy application represented by a Singleton implementation.
*/
@ -55,9 +55,11 @@ public class RemoteService implements RemoteServiceInterface {
RemoteService(RandomProvider randomProvider) {
this.randomProvider = randomProvider;
}
/**
* Remote function takes a value and multiplies it by 10 taking a random amount of time.
* Will sometimes return -1. This imitates connectivity issues a client might have to account for.
* Remote function takes a value and multiplies it by 10 taking a random amount of time. Will
* sometimes return -1. This imitates connectivity issues a client might have to account for.
*
* @param value integer value to be multiplied.
* @return if waitTime is less than {@link RemoteService#THRESHOLD}, it returns value * 10,
* otherwise {@link RemoteServiceInterface#FAILURE}.

View File

@ -23,17 +23,15 @@
package com.iluwatar.ambassador;
import static java.lang.Thread.sleep;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static java.lang.Thread.sleep;
/**
*
* ServiceAmbassador provides an interface for a ({@link Client}) to access ({@link RemoteService}).
* The interface adds logging, latency testing and usage of the service in a safe way that will not
* add stress to the remote service when connectivity issues occur.
*
*/
public class ServiceAmbassador implements RemoteServiceInterface {
@ -41,7 +39,8 @@ public class ServiceAmbassador implements RemoteServiceInterface {
private static final int RETRIES = 3;
private static final int DELAY_MS = 3000;
ServiceAmbassador() {}
ServiceAmbassador() {
}
@Override
public long doRemoteFunction(int value) {