superbAura commented on code in PR #2410: URL: https://github.com/apache/james-project/pull/2410#discussion_r1766233479
########## protocols/imap/src/main/java/org/apache/james/imap/main/DefaultImapDecoderFactory.java: ########## @@ -27,20 +27,35 @@ 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 UnpooledStatusResponseFactory unpooledStatusResponseFactory; + private final ImapCommandParserFactory imapCommandParserFactory; + + /** + * Constructs `DefaultImapDecoderFactory` with the given + * `UnpooledStatusResponseFactory`. The `ImapCommandParserFactory` + * is created internally using the provided `UnpooledStatusResponseFactory`. + * + * @param unpooledStatusResponseFactory The factory for creating status responses. + */ + public DefaultImapDecoderFactory(UnpooledStatusResponseFactory unpooledStatusResponseFactory) { Review Comment: First, added a default constructor for DefaultImapDecoderFactory. This addition enhances flexibility by allowing other classes to use the default constructor. Additionally, added another constructor that accepts an implementation of StatusResponseFactory. This change is to provide flexibility for the ResponseFactory in DefaultImapDecoderFactory in the future. Also modified two other test classes to use the constructor-based approach -- 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: notifications-unsubscr...@james.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org For additional commands, e-mail: notifications-h...@james.apache.org