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 643fe1c316a08b48baa9201f5810551552bc0e63 Author: Benoit Tellier <btell...@linagora.com> AuthorDate: Tue Mar 5 10:55:19 2019 +0700 JAMES-2665 Clock should be injected as a common service No particular reasons to only inject it for RabbitMQ. It is furthermore needed by PreDeletionHook injections for DeletedMessagesVaultHook + memory. --- .../java/org/apache/james/modules/ClockModule.java | 31 ++++++++++++++++++++++ .../apache/james/modules/CommonServicesModule.java | 1 + .../james/modules/rabbitmq/RabbitMQModule.java | 2 -- 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/ClockModule.java b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/ClockModule.java new file mode 100644 index 0000000..3d1924b --- /dev/null +++ b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/ClockModule.java @@ -0,0 +1,31 @@ +/**************************************************************** + * 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.modules; + +import java.time.Clock; + +import com.google.inject.AbstractModule; + +public class ClockModule extends AbstractModule { + @Override + protected void configure() { + bind(Clock.class).toInstance(Clock.systemUTC()); + } +} diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/CommonServicesModule.java b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/CommonServicesModule.java index 2a43447..075d905 100644 --- a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/CommonServicesModule.java +++ b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/CommonServicesModule.java @@ -62,6 +62,7 @@ public class CommonServicesModule extends AbstractModule { install(new TaskManagerModule()); install(new CleanupTaskModule()); install(new MimeMessageModule()); + install(new ClockModule()); bind(FileSystem.class).toInstance(fileSystem); bind(Configuration.class).toInstance(configuration); diff --git a/server/container/guice/rabbitmq/src/main/java/org/apache/james/modules/rabbitmq/RabbitMQModule.java b/server/container/guice/rabbitmq/src/main/java/org/apache/james/modules/rabbitmq/RabbitMQModule.java index 5d42930..ec74bf4 100644 --- a/server/container/guice/rabbitmq/src/main/java/org/apache/james/modules/rabbitmq/RabbitMQModule.java +++ b/server/container/guice/rabbitmq/src/main/java/org/apache/james/modules/rabbitmq/RabbitMQModule.java @@ -19,7 +19,6 @@ package org.apache.james.modules.rabbitmq; import java.io.FileNotFoundException; -import java.time.Clock; import java.util.concurrent.ThreadLocalRandom; import javax.inject.Named; @@ -63,7 +62,6 @@ public class RabbitMQModule extends AbstractModule { @Override protected void configure() { - bind(Clock.class).toInstance(Clock.systemUTC()); bind(ThreadLocalRandom.class).toInstance(ThreadLocalRandom.current()); bind(EnqueuedMailsDAO.class).in(Scopes.SINGLETON); --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org