You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by ad...@apache.org on 2018/08/24 11:59:52 UTC

[2/2] james-project git commit: JAMES-2527 don't require new classes for creating DTO converters

JAMES-2527 don't require new classes for creating DTO converters


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/a999bd60
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/a999bd60
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/a999bd60

Branch: refs/heads/master
Commit: a999bd6043745bd8fdd1c42b748fb5fe51a3e948
Parents: 8659a18
Author: Matthieu Baechler <ma...@apache.org>
Authored: Thu Aug 23 11:11:24 2018 +0200
Committer: Matthieu Baechler <ma...@apache.org>
Committed: Fri Aug 24 11:19:26 2018 +0200

----------------------------------------------------------------------
 .../cassandra/dto/EventDTOModule.java           | 78 ++++++++++++++++++--
 .../cassandra/CassandraEventStoreExtension.java |  4 +-
 .../cassandra/JsonEventSerializerTest.java      | 15 ++--
 .../cassandra/dto/OtherTestEventDTOModule.java  | 55 --------------
 .../cassandra/dto/TestEventDTOModule.java       | 56 --------------
 .../cassandra/dto/TestEventDTOModules.java      | 47 ++++++++++++
 .../cassandra/dto/QuotaEventDTOModules.java     | 34 +++++++++
 .../QuotaThresholdChangedEventDTOModule.java    | 54 --------------
 .../mailbox/quota/cassandra/dto/DTOTest.java    | 18 ++---
 .../listeners/CassandraEventStoreExtension.java |  5 +-
 .../CassandraDLPConfigurationStoreModule.java   |  7 +-
 .../mailbox/CassandraQuotaMailingModule.java    |  4 +-
 .../DLPConfigurationItemAddedDTOModule.java     | 53 -------------
 .../DLPConfigurationItemsRemovedDTOModule.java  | 53 -------------
 .../cassandra/DLPConfigurationModules.java      | 43 +++++++++++
 ...tSourcingDLPConfigurationStoreExtension.java |  4 +-
 .../FilteringRuleSetDefineDTOModule.java        | 52 -------------
 .../FilteringRuleSetDefineDTOModules.java       | 34 +++++++++
 .../filtering/FilteringRuleSetDefinedDTO.java   |  2 +-
 .../filtering/CassandraFilteringExtension.java  |  3 +-
 20 files changed, 261 insertions(+), 360 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/a999bd60/event-sourcing/event-store-cassandra/src/main/java/org/apache/james/eventsourcing/eventstore/cassandra/dto/EventDTOModule.java
----------------------------------------------------------------------
diff --git a/event-sourcing/event-store-cassandra/src/main/java/org/apache/james/eventsourcing/eventstore/cassandra/dto/EventDTOModule.java b/event-sourcing/event-store-cassandra/src/main/java/org/apache/james/eventsourcing/eventstore/cassandra/dto/EventDTOModule.java
index feaa5ef..ba29e91 100644
--- a/event-sourcing/event-store-cassandra/src/main/java/org/apache/james/eventsourcing/eventstore/cassandra/dto/EventDTOModule.java
+++ b/event-sourcing/event-store-cassandra/src/main/java/org/apache/james/eventsourcing/eventstore/cassandra/dto/EventDTOModule.java
@@ -21,12 +21,80 @@ package org.apache.james.eventsourcing.eventstore.cassandra.dto;
 
 import org.apache.james.eventsourcing.Event;
 
