Skip to content

Commit bb7bf2f

Browse files
committed
Notifier interface added
1 parent 28c2bf3 commit bb7bf2f

File tree

2 files changed

+35
-28
lines changed

2 files changed

+35
-28
lines changed
Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,6 @@
11
package com.olegshan.notifier;
22

3-
import org.slf4j.Logger;
4-
import org.slf4j.LoggerFactory;
5-
import org.springframework.beans.factory.annotation.Autowired;
6-
import org.springframework.mail.MailSender;
7-
import org.springframework.mail.SimpleMailMessage;
8-
import org.springframework.stereotype.Service;
3+
public interface Notifier {
94

10-
@Service
11-
public class Notifier {
12-
13-
private static final Logger LOGGER = LoggerFactory.getLogger(Notifier.class);
14-
15-
private MailSender mailSender;
16-
17-
@Autowired
18-
public Notifier(MailSender mailSender) {
19-
this.mailSender = mailSender;
20-
}
21-
22-
public void notifyAdmin(String issue) {
23-
24-
SimpleMailMessage message = new SimpleMailMessage();
25-
message.setTo("***");
26-
message.setSubject("jParser issue");
27-
message.setText(issue + "\n\nhttp://www.jparser.info");
28-
29-
mailSender.send(message);
30-
LOGGER.info("Admin was notified about following issue: " + issue + "\n");
31-
}
5+
void notifyAdmin(String issue);
326
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package com.olegshan.notifier.impl;
2+
3+
import com.olegshan.notifier.Notifier;
4+
import org.slf4j.Logger;
5+
import org.slf4j.LoggerFactory;
6+
import org.springframework.beans.factory.annotation.Autowired;
7+
import org.springframework.mail.MailSender;
8+
import org.springframework.mail.SimpleMailMessage;
9+
import org.springframework.stereotype.Service;
10+
11+
@Service
12+
public class NotifierImpl implements Notifier {
13+
14+
private static final Logger LOGGER = LoggerFactory.getLogger(NotifierImpl.class);
15+
16+
private MailSender mailSender;
17+
18+
@Autowired
19+
public NotifierImpl(MailSender mailSender) {
20+
this.mailSender = mailSender;
21+
}
22+
23+
public void notifyAdmin(String issue) {
24+
25+
SimpleMailMessage message = new SimpleMailMessage();
26+
message.setTo("olegshan@gmail.com");
27+
message.setSubject("jParser issue");
28+
message.setText(issue + "\n\nhttp://www.jparser.info");
29+
30+
mailSender.send(message);
31+
LOGGER.info("Admin was notified about following issue: " + issue + "\n");
32+
}
33+
}

0 commit comments

Comments
 (0)