mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-24 08:25:06 +00:00
📍Use lombok, reformat, and optimize the code (#1560)
* Use lombok, reformat, and optimize the code * Fix merge conflicts and some sonar issues Co-authored-by: va1m <va1m@email.com>
This commit is contained in:
@@ -35,17 +35,15 @@ import java.net.UnknownHostException;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* Represents the clients of Reactor pattern. Multiple clients are run concurrently and send logging
|
||||
* requests to Reactor.
|
||||
*/
|
||||
@Slf4j
|
||||
public class AppClient {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(AppClient.class);
|
||||
|
||||
private final ExecutorService service = Executors.newFixedThreadPool(4);
|
||||
|
||||
/**
|
||||
|
||||
@@ -28,17 +28,15 @@ import com.iluwatar.reactor.framework.ChannelHandler;
|
||||
import com.iluwatar.reactor.framework.NioDatagramChannel.DatagramPacket;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.SelectionKey;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* Logging server application logic. It logs the incoming requests on standard console and returns a
|
||||
* canned acknowledgement back to the remote peer.
|
||||
*/
|
||||
@Slf4j
|
||||
public class LoggingHandler implements ChannelHandler {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(LoggingHandler.class);
|
||||
|
||||
private static final byte[] ACK = "Data logged successfully".getBytes();
|
||||
|
||||
/**
|
||||
|
||||
@@ -30,16 +30,14 @@ import java.net.SocketAddress;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.DatagramChannel;
|
||||
import java.nio.channels.SelectionKey;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* A wrapper over {@link DatagramChannel} which can read and write data on a DatagramChannel.
|
||||
*/
|
||||
@Slf4j
|
||||
public class NioDatagramChannel extends AbstractNioChannel {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(NioDatagramChannel.class);
|
||||
|
||||
private final int port;
|
||||
|
||||
/**
|
||||
|
||||
@@ -32,8 +32,7 @@ import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* This class acts as Synchronous Event De-multiplexer and Initiation Dispatcher of Reactor pattern.
|
||||
@@ -50,10 +49,9 @@ import org.slf4j.LoggerFactory;
|
||||
* possible edge cases which are required in a real application. This implementation is meant to
|
||||
* demonstrate the fundamental concepts that lie behind Reactor pattern.
|
||||
*/
|
||||
@Slf4j
|
||||
public class NioReactor {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(NioReactor.class);
|
||||
|
||||
private final Selector selector;
|
||||
private final Dispatcher dispatcher;
|
||||
/**
|
||||
|
||||
@@ -30,17 +30,15 @@ import java.nio.ByteBuffer;
|
||||
import java.nio.channels.SelectionKey;
|
||||
import java.nio.channels.ServerSocketChannel;
|
||||
import java.nio.channels.SocketChannel;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* A wrapper over {@link NioServerSocketChannel} which can read and write data on a {@link
|
||||
* SocketChannel}.
|
||||
*/
|
||||
@Slf4j
|
||||
public class NioServerSocketChannel extends AbstractNioChannel {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(NioServerSocketChannel.class);
|
||||
|
||||
private final int port;
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user