หลังจากตัดสินใจเลือก architectural styles ที่จะใช้สำหรับการ publish Events ได้แล้ว ทีม SaaSOvation ก็หันมาโฟกัสกับการ implementation ของ components ต่าง ๆ เพื่อให้บรรลุเป้าหมายนั้นให้ได้ . . .
แกนกลางของพฤติกรรมการ publish notification ถูกวางไว้เบื้องหลัง Application Service ซึ่งก็คือ NotificationService นั่นเอง ทำให้ทีมสามารถจัดการขอบเขต transactional ของการเปลี่ยนแปลงต่าง ๆ ใน data source ของตนเองได้ อีกทั้งยังตอกย้ำว่า notification เป็นเรื่องระดับ application ไม่ใช่เรื่องระดับ domain แม้ว่า Events ที่ถูก publish ออกมาเป็น notifications จะมีจุดกำเนิดอยู่ใน model ก็ตาม
ไม่มีความจำเป็นที่ NotificationService จะต้องมี Separated Interface [Fowler, P of EAA] แต่อย่างใด ในตอนนี้จะมีการ implementation ของ Application Service เพียงแค่ตัวเดียวเท่านั้น ทีมจึงเก็บทุกอย่างให้ เรียบง่ายไว้ก่อน อย่างไรก็ตาม ทุก class ที่เรียบง่ายล้วนมี public interface เช่นกัน ตรงนี้จึงถูกนำเสนอเป็น methods แบบ stubbed-out:
package com.saasovation.identityaccess.application;
...
public class NotificationService {
...
@Transactional(readOnly=true)
public NotificationLog currentNotificationLog() {
...
}
@Transactional(readOnly=true)
public NotificationLog notificationLog(String aNotificationLogId) {
...
}
@Transactional
public void publishNotifications() {
...
}
...
}
สอง methods แรกจะถูกใช้สำหรับการ query หา NotificationLog instances ซึ่งจะถูกส่งมอบให้กับ clients ในรูปแบบของ RESTful resources และ method ที่สามจะถูกใช้เพื่อ publish Notification แต่ละ instance ผ่านกลไก messaging ทีมจะลงมือกับ methods ที่ใช้ query เพื่อดึง NotificationLog instances ให้เสร็จก่อน จากนั้นจึงค่อยหันไปให้ความสนใจกับ method ที่ต้องโต้ตอบกับ messaging infrastructure
เบื้องหน้ายังมี implementation ที่น่าสนใจอีกหลายอย่างรออยู่