Commit d2f63c762f0ce0327d9179b1dd2a784511c386b8

Authored by Igor Kulikov
1 parent cd0e8643

Fix circular dependency

@@ -21,7 +21,9 @@ import freemarker.template.Template; @@ -21,7 +21,9 @@ import freemarker.template.Template;
21 import lombok.extern.slf4j.Slf4j; 21 import lombok.extern.slf4j.Slf4j;
22 import org.apache.commons.lang3.StringUtils; 22 import org.apache.commons.lang3.StringUtils;
23 import org.jetbrains.annotations.NotNull; 23 import org.jetbrains.annotations.NotNull;
  24 +import org.springframework.beans.factory.annotation.Autowired;
24 import org.springframework.context.MessageSource; 25 import org.springframework.context.MessageSource;
  26 +import org.springframework.context.annotation.Lazy;
25 import org.springframework.core.NestedRuntimeException; 27 import org.springframework.core.NestedRuntimeException;
26 import org.springframework.mail.javamail.JavaMailSenderImpl; 28 import org.springframework.mail.javamail.JavaMailSenderImpl;
27 import org.springframework.mail.javamail.MimeMessageHelper; 29 import org.springframework.mail.javamail.MimeMessageHelper;
@@ -63,18 +65,20 @@ public class DefaultMailService implements MailService { @@ -63,18 +65,20 @@ public class DefaultMailService implements MailService {
63 private final MessageSource messages; 65 private final MessageSource messages;
64 private final Configuration freemarkerConfig; 66 private final Configuration freemarkerConfig;
65 private final AdminSettingsService adminSettingsService; 67 private final AdminSettingsService adminSettingsService;
66 - private final TbApiUsageStateService apiUsageStateService;  
67 private final TbApiUsageClient apiUsageClient; 68 private final TbApiUsageClient apiUsageClient;
68 69
  70 + @Lazy
  71 + @Autowired
  72 + private TbApiUsageStateService apiUsageStateService;
  73 +
69 private JavaMailSenderImpl mailSender; 74 private JavaMailSenderImpl mailSender;
70 75
71 private String mailFrom; 76 private String mailFrom;
72 77
73 - public DefaultMailService(MessageSource messages, Configuration freemarkerConfig, AdminSettingsService adminSettingsService, TbApiUsageStateService apiUsageStateService, TbApiUsageClient apiUsageClient) { 78 + public DefaultMailService(MessageSource messages, Configuration freemarkerConfig, AdminSettingsService adminSettingsService, TbApiUsageClient apiUsageClient) {
74 this.messages = messages; 79 this.messages = messages;
75 this.freemarkerConfig = freemarkerConfig; 80 this.freemarkerConfig = freemarkerConfig;
76 this.adminSettingsService = adminSettingsService; 81 this.adminSettingsService = adminSettingsService;
77 - this.apiUsageStateService = apiUsageStateService;  
78 this.apiUsageClient = apiUsageClient; 82 this.apiUsageClient = apiUsageClient;
79 } 83 }
80 84