jeantil commented on code in PR #2694:
URL: https://github.com/apache/james-project/pull/2694#discussion_r2022916006


##########
server/container/guice/mailet/src/main/java/org/apache/james/utils/GuiceMailetLoader.java:
##########
@@ -43,17 +43,22 @@ public class GuiceMailetLoader implements MailetLoader {
     public GuiceMailetLoader(GuiceGenericLoader genericLoader, 
Set<MailetConfigurationOverride> mailetConfigurationOverrides) {
         this.genericLoader = genericLoader;
         this.configurationOverrides = mailetConfigurationOverrides.stream()
-            .collect(ImmutableMap.toImmutableMap(
-                MailetConfigurationOverride::getClazz,
-                MailetConfigurationOverride::getNewConfiguration));
+                .collect(ImmutableMap.toImmutableMap(
+                        MailetConfigurationOverride::getClazz,
+                        MailetConfigurationOverride::getNewConfiguration));
     }
 
     @Override
     public Mailet getMailet(MailetConfig config) throws MessagingException {
         try {
             ClassName className = new ClassName(config.getMailetName());
-            Mailet result = 
genericLoader.<Mailet>withNamingSheme(MAILET_NAMING_SCHEME)
-                .instantiate(className);
+            var mailetLoader = 
genericLoader.<Mailet>withNamingSheme(MAILET_NAMING_SCHEME);
+            Class<Mailet> mailetClass = mailetLoader.locateClass(className);
+            MailetConfig mailetConfig = resolveConfiguration(mailetClass, 
config);
+            Mailet result = mailetLoader.withChildModule(
+                            binder -> 
binder.bind(MailetConfig.class).toInstance(mailetConfig)
+                    )

Review Comment:
   hmm I think I would rather have 
   ```
               Mailet result = mailetLoader.withChildModule(
                       binder -> 
binder.bind(MailetConfig.class).toInstance(mailetConfig)
               ).instantiate(className);
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org
For additional commands, e-mail: notifications-h...@james.apache.org

Reply via email to