-public interface EventDTOModule {
-    String getType();
+public class EventDTOModule<T extends Event, U extends EventDTO> {
 
-    Class<? extends EventDTO> getDTOClass();
+    public interface EventDTOConverter<T extends Event, U extends EventDTO> {
+        U convert(T event, String typeName);
+    }
 
-    Class<? extends Event> getEventClass();
+    public static <U extends Event> Builder<U> forEvent(Class<U> eventType) {
+        return new Builder<>(eventType);
+    }
 
-    EventDTO toDTO(Event event);
+    public static class Builder<T extends Event> {
+
+        private final Class<T> eventType;
+
+        private Builder(Class<T> eventType) {
+            this.eventType = eventType;
+        }
+
+        public <U extends EventDTO> RequireConversionFunctionBuilder<U> convertToDTO(Class<U> dtoType) {
+            return new RequireConversionFunctionBuilder<>(dtoType);
+        }
+
+        public class RequireConversionFunctionBuilder<U extends EventDTO> {
+
+            private final Class<U> dtoType;
+
+            private RequireConversionFunctionBuilder(Class<U> dtoType) {
+                this.dtoType = dtoType;
+            }
+
+            public RequireTypeNameBuilder convertWith(EventDTOConverter<T, U> converter) {
+                return new RequireTypeNameBuilder(converter);
+            }
+
+            public class RequireTypeNameBuilder {
+                private final EventDTOConverter<T, U> converter;
+
+                private RequireTypeNameBuilder(EventDTOConverter<T, U> converter) {
+                    this.converter = converter;
+                }
+
+                public EventDTOModule<T, U> typeName(String typeName) {
+                    return new EventDTOModule<>(converter, eventType, dtoType, typeName);
+                }
+            }
+        }
+
+    }
+
+    private final EventDTOConverter<T, U> converter;
+    private final Class<T> eventType;
+    private final Class<U> dtoType;
+    private final String typeName;
+
+    private EventDTOModule(EventDTOConverter<T, U> converter, Class<T> eventType, Class<U> dtoType, String typeName) {
+        this.converter = converter;
+        this.eventType = eventType;
+        this.dtoType = dtoType;
+        this.typeName = typeName;
+    }
+
+    public String getType() {
+        return typeName;
+    }
+
+    public Class<U> getDTOClass() {
+        return dtoType;
+    }
+
+    public Class<T> getEventClass() {
+        return eventType;
+    }
+
+    public EventDTO toDTO(T event) {
+        return converter.convert(event, typeName);
+    }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/a999bd60/event-sourcing/event-store-cassandra/src/test/java/org/apache/james/eventsourcing/eventstore/cassandra/CassandraEventStoreExtension.java
----------------------------------------------------------------------
diff --git a/event-sourcing/event-store-cassandra/src/test/java/org/apache/james/eventsourcing/eventstore/cassandra/CassandraEventStoreExtension.java b/event-sourcing/event-store-cassandra/src/test/java/org/apache/james/eventsourcing/eventstore/cassandra/CassandraEventStoreExtension.java
index 73754a9..b913ef8 100644
--- a/event-sourcing/event-store-cassandra/src/test/java/org/apache/james/eventsourcing/eventstore/cassandra/CassandraEventStoreExtension.java
+++ b/event-sourcing/event-store-cassandra/src/test/java/org/apache/james/eventsourcing/eventstore/cassandra/CassandraEventStoreExtension.java
@@ -19,12 +19,12 @@
 
 package org.apache.james.eventsourcing.eventstore.cassandra;
 
-import org.apache.james.eventsourcing.eventstore.cassandra.dto.TestEventDTOModule;
+import org.apache.james.eventsourcing.eventstore.cassandra.dto.TestEventDTOModules;
 
 import com.google.common.collect.ImmutableSet;
 
 public class CassandraEventStoreExtension extends CassandraGenericEventStoreExtension {
     public CassandraEventStoreExtension() {
-        super(ImmutableSet.of(new TestEventDTOModule()));
+        super(ImmutableSet.of(TestEventDTOModules.TEST_TYPE));
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/a999bd60/event-sourcing/event-store-cassandra/src/test/java/org/apache/james/eventsourcing/eventstore/cassandra/JsonEventSerializerTest.java
----------------------------------------------------------------------
diff --git a/event-sourcing/event-store-cassandra/src/test/java/org/apache/james/eventsourcing/eventstore/cassandra/JsonEventSerializerTest.java b/event-sourcing/event-store-cassandra/src/test/java/org/apache/james/eventsourcing/eventstore/cassandra/JsonEventSerializerTest.java
index eadb69e..bfa669f 100644
--- a/event-sourcing/event-store-cassandra/src/test/java/org/apache/james/eventsourcing/eventstore/cassandra/JsonEventSerializerTest.java
+++ b/event-sourcing/event-store-cassandra/src/test/java/org/apache/james/eventsourcing/eventstore/cassandra/JsonEventSerializerTest.java
@@ -27,8 +27,7 @@ import org.apache.james.eventsourcing.EventId;
 import org.apache.james.eventsourcing.TestAggregateId;
 import org.apache.james.eventsourcing.TestEvent;
 import org.apache.james.eventsourcing.eventstore.cassandra.dto.OtherEvent;
-import org.apache.james.eventsourcing.eventstore.cassandra.dto.OtherTestEventDTOModule;
-import org.apache.james.eventsourcing.eventstore.cassandra.dto.TestEventDTOModule;
+import org.apache.james.eventsourcing.eventstore.cassandra.dto.TestEventDTOModules;
 import org.junit.jupiter.api.Test;
 
 class JsonEventSerializerTest {
@@ -43,7 +42,7 @@ class JsonEventSerializerTest {
 
     @Test
     void shouldDeserializeKnownEvent() throws Exception {
-        assertThat(new JsonEventSerializer(new TestEventDTOModule())
+        assertThat(new JsonEventSerializer(TestEventDTOModules.TEST_TYPE)
             .deserialize(TEST_EVENT_JSON))
             .isEqualTo(TEST_EVENT);
     }
@@ -58,8 +57,8 @@ class JsonEventSerializerTest {
     @Test
     void serializeShouldHandleAllKnownEvents() throws Exception {
         JsonEventSerializer jsonEventSerializer = new JsonEventSerializer(
-            new TestEventDTOModule(),
-            new OtherTestEventDTOModule());
+            TestEventDTOModules.TEST_TYPE,
+            TestEventDTOModules.OTHER_TEST_TYPE);
 
         assertThatJson(
             jsonEventSerializer.serialize(OTHER_EVENT))
@@ -73,8 +72,8 @@ class JsonEventSerializerTest {
     @Test
     void deserializeShouldHandleAllKnownEvents() throws Exception {
         JsonEventSerializer jsonEventSerializer = new JsonEventSerializer(
-            new TestEventDTOModule(),
-            new OtherTestEventDTOModule());
+            TestEventDTOModules.TEST_TYPE,
+            TestEventDTOModules.OTHER_TEST_TYPE);
 
         assertThatJson(
             jsonEventSerializer.deserialize(OTHER_EVENT_JSON))
@@ -87,7 +86,7 @@ class JsonEventSerializerTest {
 
     @Test
     void shouldSerializeKnownEvent() throws Exception {
-        assertThatJson(new JsonEventSerializer(new TestEventDTOModule())
+        assertThatJson(new JsonEventSerializer(TestEventDTOModules.TEST_TYPE)
             .serialize(TEST_EVENT))
             .isEqualTo(TEST_EVENT_JSON);
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/a999bd60/event-sourcing/event-store-cassandra/src/test/java/org/apache/james/eventsourcing/eventstore/cassandra/dto/OtherTestEventDTOModule.java
----------------------------------------------------------------------
diff --git a/event-sourcing/event-store-cassandra/src/test/java/org/apache/james/eventsourcing/eventstore/cassandra/dto/OtherTestEventDTOModule.java b/event-sourcing/event-store-cassandra/src/test/java/org/apache/james/eventsourcing/eventstore/cassandra/dto/OtherTestEventDTOModule.java
deleted file mode 100644
index d025add..0000000
--- a/event-sourcing/event-store-cassandra/src/test/java/org/apache/james/eventsourcing/eventstore/cassandra/dto/OtherTestEventDTOModule.java
+++ /dev/null
@@ -1,55 +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.eventsourcing.eventstore.cassandra.dto;
-
-import org.apache.james.eventsourcing.Event;
-import org.testcontainers.shaded.com.google.common.base.Preconditions;
-
-public class OtherTestEventDTOModule implements EventDTOModule {
-
-    public static final String OTHER_TYPE = "other-type";
-
-    @Override
-    public String getType() {
-        return OTHER_TYPE;
-    }
-
-    @Override
-    public Class<? extends EventDTO> getDTOClass() {
-        return OtherTestEventDTO.class;
-    }
-
-    @Override
-    public Class<? extends Event> getEventClass() {
-        return OtherEvent.class;
-    }
-
-    @Override
-    public EventDTO toDTO(Event event) {
-        Preconditions.checkArgument(event instanceof OtherEvent);
-        OtherEvent otherEvent = (OtherEvent) event;
-
-        return new OtherTestEventDTO(
-            OTHER_TYPE,
-            otherEvent.getPayload(),
-            otherEvent.eventId().serialize(),
-            otherEvent.getAggregateId().getId());
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/a999bd60/event-sourcing/event-store-cassandra/src/test/java/org/apache/james/eventsourcing/eventstore/cassandra/dto/TestEventDTOModule.java
----------------------------------------------------------------------
diff --git a/event-sourcing/event-store-cassandra/src/test/java/org/apache/james/eventsourcing/eventstore/cassandra/dto/TestEventDTOModule.java b/event-sourcing/event-store-cassandra/src/test/java/org/apache/james/eventsourcing/eventstore/cassandra/dto/TestEventDTOModule.java
deleted file mode 100644
index f0613ee..0000000
--- a/event-sourcing/event-store-cassandra/src/test/java/org/apache/james/eventsourcing/eventstore/cassandra/dto/TestEventDTOModule.java
+++ /dev/null
@@ -1,56 +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.eventsourcing.eventstore.cassandra.dto;
-
-import org.apache.james.eventsourcing.Event;
-import org.apache.james.eventsourcing.TestEvent;
-import org.testcontainers.shaded.com.google.common.base.Preconditions;
-
-public class TestEventDTOModule implements EventDTOModule {
-
-    public static final String TEST_TYPE = "TestType";
-
-    @Override
-    public String getType() {
-        return TEST_TYPE;
-    }
-
-    @Override
-    public Class<? extends EventDTO> getDTOClass() {
-        return TestEventDTO.class;
-    }
-
-    @Override
-    public Class<? extends Event> getEventClass() {
-        return TestEvent.class;
-    }
-
-    @Override
-    public EventDTO toDTO(Event event) {
-        Preconditions.checkArgument(event instanceof TestEvent);
-
-        TestEvent testEvent = (TestEvent) event;
-        return new TestEventDTO(
-            TEST_TYPE,
-            testEvent.getData(),
-            testEvent.eventId().serialize(),
-            testEvent.getAggregateId().getId());
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/a999bd60/event-sourcing/event-store-cassandra/src/test/java/org/apache/james/eventsourcing/eventstore/cassandra/dto/TestEventDTOModules.java
----------------------------------------------------------------------
diff --git a/event-sourcing/event-store-cassandra/src/test/java/org/apache/james/eventsourcing/eventstore/cassandra/dto/TestEventDTOModules.java b/event-sourcing/event-store-cassandra/src/test/java/org/apache/james/eventsourcing/eventstore/cassandra/dto/TestEventDTOModules.java
new file mode 100644
index 0000000..1040380
--- /dev/null
+++ b/event-sourcing/event-store-cassandra/src/test/java/org/apache/james/eventsourcing/eventstore/cassandra/dto/TestEventDTOModules.java
@@ -0,0 +1,47 @@
+/****************************************************************
+ * 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.eventsourcing.eventstore.cassandra.dto;
+
+import org.apache.james.eventsourcing.TestEvent;
+
+public interface TestEventDTOModules {
+
+    EventDTOModule<TestEvent, TestEventDTO> TEST_TYPE =
+        EventDTOModule
+            .forEvent(TestEvent.class)
+            .convertToDTO(TestEventDTO.class)
+            .convertWith((event, typeName) -> new TestEventDTO(
+                typeName,
+                event.getData(),
+                event.eventId().serialize(),
+                event.getAggregateId().getId()))
+            .typeName("TestType");
+
+    EventDTOModule<OtherEvent, OtherTestEventDTO> OTHER_TEST_TYPE =
+        EventDTOModule
+            .forEvent(OtherEvent.class)
+            .convertToDTO(OtherTestEventDTO.class)
+            .convertWith(((event, typeName) -> new OtherTestEventDTO(
+                typeName,
+                event.getPayload(),
+                event.eventId().serialize(),
+                event.getAggregateId().getId())))
+            .typeName("other-type");
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/a999bd60/mailbox/plugin/quota-mailing-cassandra/src/main/java/org/apache/james/mailbox/quota/cassandra/dto/QuotaEventDTOModules.java
----------------------------------------------------------------------
diff --git a/mailbox/plugin/quota-mailing-cassandra/src/main/java/org/apache/james/mailbox/quota/cassandra/dto/QuotaEventDTOModules.java b/mailbox/plugin/quota-mailing-cassandra/src/main/java/org/apache/james/mailbox/quota/cassandra/dto/QuotaEventDTOModules.java
new file mode 100644
index 0000000..1697d5e
--- /dev/null
+++ b/mailbox/plugin/quota-mailing-cassandra/src/main/java/org/apache/james/mailbox/quota/cassandra/dto/QuotaEventDTOModules.java
@@ -0,0 +1,34 @@
+/****************************************************************
+ * 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.mailbox.quota.cassandra.dto;
+
+import org.apache.james.eventsourcing.eventstore.cassandra.dto.EventDTOModule;
+import org.apache.james.mailbox.quota.mailing.events.QuotaThresholdChangedEvent;
+
+public interface QuotaEventDTOModules {
+
+    EventDTOModule<QuotaThresholdChangedEvent, QuotaThresholdChangedEventDTO> QUOTA_THRESHOLD_CHANGE =
+        EventDTOModule
+            .forEvent(QuotaThresholdChangedEvent.class)
+            .convertToDTO(QuotaThresholdChangedEventDTO.class)
+            .convertWith(QuotaThresholdChangedEventDTO::from)
+            .typeName("quota-threshold-change");
+
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/a999bd60/mailbox/plugin/quota-mailing-cassandra/src/main/java/org/apache/james/mailbox/quota/cassandra/dto/QuotaThresholdChangedEventDTOModule.java
----------------------------------------------------------------------
diff --git a/mailbox/plugin/quota-mailing-cassandra/src/main/java/org/apache/james/mailbox/quota/cassandra/dto/QuotaThresholdChangedEventDTOModule.java b/mailbox/plugin/quota-mailing-cassandra/src/main/java/org/apache/james/mailbox/quota/cassandra/dto/QuotaThresholdChangedEventDTOModule.java
deleted file mode 100644
index 7c37b7f..0000000
--- a/mailbox/plugin/quota-mailing-cassandra/src/main/java/org/apache/james/mailbox/quota/cassandra/dto/QuotaThresholdChangedEventDTOModule.java
+++ /dev/null
@@ -1,54 +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.mailbox.quota.cassandra.dto;
-
-import org.apache.james.eventsourcing.Event;
-import org.apache.james.eventsourcing.eventstore.cassandra.dto.EventDTO;
-import org.apache.james.eventsourcing.eventstore.cassandra.dto.EventDTOModule;
-import org.apache.james.mailbox.quota.mailing.events.QuotaThresholdChangedEvent;
-
-import com.google.common.base.Preconditions;
-
-public class QuotaThresholdChangedEventDTOModule implements EventDTOModule {
-    private static final String QUOTA_THRESHOLD_CHANGE = "quota-threshold-change";
-
-    @Override
-    public String getType() {
-        return QUOTA_THRESHOLD_CHANGE;
-    }
-
-    @Override
-    public Class<? extends EventDTO> getDTOClass() {
-        return QuotaThresholdChangedEventDTO.class;
-    }
-
-    @Override
-    public Class<? extends Event> getEventClass() {
-        return QuotaThresholdChangedEvent.class;
-    }
-
-    @Override
-    public EventDTO toDTO(Event event) {
-        Preconditions.checkArgument(event instanceof QuotaThresholdChangedEvent);
-        return QuotaThresholdChangedEventDTO.from(
-            (QuotaThresholdChangedEvent) event,
-            QUOTA_THRESHOLD_CHANGE);
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/a999bd60/mailbox/plugin/quota-mailing-cassandra/src/test/java/org/apache/james/mailbox/quota/cassandra/dto/DTOTest.java
----------------------------------------------------------------------
diff --git a/mailbox/plugin/quota-mailing-cassandra/src/test/java/org/apache/james/mailbox/quota/cassandra/dto/DTOTest.java b/mailbox/plugin/quota-mailing-cassandra/src/test/java/org/apache/james/mailbox/quota/cassandra/dto/DTOTest.java
index 7556e38..e644f97 100644
--- a/mailbox/plugin/quota-mailing-cassandra/src/test/java/org/apache/james/mailbox/quota/cassandra/dto/DTOTest.java
+++ b/mailbox/plugin/quota-mailing-cassandra/src/test/java/org/apache/james/mailbox/quota/cassandra/dto/DTOTest.java
@@ -133,7 +133,7 @@ class DTOTest {
     @Test
     void shouldSerializeQuotaThresholdChangedEventDTO() throws Exception {
         assertThatJson(objectMapper.writeValueAsString(
-            new QuotaThresholdChangedEventDTOModule().toDTO(EVENT)))
+            QuotaEventDTOModules.QUOTA_THRESHOLD_CHANGE.toDTO(EVENT)))
             .isEqualTo(EVENT_JSON);
     }
 
@@ -146,56 +146,56 @@ class DTOTest {
 
     @Test
     void shouldSerializeQuotaThresholdChangedEvent() throws Exception {
-        assertThatJson(new JsonEventSerializer(new QuotaThresholdChangedEventDTOModule())
+        assertThatJson(new JsonEventSerializer(QuotaEventDTOModules.QUOTA_THRESHOLD_CHANGE)
             .serialize(EVENT))
             .isEqualTo(EVENT_JSON);
     }
 
     @Test
     void shouldDeserializeQuotaThresholdChangedEvent() throws Exception {
-        assertThatJson(new JsonEventSerializer(new QuotaThresholdChangedEventDTOModule())
+        assertThatJson(new JsonEventSerializer(QuotaEventDTOModules.QUOTA_THRESHOLD_CHANGE)
             .deserialize(EVENT_JSON))
             .isEqualTo(EVENT);
     }
 
     @Test
     void shouldSerializeEvent2() throws Exception {
-        assertThatJson(new JsonEventSerializer(new QuotaThresholdChangedEventDTOModule())
+        assertThatJson(new JsonEventSerializer(QuotaEventDTOModules.QUOTA_THRESHOLD_CHANGE)
             .serialize(EVENT_2))
             .isEqualTo(EVENT_JSON_2);
     }
 
     @Test
     void shouldDeserializeEvent2() throws Exception {
-        assertThatJson(new JsonEventSerializer(new QuotaThresholdChangedEventDTOModule())
+        assertThatJson(new JsonEventSerializer(QuotaEventDTOModules.QUOTA_THRESHOLD_CHANGE)
             .deserialize(EVENT_JSON_2))
             .isEqualTo(EVENT_2);
     }
 
     @Test
     void shouldSerializeEvent3() throws Exception {
-        assertThatJson(new JsonEventSerializer(new QuotaThresholdChangedEventDTOModule())
+        assertThatJson(new JsonEventSerializer(QuotaEventDTOModules.QUOTA_THRESHOLD_CHANGE)
             .serialize(EVENT_3))
             .isEqualTo(EVENT_JSON_3);
     }
 
     @Test
     void shouldDeserializeEvent3() throws Exception {
-        assertThatJson(new JsonEventSerializer(new QuotaThresholdChangedEventDTOModule())
+        assertThatJson(new JsonEventSerializer(QuotaEventDTOModules.QUOTA_THRESHOLD_CHANGE)
             .deserialize(EVENT_JSON_3))
             .isEqualTo(EVENT_3);
     }
 
     @Test
     void shouldSerializeEvent4() throws Exception {
-        assertThatJson(new JsonEventSerializer(new QuotaThresholdChangedEventDTOModule())
+        assertThatJson(new JsonEventSerializer(QuotaEventDTOModules.QUOTA_THRESHOLD_CHANGE)
             .serialize(EVENT_4))
             .isEqualTo(EVENT_JSON_4);
     }
 
     @Test
     void shouldDeserializeEvent4() throws Exception {
-        assertThatJson(new JsonEventSerializer(new QuotaThresholdChangedEventDTOModule())
+        assertThatJson(new JsonEventSerializer(QuotaEventDTOModules.QUOTA_THRESHOLD_CHANGE)
             .deserialize(EVENT_JSON_4))
             .isEqualTo(EVENT_4);
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/a999bd60/mailbox/plugin/quota-mailing-cassandra/src/test/java/org/apache/james/mailbox/quota/cassandra/listeners/CassandraEventStoreExtension.java
----------------------------------------------------------------------
diff --git a/mailbox/plugin/quota-mailing-cassandra/src/test/java/org/apache/james/mailbox/quota/cassandra/listeners/CassandraEventStoreExtension.java b/mailbox/plugin/quota-mailing-cassandra/src/test/java/org/apache/james/mailbox/quota/cassandra/listeners/CassandraEventStoreExtension.java
index f46a605..0218c78 100644
--- a/mailbox/plugin/quota-mailing-cassandra/src/test/java/org/apache/james/mailbox/quota/cassandra/listeners/CassandraEventStoreExtension.java
+++ b/mailbox/plugin/quota-mailing-cassandra/src/test/java/org/apache/james/mailbox/quota/cassandra/listeners/CassandraEventStoreExtension.java
@@ -20,13 +20,12 @@
 package org.apache.james.mailbox.quota.cassandra.listeners;
 
 import org.apache.james.eventsourcing.eventstore.cassandra.CassandraGenericEventStoreExtension;
-import org.apache.james.mailbox.quota.cassandra.dto.QuotaThresholdChangedEventDTOModule;
+import org.apache.james.mailbox.quota.cassandra.dto.QuotaEventDTOModules;
 
 import com.google.common.collect.ImmutableSet;
 
 public class CassandraEventStoreExtension extends CassandraGenericEventStoreExtension {
     public CassandraEventStoreExtension() {
-        super(ImmutableSet.of(
-            new QuotaThresholdChangedEventDTOModule()));
+        super(ImmutableSet.of(QuotaEventDTOModules.QUOTA_THRESHOLD_CHANGE));
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/a999bd60/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/data/CassandraDLPConfigurationStoreModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/data/CassandraDLPConfigurationStoreModule.java b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/data/CassandraDLPConfigurationStoreModule.java
index 5d3abc7..1ee1595 100644
--- a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/data/CassandraDLPConfigurationStoreModule.java
+++ b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/data/CassandraDLPConfigurationStoreModule.java
@@ -21,8 +21,7 @@ package org.apache.james.modules.data;
 
 import org.apache.james.dlp.api.DLPConfigurationStore;
 import org.apache.james.dlp.eventsourcing.EventSourcingDLPConfigurationStore;
-import org.apache.james.dlp.eventsourcing.cassandra.DLPConfigurationItemAddedDTOModule;
-import org.apache.james.dlp.eventsourcing.cassandra.DLPConfigurationItemsRemovedDTOModule;
+import org.apache.james.dlp.eventsourcing.cassandra.DLPConfigurationModules;
 import org.apache.james.eventsourcing.eventstore.cassandra.dto.EventDTOModule;
 
 import com.google.inject.AbstractModule;
@@ -38,7 +37,7 @@ public class CassandraDLPConfigurationStoreModule extends AbstractModule {
 
         Multibinder<EventDTOModule> eventDTOModuleBinder = Multibinder.newSetBinder(binder(), EventDTOModule.class);
 
-        eventDTOModuleBinder.addBinding().to(DLPConfigurationItemAddedDTOModule.class);
-        eventDTOModuleBinder.addBinding().to(DLPConfigurationItemsRemovedDTOModule.class);
+        eventDTOModuleBinder.addBinding().toInstance(DLPConfigurationModules.DLP_CONFIGURATION_STORE);
+        eventDTOModuleBinder.addBinding().toInstance(DLPConfigurationModules.DLP_CONFIGURATION_CLEAR);
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/a999bd60/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraQuotaMailingModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraQuotaMailingModule.java b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraQuotaMailingModule.java
index f81d572..c33137e 100644
--- a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraQuotaMailingModule.java
+++ b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraQuotaMailingModule.java
@@ -20,7 +20,7 @@
 package org.apache.james.modules.mailbox;
 
 import org.apache.james.eventsourcing.eventstore.cassandra.dto.EventDTOModule;
-import org.apache.james.mailbox.quota.cassandra.dto.QuotaThresholdChangedEventDTOModule;
+import org.apache.james.mailbox.quota.cassandra.dto.QuotaEventDTOModules;
 
 import com.google.inject.AbstractModule;
 import com.google.inject.multibindings.Multibinder;
@@ -30,6 +30,6 @@ public class CassandraQuotaMailingModule extends AbstractModule {
     protected void configure() {
         Multibinder.newSetBinder(binder(), EventDTOModule.class)
             .addBinding()
-            .to(QuotaThresholdChangedEventDTOModule.class);
+            .toInstance(QuotaEventDTOModules.QUOTA_THRESHOLD_CHANGE);
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/a999bd60/server/data/data-cassandra/src/main/java/org/apache/james/dlp/eventsourcing/cassandra/DLPConfigurationItemAddedDTOModule.java
----------------------------------------------------------------------
diff --git a/server/data/data-cassandra/src/main/java/org/apache/james/dlp/eventsourcing/cassandra/DLPConfigurationItemAddedDTOModule.java b/server/data/data-cassandra/src/main/java/org/apache/james/dlp/eventsourcing/cassandra/DLPConfigurationItemAddedDTOModule.java
deleted file mode 100644
index d38808b..0000000
--- a/server/data/data-cassandra/src/main/java/org/apache/james/dlp/eventsourcing/cassandra/DLPConfigurationItemAddedDTOModule.java
+++ /dev/null
@@ -1,53 +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.dlp.eventsourcing.cassandra;
-
-import org.apache.james.dlp.eventsourcing.events.ConfigurationItemsAdded;
-import org.apache.james.eventsourcing.Event;
-import org.apache.james.eventsourcing.eventstore.cassandra.dto.EventDTO;
-import org.apache.james.eventsourcing.eventstore.cassandra.dto.EventDTOModule;
-
-import com.google.common.base.Preconditions;
-
-public class DLPConfigurationItemAddedDTOModule implements EventDTOModule {
-    private static final String DLP_CONFIGURATION_STORE = "dlp-configuration-store";
-
-    @Override
-    public String getType() {
-        return DLP_CONFIGURATION_STORE;
-    }
-
-    @Override
-    public Class<? extends EventDTO> getDTOClass() {
-        return DLPConfigurationItemAddedDTO.class;
-    }
-
-    @Override
-    public Class<? extends Event> getEventClass() {
-        return ConfigurationItemsAdded.class;
-    }
-
-    @Override
-    public EventDTO toDTO(Event event) {
-        Preconditions.checkArgument(event instanceof ConfigurationItemsAdded);
-        return DLPConfigurationItemAddedDTO
-            .from((ConfigurationItemsAdded) event, DLP_CONFIGURATION_STORE);
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/a999bd60/server/data/data-cassandra/src/main/java/org/apache/james/dlp/eventsourcing/cassandra/DLPConfigurationItemsRemovedDTOModule.java
----------------------------------------------------------------------
diff --git a/server/data/data-cassandra/src/main/java/org/apache/james/dlp/eventsourcing/cassandra/DLPConfigurationItemsRemovedDTOModule.java b/server/data/data-cassandra/src/main/java/org/apache/james/dlp/eventsourcing/cassandra/DLPConfigurationItemsRemovedDTOModule.java
deleted file mode 100644
index 9e259cd..0000000
--- a/server/data/data-cassandra/src/main/java/org/apache/james/dlp/eventsourcing/cassandra/DLPConfigurationItemsRemovedDTOModule.java
+++ /dev/null
@@ -1,53 +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.dlp.eventsourcing.cassandra;
-
-import org.apache.james.dlp.eventsourcing.events.ConfigurationItemsRemoved;
-import org.apache.james.eventsourcing.Event;
-import org.apache.james.eventsourcing.eventstore.cassandra.dto.EventDTO;
-import org.apache.james.eventsourcing.eventstore.cassandra.dto.EventDTOModule;
-
-import com.google.common.base.Preconditions;
-
-public class DLPConfigurationItemsRemovedDTOModule implements EventDTOModule {
-    private static final String DLP_CONFIGURATION_CLEAR = "dlp-configuration-clear";
-
-    @Override
-    public String getType() {
-        return DLP_CONFIGURATION_CLEAR;
-    }
-
-    @Override
-    public Class<? extends EventDTO> getDTOClass() {
-        return DLPConfigurationItemsRemovedDTO.class;
-    }
-
-    @Override
-    public Class<? extends Event> getEventClass() {
-        return ConfigurationItemsRemoved.class;
-    }
-
-    @Override
-    public EventDTO toDTO(Event event) {
-        Preconditions.checkArgument(event instanceof ConfigurationItemsRemoved);
-        return DLPConfigurationItemsRemovedDTO
-            .from((ConfigurationItemsRemoved) event, DLP_CONFIGURATION_CLEAR);
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/a999bd60/server/data/data-cassandra/src/main/java/org/apache/james/dlp/eventsourcing/cassandra/DLPConfigurationModules.java
----------------------------------------------------------------------
diff --git a/server/data/data-cassandra/src/main/java/org/apache/james/dlp/eventsourcing/cassandra/DLPConfigurationModules.java b/server/data/data-cassandra/src/main/java/org/apache/james/dlp/eventsourcing/cassandra/DLPConfigurationModules.java
new file mode 100644
index 0000000..c068900
--- /dev/null
+++ b/server/data/data-cassandra/src/main/java/org/apache/james/dlp/eventsourcing/cassandra/DLPConfigurationModules.java
@@ -0,0 +1,43 @@
+/****************************************************************
+ * 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.dlp.eventsourcing.cassandra;
+
+import org.apache.james.dlp.eventsourcing.events.ConfigurationItemsAdded;
+import org.apache.james.dlp.eventsourcing.events.ConfigurationItemsRemoved;
+import org.apache.james.eventsourcing.eventstore.cassandra.dto.EventDTOModule;
+
+public interface DLPConfigurationModules {
+
+    EventDTOModule<ConfigurationItemsAdded, DLPConfigurationItemAddedDTO> DLP_CONFIGURATION_STORE =
+        EventDTOModule
+            .forEvent(ConfigurationItemsAdded.class)
+            .convertToDTO(DLPConfigurationItemAddedDTO.class)
+            .convertWith(DLPConfigurationItemAddedDTO::from)
+            .typeName("dlp-configuration-store");
+
+    EventDTOModule<ConfigurationItemsRemoved, DLPConfigurationItemsRemovedDTO> DLP_CONFIGURATION_CLEAR =
+        EventDTOModule
+            .forEvent(ConfigurationItemsRemoved.class)
+            .convertToDTO(DLPConfigurationItemsRemovedDTO.class)
+            .convertWith(DLPConfigurationItemsRemovedDTO::from)
+            .typeName("dlp-configuration-clear");
+
+
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/a999bd60/server/data/data-cassandra/src/test/java/org/apache/james/dlp/eventsourcing/cassandra/CassandraEventSourcingDLPConfigurationStoreExtension.java
----------------------------------------------------------------------
diff --git a/server/data/data-cassandra/src/test/java/org/apache/james/dlp/eventsourcing/cassandra/CassandraEventSourcingDLPConfigurationStoreExtension.java b/server/data/data-cassandra/src/test/java/org/apache/james/dlp/eventsourcing/cassandra/CassandraEventSourcingDLPConfigurationStoreExtension.java
index e5d04fb..1f152d2 100644
--- a/server/data/data-cassandra/src/test/java/org/apache/james/dlp/eventsourcing/cassandra/CassandraEventSourcingDLPConfigurationStoreExtension.java
+++ b/server/data/data-cassandra/src/test/java/org/apache/james/dlp/eventsourcing/cassandra/CassandraEventSourcingDLPConfigurationStoreExtension.java
@@ -73,7 +73,9 @@ public class CassandraEventSourcingDLPConfigurationStoreExtension implements Bef
     @Override
     public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
         JsonEventSerializer jsonEventSerializer = new JsonEventSerializer(
-            ImmutableSet.of(new DLPConfigurationItemAddedDTOModule(), new DLPConfigurationItemsRemovedDTOModule()));
+            ImmutableSet.of(
+                DLPConfigurationModules.DLP_CONFIGURATION_STORE,
+                DLPConfigurationModules.DLP_CONFIGURATION_CLEAR));
 
         EventStoreDao eventStoreDao = new EventStoreDao(
             cassandra.getConf(),

http://git-wip-us.apache.org/repos/asf/james-project/blob/a999bd60/server/data/data-jmap-cassandra/src/main/java/org/apache/james/jmap/cassandra/filtering/FilteringRuleSetDefineDTOModule.java
----------------------------------------------------------------------
diff --git a/server/data/data-jmap-cassandra/src/main/java/org/apache/james/jmap/cassandra/filtering/FilteringRuleSetDefineDTOModule.java b/server/data/data-jmap-cassandra/src/main/java/org/apache/james/jmap/cassandra/filtering/FilteringRuleSetDefineDTOModule.java
deleted file mode 100644
index 9a59fa6..0000000
--- a/server/data/data-jmap-cassandra/src/main/java/org/apache/james/jmap/cassandra/filtering/FilteringRuleSetDefineDTOModule.java
+++ /dev/null
@@ -1,52 +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.jmap.cassandra.filtering;
-
-import org.apache.james.eventsourcing.Event;
-import org.apache.james.eventsourcing.eventstore.cassandra.dto.EventDTO;
-import org.apache.james.eventsourcing.eventstore.cassandra.dto.EventDTOModule;
-import org.apache.james.jmap.api.filtering.impl.RuleSetDefined;
-
-import com.google.common.base.Preconditions;
-
-public class FilteringRuleSetDefineDTOModule implements EventDTOModule {
-    private static final String FILTERING_RULE_SET_DEFINED = "filtering-rule-set-defined";
-
-    @Override
-    public String getType() {
-        return FILTERING_RULE_SET_DEFINED;
-    }
-
-    @Override
-    public Class<? extends EventDTO> getDTOClass() {
-        return FilteringRuleSetDefinedDTO.class;
-    }
-
-    @Override
-    public Class<? extends Event> getEventClass() {
-        return RuleSetDefined.class;
-    }
-
-    @Override
-    public EventDTO toDTO(Event event) {
-        Preconditions.checkArgument(event instanceof RuleSetDefined);
-        return FilteringRuleSetDefinedDTO.from((RuleSetDefined) event, FILTERING_RULE_SET_DEFINED);
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/a999bd60/server/data/data-jmap-cassandra/src/main/java/org/apache/james/jmap/cassandra/filtering/FilteringRuleSetDefineDTOModules.java
----------------------------------------------------------------------
diff --git a/server/data/data-jmap-cassandra/src/main/java/org/apache/james/jmap/cassandra/filtering/FilteringRuleSetDefineDTOModules.java b/server/data/data-jmap-cassandra/src/main/java/org/apache/james/jmap/cassandra/filtering/FilteringRuleSetDefineDTOModules.java
new file mode 100644
index 0000000..0c56b1c
--- /dev/null
+++ b/server/data/data-jmap-cassandra/src/main/java/org/apache/james/jmap/cassandra/filtering/FilteringRuleSetDefineDTOModules.java
@@ -0,0 +1,34 @@
+/****************************************************************
+ * 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.jmap.cassandra.filtering;
+
+import org.apache.james.eventsourcing.eventstore.cassandra.dto.EventDTOModule;
+import org.apache.james.jmap.api.filtering.impl.RuleSetDefined;
+
+public interface FilteringRuleSetDefineDTOModules {
+
+    EventDTOModule<RuleSetDefined, FilteringRuleSetDefinedDTO> FILTERING_RULE_SET_DEFINED =
+        EventDTOModule
+            .forEvent(RuleSetDefined.class)
+            .convertToDTO(FilteringRuleSetDefinedDTO.class)
+            .convertWith(FilteringRuleSetDefinedDTO::from)
+            .typeName("filtering-rule-set-defined");
+
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/a999bd60/server/data/data-jmap-cassandra/src/main/java/org/apache/james/jmap/cassandra/filtering/FilteringRuleSetDefinedDTO.java
----------------------------------------------------------------------
diff --git a/server/data/data-jmap-cassandra/src/main/java/org/apache/james/jmap/cassandra/filtering/FilteringRuleSetDefinedDTO.java b/server/data/data-jmap-cassandra/src/main/java/org/apache/james/jmap/cassandra/filtering/FilteringRuleSetDefinedDTO.java
index c2357f9..5a0de2c 100644
--- a/server/data/data-jmap-cassandra/src/main/java/org/apache/james/jmap/cassandra/filtering/FilteringRuleSetDefinedDTO.java
+++ b/server/data/data-jmap-cassandra/src/main/java/org/apache/james/jmap/cassandra/filtering/FilteringRuleSetDefinedDTO.java
@@ -34,7 +34,7 @@ import com.google.common.collect.ImmutableList;
 
 public class FilteringRuleSetDefinedDTO implements EventDTO {
 
-    public static EventDTO from(RuleSetDefined event, String type) {
+    public static FilteringRuleSetDefinedDTO from(RuleSetDefined event, String type) {
         return new FilteringRuleSetDefinedDTO(
             type, event.eventId().serialize(),
             event.getAggregateId().asAggregateKey(),

http://git-wip-us.apache.org/repos/asf/james-project/blob/a999bd60/server/data/data-jmap-cassandra/src/test/java/org/apache/james/jmap/cassandra/filtering/CassandraFilteringExtension.java
----------------------------------------------------------------------
diff --git a/server/data/data-jmap-cassandra/src/test/java/org/apache/james/jmap/cassandra/filtering/CassandraFilteringExtension.java b/server/data/data-jmap-cassandra/src/test/java/org/apache/james/jmap/cassandra/filtering/CassandraFilteringExtension.java
index 522b45f..300bd5d 100644
--- a/server/data/data-jmap-cassandra/src/test/java/org/apache/james/jmap/cassandra/filtering/CassandraFilteringExtension.java
+++ b/server/data/data-jmap-cassandra/src/test/java/org/apache/james/jmap/cassandra/filtering/CassandraFilteringExtension.java
@@ -25,7 +25,6 @@ import com.google.common.collect.ImmutableSet;
 
 public class CassandraFilteringExtension extends CassandraGenericEventStoreExtension {
     public CassandraFilteringExtension() {
-        super(ImmutableSet.of(
-            new FilteringRuleSetDefineDTOModule()));
+        super(ImmutableSet.of(FilteringRuleSetDefineDTOModules.FILTERING_RULE_SET_DEFINED));
     }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org