mirror of
https://github.com/klmp200/PQT_Gestionnaire_vente_stock.git
synced 2024-11-22 08:13:20 +00:00
[CLIENT] #6.A : Ajout de logs
This commit is contained in:
parent
d3b5e75896
commit
7f0dc93890
@ -4,9 +4,13 @@ import com.pqt.client.gui.FrameManager;
|
|||||||
import javafx.application.Application;
|
import javafx.application.Application;
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
public class Main extends Application{
|
public class Main extends Application{
|
||||||
|
|
||||||
|
private static Logger LOGGER = LogManager.getLogger(Main.class);
|
||||||
|
|
||||||
public static void main(String[] args){
|
public static void main(String[] args){
|
||||||
launch(args);
|
launch(args);
|
||||||
}
|
}
|
||||||
@ -15,6 +19,7 @@ public class Main extends Application{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start(Stage primaryStage) {
|
public void start(Stage primaryStage) {
|
||||||
|
LOGGER.info("Instanciation de l'application JFX du client");
|
||||||
fm = new FrameManager(primaryStage);
|
fm = new FrameManager(primaryStage);
|
||||||
|
|
||||||
primaryStage.setOnCloseRequest(event-> Platform.exit());
|
primaryStage.setOnCloseRequest(event-> Platform.exit());
|
||||||
@ -24,6 +29,7 @@ public class Main extends Application{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stop(){
|
public void stop(){
|
||||||
|
LOGGER.info("Fermeture de l'application JFX du client");
|
||||||
if(fm!=null)
|
if(fm!=null)
|
||||||
fm.onCloseEvent();
|
fm.onCloseEvent();
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,8 @@ import com.pqt.client.module.query.query_callback.ICollectionItemMessageCallback
|
|||||||
import com.pqt.client.module.query.query_callback.INoItemMessageCallback;
|
import com.pqt.client.module.query.query_callback.INoItemMessageCallback;
|
||||||
import com.pqt.core.entities.user_account.Account;
|
import com.pqt.core.entities.user_account.Account;
|
||||||
import com.pqt.client.module.account.listeners.IAccountListener;
|
import com.pqt.client.module.account.listeners.IAccountListener;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import javax.swing.event.EventListenerList;
|
import javax.swing.event.EventListenerList;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -15,10 +17,10 @@ import java.util.Collection;
|
|||||||
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.CountDownLatch;
|
||||||
|
|
||||||
//TODO écrire javadoc
|
//TODO écrire javadoc
|
||||||
//TODO Issue #6 : add log lines
|
|
||||||
//TODO Issue #17 : supporter la modif de comptes
|
|
||||||
public class AccountService {
|
public class AccountService {
|
||||||
|
|
||||||
|
private static Logger LOGGER = LogManager.getLogger(AccountService.class);
|
||||||
|
|
||||||
private QueryExecutor executor;
|
private QueryExecutor executor;
|
||||||
private Account currentAccount;
|
private Account currentAccount;
|
||||||
private boolean connected;
|
private boolean connected;
|
||||||
@ -26,9 +28,11 @@ public class AccountService {
|
|||||||
private EventListenerList listenerList;
|
private EventListenerList listenerList;
|
||||||
|
|
||||||
public AccountService(QueryExecutor executor){
|
public AccountService(QueryExecutor executor){
|
||||||
|
LOGGER.info("Initialisation du service 'Account'");
|
||||||
this.executor = executor;
|
this.executor = executor;
|
||||||
listenerList = new EventListenerList();
|
listenerList = new EventListenerList();
|
||||||
accounts = new ArrayList<>();
|
accounts = new ArrayList<>();
|
||||||
|
LOGGER.info("Service 'Account' initialisé");
|
||||||
}
|
}
|
||||||
|
|
||||||
public Account getCurrentAccount() {
|
public Account getCurrentAccount() {
|
||||||
@ -65,30 +69,44 @@ public class AccountService {
|
|||||||
&& currentAccount.getUsername().equals(acc.getUsername())
|
&& currentAccount.getUsername().equals(acc.getUsername())
|
||||||
&& currentAccount.getPermissionLevel().equals(acc.getPermissionLevel())) {
|
&& currentAccount.getPermissionLevel().equals(acc.getPermissionLevel())) {
|
||||||
connected = state;
|
connected = state;
|
||||||
Arrays.stream(listenerList.getListeners(IAccountListener.class))
|
fireAccountStatusChangedEvent(connected);
|
||||||
.forEach(l->l.onAccountStatusChangedEvent(connected));
|
|
||||||
}else
|
}else
|
||||||
Arrays.stream(listenerList.getListeners(IAccountListener.class))
|
fireAccountStatusNotChangedEvent(
|
||||||
.forEach(l->l.onAccountStatusNotChangedEvent(
|
|
||||||
new IllegalStateException("Account service not in the right state")
|
new IllegalStateException("Account service not in the right state")
|
||||||
));
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void err(Throwable cause) {
|
public void err(Throwable cause) {
|
||||||
Arrays.stream(listenerList.getListeners(IAccountListener.class))
|
fireAccountStatusNotChangedEvent(cause);
|
||||||
.forEach(l->l.onAccountStatusNotChangedEvent(cause));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void ref(Throwable cause) {
|
public void ref(Throwable cause) {
|
||||||
Arrays.stream(listenerList.getListeners(IAccountListener.class))
|
fireAccountStatusNotChangedEvent(cause);
|
||||||
.forEach(l->l.onAccountStatusNotChangedEvent(cause));
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void fireAccountStatusChangedEvent(boolean connected){
|
||||||
|
LOGGER.info("Etat du compte courant changé à {}", connected);
|
||||||
|
Arrays.stream(listenerList.getListeners(IAccountListener.class))
|
||||||
|
.forEach(l->l.onAccountStatusChangedEvent(connected));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fireAccountStatusNotChangedEvent(Throwable cause){
|
||||||
|
LOGGER.info("Etat du compte courant inchangé : {}", cause);
|
||||||
|
Arrays.stream(listenerList.getListeners(IAccountListener.class))
|
||||||
|
.forEach(l->l.onAccountStatusNotChangedEvent(cause));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fireAccountListChangedEvent(){
|
||||||
|
LOGGER.info("Liste des comptes utilisateurs changée");
|
||||||
|
Arrays.stream(listenerList.getListeners(IAccountListener.class))
|
||||||
|
.forEach(IAccountListener::onAccountListChangedEvent);
|
||||||
|
}
|
||||||
|
|
||||||
public void addListener(IAccountListener listener) {
|
public void addListener(IAccountListener listener) {
|
||||||
listenerList.add(IAccountListener.class, listener);
|
listenerList.add(IAccountListener.class, listener);
|
||||||
}
|
}
|
||||||
@ -116,13 +134,13 @@ public class AccountService {
|
|||||||
@Override
|
@Override
|
||||||
public void ack(Collection<Account> obj) {
|
public void ack(Collection<Account> obj) {
|
||||||
accounts = obj;
|
accounts = obj;
|
||||||
Arrays.stream(listenerList.getListeners(IAccountListener.class))
|
fireAccountListChangedEvent();
|
||||||
.forEach(IAccountListener::onAccountListChangedEvent);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void shutdown() {
|
public void shutdown() {
|
||||||
|
LOGGER.info("Fermeture du service 'Account'");
|
||||||
if(connected) {
|
if(connected) {
|
||||||
try {
|
try {
|
||||||
CountDownLatch latch = new CountDownLatch(1);
|
CountDownLatch latch = new CountDownLatch(1);
|
||||||
@ -130,13 +148,11 @@ public class AccountService {
|
|||||||
this.addListener(new AccountListenerAdapter() {
|
this.addListener(new AccountListenerAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void onAccountStatusChangedEvent(boolean status) {
|
public void onAccountStatusChangedEvent(boolean status) {
|
||||||
//TODO Issue #6 : ajouter des logs
|
|
||||||
latch.countDown();
|
latch.countDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAccountStatusNotChangedEvent(Throwable cause) {
|
public void onAccountStatusNotChangedEvent(Throwable cause) {
|
||||||
//TODO Issue #6 : ajouter des logs
|
|
||||||
cause.printStackTrace();
|
cause.printStackTrace();
|
||||||
latch.countDown();
|
latch.countDown();
|
||||||
}
|
}
|
||||||
@ -145,8 +161,7 @@ public class AccountService {
|
|||||||
}).start();
|
}).start();
|
||||||
latch.await(); // Wait for thread to call latch.countDown()
|
latch.await(); // Wait for thread to call latch.countDown()
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
//TODO Issue #6 : ajouter des logs
|
LOGGER.error("Interruption de la procédure de fermeture du service 'Account' : {}", e);
|
||||||
e.printStackTrace();
|
|
||||||
}finally {
|
}finally {
|
||||||
listenerList = null;
|
listenerList = null;
|
||||||
}
|
}
|
||||||
@ -159,18 +174,15 @@ public class AccountService {
|
|||||||
executor.executeAccountUpdateQuery(builder.build(), new INoItemMessageCallback() {
|
executor.executeAccountUpdateQuery(builder.build(), new INoItemMessageCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void ack() {
|
public void ack() {
|
||||||
//TODO Issue #6 : add log line
|
|
||||||
refreshAccounts();
|
refreshAccounts();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void err(Throwable cause) {
|
public void err(Throwable cause) {
|
||||||
//TODO Issue #6 : add log line
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void ref(Throwable cause) {
|
public void ref(Throwable cause) {
|
||||||
//TODO Issue #6 : add log line
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -3,21 +3,27 @@ package com.pqt.client.module.connection;
|
|||||||
import com.pqt.client.module.connection.listeners.IConnectionListener;
|
import com.pqt.client.module.connection.listeners.IConnectionListener;
|
||||||
import com.pqt.client.module.connection.senders.HttpTextSender;
|
import com.pqt.client.module.connection.senders.HttpTextSender;
|
||||||
import com.pqt.client.module.connection.senders.ITextSender;
|
import com.pqt.client.module.connection.senders.ITextSender;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import java.util.concurrent.*;
|
import java.util.concurrent.*;
|
||||||
|
|
||||||
//TODO Issue #5 : écrire javadoc
|
//TODO Issue #5 : écrire javadoc
|
||||||
public class ConnectionService {
|
public class ConnectionService {
|
||||||
|
|
||||||
|
private static Logger LOGGER = LogManager.getLogger(ConnectionService.class);
|
||||||
|
|
||||||
private String serverUrl;
|
private String serverUrl;
|
||||||
private ExecutorService executor;
|
private ExecutorService executor;
|
||||||
private ITextSender textSender;
|
private ITextSender textSender;
|
||||||
|
|
||||||
public ConnectionService(String serverUrl) {
|
public ConnectionService(String serverUrl) {
|
||||||
|
LOGGER.info("Initialisation du service 'Connection'");
|
||||||
executor = new ThreadPoolExecutor(1, 1, 1000,
|
executor = new ThreadPoolExecutor(1, 1, 1000,
|
||||||
TimeUnit.SECONDS, new LinkedBlockingQueue<>());
|
TimeUnit.SECONDS, new LinkedBlockingQueue<>());
|
||||||
this.serverUrl = serverUrl;
|
this.serverUrl = serverUrl;
|
||||||
this.textSender = new HttpTextSender();
|
this.textSender = new HttpTextSender();
|
||||||
|
LOGGER.info("Service 'Connection' initialisé");
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getServerUrl() {
|
public String getServerUrl() {
|
||||||
@ -25,6 +31,7 @@ public class ConnectionService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setServerUrl(String url){
|
public void setServerUrl(String url){
|
||||||
|
LOGGER.info("L'url du serveur est : {}", url);
|
||||||
this.serverUrl = url;
|
this.serverUrl = url;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,6 +72,7 @@ public class ConnectionService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void shutdown() {
|
public void shutdown() {
|
||||||
|
LOGGER.info("Fermeture du service 'Connection'");
|
||||||
stop(false);
|
stop(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package com.pqt.client.module.connection.senders;
|
package com.pqt.client.module.connection.senders;
|
||||||
|
|
||||||
import com.pqt.client.module.connection.listeners.IConnectionListener;
|
import com.pqt.client.module.connection.listeners.IConnectionListener;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.net.ConnectException;
|
import java.net.ConnectException;
|
||||||
@ -9,10 +11,13 @@ import java.net.URL;
|
|||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
|
|
||||||
public class HttpTextSender implements ITextSender{
|
public class HttpTextSender implements ITextSender{
|
||||||
|
private static Logger LOGGER = LogManager.getLogger(HttpTextSender.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void send(String host, String text, IConnectionListener listener) {
|
public void send(String host, String text, IConnectionListener listener) {
|
||||||
try {
|
try {
|
||||||
String trueURL = String.format("http://%s?%s", host, format(text));
|
String trueURL = String.format("http://%s?%s", host, format(text));
|
||||||
|
LOGGER.trace("Envoi de la requête HTTP : {}", trueURL);
|
||||||
|
|
||||||
HttpURLConnection con = (HttpURLConnection) new URL(trueURL).openConnection();
|
HttpURLConnection con = (HttpURLConnection) new URL(trueURL).openConnection();
|
||||||
con.setRequestMethod("GET");
|
con.setRequestMethod("GET");
|
||||||
@ -23,6 +28,7 @@ public class HttpTextSender implements ITextSender{
|
|||||||
|
|
||||||
con.setDoOutput(true);
|
con.setDoOutput(true);
|
||||||
con.connect();
|
con.connect();
|
||||||
|
LOGGER.trace("Connexion du HTTPTextSender");
|
||||||
listener.onConnectedEvent();
|
listener.onConnectedEvent();
|
||||||
|
|
||||||
try(BufferedReader in = new BufferedReader(
|
try(BufferedReader in = new BufferedReader(
|
||||||
@ -32,28 +38,28 @@ public class HttpTextSender implements ITextSender{
|
|||||||
while ((inputLine = in.readLine()) != null) {
|
while ((inputLine = in.readLine()) != null) {
|
||||||
content.append(inputLine);
|
content.append(inputLine);
|
||||||
}
|
}
|
||||||
|
LOGGER.trace("réception de la réponse : {}", content.toString());
|
||||||
listener.onMessageReceivedEvent(content.toString());
|
listener.onMessageReceivedEvent(content.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
con.disconnect();
|
con.disconnect();
|
||||||
}catch (Exception e) {
|
}catch (Exception e) {
|
||||||
//TODO Issue #6 : ajouter un log ici
|
LOGGER.error("Erreur durant l'envoi d'un message via HTTP vers le serveur : {}", e);
|
||||||
e.printStackTrace();
|
|
||||||
listener.onConnexionError(e);
|
listener.onConnexionError(e);
|
||||||
}finally {
|
}finally {
|
||||||
|
LOGGER.trace("Déconnexion du HTTPTextSender");
|
||||||
listener.onDisconnectedEvent();
|
listener.onDisconnectedEvent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Méthode à modifier pour encoder le message suivant un algorithme spécifique
|
// Méthode à modifier pour encoder le message suivant un algorithme spécifique
|
||||||
private String format(String toFormat){
|
private String format(String toFormat){
|
||||||
try {
|
|
||||||
String encodeTo = "UTF-8";
|
String encodeTo = "UTF-8";
|
||||||
|
try {
|
||||||
return String.format("format=%s&message=%s", encodeTo, URLEncoder.encode(toFormat, encodeTo));
|
return String.format("format=%s&message=%s", encodeTo, URLEncoder.encode(toFormat, encodeTo));
|
||||||
}catch(UnsupportedEncodingException e){
|
}catch(UnsupportedEncodingException e){
|
||||||
//TODO Issue #6 : ajouter un log ici
|
LOGGER.error("Erreur d'encodage du texte à envoyer vers format {} : {}", encodeTo, e);
|
||||||
e.printStackTrace();
|
LOGGER.error("Utilisation de la chaine non-formatée");
|
||||||
}
|
}
|
||||||
return String.format("message=%s", toFormat);
|
return String.format("message=%s", toFormat);
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,8 @@ import com.pqt.client.module.query.query_callback.IMapItemMessageCallback;
|
|||||||
import com.pqt.client.module.query.query_callback.INoItemMessageCallback;
|
import com.pqt.client.module.query.query_callback.INoItemMessageCallback;
|
||||||
import com.pqt.core.entities.server_config.ConfigFields;
|
import com.pqt.core.entities.server_config.ConfigFields;
|
||||||
import com.pqt.core.entities.server_config.ServerConfig;
|
import com.pqt.core.entities.server_config.ServerConfig;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import javax.swing.event.EventListenerList;
|
import javax.swing.event.EventListenerList;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@ -18,16 +20,20 @@ import java.util.*;
|
|||||||
*/
|
*/
|
||||||
public class NetworkService {
|
public class NetworkService {
|
||||||
|
|
||||||
|
private static Logger LOGGER = LogManager.getLogger(NetworkService.class);
|
||||||
|
|
||||||
private final QueryExecutor queryExecutor;
|
private final QueryExecutor queryExecutor;
|
||||||
private final ConnectionService connectionService;
|
private final ConnectionService connectionService;
|
||||||
private final EventListenerList listenerList;
|
private final EventListenerList listenerList;
|
||||||
private final ServerConfigCache configCache;
|
private final ServerConfigCache configCache;
|
||||||
|
|
||||||
public NetworkService(QueryExecutor queryExecutor, ConnectionService connectionService) {
|
public NetworkService(QueryExecutor queryExecutor, ConnectionService connectionService) {
|
||||||
|
LOGGER.info("Initialisation du service 'Network'");
|
||||||
this.queryExecutor = queryExecutor;
|
this.queryExecutor = queryExecutor;
|
||||||
this.connectionService = connectionService;
|
this.connectionService = connectionService;
|
||||||
listenerList = new EventListenerList();
|
listenerList = new EventListenerList();
|
||||||
configCache = new ServerConfigCache();
|
configCache = new ServerConfigCache();
|
||||||
|
LOGGER.info("Service 'Network' initialisé");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addListener(INetworkServiceListener l){
|
public void addListener(INetworkServiceListener l){
|
||||||
@ -40,9 +46,11 @@ public class NetworkService {
|
|||||||
|
|
||||||
public void sendPQTPing(String host, Integer port){
|
public void sendPQTPing(String host, Integer port){
|
||||||
checkData(host, port);
|
checkData(host, port);
|
||||||
|
LOGGER.trace("Envoi d'un ping");
|
||||||
queryExecutor.executePingQuery(new INoItemMessageCallback() {
|
queryExecutor.executePingQuery(new INoItemMessageCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void ack() {
|
public void ack() {
|
||||||
|
LOGGER.trace("Réponse au ping -> ACK");
|
||||||
Arrays.stream(listenerList.getListeners(INetworkServiceListener.class))
|
Arrays.stream(listenerList.getListeners(INetworkServiceListener.class))
|
||||||
.forEach(l->l.onPQTPingSuccessEvent(host, port));
|
.forEach(l->l.onPQTPingSuccessEvent(host, port));
|
||||||
sendConfigRequest(host, port);
|
sendConfigRequest(host, port);
|
||||||
@ -50,12 +58,14 @@ public class NetworkService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void err(Throwable cause) {
|
public void err(Throwable cause) {
|
||||||
|
LOGGER.trace("Réponse au ping -> ERR");
|
||||||
Arrays.stream(listenerList.getListeners(INetworkServiceListener.class))
|
Arrays.stream(listenerList.getListeners(INetworkServiceListener.class))
|
||||||
.forEach(l->l.onPQTPingFailureEvent(host, port, cause));
|
.forEach(l->l.onPQTPingFailureEvent(host, port, cause));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void ref(Throwable cause) {
|
public void ref(Throwable cause) {
|
||||||
|
LOGGER.trace("Réponse au ping -> REF");
|
||||||
Arrays.stream(listenerList.getListeners(INetworkServiceListener.class))
|
Arrays.stream(listenerList.getListeners(INetworkServiceListener.class))
|
||||||
.forEach(l->l.onPQTPingFailureEvent(host, port, cause));
|
.forEach(l->l.onPQTPingFailureEvent(host, port, cause));
|
||||||
}
|
}
|
||||||
@ -79,20 +89,22 @@ public class NetworkService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void sendConfigRequest(String host, Integer port){
|
private void sendConfigRequest(String host, Integer port){
|
||||||
|
LOGGER.trace("Envoi d'une demande de configuration serveur");
|
||||||
queryExecutor.executeConfigListQuery(new IMapItemMessageCallback<String, String>(){
|
queryExecutor.executeConfigListQuery(new IMapItemMessageCallback<String, String>(){
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void err(Throwable cause) {
|
public void err(Throwable cause) {
|
||||||
//TODO Issue #6 : ajouter log erreur
|
LOGGER.error("Erreur lors de la demande de configurations serveur : {}", cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void ref(Throwable cause) {
|
public void ref(Throwable cause) {
|
||||||
//TODO Issue #6 : ajouter log erreur
|
LOGGER.error("Demande de configurations serveur refusée : {}", cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void ack(Map<String, String> obj) {
|
public void ack(Map<String, String> obj) {
|
||||||
|
LOGGER.trace("Demande de configuration serveur acceptée");
|
||||||
configCache.addServerConfig(host, port, convertToServerConfig(obj));
|
configCache.addServerConfig(host, port, convertToServerConfig(obj));
|
||||||
Arrays.stream(listenerList.getListeners(INetworkServiceListener.class))
|
Arrays.stream(listenerList.getListeners(INetworkServiceListener.class))
|
||||||
.forEach(INetworkServiceListener::onNewServerConfigData);
|
.forEach(INetworkServiceListener::onNewServerConfigData);
|
||||||
@ -141,6 +153,7 @@ public class NetworkService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void shutdown() {
|
public void shutdown() {
|
||||||
|
LOGGER.info("Fermeture du service 'Network'");
|
||||||
//Nothing to do
|
//Nothing to do
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,20 +15,26 @@ import com.pqt.core.entities.product.ProductUpdate;
|
|||||||
import com.pqt.core.entities.sale.LightweightSale;
|
import com.pqt.core.entities.sale.LightweightSale;
|
||||||
import com.pqt.core.entities.user_account.Account;
|
import com.pqt.core.entities.user_account.Account;
|
||||||
import com.pqt.core.entities.user_account.AccountUpdate;
|
import com.pqt.core.entities.user_account.AccountUpdate;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
//TODO Issue #5 : écrire javadoc
|
//TODO Issue #5 : écrire javadoc
|
||||||
public class QueryExecutor {
|
public class QueryExecutor {
|
||||||
|
|
||||||
|
private static Logger LOGGER = LogManager.getLogger(QueryExecutor.class);
|
||||||
|
|
||||||
private IMessageToolFactory messageToolFactory;
|
private IMessageToolFactory messageToolFactory;
|
||||||
private ConnectionService connectionService;
|
private ConnectionService connectionService;
|
||||||
private QueryMessageFactory messageFactory;
|
private QueryMessageFactory messageFactory;
|
||||||
|
|
||||||
public QueryExecutor(ConnectionService connectionService){
|
public QueryExecutor(ConnectionService connectionService){
|
||||||
|
LOGGER.info("Initialisation du QueryExecutor");
|
||||||
messageToolFactory = new GSonMessageToolFactory();
|
messageToolFactory = new GSonMessageToolFactory();
|
||||||
this.connectionService = connectionService;
|
this.connectionService = connectionService;
|
||||||
this.messageFactory = new QueryMessageFactory(messageToolFactory);
|
this.messageFactory = new QueryMessageFactory(messageToolFactory);
|
||||||
|
LOGGER.info("QueryExecutor initialisé");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAccountService(AccountService accountService){
|
public void setAccountService(AccountService accountService){
|
||||||
@ -56,9 +62,11 @@ public class QueryExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void sendMessage(Message message, INoItemMessageCallback callback, MessageType responseType){
|
private void sendMessage(Message message, INoItemMessageCallback callback, MessageType responseType){
|
||||||
|
LOGGER.debug("Envoi d'un message de type '{}' en mode no-item", message.getType().name());
|
||||||
connectionService.sendText(messageToolFactory.getObjectFormatter(Message.class).format(message), new IConnectionListener() {
|
connectionService.sendText(messageToolFactory.getObjectFormatter(Message.class).format(message), new IConnectionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onMessageReceivedEvent(String msg) {
|
public void onMessageReceivedEvent(String msg) {
|
||||||
|
LOGGER.trace("Réception d'une réponse : {}",msg);
|
||||||
Message response = messageToolFactory.getObjectParser(Message.class).parse(msg);
|
Message response = messageToolFactory.getObjectParser(Message.class).parse(msg);
|
||||||
if(response.getType().equals(responseType))
|
if(response.getType().equals(responseType))
|
||||||
callback.ack();
|
callback.ack();
|
||||||
@ -68,21 +76,23 @@ public class QueryExecutor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConnectedEvent() {
|
public void onConnectedEvent() {
|
||||||
|
LOGGER.trace("Connexion au serveur");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisconnectedEvent() {
|
public void onDisconnectedEvent() {
|
||||||
|
LOGGER.trace("Déconnexion au serveur");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTimeOutEvent() {
|
public void onTimeOutEvent() {
|
||||||
|
LOGGER.trace("Timeout du server");
|
||||||
callback.err(new MessageTimeoutException());
|
callback.err(new MessageTimeoutException());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConnexionError(Throwable e) {
|
public void onConnexionError(Throwable e) {
|
||||||
|
LOGGER.warn("Erreur durant l'envoi d'un message : {}", e);
|
||||||
callback.err(e);
|
callback.err(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -97,9 +107,11 @@ public class QueryExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private <T> void sendMessage(Message message, ICollectionItemMessageCallback<T> callback, Class<T> clazz, MessageType responseType, String itemHeader){
|
private <T> void sendMessage(Message message, ICollectionItemMessageCallback<T> callback, Class<T> clazz, MessageType responseType, String itemHeader){
|
||||||
|
LOGGER.debug("Envoi d'un message de type '{}' en mode collection-item", message.getType().name());
|
||||||
connectionService.sendText(messageToolFactory.getObjectFormatter(Message.class).format(message), new IConnectionListener() {
|
connectionService.sendText(messageToolFactory.getObjectFormatter(Message.class).format(message), new IConnectionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onMessageReceivedEvent(String msg) {
|
public void onMessageReceivedEvent(String msg) {
|
||||||
|
LOGGER.trace("Réception d'une réponse : {}",msg);
|
||||||
Message response = messageToolFactory.getObjectParser(Message.class).parse(msg);
|
Message response = messageToolFactory.getObjectParser(Message.class).parse(msg);
|
||||||
if(response.getType().equals(responseType)) {
|
if(response.getType().equals(responseType)) {
|
||||||
String item = response.getField(itemHeader);
|
String item = response.getField(itemHeader);
|
||||||
@ -114,21 +126,23 @@ public class QueryExecutor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConnectedEvent() {
|
public void onConnectedEvent() {
|
||||||
|
LOGGER.trace("Connexion au serveur");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisconnectedEvent() {
|
public void onDisconnectedEvent() {
|
||||||
|
LOGGER.trace("Déconnexion au serveur");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTimeOutEvent() {
|
public void onTimeOutEvent() {
|
||||||
|
LOGGER.trace("Timeout du server");
|
||||||
callback.err(new MessageTimeoutException());
|
callback.err(new MessageTimeoutException());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConnexionError(Throwable e) {
|
public void onConnexionError(Throwable e) {
|
||||||
|
LOGGER.warn("Erreur durant l'envoi d'un message : {}", e);
|
||||||
callback.err(e);
|
callback.err(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -144,9 +158,11 @@ public class QueryExecutor {
|
|||||||
|
|
||||||
//TODO à rendre générique pour toute Map<T, U> au lieu de Map<String, String>
|
//TODO à rendre générique pour toute Map<T, U> au lieu de Map<String, String>
|
||||||
private void sendMessage(Message message, IMapItemMessageCallback<String, String> callback, MessageType responseType){
|
private void sendMessage(Message message, IMapItemMessageCallback<String, String> callback, MessageType responseType){
|
||||||
|
LOGGER.debug("Envoi d'un message de type '{}' en mode map-item", message.getType().name());
|
||||||
connectionService.sendText(messageToolFactory.getObjectFormatter(Message.class).format(message), new IConnectionListener() {
|
connectionService.sendText(messageToolFactory.getObjectFormatter(Message.class).format(message), new IConnectionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onMessageReceivedEvent(String msg) {
|
public void onMessageReceivedEvent(String msg) {
|
||||||
|
LOGGER.trace("Réception d'une réponse : {}",msg);
|
||||||
Message response = messageToolFactory.getObjectParser(Message.class).parse(msg);
|
Message response = messageToolFactory.getObjectParser(Message.class).parse(msg);
|
||||||
if(response.getType().equals(responseType)){
|
if(response.getType().equals(responseType)){
|
||||||
callback.ack(response.getFields());
|
callback.ack(response.getFields());
|
||||||
@ -156,21 +172,23 @@ public class QueryExecutor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConnectedEvent() {
|
public void onConnectedEvent() {
|
||||||
|
LOGGER.trace("Connexion au serveur");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisconnectedEvent() {
|
public void onDisconnectedEvent() {
|
||||||
|
LOGGER.trace("Déconnexion au serveur");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTimeOutEvent() {
|
public void onTimeOutEvent() {
|
||||||
|
LOGGER.trace("Timeout du server");
|
||||||
callback.err(new MessageTimeoutException());
|
callback.err(new MessageTimeoutException());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConnexionError(Throwable e) {
|
public void onConnexionError(Throwable e) {
|
||||||
|
LOGGER.warn("Erreur durant l'envoi d'un message : {}", e);
|
||||||
callback.err(e);
|
callback.err(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -204,6 +222,7 @@ public class QueryExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void shutdown() {
|
public void shutdown() {
|
||||||
|
LOGGER.info("Fermeture du QueryExecutor");
|
||||||
//Nothing to do
|
//Nothing to do
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,21 +6,26 @@ import com.pqt.client.module.sale.listeners.ISaleFirerer;
|
|||||||
import com.pqt.client.module.sale.listeners.ISaleListener;
|
import com.pqt.client.module.sale.listeners.ISaleListener;
|
||||||
import com.pqt.client.module.sale.listeners.SimpleSaleFirerer;
|
import com.pqt.client.module.sale.listeners.SimpleSaleFirerer;
|
||||||
import com.pqt.core.entities.sale.SaleType;
|
import com.pqt.core.entities.sale.SaleType;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
//TODO Issue #5 : écrire javadoc
|
//TODO Issue #5 : écrire javadoc
|
||||||
//TODO Issue #6 : add log lines
|
|
||||||
public class SaleService {
|
public class SaleService {
|
||||||
|
|
||||||
|
private static Logger LOGGER = LogManager.getLogger(SaleService.class);
|
||||||
|
|
||||||
private long saleId;
|
private long saleId;
|
||||||
private ISaleFirerer eventFirerer;
|
private ISaleFirerer eventFirerer;
|
||||||
private QueryExecutor executor;
|
private QueryExecutor executor;
|
||||||
|
|
||||||
public SaleService(QueryExecutor executor) {
|
public SaleService(QueryExecutor executor) {
|
||||||
|
LOGGER.info("Initialisation du service 'Sale'");
|
||||||
saleId = 0;
|
saleId = 0;
|
||||||
eventFirerer = new SimpleSaleFirerer();
|
eventFirerer = new SimpleSaleFirerer();
|
||||||
this.executor = executor;
|
this.executor = executor;
|
||||||
|
LOGGER.info("Service 'Sale' initialisé");
|
||||||
}
|
}
|
||||||
|
|
||||||
public SaleBuilder getNewSaleBuilder() {
|
public SaleBuilder getNewSaleBuilder() {
|
||||||
@ -34,19 +39,23 @@ public class SaleService {
|
|||||||
else
|
else
|
||||||
saleId = 0;
|
saleId = 0;
|
||||||
|
|
||||||
|
LOGGER.debug("Soumission de la commande numéro {}", saleId);
|
||||||
executor.executeSaleQuery(saleBuilder.buildLightweight(), new INoItemMessageCallback() {
|
executor.executeSaleQuery(saleBuilder.buildLightweight(), new INoItemMessageCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void ack() {
|
public void ack() {
|
||||||
|
LOGGER.debug("Commande {} acceptée", saleId);
|
||||||
eventFirerer.fireSaleValidationSuccess(currentSaleId);
|
eventFirerer.fireSaleValidationSuccess(currentSaleId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void err(Throwable cause) {
|
public void err(Throwable cause) {
|
||||||
|
LOGGER.debug("Erreur durant la soumission de la commande {} : {}", saleId, cause.getMessage());
|
||||||
eventFirerer.fireSaleValidationError(currentSaleId, cause);
|
eventFirerer.fireSaleValidationError(currentSaleId, cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void ref(Throwable cause) {
|
public void ref(Throwable cause) {
|
||||||
|
LOGGER.debug("Commande {} refusée : {}", saleId, cause.getMessage());
|
||||||
eventFirerer.fireSaleValidationRefused(currentSaleId, cause);
|
eventFirerer.fireSaleValidationRefused(currentSaleId, cause);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -80,6 +89,7 @@ public class SaleService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void shutdown() {
|
public void shutdown() {
|
||||||
|
LOGGER.info("Fermeture du service 'Sale'");
|
||||||
//Nothing to do
|
//Nothing to do
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,12 +5,16 @@ import com.pqt.client.module.query.query_callback.IMapItemMessageCallback;
|
|||||||
import com.pqt.client.module.stat.listeners.IStatFirerer;
|
import com.pqt.client.module.stat.listeners.IStatFirerer;
|
||||||
import com.pqt.client.module.stat.listeners.IStatListener;
|
import com.pqt.client.module.stat.listeners.IStatListener;
|
||||||
import com.pqt.client.module.stat.listeners.SimpleStatFirerer;
|
import com.pqt.client.module.stat.listeners.SimpleStatFirerer;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
//TODO Issue #5 : écrire javadoc
|
//TODO Issue #5 : écrire javadoc
|
||||||
public class StatDao {
|
public class StatDao {
|
||||||
|
|
||||||
|
private static Logger LOGGER = LogManager.getLogger(StatDao.class);
|
||||||
|
|
||||||
private Date lastRefreshTimestamp;
|
private Date lastRefreshTimestamp;
|
||||||
private Map<String, String> stats;
|
private Map<String, String> stats;
|
||||||
private IStatFirerer eventFirerer;
|
private IStatFirerer eventFirerer;
|
||||||
@ -28,24 +32,25 @@ public class StatDao {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void refreshStats() {
|
public void refreshStats() {
|
||||||
|
LOGGER.trace("Mise à jour des statistiques");
|
||||||
executor.executeStatQuery(new IMapItemMessageCallback<String, String>() {
|
executor.executeStatQuery(new IMapItemMessageCallback<String, String>() {
|
||||||
@Override
|
@Override
|
||||||
public void err(Throwable cause) {
|
public void err(Throwable cause) {
|
||||||
eventFirerer.fireGetStatError(cause);
|
eventFirerer.fireGetStatError(cause);
|
||||||
//TODO Issue #6 : add log line
|
LOGGER.trace("Erreur de mise à jour des statistiques : {}", cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void ref(Throwable cause) {
|
public void ref(Throwable cause) {
|
||||||
eventFirerer.fireGetStatRefused(cause);
|
eventFirerer.fireGetStatRefused(cause);
|
||||||
//TODO Issue #6 : add log line
|
LOGGER.trace("Mise à jour des statistiques refusée : {}", cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void ack(Map<String, String> stats) {
|
public void ack(Map<String, String> stats) {
|
||||||
replaceStats(stats);
|
replaceStats(stats);
|
||||||
eventFirerer.fireGetStatSuccess();
|
eventFirerer.fireGetStatSuccess();
|
||||||
//TODO Issue #6 : add log line
|
LOGGER.trace("Mise à jour des statistiques finie");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -2,17 +2,22 @@ package com.pqt.client.module.stat;
|
|||||||
|
|
||||||
import com.pqt.client.module.query.QueryExecutor;
|
import com.pqt.client.module.query.QueryExecutor;
|
||||||
import com.pqt.client.module.stat.listeners.IStatListener;
|
import com.pqt.client.module.stat.listeners.IStatListener;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
//TODO Issue #5 : écrire javadoc
|
//TODO Issue #5 : écrire javadoc
|
||||||
//TODO Issue #6 : add log lines
|
|
||||||
public class StatService {
|
public class StatService {
|
||||||
|
|
||||||
|
private static Logger LOGGER = LogManager.getLogger(StatService.class);
|
||||||
|
|
||||||
private StatDao dao;
|
private StatDao dao;
|
||||||
|
|
||||||
public StatService(QueryExecutor executor) {
|
public StatService(QueryExecutor executor) {
|
||||||
|
LOGGER.info("Initialisation du service 'Stat'");
|
||||||
dao = new StatDao(executor);
|
dao = new StatDao(executor);
|
||||||
|
LOGGER.info("Service 'Stat' initialisé");
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String,String> getStats() {
|
public Map<String,String> getStats() {
|
||||||
@ -32,6 +37,7 @@ public class StatService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void shutdown() {
|
public void shutdown() {
|
||||||
|
LOGGER.info("Fermeture du service 'Stat'");
|
||||||
//Nothing to do
|
//Nothing to do
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,8 @@ import com.pqt.client.module.stock.Listeners.IStockListener;
|
|||||||
import com.pqt.client.module.stock.Listeners.SimpleStockFirerer;
|
import com.pqt.client.module.stock.Listeners.SimpleStockFirerer;
|
||||||
import com.pqt.core.entities.product.Product;
|
import com.pqt.core.entities.product.Product;
|
||||||
import com.pqt.core.entities.product.ProductUpdate;
|
import com.pqt.core.entities.product.ProductUpdate;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -17,6 +19,8 @@ import java.util.List;
|
|||||||
//TODO Issue #5 : écrire javadoc
|
//TODO Issue #5 : écrire javadoc
|
||||||
public class StockDao {
|
public class StockDao {
|
||||||
|
|
||||||
|
private static Logger LOGGER = LogManager.getLogger(StockDao.class);
|
||||||
|
|
||||||
private long updateId;
|
private long updateId;
|
||||||
private IStockFirerer eventFirerer;
|
private IStockFirerer eventFirerer;
|
||||||
private Date lastRefreshTimestamp;
|
private Date lastRefreshTimestamp;
|
||||||
@ -40,23 +44,24 @@ public class StockDao {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void refreshProductList() {
|
public void refreshProductList() {
|
||||||
|
LOGGER.trace("Demande de mise à jour du stock");
|
||||||
executor.executeStockQuery(new ICollectionItemMessageCallback<Product>() {
|
executor.executeStockQuery(new ICollectionItemMessageCallback<Product>() {
|
||||||
@Override
|
@Override
|
||||||
public void ack(Collection<Product> obj) {
|
public void ack(Collection<Product> obj) {
|
||||||
replaceProductList(obj);
|
replaceProductList(obj);
|
||||||
eventFirerer.fireGetProductListSuccessEvent();
|
eventFirerer.fireGetProductListSuccessEvent();
|
||||||
//TODO Issue #6 : add log line
|
LOGGER.trace("Mise à jour du stock");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void err(Throwable cause) {
|
public void err(Throwable cause) {
|
||||||
//TODO Issue #6 : add log line
|
LOGGER.trace("Demande de mise à jour du stock");
|
||||||
eventFirerer.fireGetProductListErrorEvent(cause);
|
eventFirerer.fireGetProductListErrorEvent(cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void ref(Throwable cause) {
|
public void ref(Throwable cause) {
|
||||||
//TODO Issue #6 : add log line
|
LOGGER.trace("Demande de mise à jour du stock refusée : {}", cause);
|
||||||
eventFirerer.fireGetProductListRefusedEvent(cause);
|
eventFirerer.fireGetProductListRefusedEvent(cause);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -79,23 +84,24 @@ public class StockDao {
|
|||||||
updateId++;
|
updateId++;
|
||||||
else
|
else
|
||||||
updateId = 0;
|
updateId = 0;
|
||||||
|
LOGGER.trace("Demande de modification du stock : modification numéro {}", updateId);
|
||||||
executor.executeStockUpdateQuery(updates, new INoItemMessageCallback() {
|
executor.executeStockUpdateQuery(updates, new INoItemMessageCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void ack() {
|
public void ack() {
|
||||||
//TODO Issue #6 : add log line
|
LOGGER.trace("Modification du stock numéro {} acceptée", updateId);
|
||||||
refreshProductList();
|
refreshProductList();
|
||||||
eventFirerer.fireProductListUpdateSuccessEvent(currentUpdateId);
|
eventFirerer.fireProductListUpdateSuccessEvent(currentUpdateId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void err(Throwable cause) {
|
public void err(Throwable cause) {
|
||||||
//TODO Issue #6 : add log line
|
LOGGER.trace("Erreur durant la modification du stock numéro {} : {}", updateId, cause.getMessage());
|
||||||
eventFirerer.fireProductListUpdateErrorEvent(currentUpdateId, cause);
|
eventFirerer.fireProductListUpdateErrorEvent(currentUpdateId, cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void ref(Throwable cause) {
|
public void ref(Throwable cause) {
|
||||||
//TODO Issue #6 : add log line
|
LOGGER.trace("Modification du stock numéro {} refusée : {}", updateId, cause.getMessage());
|
||||||
eventFirerer.fireProductListUpdateRefusedEvent(currentUpdateId, cause);
|
eventFirerer.fireProductListUpdateRefusedEvent(currentUpdateId, cause);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -3,17 +3,22 @@ package com.pqt.client.module.stock;
|
|||||||
import com.pqt.client.module.query.QueryExecutor;
|
import com.pqt.client.module.query.QueryExecutor;
|
||||||
import com.pqt.core.entities.product.Product;
|
import com.pqt.core.entities.product.Product;
|
||||||
import com.pqt.client.module.stock.Listeners.IStockListener;
|
import com.pqt.client.module.stock.Listeners.IStockListener;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
//TODO Issue #6 : Add log lines
|
|
||||||
public class StockService {
|
public class StockService {
|
||||||
|
|
||||||
|
private static Logger LOGGER = LogManager.getLogger(StockService.class);
|
||||||
|
|
||||||
private StockDao dao;
|
private StockDao dao;
|
||||||
|
|
||||||
public StockService(QueryExecutor executor) {
|
public StockService(QueryExecutor executor) {
|
||||||
|
LOGGER.info("Initialisation du service 'Stock'");
|
||||||
dao = new StockDao(executor);
|
dao = new StockDao(executor);
|
||||||
|
LOGGER.info("Service 'Stock' initialisé");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -131,6 +136,7 @@ public class StockService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void shutdown() {
|
public void shutdown() {
|
||||||
|
LOGGER.info("Fermeture du service 'Stock'");
|
||||||
//Nothing to do
|
//Nothing to do
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user