diff --git a/app/src/main/java/lightcontainer/App.java b/app/src/main/java/lightcontainer/App.java index d5111fa..3aae4e2 100644 --- a/app/src/main/java/lightcontainer/App.java +++ b/app/src/main/java/lightcontainer/App.java @@ -30,15 +30,13 @@ public class App { protocolRep.addReader(new HelloRule()); new UnicastServerListener(clientRep, UNICAST_PORT); - MulticastServerListener multiCast = new MulticastServerListener(storeRep, protocolRep, MULTICAST_IP, MULTICAST_PORT); - multiCast.run(); + new MulticastServerListener(storeRep, protocolRep, MULTICAST_IP, MULTICAST_PORT); FileFrontEnd ffe = new FileFrontEnd(clientRep, storeRep); // close repo et client et server. Thread.sleep(60000); - multiCast.stop(); clientRep.close(); storeRep.close(); } diff --git a/app/src/main/java/lightcontainer/domains/client/ClientHandler.java b/app/src/main/java/lightcontainer/domains/client/ClientHandler.java index 9dc6100..53f7ba0 100644 --- a/app/src/main/java/lightcontainer/domains/client/ClientHandler.java +++ b/app/src/main/java/lightcontainer/domains/client/ClientHandler.java @@ -5,6 +5,7 @@ import lightcontainer.interfaces.ClientHandlerFFE; import java.io.*; import java.net.Socket; import java.nio.charset.StandardCharsets; +import java.util.Objects; /** * ClientHandler diff --git a/app/src/main/java/lightcontainer/domains/client/StoreProcessor.java b/app/src/main/java/lightcontainer/domains/client/StoreProcessor.java index 55c4d2e..b573ab4 100644 --- a/app/src/main/java/lightcontainer/domains/client/StoreProcessor.java +++ b/app/src/main/java/lightcontainer/domains/client/StoreProcessor.java @@ -22,10 +22,10 @@ import java.util.Objects; * @author Jérémi NIHART */ public class StoreProcessor implements Runnable, AutoCloseable { - private String domain; // Variables private final StoreProcessorFFE fileFrontEnd; private final Socket store; + private final String domain; private boolean client_run; private BufferedReader reader; @@ -96,6 +96,9 @@ public class StoreProcessor implements Runnable, AutoCloseable { } } + /** + * Compare two StoreProcessor object to check if equals. + */ @Override public boolean equals(Object o) { if (this == o) return true; @@ -104,6 +107,9 @@ public class StoreProcessor implements Runnable, AutoCloseable { return Objects.equals(domain, that.domain); } + /** + * Get hash code + */ @Override public int hashCode() { return Objects.hash(domain); diff --git a/app/src/main/java/lightcontainer/protocol/ProtocolReader.java b/app/src/main/java/lightcontainer/protocol/ProtocolReader.java index a61d3e7..89046df 100644 --- a/app/src/main/java/lightcontainer/protocol/ProtocolReader.java +++ b/app/src/main/java/lightcontainer/protocol/ProtocolReader.java @@ -4,14 +4,14 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; public abstract class ProtocolReader { - + // Variables private final Pattern rulePattern; + // Constructor protected ProtocolReader(String pattern) { this.rulePattern = Pattern.compile(pattern); } - public abstract class ProtocolResult {} /** @@ -27,17 +27,14 @@ public abstract class ProtocolReader { for (int i = 1; i <= groups.length; ++i) groups[i - 1] = ruleMatcher.group(i); - return onExecuted(groups); } - return null; } /** * Cette méthode est appelée lors de l'exécution de la règle - * @param data + * @param data Paramètres pour créer la commande. */ protected abstract T onExecuted(String... data); - } diff --git a/app/src/main/java/lightcontainer/protocol/ProtocolWriter.java b/app/src/main/java/lightcontainer/protocol/ProtocolWriter.java index 4605a30..ba857bd 100644 --- a/app/src/main/java/lightcontainer/protocol/ProtocolWriter.java +++ b/app/src/main/java/lightcontainer/protocol/ProtocolWriter.java @@ -5,19 +5,19 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; public abstract class ProtocolWriter { - + // Variables private final Pattern rulePattern; private final String cmdName; - + // Constructor protected ProtocolWriter(String cmdName, String pattern) { this.rulePattern = Pattern.compile(pattern); this.cmdName = cmdName; } /** - * Permet de récupérer le nom du protocol - * @return + * Permet de récupérer le nom de la commande. + * @return Nom de la commande. */ public String getCmdName() { return cmdName; @@ -25,16 +25,16 @@ public abstract class ProtocolWriter { /** * Permet de contruire une commande selon une règle établie. - * @param datas Les données à ajouter dans la commande; L'ordre défini leur position dans la commande + * @param data Les données à ajouter dans la commande; L'ordre défini leur position dans la commande * @return La commande construite */ - public String execute(String... datas) { + public String execute(String... data) { // Concatatène le nom de la commande avec les données (trim), avec un espace entre chaque - String command = null; + String command; StringJoiner builder = new StringJoiner(" ", this.cmdName, "\r\n"); - for (String data : datas) - builder.add(data); + for (String param : data) + builder.add(param); command = builder.toString(); diff --git a/app/src/main/java/lightcontainer/repository/ProtocolRepositoryImpl.java b/app/src/main/java/lightcontainer/repository/ProtocolRepositoryImpl.java index 7735ef0..dad49c8 100644 --- a/app/src/main/java/lightcontainer/repository/ProtocolRepositoryImpl.java +++ b/app/src/main/java/lightcontainer/repository/ProtocolRepositoryImpl.java @@ -23,9 +23,9 @@ public class ProtocolRepositoryImpl implements ProtocolRepository { } @Override - public String executeWriter(String... datas) { + public String executeWriter(String... data) { for (ProtocolWriter writer : writers) { - String command = writer.execute(datas); + String command = writer.execute(data); if (command != null) { return command; } diff --git a/app/src/main/java/lightcontainer/repository/StoreProcessorRepository.java b/app/src/main/java/lightcontainer/repository/StoreProcessorRepository.java index 2eea8d4..4171a5b 100644 --- a/app/src/main/java/lightcontainer/repository/StoreProcessorRepository.java +++ b/app/src/main/java/lightcontainer/repository/StoreProcessorRepository.java @@ -4,9 +4,7 @@ import lightcontainer.domains.client.StoreProcessor; import lightcontainer.domains.server.MulticastServerListener; import lightcontainer.interfaces.MulticastSPR; -import java.util.ArrayList; import java.util.HashSet; -import java.util.List; import java.util.Set; // TODO : C'est genre un ClientHandlerManager quoi hein, normal qu'il fasse blinder de chose ;) /**