This is an automated email from the ASF dual-hosted git repository.
matthieu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
The following commit(s) were added to refs/heads/master by this push:
new 6cadb87c34 Implement immutable and invariant things as static fields
(#1431)
6cadb87c34 is described below
commit 6cadb87c34d761ac34966cfeef64f8b09e20ad6b
Author: Matthieu Baechler <[email protected]>
AuthorDate: Mon Feb 13 16:21:06 2023 +0000
Implement immutable and invariant things as static fields (#1431)
* As CoreCmdHandlerLoader always return the same immutable list of clasess,
it can be static
* Reformat a comment for better readability
* Remove a null handling as it never happens
---
.../apache/james/examples/MyCmdHandlerLoader.java | 66 ++++++++++------------
.../netty/BasicChannelInboundHandler.java | 23 ++++----
.../james/lmtpserver/CoreCmdHandlerLoader.java | 48 ++++++++--------
.../MailetContainerCmdHandlerLoader.java | 48 ++++++++--------
.../james/lmtpserver/jmx/JMXHandlersLoader.java | 10 ++--
.../pop3server/core/CoreCmdHandlerLoader.java | 66 ++++++++--------------
.../james/pop3server/jmx/JMXHandlersLoader.java | 10 ++--
.../james/smtpserver/CoreCmdHandlerLoader.java | 64 ++++++++++-----------
.../apache/james/smtpserver/JamesMessageHook.java | 6 +-
.../james/smtpserver/jmx/JMXHandlersLoader.java | 12 ++--
10 files changed, 155 insertions(+), 198 deletions(-)
diff --git
a/examples/custom-smtp-command/src/main/java/org/apache/james/examples/MyCmdHandlerLoader.java
b/examples/custom-smtp-command/src/main/java/org/apache/james/examples/MyCmdHandlerLoader.java
index d5a4386b18..7b224ee9a6 100644
---
a/examples/custom-smtp-command/src/main/java/org/apache/james/examples/MyCmdHandlerLoader.java
+++
b/examples/custom-smtp-command/src/main/java/org/apache/james/examples/MyCmdHandlerLoader.java
@@ -19,9 +19,7 @@
package org.apache.james.examples;
-import java.util.LinkedList;
import java.util.List;
-import java.util.stream.Stream;
import org.apache.james.protocols.api.handler.CommandDispatcher;
import org.apache.james.protocols.api.handler.CommandHandlerResultLogger;
@@ -57,41 +55,39 @@ import org.apache.james.smtpserver.UsersRepositoryAuthHook;
*/
public class MyCmdHandlerLoader implements HandlersPackage {
- private final List<String> commands = new LinkedList<>();
+ private static final List<String> commands = List.of(
+ JamesWelcomeMessageHandler.class.getName(),
+ CommandDispatcher.class.getName(),
+ AuthCmdHandler.class.getName(),
+ JamesDataCmdHandler.class.getName(),
+ EhloCmdHandler.class.getName(),
+ ExpnCmdHandler.class.getName(),
+ HeloCmdHandler.class.getName(),
+ HelpCmdHandler.class.getName(),
+ JamesMailCmdHandler.class.getName(),
+ NoopCmdHandler.class.getName(),
+ QuitCmdHandler.class.getName(),
+ JamesRcptCmdHandler.class.getName(),
+ RsetCmdHandler.class.getName(),
+ VrfyCmdHandler.class.getName(),
+ MailSizeEsmtpExtension.class.getName(),
+ UsersRepositoryAuthHook.class.getName(),
+ AuthRequiredToRelayRcptHook.class.getName(),
+ SenderAuthIdentifyVerificationHook.class.getName(),
+ PostmasterAbuseRcptHook.class.getName(),
+ ReceivedDataLineFilter.class.getName(),
+ DataLineJamesMessageHookHandler.class.getName(),
+ StartTlsCmdHandler.class.getName(),
+ AddDefaultAttributesMessageHook.class.getName(),
+ SendMailHandler.class.getName(),
+ UnknownCmdHandler.class.getName(),
+ CommandHandlerResultLogger.class.getName(),
+ HookResultLogger.class.getName(),
+ // Support MYNOOP
+ MyNoopCmdHandler.class.getName()
+ );
public MyCmdHandlerLoader() {
- Stream.of(
- JamesWelcomeMessageHandler.class,
- CommandDispatcher.class,
- AuthCmdHandler.class,
- JamesDataCmdHandler.class,
- EhloCmdHandler.class,
- ExpnCmdHandler.class,
- HeloCmdHandler.class,
- HelpCmdHandler.class,
- JamesMailCmdHandler.class,
- NoopCmdHandler.class,
- QuitCmdHandler.class,
- JamesRcptCmdHandler.class,
- RsetCmdHandler.class,
- VrfyCmdHandler.class,
- MailSizeEsmtpExtension.class,
- UsersRepositoryAuthHook.class,
- AuthRequiredToRelayRcptHook.class,
- SenderAuthIdentifyVerificationHook.class,
- PostmasterAbuseRcptHook.class,
- ReceivedDataLineFilter.class,
- DataLineJamesMessageHookHandler.class,
- StartTlsCmdHandler.class,
- AddDefaultAttributesMessageHook.class,
- SendMailHandler.class,
- UnknownCmdHandler.class,
- CommandHandlerResultLogger.class,
- HookResultLogger.class,
- // Support MYNOOP
- MyNoopCmdHandler.class)
- .map(Class::getName)
- .forEachOrdered(commands::add);
}
@Override
diff --git
a/protocols/netty/src/main/java/org/apache/james/protocols/netty/BasicChannelInboundHandler.java
b/protocols/netty/src/main/java/org/apache/james/protocols/netty/BasicChannelInboundHandler.java
index 55573f2833..95207bdda1 100644
---
a/protocols/netty/src/main/java/org/apache/james/protocols/netty/BasicChannelInboundHandler.java
+++
b/protocols/netty/src/main/java/org/apache/james/protocols/netty/BasicChannelInboundHandler.java
@@ -101,20 +101,17 @@ public class BasicChannelInboundHandler extends
ChannelInboundHandlerAdapter imp
List<ProtocolHandlerResultHandler> resultHandlers =
chain.getHandlers(ProtocolHandlerResultHandler.class);
LOGGER.info("Connection established from {}",
session.getRemoteAddress().getAddress().getHostAddress());
- if (connectHandlers != null) {
- for (ConnectHandler cHandler : connectHandlers) {
- long start = System.currentTimeMillis();
- Response response = cHandler.onConnect(session);
- long executionTime = System.currentTimeMillis() - start;
-
- for (ProtocolHandlerResultHandler resultHandler :
resultHandlers) {
- resultHandler.onResponse(session, response,
executionTime, cHandler);
- }
- if (response != null) {
- // TODO: This kind of sucks but I was able to come up
with something more elegant here
- ((ProtocolSessionImpl)
session).getProtocolTransport().writeResponse(response, session);
- }
+ for (ConnectHandler cHandler : connectHandlers) {
+ long start = System.currentTimeMillis();
+ Response response = cHandler.onConnect(session);
+ long executionTime = System.currentTimeMillis() - start;
+ for (ProtocolHandlerResultHandler resultHandler :
resultHandlers) {
+ resultHandler.onResponse(session, response, executionTime,
cHandler);
+ }
+ if (response != null) {
+ // TODO: This kind of sucks but I was able to come up with
something more elegant here
+ ((ProtocolSessionImpl)
session).getProtocolTransport().writeResponse(response, session);
}
}
diff --git
a/server/protocols/protocols-lmtp/src/main/java/org/apache/james/lmtpserver/CoreCmdHandlerLoader.java
b/server/protocols/protocols-lmtp/src/main/java/org/apache/james/lmtpserver/CoreCmdHandlerLoader.java
index bc26b22d8f..90632273bc 100644
---
a/server/protocols/protocols-lmtp/src/main/java/org/apache/james/lmtpserver/CoreCmdHandlerLoader.java
+++
b/server/protocols/protocols-lmtp/src/main/java/org/apache/james/lmtpserver/CoreCmdHandlerLoader.java
@@ -19,9 +19,7 @@
package org.apache.james.lmtpserver;
-import java.util.LinkedList;
import java.util.List;
-import java.util.stream.Stream;
import org.apache.james.lmtpserver.hook.MailboxDeliverToRecipientHandler;
import org.apache.james.protocols.api.handler.CommandDispatcher;
@@ -49,32 +47,30 @@ import
org.apache.james.smtpserver.fastfail.ValidRcptHandler;
*/
public class CoreCmdHandlerLoader implements HandlersPackage {
- private final List<String> commands = new LinkedList<>();
+ private static final List<String> commands = List.of(
+ WelcomeMessageHandler.class.getName(),
+ CommandDispatcher.class.getName(),
+ JamesDataCmdHandler.class.getName(),
+ ExpnCmdHandler.class.getName(),
+ LhloCmdHandler.class.getName(),
+ JamesMailCmdHandler.class.getName(),
+ NoopCmdHandler.class.getName(),
+ QuitCmdHandler.class.getName(),
+ JamesRcptCmdHandler.class.getName(),
+ ValidRcptHandler.class.getName(),
+ RsetCmdHandler.class.getName(),
+ VrfyCmdHandler.class.getName(),
+ MailSizeEsmtpExtension.class.getName(),
+ AuthRequiredToRelayRcptHook.class.getName(),
+ PostmasterAbuseRcptHook.class.getName(),
+ ReceivedDataLineFilter.class.getName(),
+ DataLineLMTPHandler.class.getName(),
+ MailboxDeliverToRecipientHandler.class.getName(),
+ CommandHandlerResultLogger.class.getName(),
+ HookResultLogger.class.getName()
+ );
public CoreCmdHandlerLoader() {
- Stream.of(
- WelcomeMessageHandler.class,
- CommandDispatcher.class,
- JamesDataCmdHandler.class,
- ExpnCmdHandler.class,
- LhloCmdHandler.class,
- JamesMailCmdHandler.class,
- NoopCmdHandler.class,
- QuitCmdHandler.class,
- JamesRcptCmdHandler.class,
- ValidRcptHandler.class,
- RsetCmdHandler.class,
- VrfyCmdHandler.class,
- MailSizeEsmtpExtension.class,
- AuthRequiredToRelayRcptHook.class,
- PostmasterAbuseRcptHook.class,
- ReceivedDataLineFilter.class,
- DataLineLMTPHandler.class,
- MailboxDeliverToRecipientHandler.class,
- CommandHandlerResultLogger.class,
- HookResultLogger.class)
- .map(Class::getName)
- .forEachOrdered(commands::add);
}
@Override
diff --git
a/server/protocols/protocols-lmtp/src/main/java/org/apache/james/lmtpserver/MailetContainerCmdHandlerLoader.java
b/server/protocols/protocols-lmtp/src/main/java/org/apache/james/lmtpserver/MailetContainerCmdHandlerLoader.java
index f86289b183..256202b14f 100644
---
a/server/protocols/protocols-lmtp/src/main/java/org/apache/james/lmtpserver/MailetContainerCmdHandlerLoader.java
+++
b/server/protocols/protocols-lmtp/src/main/java/org/apache/james/lmtpserver/MailetContainerCmdHandlerLoader.java
@@ -19,9 +19,7 @@
package org.apache.james.lmtpserver;
-import java.util.LinkedList;
import java.util.List;
-import java.util.stream.Stream;
import org.apache.james.protocols.api.handler.CommandDispatcher;
import org.apache.james.protocols.api.handler.CommandHandlerResultLogger;
@@ -48,33 +46,31 @@ import
org.apache.james.smtpserver.fastfail.ValidRcptHandler;
*/
public class MailetContainerCmdHandlerLoader implements HandlersPackage {
- private final List<String> commands = new LinkedList<>();
+ private static final List<String> commands = List.of(
+ WelcomeMessageHandler.class.getName(),
+ CommandDispatcher.class.getName(),
+ JamesDataCmdHandler.class.getName(),
+ ExpnCmdHandler.class.getName(),
+ LhloCmdHandler.class.getName(),
+ JamesMailCmdHandler.class.getName(),
+ NoopCmdHandler.class.getName(),
+ QuitCmdHandler.class.getName(),
+ JamesRcptCmdHandler.class.getName(),
+ ValidRcptHandler.class.getName(),
+ RsetCmdHandler.class.getName(),
+ VrfyCmdHandler.class.getName(),
+ MailSizeEsmtpExtension.class.getName(),
+ AuthRequiredToRelayRcptHook.class.getName(),
+ PostmasterAbuseRcptHook.class.getName(),
+ ReceivedDataLineFilter.class.getName(),
+ MailetContainerHandler.class.getName(),
+ CommandHandlerResultLogger.class.getName(),
+ NoopJamesMessageHook.class.getName(),
+ HookResultLogger.class.getName()
+ );
public MailetContainerCmdHandlerLoader() {
- Stream.of(
- WelcomeMessageHandler.class,
- CommandDispatcher.class,
- JamesDataCmdHandler.class,
- ExpnCmdHandler.class,
- LhloCmdHandler.class,
- JamesMailCmdHandler.class,
- NoopCmdHandler.class,
- QuitCmdHandler.class,
- JamesRcptCmdHandler.class,
- ValidRcptHandler.class,
- RsetCmdHandler.class,
- VrfyCmdHandler.class,
- MailSizeEsmtpExtension.class,
- AuthRequiredToRelayRcptHook.class,
- PostmasterAbuseRcptHook.class,
- ReceivedDataLineFilter.class,
- MailetContainerHandler.class,
- CommandHandlerResultLogger.class,
- NoopJamesMessageHook.class,
- HookResultLogger.class)
- .map(Class::getName)
- .forEachOrdered(commands::add);
}
@Override
diff --git
a/server/protocols/protocols-lmtp/src/main/java/org/apache/james/lmtpserver/jmx/JMXHandlersLoader.java
b/server/protocols/protocols-lmtp/src/main/java/org/apache/james/lmtpserver/jmx/JMXHandlersLoader.java
index d4be40e0f0..53f6af86a5 100644
---
a/server/protocols/protocols-lmtp/src/main/java/org/apache/james/lmtpserver/jmx/JMXHandlersLoader.java
+++
b/server/protocols/protocols-lmtp/src/main/java/org/apache/james/lmtpserver/jmx/JMXHandlersLoader.java
@@ -18,19 +18,19 @@
****************************************************************/
package org.apache.james.lmtpserver.jmx;
-import java.util.ArrayList;
import java.util.List;
import org.apache.james.protocols.lib.handler.HandlersPackage;
public class JMXHandlersLoader implements HandlersPackage {
- private final List<String> handlers = new ArrayList<>();
+ private static final List<String> handlers = List.of(
+ ConnectHandlerResultJMXMonitor.class.getName(),
+ CommandHandlerResultJMXMonitor.class.getName(),
+ LineHandlerResultJMXMonitor.class.getName()
+ );
public JMXHandlersLoader() {
- handlers.add(ConnectHandlerResultJMXMonitor.class.getName());
- handlers.add(CommandHandlerResultJMXMonitor.class.getName());
- handlers.add(LineHandlerResultJMXMonitor.class.getName());
}
@Override
diff --git
a/server/protocols/protocols-pop3/src/main/java/org/apache/james/pop3server/core/CoreCmdHandlerLoader.java
b/server/protocols/protocols-pop3/src/main/java/org/apache/james/pop3server/core/CoreCmdHandlerLoader.java
index 504c62ed14..1f75f44a18 100644
---
a/server/protocols/protocols-pop3/src/main/java/org/apache/james/pop3server/core/CoreCmdHandlerLoader.java
+++
b/server/protocols/protocols-pop3/src/main/java/org/apache/james/pop3server/core/CoreCmdHandlerLoader.java
@@ -19,7 +19,6 @@
package org.apache.james.pop3server.core;
-import java.util.LinkedList;
import java.util.List;
import org.apache.james.protocols.api.handler.CommandDispatcher;
@@ -42,52 +41,31 @@ import
org.apache.james.protocols.pop3.core.WelcomeMessageHandler;
public class CoreCmdHandlerLoader implements HandlersPackage {
- private static final String CAPACMDHANDLER =
CapaCmdHandler.class.getName();
- private static final String USERCMDHANDLER =
UserCmdHandler.class.getName();
- private static final String PASSCMDHANDLER =
PassCmdHandler.class.getName();
- private static final String LISTCMDHANDLER =
ListCmdHandler.class.getName();
- private static final String UIDLCMDHANDLER =
UidlCmdHandler.class.getName();
- private static final String RSETCMDHANDLER =
RsetCmdHandler.class.getName();
- private static final String DELECMDHANDLER =
DeleCmdHandler.class.getName();
- private static final String NOOPCMDHANDLER =
NoopCmdHandler.class.getName();
- private static final String RETRSCMDHANDLER =
RetrCmdHandler.class.getName();
- private static final String TOPCMDHANDLER = TopCmdHandler.class.getName();
- private static final String STATCMDHANDLER =
StatCmdHandler.class.getName();
- private static final String QUITCMDHANDLER =
QuitCmdHandler.class.getName();
- private static final String WELCOMEMESSAGEHANDLER =
WelcomeMessageHandler.class.getName();
- private static final String UNKOWNCMDHANDLER =
UnknownCmdHandler.class.getName();
- private static final String STLSCMDHANDLER =
StlsCmdHandler.class.getName();
- private static final String COMMANDDISPATCHER =
CommandDispatcher.class.getName();
-
- // logging stuff
- private static final String COMMANDHANDLERRESULTLOGGER =
CommandHandlerResultLogger.class.getName();
-
-
- private final List<String> commands = new LinkedList<>();
+ private static final List<String> commands = List.of(
+ // Insert the base commands in the Map
+ WelcomeMessageHandler.class.getName(),
+ CommandDispatcher.class.getName(),
+ CapaCmdHandler.class.getName(),
+ UserCmdHandler.class.getName(),
+ PassCmdHandler.class.getName(),
+ ListCmdHandler.class.getName(),
+ UidlCmdHandler.class.getName(),
+ RsetCmdHandler.class.getName(),
+ DeleCmdHandler.class.getName(),
+ NoopCmdHandler.class.getName(),
+ RetrCmdHandler.class.getName(),
+ TopCmdHandler.class.getName(),
+ StatCmdHandler.class.getName(),
+ QuitCmdHandler.class.getName(),
+ UnknownCmdHandler.class.getName(),
+ // add STARTTLS support to the core. See JAMES-1224
+ StlsCmdHandler.class.getName(),
+ // Add logging stuff
+ CommandHandlerResultLogger.class.getName()
+ );
public CoreCmdHandlerLoader() {
- // Insert the base commands in the Map
- commands.add(WELCOMEMESSAGEHANDLER);
- commands.add(COMMANDDISPATCHER);
- commands.add(CAPACMDHANDLER);
- commands.add(USERCMDHANDLER);
- commands.add(PASSCMDHANDLER);
- commands.add(LISTCMDHANDLER);
- commands.add(UIDLCMDHANDLER);
- commands.add(RSETCMDHANDLER);
- commands.add(DELECMDHANDLER);
- commands.add(NOOPCMDHANDLER);
- commands.add(RETRSCMDHANDLER);
- commands.add(TOPCMDHANDLER);
- commands.add(STATCMDHANDLER);
- commands.add(QUITCMDHANDLER);
- commands.add(UNKOWNCMDHANDLER);
- // add STARTTLS support to the core. See JAMES-1224
- commands.add(STLSCMDHANDLER);
-
- // Add logging stuff
- commands.add(COMMANDHANDLERRESULTLOGGER);
}
@Override
diff --git
a/server/protocols/protocols-pop3/src/main/java/org/apache/james/pop3server/jmx/JMXHandlersLoader.java
b/server/protocols/protocols-pop3/src/main/java/org/apache/james/pop3server/jmx/JMXHandlersLoader.java
index d812dea2e5..871aeb1438 100644
---
a/server/protocols/protocols-pop3/src/main/java/org/apache/james/pop3server/jmx/JMXHandlersLoader.java
+++
b/server/protocols/protocols-pop3/src/main/java/org/apache/james/pop3server/jmx/JMXHandlersLoader.java
@@ -18,19 +18,19 @@
****************************************************************/
package org.apache.james.pop3server.jmx;
-import java.util.ArrayList;
import java.util.List;
import org.apache.james.protocols.lib.handler.HandlersPackage;
public class JMXHandlersLoader implements HandlersPackage {
- private final List<String> handlers = new ArrayList<>();
+ private static final List<String> handlers = List.of(
+ ConnectHandlerResultJMXMonitor.class.getName(),
+ CommandHandlerResultJMXMonitor.class.getName(),
+ LineHandlerResultJMXMonitor.class.getName()
+ );
public JMXHandlersLoader() {
- handlers.add(ConnectHandlerResultJMXMonitor.class.getName());
- handlers.add(CommandHandlerResultJMXMonitor.class.getName());
- handlers.add(LineHandlerResultJMXMonitor.class.getName());
}
@Override
diff --git
a/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/CoreCmdHandlerLoader.java
b/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/CoreCmdHandlerLoader.java
index e31e1f43b5..9ce5ef68ab 100644
---
a/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/CoreCmdHandlerLoader.java
+++
b/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/CoreCmdHandlerLoader.java
@@ -19,9 +19,7 @@
package org.apache.james.smtpserver;
-import java.util.LinkedList;
import java.util.List;
-import java.util.stream.Stream;
import org.apache.james.protocols.api.handler.CommandDispatcher;
import org.apache.james.protocols.api.handler.CommandHandlerResultLogger;
@@ -47,41 +45,37 @@ import
org.apache.james.protocols.smtp.core.log.HookResultLogger;
*/
public class CoreCmdHandlerLoader implements HandlersPackage {
- private final List<String> commands = new LinkedList<>();
+ private static final List<String> commands = List.of(
+ JamesWelcomeMessageHandler.class.getName(),
+ CommandDispatcher.class.getName(),
+ AuthCmdHandler.class.getName(),
+ JamesDataCmdHandler.class.getName(),
+ EhloCmdHandler.class.getName(),
+ ExpnCmdHandler.class.getName(),
+ HeloCmdHandler.class.getName(),
+ HelpCmdHandler.class.getName(),
+ JamesMailCmdHandler.class.getName(),
+ NoopCmdHandler.class.getName(),
+ QuitCmdHandler.class.getName(),
+ JamesRcptCmdHandler.class.getName(),
+ RsetCmdHandler.class.getName(),
+ VrfyCmdHandler.class.getName(),
+ MailSizeEsmtpExtension.class.getName(),
+ UsersRepositoryAuthHook.class.getName(),
+ AuthRequiredToRelayRcptHook.class.getName(),
+ SenderAuthIdentifyVerificationHook.class.getName(),
+ PostmasterAbuseRcptHook.class.getName(),
+ ReceivedDataLineFilter.class.getName(),
+ DataLineJamesMessageHookHandler.class.getName(),
+ StartTlsCmdHandler.class.getName(),
+ AddDefaultAttributesMessageHook.class.getName(),
+ SendMailHandler.class.getName(),
+ UnknownCmdHandler.class.getName(),
+ // Add logging stuff
+ CommandHandlerResultLogger.class.getName(),
+ HookResultLogger.class.getName());
public CoreCmdHandlerLoader() {
- // Insert the base commands in the Map
- Stream.of(
- JamesWelcomeMessageHandler.class,
- CommandDispatcher.class,
- AuthCmdHandler.class,
- JamesDataCmdHandler.class,
- EhloCmdHandler.class,
- ExpnCmdHandler.class,
- HeloCmdHandler.class,
- HelpCmdHandler.class,
- JamesMailCmdHandler.class,
- NoopCmdHandler.class,
- QuitCmdHandler.class,
- JamesRcptCmdHandler.class,
- RsetCmdHandler.class,
- VrfyCmdHandler.class,
- MailSizeEsmtpExtension.class,
- UsersRepositoryAuthHook.class,
- AuthRequiredToRelayRcptHook.class,
- SenderAuthIdentifyVerificationHook.class,
- PostmasterAbuseRcptHook.class,
- ReceivedDataLineFilter.class,
- DataLineJamesMessageHookHandler.class,
- StartTlsCmdHandler.class,
- AddDefaultAttributesMessageHook.class,
- SendMailHandler.class,
- UnknownCmdHandler.class,
- // Add logging stuff
- CommandHandlerResultLogger.class,
- HookResultLogger.class)
- .map(Class::getName)
- .forEachOrdered(commands::add);
}
@Override
diff --git
a/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/JamesMessageHook.java
b/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/JamesMessageHook.java
index 95dbf89fea..787401b092 100644
---
a/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/JamesMessageHook.java
+++
b/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/JamesMessageHook.java
@@ -24,9 +24,9 @@ import org.apache.james.protocols.smtp.hook.HookResult;
import org.apache.mailet.Mail;
/**
- * Custom message handlers must implement this interface The message hooks will
- * be server-wide common to all the SMTPHandlers, therefore the handlers must
- * store all the state information in the SMTPSession object
+ * Custom message handlers must implement this interface.
+ * The message hooks will be server-wide common to all the SMTPHandlers,
+ * therefore the handlers must store all the state information in the
SMTPSession object
*/
public interface JamesMessageHook extends Hook {
/**
diff --git
a/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/jmx/JMXHandlersLoader.java
b/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/jmx/JMXHandlersLoader.java
index f5647ace70..53f7b92cda 100644
---
a/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/jmx/JMXHandlersLoader.java
+++
b/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/jmx/JMXHandlersLoader.java
@@ -18,20 +18,20 @@
****************************************************************/
package org.apache.james.smtpserver.jmx;
-import java.util.ArrayList;
import java.util.List;
import org.apache.james.protocols.lib.handler.HandlersPackage;
public class JMXHandlersLoader implements HandlersPackage {
- private final List<String> handlers = new ArrayList<>();
+ private static final List<String> handlers = List.of(
+ ConnectHandlerResultJMXMonitor.class.getName(),
+ CommandHandlerResultJMXMonitor.class.getName(),
+ LineHandlerResultJMXMonitor.class.getName(),
+ HookResultJMXMonitor.class.getName()
+ );
public JMXHandlersLoader() {
- handlers.add(ConnectHandlerResultJMXMonitor.class.getName());
- handlers.add(CommandHandlerResultJMXMonitor.class.getName());
- handlers.add(LineHandlerResultJMXMonitor.class.getName());
- handlers.add(HookResultJMXMonitor.class.getName());
}
@Override
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]