This is an automated email from the ASF dual-hosted git repository. btellier pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git
commit c2cb64331d09a5ee043e323426e9c41b1fead893 Author: Benoit Tellier <[email protected]> AuthorDate: Fri Dec 6 15:27:45 2019 +0700 PROTOCOLS-120 parserFactory field should be final in UidCommandParser Additional bonus: we can get rid of some reflection! --- .../imap/decode/DelegatingImapCommandParser.java | 27 ---------------------- .../imap/decode/parser/ImapParserFactory.java | 8 +------ .../james/imap/decode/parser/UidCommandParser.java | 18 ++++----------- 3 files changed, 5 insertions(+), 48 deletions(-) diff --git a/protocols/imap/src/main/java/org/apache/james/imap/decode/DelegatingImapCommandParser.java b/protocols/imap/src/main/java/org/apache/james/imap/decode/DelegatingImapCommandParser.java deleted file mode 100644 index 9c8b1fb..0000000 --- a/protocols/imap/src/main/java/org/apache/james/imap/decode/DelegatingImapCommandParser.java +++ /dev/null @@ -1,27 +0,0 @@ -/**************************************************************** - * Licensed to the Apache Software Foundation (ASF) under one * - * or more contributor license agreements. See the NOTICE file * - * distributed with this work for additional information * - * regarding copyright ownership. The ASF licenses this file * - * to you under the Apache License, Version 2.0 (the * - * "License"); you may not use this file except in compliance * - * with the License. You may obtain a copy of the License at * - * * - * http://www.apache.org/licenses/LICENSE-2.0 * - * * - * Unless required by applicable law or agreed to in writing, * - * software distributed under the License is distributed on an * - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * - * KIND, either express or implied. See the License for the * - * specific language governing permissions and limitations * - * under the License. * - ****************************************************************/ -package org.apache.james.imap.decode; - -public interface DelegatingImapCommandParser { - - ImapCommandParserFactory getParserFactory(); - - void setParserFactory(ImapCommandParserFactory imapCommandFactory); - -} diff --git a/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/ImapParserFactory.java b/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/ImapParserFactory.java index f4ca8fd..3d2be5e 100644 --- a/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/ImapParserFactory.java +++ b/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/ImapParserFactory.java @@ -25,7 +25,6 @@ import java.util.Map; import org.apache.james.imap.api.ImapConstants; import org.apache.james.imap.api.message.response.StatusResponseFactory; -import org.apache.james.imap.decode.DelegatingImapCommandParser; import org.apache.james.imap.decode.ImapCommandParser; import org.apache.james.imap.decode.ImapCommandParserFactory; import org.apache.james.imap.decode.MessagingImapCommandParser; @@ -90,7 +89,7 @@ public class ImapParserFactory implements ImapCommandParserFactory { imapCommands.put(ImapConstants.SEARCH_COMMAND_NAME, new SearchCommandParser()); imapCommands.put(ImapConstants.FETCH_COMMAND_NAME, new FetchCommandParser()); imapCommands.put(ImapConstants.STORE_COMMAND_NAME, new StoreCommandParser()); - imapCommands.put(ImapConstants.UID_COMMAND_NAME, new UidCommandParser()); + imapCommands.put(ImapConstants.UID_COMMAND_NAME, new UidCommandParser(this)); imapCommands.put(ImapConstants.IDLE_COMMAND_NAME, new IdleCommandParser()); imapCommands.put(ImapConstants.STARTTLS, new StartTLSCommandParser()); @@ -127,14 +126,9 @@ public class ImapParserFactory implements ImapCommandParserFactory { } private void initialiseParser(ImapCommandParser cmd) { - if (cmd instanceof DelegatingImapCommandParser) { - ((DelegatingImapCommandParser) cmd).setParserFactory(this); - } - if (cmd instanceof MessagingImapCommandParser) { final MessagingImapCommandParser messagingImapCommandParser = (MessagingImapCommandParser) cmd; messagingImapCommandParser.setStatusResponseFactory(statusResponseFactory); } } - } diff --git a/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/UidCommandParser.java b/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/UidCommandParser.java index 0ae7885..2c1e0ef 100644 --- a/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/UidCommandParser.java +++ b/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/UidCommandParser.java @@ -25,7 +25,6 @@ import org.apache.james.imap.api.Tag; import org.apache.james.imap.api.display.HumanReadableText; import org.apache.james.imap.api.process.ImapSession; import org.apache.james.imap.decode.DecodingException; -import org.apache.james.imap.decode.DelegatingImapCommandParser; import org.apache.james.imap.decode.ImapCommandParser; import org.apache.james.imap.decode.ImapCommandParserFactory; import org.apache.james.imap.decode.ImapRequestLineReader; @@ -36,23 +35,14 @@ import org.slf4j.LoggerFactory; /** * Parse UID commands */ -public class UidCommandParser extends AbstractImapCommandParser implements DelegatingImapCommandParser { +public class UidCommandParser extends AbstractImapCommandParser { private static final Logger LOGGER = LoggerFactory.getLogger(UidCommandParser.class); - private ImapCommandParserFactory parserFactory; + private final ImapCommandParserFactory parserFactory; - public UidCommandParser() { + public UidCommandParser(ImapCommandParserFactory parserFactory) { super(ImapCommand.selectedStateCommand(ImapConstants.UID_COMMAND_NAME)); - } - - @Override - public ImapCommandParserFactory getParserFactory() { - return parserFactory; - } - - @Override - public void setParserFactory(ImapCommandParserFactory imapCommandFactory) { - this.parserFactory = imapCommandFactory; + this.parserFactory = parserFactory; } @Override --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
