diff --git a/guice-intro/src/main/java/com/baeldung/examples/guice/marker/Communicator.java b/guice-intro/src/main/java/com/baeldung/examples/guice/marker/Communicator.java deleted file mode 100644 index 239666b6ab..0000000000 --- a/guice-intro/src/main/java/com/baeldung/examples/guice/marker/Communicator.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.baeldung.examples.guice.marker; - -/** - * - * @author Baeldung - */ -public interface Communicator { - - public boolean sendMessage(String message); - -} diff --git a/guice-intro/pom.xml b/guice/pom.xml similarity index 94% rename from guice-intro/pom.xml rename to guice/pom.xml index 1f0d7679b7..df87021794 100644 --- a/guice-intro/pom.xml +++ b/guice/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.baeldung.examples.guice - guice-intro + guice 1.0-SNAPSHOT jar @@ -30,5 +30,5 @@ 1.8 4.1.0 - guice-intro + guice diff --git a/guice-intro/src/main/java/com/baeldung/examples/RunGuice.java b/guice/src/main/java/com/baeldung/examples/RunGuice.java similarity index 76% rename from guice-intro/src/main/java/com/baeldung/examples/RunGuice.java rename to guice/src/main/java/com/baeldung/examples/RunGuice.java index b4b3e8571e..a07447cde8 100644 --- a/guice-intro/src/main/java/com/baeldung/examples/RunGuice.java +++ b/guice/src/main/java/com/baeldung/examples/RunGuice.java @@ -10,7 +10,7 @@ import java.util.Scanner; /** * - * @author Baeldung + * @author baeldung */ public class RunGuice { @@ -18,14 +18,10 @@ public class RunGuice { Injector injector = Guice.createInjector(new BasicModule(), new AOPModule()); Communication comms = injector.getInstance(Communication.class); Scanner scanner = new Scanner(System.in); - System.out.println("Enter your message to be sent; press Q to quit and P to print the message log"); while (true) { String input = scanner.nextLine(); if (input.equalsIgnoreCase("q")) { System.exit(0); - } - if (input.equalsIgnoreCase("p")) { - comms.print(); } else { comms.sendMessage(input); } diff --git a/guice-intro/src/main/java/com/baeldung/examples/guice/Communication.java b/guice/src/main/java/com/baeldung/examples/guice/Communication.java similarity index 54% rename from guice-intro/src/main/java/com/baeldung/examples/guice/Communication.java rename to guice/src/main/java/com/baeldung/examples/guice/Communication.java index c4b17b57d2..7f7cb822d8 100644 --- a/guice-intro/src/main/java/com/baeldung/examples/guice/Communication.java +++ b/guice/src/main/java/com/baeldung/examples/guice/Communication.java @@ -10,7 +10,7 @@ import java.util.logging.Logger; /** * - * @author Baeldung + * @author baeldung */ public class Communication { @@ -19,37 +19,20 @@ public class Communication { @Inject private Logger logger; - private Queue messageLog; - - @Named("CommsUUID") - private String commsID; - @Inject private DefaultCommunicator communicator; public Communication(Boolean keepRecords) { if (keepRecords) { - messageLog = new LinkedList(); + System.out.println("keeping records"); } } public boolean sendMessage(String message) { - if (!message.isEmpty() && messageLog != null) { - messageLog.add(message); - } + return communicator.sendMessage(message); } - - public void print() { - if (messageLog != null) { - for (String message : messageLog) { - logger.info(message); - } - } else { - logger.info("Message logging wasn't enabled"); - } - } - + public DefaultCommunicator getCommunicator() { return this.communicator; } diff --git a/guice-intro/src/main/java/com/baeldung/examples/guice/CommunicationMode.java b/guice/src/main/java/com/baeldung/examples/guice/CommunicationMode.java similarity index 100% rename from guice-intro/src/main/java/com/baeldung/examples/guice/CommunicationMode.java rename to guice/src/main/java/com/baeldung/examples/guice/CommunicationMode.java diff --git a/guice-intro/src/main/java/com/baeldung/examples/guice/DefaultCommunicator.java b/guice/src/main/java/com/baeldung/examples/guice/DefaultCommunicator.java similarity index 93% rename from guice-intro/src/main/java/com/baeldung/examples/guice/DefaultCommunicator.java rename to guice/src/main/java/com/baeldung/examples/guice/DefaultCommunicator.java index 423c24f789..c65644646a 100644 --- a/guice-intro/src/main/java/com/baeldung/examples/guice/DefaultCommunicator.java +++ b/guice/src/main/java/com/baeldung/examples/guice/DefaultCommunicator.java @@ -5,7 +5,10 @@ import com.baeldung.examples.guice.marker.Communicator; import com.google.inject.Inject; import com.google.inject.name.Named; - +/** + * + * @author baeldung + */ public class DefaultCommunicator implements Communicator { private CommunicationMode defaultCommsMode; diff --git a/guice-intro/src/main/java/com/baeldung/examples/guice/EmailCommunicationMode.java b/guice/src/main/java/com/baeldung/examples/guice/EmailCommunicationMode.java similarity index 92% rename from guice-intro/src/main/java/com/baeldung/examples/guice/EmailCommunicationMode.java rename to guice/src/main/java/com/baeldung/examples/guice/EmailCommunicationMode.java index 642ee7ace0..3caca0edcc 100644 --- a/guice-intro/src/main/java/com/baeldung/examples/guice/EmailCommunicationMode.java +++ b/guice/src/main/java/com/baeldung/examples/guice/EmailCommunicationMode.java @@ -1,3 +1,4 @@ + package com.baeldung.examples.guice; import com.baeldung.examples.guice.aop.MessageSentLoggable; @@ -5,7 +6,7 @@ import com.baeldung.examples.guice.constant.CommunicationModel; /** * - * @author Baekdung + * @author baeldung */ public class EmailCommunicationMode implements CommunicationMode { diff --git a/guice-intro/src/main/java/com/baeldung/examples/guice/IMCommunicationMode.java b/guice/src/main/java/com/baeldung/examples/guice/IMCommunicationMode.java similarity index 92% rename from guice-intro/src/main/java/com/baeldung/examples/guice/IMCommunicationMode.java rename to guice/src/main/java/com/baeldung/examples/guice/IMCommunicationMode.java index 9f34e9a241..bc9bd61449 100644 --- a/guice-intro/src/main/java/com/baeldung/examples/guice/IMCommunicationMode.java +++ b/guice/src/main/java/com/baeldung/examples/guice/IMCommunicationMode.java @@ -8,7 +8,7 @@ import java.util.logging.Logger; /** * - * @author Baeldung + * @author baeldung */ public class IMCommunicationMode implements CommunicationMode { diff --git a/guice-intro/src/main/java/com/baeldung/examples/guice/SMSCommunicationMode.java b/guice/src/main/java/com/baeldung/examples/guice/SMSCommunicationMode.java similarity index 92% rename from guice-intro/src/main/java/com/baeldung/examples/guice/SMSCommunicationMode.java rename to guice/src/main/java/com/baeldung/examples/guice/SMSCommunicationMode.java index 251e249971..28475839dd 100644 --- a/guice-intro/src/main/java/com/baeldung/examples/guice/SMSCommunicationMode.java +++ b/guice/src/main/java/com/baeldung/examples/guice/SMSCommunicationMode.java @@ -1,3 +1,4 @@ + package com.baeldung.examples.guice; import com.baeldung.examples.guice.aop.MessageSentLoggable; @@ -7,7 +8,7 @@ import java.util.logging.Logger; /** * - * @author Baeldung + * @author baeldung */ public class SMSCommunicationMode implements CommunicationMode { diff --git a/guice-intro/src/main/java/com/baeldung/examples/guice/aop/MessageLogger.java b/guice/src/main/java/com/baeldung/examples/guice/aop/MessageLogger.java similarity index 88% rename from guice-intro/src/main/java/com/baeldung/examples/guice/aop/MessageLogger.java rename to guice/src/main/java/com/baeldung/examples/guice/aop/MessageLogger.java index 8926dfa714..2ad5f8b92e 100644 --- a/guice-intro/src/main/java/com/baeldung/examples/guice/aop/MessageLogger.java +++ b/guice/src/main/java/com/baeldung/examples/guice/aop/MessageLogger.java @@ -1,12 +1,14 @@ + package com.baeldung.examples.guice.aop; +import com.google.inject.Inject; import java.util.logging.Logger; import org.aopalliance.intercept.MethodInterceptor; import org.aopalliance.intercept.MethodInvocation; /** * - * @author Baeldung + * @author baeldung */ public class MessageLogger implements MethodInterceptor { diff --git a/guice-intro/src/main/java/com/baeldung/examples/guice/aop/MessageSentLoggable.java b/guice/src/main/java/com/baeldung/examples/guice/aop/MessageSentLoggable.java similarity index 89% rename from guice-intro/src/main/java/com/baeldung/examples/guice/aop/MessageSentLoggable.java rename to guice/src/main/java/com/baeldung/examples/guice/aop/MessageSentLoggable.java index cacf3bde7c..5e5a411d0e 100644 --- a/guice-intro/src/main/java/com/baeldung/examples/guice/aop/MessageSentLoggable.java +++ b/guice/src/main/java/com/baeldung/examples/guice/aop/MessageSentLoggable.java @@ -1,3 +1,4 @@ + package com.baeldung.examples.guice.aop; import java.lang.annotation.ElementType; @@ -7,7 +8,7 @@ import java.lang.annotation.Target; /** * - * @author Baeldung + * @author baeldung */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) diff --git a/guice-intro/src/main/java/com/baeldung/examples/guice/binding/AOPModule.java b/guice/src/main/java/com/baeldung/examples/guice/binding/AOPModule.java similarity index 92% rename from guice-intro/src/main/java/com/baeldung/examples/guice/binding/AOPModule.java rename to guice/src/main/java/com/baeldung/examples/guice/binding/AOPModule.java index dc9d258efa..109d9a6389 100644 --- a/guice-intro/src/main/java/com/baeldung/examples/guice/binding/AOPModule.java +++ b/guice/src/main/java/com/baeldung/examples/guice/binding/AOPModule.java @@ -1,3 +1,4 @@ + package com.baeldung.examples.guice.binding; import com.baeldung.examples.guice.aop.MessageLogger; @@ -7,7 +8,7 @@ import com.google.inject.matcher.Matchers; /** * - * @author Baeldung + * @author baeldung */ public class AOPModule extends AbstractModule { diff --git a/guice-intro/src/main/java/com/baeldung/examples/guice/binding/BasicModule.java b/guice/src/main/java/com/baeldung/examples/guice/binding/BasicModule.java similarity index 96% rename from guice-intro/src/main/java/com/baeldung/examples/guice/binding/BasicModule.java rename to guice/src/main/java/com/baeldung/examples/guice/binding/BasicModule.java index 9168195130..93f0fe54ba 100644 --- a/guice-intro/src/main/java/com/baeldung/examples/guice/binding/BasicModule.java +++ b/guice/src/main/java/com/baeldung/examples/guice/binding/BasicModule.java @@ -1,3 +1,4 @@ + package com.baeldung.examples.guice.binding; import com.baeldung.examples.guice.Communication; @@ -13,7 +14,7 @@ import java.util.logging.Logger; /** * - * @author Baeldung + * @author baeldung */ public class BasicModule extends AbstractModule { diff --git a/guice-intro/src/main/java/com/baeldung/examples/guice/constant/CommunicationModel.java b/guice/src/main/java/com/baeldung/examples/guice/constant/CommunicationModel.java similarity index 86% rename from guice-intro/src/main/java/com/baeldung/examples/guice/constant/CommunicationModel.java rename to guice/src/main/java/com/baeldung/examples/guice/constant/CommunicationModel.java index b9fa604a32..d12420a0db 100644 --- a/guice-intro/src/main/java/com/baeldung/examples/guice/constant/CommunicationModel.java +++ b/guice/src/main/java/com/baeldung/examples/guice/constant/CommunicationModel.java @@ -1,8 +1,9 @@ + package com.baeldung.examples.guice.constant; /** * - * @author Baeldung + * @author baeldung */ public enum CommunicationModel { diff --git a/guice/src/main/java/com/baeldung/examples/guice/marker/Communicator.java b/guice/src/main/java/com/baeldung/examples/guice/marker/Communicator.java new file mode 100644 index 0000000000..7425f1c283 --- /dev/null +++ b/guice/src/main/java/com/baeldung/examples/guice/marker/Communicator.java @@ -0,0 +1,14 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.baeldung.examples.guice.marker; + +/** + * + * @author Tayo + */ +public interface Communicator { + +} diff --git a/guice-intro/src/main/java/com/baeldung/examples/guice/modules/BasicModule.java b/guice/src/main/java/com/baeldung/examples/guice/modules/BasicModule.java similarity index 96% rename from guice-intro/src/main/java/com/baeldung/examples/guice/modules/BasicModule.java rename to guice/src/main/java/com/baeldung/examples/guice/modules/BasicModule.java index 47b3e2e573..ed83cf3649 100644 --- a/guice-intro/src/main/java/com/baeldung/examples/guice/modules/BasicModule.java +++ b/guice/src/main/java/com/baeldung/examples/guice/modules/BasicModule.java @@ -1,3 +1,4 @@ + package com.baeldung.examples.guice.modules; import com.baeldung.examples.guice.Communication; @@ -13,7 +14,7 @@ import java.util.logging.Logger; /** * - * @author Baeldung + * @author baeldung */ public class BasicModule extends AbstractModule { diff --git a/pom.xml b/pom.xml index ee7e75d3cf..c12562551f 100644 --- a/pom.xml +++ b/pom.xml @@ -47,7 +47,7 @@ guava guava18 guava19 - guice-intro + guice disruptor handling-spring-static-resources