mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-16 08:58:49 +00:00
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:
@@ -29,12 +29,11 @@ package com.iluwatar.client.session;
|
||||
* The Client-Session pattern allows the session data to be stored on the client side and send this
|
||||
* data to the server with each request.
|
||||
*
|
||||
* <p> In this example, The {@link Server} class represents the server that would process the
|
||||
* <p>In this example, The {@link Server} class represents the server that would process the
|
||||
* incoming {@link Request} and also assign {@link Session} to a client. Here one instance of Server
|
||||
* is created. The we create two sessions for two different clients. These sessions are then passed
|
||||
* on to the server in the request along with the data. The server is then able to interpret the
|
||||
* client based on the session associated with it.
|
||||
* </p>
|
||||
*/
|
||||
public class App {
|
||||
|
||||
|
||||
@@ -28,9 +28,7 @@ package com.iluwatar.client.session;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* The Request class which contains the Session details and data.
|
||||
*/
|
||||
/** The Request class which contains the Session details and data. */
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class Request {
|
||||
@@ -38,5 +36,4 @@ public class Request {
|
||||
private String data;
|
||||
|
||||
private Session session;
|
||||
|
||||
}
|
||||
|
||||
@@ -31,7 +31,8 @@ import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* The Server class. The client communicates with the server and request processing and getting a new session.
|
||||
* The Server class. The client communicates with the server and request processing and getting a
|
||||
* new session.
|
||||
*/
|
||||
@Slf4j
|
||||
@Data
|
||||
@@ -41,12 +42,10 @@ public class Server {
|
||||
|
||||
private int port;
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new session.
|
||||
*
|
||||
* @param name name of the client
|
||||
*
|
||||
* @return Session Object
|
||||
*/
|
||||
public Session getSession(String name) {
|
||||
@@ -59,7 +58,10 @@ public class Server {
|
||||
* @param request Request object with data and Session
|
||||
*/
|
||||
public void process(Request request) {
|
||||
LOGGER.info("Processing Request with client: " + request.getSession().getClientName() + " data: " + request.getData());
|
||||
LOGGER.info(
|
||||
"Processing Request with client: "
|
||||
+ request.getSession().getClientName()
|
||||
+ " data: "
|
||||
+ request.getData());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -29,20 +29,16 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* The Session class. Each client get assigned a Session which is then used for further communications.
|
||||
* The Session class. Each client get assigned a Session which is then used for further
|
||||
* communications.
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class Session {
|
||||
|
||||
/**
|
||||
* Session id.
|
||||
*/
|
||||
/** Session id. */
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* Client name.
|
||||
*/
|
||||
/** Client name. */
|
||||
private String clientName;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user