RMI Crawler->JMX Crawler
This commit is contained in:
parent
12613b1cda
commit
64c6252145
14
pom.xml
14
pom.xml
|
@ -27,8 +27,9 @@
|
|||
<spring.crypto.version>4.2.3.RELEASE</spring.crypto.version>
|
||||
<hibernate.version>5.2.10.Final</hibernate.version>
|
||||
<javax.mail.version>1.4.7</javax.mail.version>
|
||||
<javax.mail-api.version>1.6.0</javax.mail-api.version>
|
||||
<jackson.mapper.version>1.9.13</jackson.mapper.version>
|
||||
|
||||
<apache.velocity.version>1.7</apache.velocity.version>
|
||||
<docker.registry.name>docker.loafle.net/overflow</docker.registry.name>
|
||||
</properties>
|
||||
|
||||
|
@ -128,6 +129,17 @@
|
|||
<version>${javax.mail.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.mail</groupId>
|
||||
<artifactId>javax.mail-api</artifactId>
|
||||
<version>${javax.mail-api.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.velocity</groupId>
|
||||
<artifactId>velocity</artifactId>
|
||||
<version>${apache.velocity.version}</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/commons-codec/commons-codec -->
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
|
|
108
src/main/java/com/loafle/overflow/commons/model/Mail.java
Normal file
108
src/main/java/com/loafle/overflow/commons/model/Mail.java
Normal file
|
@ -0,0 +1,108 @@
|
|||
package com.loafle.overflow.commons.model;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by geek on 18. 1. 3.
|
||||
*/
|
||||
public class Mail {
|
||||
private String mailFrom;
|
||||
|
||||
private String mailTo;
|
||||
|
||||
private String mailCc;
|
||||
|
||||
private String mailBcc;
|
||||
|
||||
private String mailSubject;
|
||||
|
||||
private String mailContent;
|
||||
|
||||
private String contentType;
|
||||
|
||||
private List< Object > attachments;
|
||||
|
||||
private Map< String, Object > model;
|
||||
|
||||
public Mail() {
|
||||
contentType = "text/plain";
|
||||
}
|
||||
|
||||
public String getContentType() {
|
||||
return contentType;
|
||||
}
|
||||
|
||||
public void setContentType(String contentType) {
|
||||
this.contentType = contentType;
|
||||
}
|
||||
|
||||
public String getMailBcc() {
|
||||
return mailBcc;
|
||||
}
|
||||
|
||||
public void setMailBcc(String mailBcc) {
|
||||
this.mailBcc = mailBcc;
|
||||
}
|
||||
|
||||
public String getMailCc() {
|
||||
return mailCc;
|
||||
}
|
||||
|
||||
public void setMailCc(String mailCc) {
|
||||
this.mailCc = mailCc;
|
||||
}
|
||||
|
||||
public String getMailFrom() {
|
||||
return mailFrom;
|
||||
}
|
||||
|
||||
public void setMailFrom(String mailFrom) {
|
||||
this.mailFrom = mailFrom;
|
||||
}
|
||||
|
||||
public String getMailSubject() {
|
||||
return mailSubject;
|
||||
}
|
||||
|
||||
public void setMailSubject(String mailSubject) {
|
||||
this.mailSubject = mailSubject;
|
||||
}
|
||||
|
||||
public String getMailTo() {
|
||||
return mailTo;
|
||||
}
|
||||
|
||||
public void setMailTo(String mailTo) {
|
||||
this.mailTo = mailTo;
|
||||
}
|
||||
|
||||
public Date getMailSendDate() {
|
||||
return new Date();
|
||||
}
|
||||
|
||||
public String getMailContent() {
|
||||
return mailContent;
|
||||
}
|
||||
|
||||
public void setMailContent(String mailContent) {
|
||||
this.mailContent = mailContent;
|
||||
}
|
||||
|
||||
public List< Object > getAttachments() {
|
||||
return attachments;
|
||||
}
|
||||
|
||||
public void setAttachments(List < Object > attachments) {
|
||||
this.attachments = attachments;
|
||||
}
|
||||
|
||||
public Map< String, Object > getModel() {
|
||||
return model;
|
||||
}
|
||||
|
||||
public void setModel(Map < String, Object > model) {
|
||||
this.model = model;
|
||||
}
|
||||
}
|
|
@ -1,13 +1,15 @@
|
|||
package com.loafle.overflow.commons.utils;
|
||||
|
||||
import com.loafle.overflow.commons.model.Mail;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.velocity.app.VelocityEngine;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.io.FileSystemResource;
|
||||
import org.springframework.mail.MailException;
|
||||
import org.springframework.mail.SimpleMailMessage;
|
||||
import org.springframework.mail.javamail.JavaMailSender;
|
||||
import org.springframework.mail.javamail.MimeMessageHelper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.ui.velocity.VelocityEngineUtils;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.spec.IvParameterSpec;
|
||||
|
@ -15,6 +17,7 @@ import javax.crypto.spec.SecretKeySpec;
|
|||
import javax.mail.MessagingException;
|
||||
import javax.mail.internet.MimeMessage;
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by geek on 17. 8. 30.
|
||||
|
@ -25,32 +28,35 @@ public class EmailSender {
|
|||
@Autowired
|
||||
private JavaMailSender mailSender;
|
||||
|
||||
@Autowired
|
||||
private VelocityEngine velocityEngine;
|
||||
|
||||
private String key = "loafle@RandomKey";
|
||||
private String initVector = "loafleInitVector";
|
||||
|
||||
|
||||
public void sendSimpleEmail(String to, String sub, String message) throws MailException {
|
||||
public void sendSimpleEmail(Mail mail) throws MailException {
|
||||
|
||||
SimpleMailMessage message1 = new SimpleMailMessage();
|
||||
message1.setTo(to);
|
||||
message1.setSubject(sub);
|
||||
message1.setText(message);
|
||||
message1.setTo(mail.getMailTo());
|
||||
message1.setSubject(mail.getMailSubject());
|
||||
message1.setText(getContentFromTemplate(mail.getModel()));
|
||||
message1.setFrom("geek@loafle.com");
|
||||
|
||||
mailSender.send(message1);
|
||||
}
|
||||
|
||||
public void sendMailWithAttachment(String to, String sub, String text, String path) throws MessagingException {
|
||||
public void sendMailWithAttachment(Mail mail) throws MessagingException {
|
||||
MimeMessage message = mailSender.createMimeMessage();
|
||||
// pass 'true' to the constructor to create a multipart message
|
||||
MimeMessageHelper helper = new MimeMessageHelper(message, true);
|
||||
|
||||
helper.setTo(to);
|
||||
helper.setSubject(sub);
|
||||
helper.setText(text);
|
||||
helper.setTo(mail.getMailTo());
|
||||
helper.setSubject(mail.getMailSubject());
|
||||
helper.setText(mail.getMailContent());
|
||||
helper.setFrom("geek@loafle.com");
|
||||
FileSystemResource file = new FileSystemResource(new File(path));
|
||||
helper.addAttachment("Invoice", file);
|
||||
// FileSystemResource file = new FileSystemResource(new File(mail.getAttachments()));
|
||||
// helper.addAttachment("Invoice", file);
|
||||
|
||||
mailSender.send(message);
|
||||
}
|
||||
|
@ -93,4 +99,15 @@ public class EmailSender {
|
|||
|
||||
return null;
|
||||
}
|
||||
|
||||
private String getContentFromTemplate(Map<String, Object> model) {
|
||||
StringBuffer content = new StringBuffer();
|
||||
try {
|
||||
content.append(VelocityEngineUtils.mergeTemplateIntoString(velocityEngine,"/templates/email-template.vm", "UTF-8", model));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return content.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.loafle.overflow.module.email.service;
|
||||
|
||||
import com.loafle.overflow.commons.model.Mail;
|
||||
import com.loafle.overflow.commons.utils.EmailSender;
|
||||
import com.loafle.overflow.module.domain.dao.DomainDAO;
|
||||
import com.loafle.overflow.module.domain.dao.DomainMemberDAO;
|
||||
|
@ -20,9 +21,7 @@ import org.springframework.stereotype.Service;
|
|||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Created by geek on 17. 6. 28.
|
||||
|
@ -58,7 +57,18 @@ public class EmailAuthService {
|
|||
String encode = URLEncoder.encode(en, "UTF-8");
|
||||
|
||||
// System.out.println("encode = [" + encode + "]");
|
||||
emailSender.sendSimpleEmail(memberEmail, "Confirm Email", "http://127.0.0.1:19080/account/check_email?key="+ encode +"\r\nConfirm Email");
|
||||
Mail mail = new Mail();
|
||||
mail.setMailTo(memberEmail);
|
||||
mail.setMailSubject("Confirm Email");
|
||||
mail.setMailContent("http://127.0.0.1:19080/account/check_email?key="+ encode +"\r\nConfirm Email");
|
||||
Map<String, Object> model = new HashMap<>();
|
||||
model.put("firstName", auth.getMember().getName());
|
||||
model.put("lastName", auth.getMember().getCompanyName());
|
||||
model.put("location", "Seoul");
|
||||
model.put("signature", "www.loafle.com");
|
||||
|
||||
mail.setModel(model);
|
||||
emailSender.sendSimpleEmail(mail);
|
||||
|
||||
this.emailAuthDAO.save(auth);
|
||||
|
||||
|
|
|
@ -70,7 +70,8 @@ public class MemberService {
|
|||
}
|
||||
m.setSigninFailCount(m.getSigninFailCount()+1);
|
||||
this.modify(m);
|
||||
throw new SignInPwNotMatchException();
|
||||
// throw new SignInPwNotMatchException();
|
||||
return null;
|
||||
}
|
||||
|
||||
m.setSigninFailCount(0);
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
package com.loafle.overflow.spring;
|
||||
|
||||
import org.apache.velocity.app.VelocityEngine;
|
||||
import org.apache.velocity.exception.VelocityException;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.mail.javamail.JavaMailSenderImpl;
|
||||
import org.springframework.ui.velocity.VelocityEngineFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
|
@ -54,6 +58,14 @@ public class MailConfiguration {
|
|||
return javaMailProperties;
|
||||
}
|
||||
|
||||
|
||||
@Bean
|
||||
public VelocityEngine getVelocityEngine() throws VelocityException, IOException {
|
||||
Properties properties = new Properties();
|
||||
properties.load(this.getClass().getResourceAsStream("/velocity.properties"));
|
||||
return new VelocityEngine(properties);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -864,6 +864,9 @@ INSERT INTO public."member" (company_name,create_date,email,"name",phone,pw,stat
|
|||
INSERT INTO public.email_auth (auth_confirm_date,create_date,email_auth_key,member_id) VALUES (
|
||||
NULL,'2017-06-26 15:28:48.895','dbseogns1234',1);
|
||||
|
||||
INSERT INTO public.email_auth (auth_confirm_date,create_date,email_auth_key,member_id) VALUES (
|
||||
NULL,'2017-11-22 12:28:48.895','dbseogns1234',1);
|
||||
|
||||
INSERT INTO public."domain" (create_date,"name") VALUES (
|
||||
'2017-06-26 11:25:44.866','overFlow''s domain');
|
||||
|
||||
|
|
6
src/main/resources/local/velocity.properties
Normal file
6
src/main/resources/local/velocity.properties
Normal file
|
@ -0,0 +1,6 @@
|
|||
resource.loader=jar
|
||||
jar.resource.loader.class=org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
|
||||
jar.runtime.log.logsystem.class=org.apache.velocity.runtime.log.SimpleLog4JLogSystem
|
||||
jar.runtime.log.logsystem.log4j.category=velocity
|
||||
jar.resource.loader.cache=true
|
||||
input.encoding=UTF-8
|
13
src/main/resources/signup_email.vm
Normal file
13
src/main/resources/signup_email.vm
Normal file
|
@ -0,0 +1,13 @@
|
|||
<html>
|
||||
|
||||
<head></head>
|
||||
|
||||
<body>
|
||||
<p>Dear ${firstName} ${lastName},</p>
|
||||
<p>Sending Email <b>Velocity Template Test !!!</b></p>
|
||||
<p>Thanks</p>
|
||||
<p>${signature}</p>
|
||||
<p>${location}</p>
|
||||
</body>
|
||||
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user