diff --git a/src/main/java/com/clearlydecoded/messenger/demo/processor/GingerCookieOrderHandler.java b/src/main/java/com/clearlydecoded/messenger/demo/processor/GingerCookieOrderProcessor.java similarity index 97% rename from src/main/java/com/clearlydecoded/messenger/demo/processor/GingerCookieOrderHandler.java rename to src/main/java/com/clearlydecoded/messenger/demo/processor/GingerCookieOrderProcessor.java index 69883cc..35630af 100644 --- a/src/main/java/com/clearlydecoded/messenger/demo/processor/GingerCookieOrderHandler.java +++ b/src/main/java/com/clearlydecoded/messenger/demo/processor/GingerCookieOrderProcessor.java @@ -23,7 +23,7 @@ * @author Yaakov Chaikin (yaakov@ClearlyDecoded.com) */ @Service -public class GingerCookieOrderHandler extends +public class GingerCookieOrderProcessor extends AbstractMessageProcessor { @SuppressWarnings("SpringJavaAutowiredFieldsWarningInspection") diff --git a/src/main/java/com/clearlydecoded/messenger/demo/processor/GreetMeMessageProcessor.java b/src/main/java/com/clearlydecoded/messenger/demo/processor/GreetMeMessageProcessor.java index 6ce3ae3..6c9467a 100644 --- a/src/main/java/com/clearlydecoded/messenger/demo/processor/GreetMeMessageProcessor.java +++ b/src/main/java/com/clearlydecoded/messenger/demo/processor/GreetMeMessageProcessor.java @@ -8,7 +8,7 @@ */ package com.clearlydecoded.messenger.demo.processor; -import com.clearlydecoded.messenger.MessageProcessor; +import com.clearlydecoded.messenger.AbstractMessageProcessor; import com.clearlydecoded.messenger.demo.message.GreetMeMessage; import com.clearlydecoded.messenger.demo.message.GreetMeMessageResponse; import org.springframework.stereotype.Service; @@ -19,8 +19,8 @@ * @author Yaakov Chaikin (yaakov@ClearlyDecoded.com) */ @Service // Must have this annotation for Spring to discover the class -public class GreetMeMessageProcessor implements - MessageProcessor { +public class GreetMeMessageProcessor extends + AbstractMessageProcessor { @Override public GreetMeMessageResponse process(GreetMeMessage message) { @@ -28,22 +28,4 @@ public GreetMeMessageResponse process(GreetMeMessage message) { // This is where you write the actual business logic return new GreetMeMessageResponse("Hello " + message.getMyName()); } - - @Override - public String getCompatibleMessageType() { - // SEE! Defining that TYPE as public static final paid off! - // You certainly CAN just hardcode a string here, but this is more robust. - // Don't worry, if you mess this up, the validation at startup will catch it - return GreetMeMessage.TYPE; - } - - @Override - public Class getCompatibleMessageClassType() { - return GreetMeMessage.class; // not possible to mess up here - } - - @Override - public Class getCompatibleMessageResponseClassType() { - return GreetMeMessageResponse.class; // not possible to mess up here - } } diff --git a/src/main/java/com/clearlydecoded/messenger/demo/processor/MaxSugarOrderHandler.java b/src/main/java/com/clearlydecoded/messenger/demo/processor/MaxSugarOrderProcessor.java similarity index 97% rename from src/main/java/com/clearlydecoded/messenger/demo/processor/MaxSugarOrderHandler.java rename to src/main/java/com/clearlydecoded/messenger/demo/processor/MaxSugarOrderProcessor.java index 86aea09..dfa4c77 100644 --- a/src/main/java/com/clearlydecoded/messenger/demo/processor/MaxSugarOrderHandler.java +++ b/src/main/java/com/clearlydecoded/messenger/demo/processor/MaxSugarOrderProcessor.java @@ -24,7 +24,7 @@ * @author Yaakov Chaikin (yaakov@ClearlyDecoded.com) */ @Service -public class MaxSugarOrderHandler extends +public class MaxSugarOrderProcessor extends AbstractMessageProcessor { @SuppressWarnings("SpringJavaAutowiredFieldsWarningInspection") diff --git a/src/main/java/com/clearlydecoded/messenger/demo/processor/SugarComaCookieOrderProcessor.java b/src/main/java/com/clearlydecoded/messenger/demo/processor/SugarComaCookieOrderProcessor.java index 2b0e461..875e757 100644 --- a/src/main/java/com/clearlydecoded/messenger/demo/processor/SugarComaCookieOrderProcessor.java +++ b/src/main/java/com/clearlydecoded/messenger/demo/processor/SugarComaCookieOrderProcessor.java @@ -8,7 +8,7 @@ */ package com.clearlydecoded.messenger.demo.processor; -import com.clearlydecoded.messenger.AbstractMessageProcessor; +import com.clearlydecoded.messenger.MessageProcessor; import com.clearlydecoded.messenger.demo.message.SugarComaCookieOrder; import com.clearlydecoded.messenger.demo.message.SugarComaCookieOrderResponse; import com.clearlydecoded.messenger.demo.model.Cookie; @@ -22,9 +22,9 @@ * * @author Yaakov Chaikin (yaakov@ClearlyDecoded.com) */ -@Service -public class SugarComaCookieOrderProcessor extends - AbstractMessageProcessor { +@Service // Must have this annotation for Spring to discover the class +public class SugarComaCookieOrderProcessor implements + MessageProcessor { @SuppressWarnings("SpringJavaAutowiredFieldsWarningInspection") @Autowired @@ -33,7 +33,26 @@ public class SugarComaCookieOrderProcessor extends @Override public SugarComaCookieOrderResponse process(SugarComaCookieOrder message) { + // This is where you write the actual business logic Cookie comaCookie = cookieStoreService.giveMeSugarComaCookie(); return new SugarComaCookieOrderResponse(comaCookie); } + + @Override + public String getCompatibleMessageType() { + // SEE! Defining that TYPE as public static final paid off! + // You certainly CAN just hardcode a string here, but this is more robust. + // Don't worry, if you mess this up, the validation at startup will catch it + return SugarComaCookieOrder.TYPE; + } + + @Override + public Class getCompatibleMessageClassType() { + return SugarComaCookieOrder.class; // not possible to mess up here + } + + @Override + public Class getCompatibleMessageResponseClassType() { + return SugarComaCookieOrderResponse.class; // not possible to mess up here + } }