Skip to content

Commit

Permalink
Simplify JMAP module structure
Browse files Browse the repository at this point in the history
  • Loading branch information
chibenwa committed Jan 20, 2025
1 parent 6932015 commit c0f37af
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 80 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
import org.apache.james.eventsourcing.eventstore.EventNestedTypes;
import org.apache.james.jmap.JMAPListenerModule;
import org.apache.james.jmap.JMAPModule;
import org.apache.james.jmap.rfc8621.BlobResolverModule;
import org.apache.james.jmap.rfc8621.RFC8621MethodsModule;
import org.apache.james.json.DTOModule;
import org.apache.james.modules.BlobExportMechanismModule;
import org.apache.james.modules.CassandraConsistencyTaskSerializationModule;
Expand Down Expand Up @@ -133,9 +131,7 @@ public class CassandraJamesServerMain implements JamesServerMain {
new ProtocolHandlerModule(),
new SMTPServerModule(),
new JMAPServerModule(),
new JMAPModule(),
new RFC8621MethodsModule(),
new BlobResolverModule(),
JMAPModule.INSTANCE,
new JmapEventBusModule(),
WEBADMIN);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
import org.apache.james.eventsourcing.eventstore.EventNestedTypes;
import org.apache.james.jmap.JMAPListenerModule;
import org.apache.james.jmap.JMAPModule;
import org.apache.james.jmap.rfc8621.BlobResolverModule;
import org.apache.james.jmap.rfc8621.RFC8621MethodsModule;
import org.apache.james.json.DTO;
import org.apache.james.json.DTOModule;
import org.apache.james.modules.BlobExportMechanismModule;
Expand Down Expand Up @@ -141,9 +139,7 @@ public class CassandraRabbitMQJamesServerMain implements JamesServerMain {
new ProtocolHandlerModule(),
new SMTPServerModule(),
new JMAPServerModule(),
new JMAPModule(),
new RFC8621MethodsModule(),
new BlobResolverModule(),
JMAPModule.INSTANCE,
new JmapEventBusModule(),
WEBADMIN);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
import org.apache.james.data.UsersRepositoryModuleChooser;
import org.apache.james.eventsourcing.eventstore.EventNestedTypes;
import org.apache.james.jmap.JMAPModule;
import org.apache.james.jmap.rfc8621.BlobResolverModule;
import org.apache.james.jmap.rfc8621.RFC8621MethodsModule;
import org.apache.james.json.DTO;
import org.apache.james.json.DTOModule;
import org.apache.james.mailbox.NoACLMapper;
Expand Down Expand Up @@ -130,9 +128,7 @@ public class DistributedPOP3JamesServerMain implements JamesServerMain {
public static final Module PROTOCOLS = Modules.combine(
new LMTPServerModule(),
new JMAPServerModule(),
new JMAPModule(),
new RFC8621MethodsModule(),
new BlobResolverModule(),
JMAPModule.INSTANCE,
new JMAPEventBusModule(),
new ManageSieveServerModule(),
new POP3ServerModule(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
import org.apache.james.jmap.api.identity.CustomIdentityDAO;
import org.apache.james.jmap.memory.identity.MemoryCustomIdentityDAO;
import org.apache.james.jmap.memory.pushsubscription.MemoryPushSubscriptionModule;
import org.apache.james.jmap.rfc8621.BlobResolverModule;
import org.apache.james.jmap.rfc8621.RFC8621MethodsModule;
import org.apache.james.jwt.JwtConfiguration;
import org.apache.james.modules.BlobExportMechanismModule;
import org.apache.james.modules.BlobMemoryModule;
Expand Down Expand Up @@ -124,9 +122,7 @@ public class MemoryJamesServerMain implements JamesServerMain {
new JmapTasksModule(),
new MemoryDataJmapModule(),
new MemoryPushSubscriptionModule(),
new JMAPModule(),
new RFC8621MethodsModule(),
new BlobResolverModule(),
JMAPModule.INSTANCE,
new JMAPServerModule());

public static final Module IN_MEMORY_SERVER_MODULE = Modules.combine(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.Optional;
import java.util.stream.Stream;

import com.google.inject.Module;
import jakarta.inject.Named;

import org.apache.commons.configuration2.Configuration;
Expand All @@ -47,6 +48,11 @@
import org.apache.james.jmap.core.VacationResponseCapabilityFactory$;
import org.apache.james.jmap.core.WebSocketCapabilityFactory$;
import org.apache.james.jmap.mailet.filter.JMAPFiltering;
import org.apache.james.jmap.rfc8621.RFC8621MethodsModule;
import org.apache.james.jmap.routes.BlobResolver;
import org.apache.james.jmap.routes.MessageBlobResolver;
import org.apache.james.jmap.routes.MessagePartBlobResolver;
import org.apache.james.jmap.routes.UploadResolver;
import org.apache.james.jmap.send.PostDequeueDecoratorFactory;
import org.apache.james.jmap.utils.JsoupHtmlTextExtractor;
import org.apache.james.jwt.JwtConfiguration;
Expand All @@ -63,7 +69,10 @@
import org.apache.james.transport.matchers.RecipientIsLocal;
import org.apache.james.util.Port;
import org.apache.james.util.Size;
import org.apache.james.util.date.DefaultZonedDateTimeProvider;
import org.apache.james.util.date.ZonedDateTimeProvider;
import org.apache.james.util.html.HtmlTextExtractor;
import org.apache.james.util.mime.MessageContentExtractor;
import org.apache.james.utils.PropertiesProvider;
import org.apache.mailet.Mail;
import org.slf4j.Logger;
Expand All @@ -81,6 +90,18 @@
import com.google.inject.multibindings.ProvidesIntoSet;

public class JMAPModule extends AbstractModule {
public static Module BLOBS_RESOLVERS = binder -> {
Multibinder<BlobResolver> blobResolverMultibinder = Multibinder.newSetBinder(binder, BlobResolver.class);
blobResolverMultibinder.addBinding().to(MessageBlobResolver.class);
blobResolverMultibinder.addBinding().to(UploadResolver.class);
blobResolverMultibinder.addBinding().to(MessagePartBlobResolver.class);
};
public static Module INSTANCE = binder -> {
binder.install(new JMAPModule());
binder.install(new RFC8621MethodsModule());
binder.install(BLOBS_RESOLVERS);
};

private static final int DEFAULT_JMAP_PORT = 80;
private static final Logger LOGGER = LoggerFactory.getLogger(JMAPModule.class);
public static final MailetContainerModule.DefaultProcessorsConfigurationSupplier DEFAULT_JMAP_PROCESSORS_CONFIGURATION_SUPPLIER =
Expand Down Expand Up @@ -114,10 +135,12 @@ public class JMAPModule extends AbstractModule {

@Override
protected void configure() {
install(new JMAPWithoutDraftCommonModule());
install(binder -> binder
.bind(MailetContainerModule.DefaultProcessorsConfigurationSupplier.class)
.toInstance(DEFAULT_JMAP_PROCESSORS_CONFIGURATION_SUPPLIER));
bind(MessageContentExtractor.class).in(Scopes.SINGLETON);
bind(DefaultZonedDateTimeProvider.class).in(Scopes.SINGLETON);
bind(ZonedDateTimeProvider.class).to(DefaultZonedDateTimeProvider.class);

bind(MailetContainerModule.DefaultProcessorsConfigurationSupplier.class)
.toInstance(DEFAULT_JMAP_PROCESSORS_CONFIGURATION_SUPPLIER);

bind(JMAPServer.class).in(Scopes.SINGLETON);
bind(JsoupHtmlTextExtractor.class).in(Scopes.SINGLETON);
Expand Down

This file was deleted.

This file was deleted.

0 comments on commit c0f37af

Please sign in to comment.