Arsnael commented on code in PR #2410:
URL: https://github.com/apache/james-project/pull/2410#discussion_r1767979781


##########
protocols/imap/src/main/java/org/apache/james/imap/main/DefaultImapDecoderFactory.java:
##########
@@ -27,20 +28,46 @@
 import org.apache.james.imap.message.response.UnpooledStatusResponseFactory;
 
 /**
- * TODO: this is temporary: should let the container do the coupling. TODO:
- * convert to POJO
+ * Factory class for creating `ImapDecoder` instances.
+ *
+ * This class is a POJO that manually manages its dependencies.
+ * Dependencies are injected through the constructor, which allows for
+ * better decoupling and easier testing.
+ *
+ * The creation of `ImapCommandParserFactory` is handled internally by
+ * this factory, based on the provided `UnpooledStatusResponseFactory`.
  */
 public class DefaultImapDecoderFactory implements ImapDecoderFactory {
 
-    public static ImapDecoder createDecoder() {
-        final UnpooledStatusResponseFactory unpooledStatusResponseFactory = 
new UnpooledStatusResponseFactory();
-        final ImapCommandParserFactory imapCommands = new 
ImapParserFactory(unpooledStatusResponseFactory);
-        return new DefaultImapDecoder(unpooledStatusResponseFactory, 
imapCommands);
+    private final StatusResponseFactory statusResponseFactory;
+    private final ImapCommandParserFactory imapCommandParserFactory;
+
+    /**
+     * Default constructor.
+     * This constructor creates an instance of DefaultImapDecoderFactory with 
an UnpooledStatusResponseFactory as the default implementation.
+     */
+    public DefaultImapDecoderFactory() {
+        this(new UnpooledStatusResponseFactory());
     }
 
+    /**
+     * Constructor that accepts a specific implementation of 
StatusResponseFactory.
+     * This constructor allows for flexibility by enabling different 
implementations of StatusResponseFactory to be used.
+     *
+     * @param statusResponseFactory An implementation of StatusResponseFactory 
to be used for creating IMAP command parsers and decoders.
+     */
+    public DefaultImapDecoderFactory(StatusResponseFactory 
statusResponseFactory) {
+        this.statusResponseFactory = statusResponseFactory;
+        this.imapCommandParserFactory = new 
ImapParserFactory(statusResponseFactory);

Review Comment:
   Not necessary, you should pass that as an argument as well, and not building 
the default (that you can pass via your `DefaultImapDecoderFactory()` 
constructor)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to