BrightSide Workbench Full Report + Source Code
org.turro.mail.impl.MailMessagePoolSender Class Reference
Inheritance diagram for org.turro.mail.impl.MailMessagePoolSender:
Collaboration diagram for org.turro.mail.impl.MailMessagePoolSender:

Public Member Functions

 MailMessagePoolSender (Set< MailMessage > pool)
 
void send (Command onFinish)
 
void run ()
 

Detailed Description

Author
Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g

Definition at line 37 of file MailMessagePoolSender.java.

Constructor & Destructor Documentation

◆ MailMessagePoolSender()

org.turro.mail.impl.MailMessagePoolSender.MailMessagePoolSender ( Set< MailMessage pool)

Definition at line 42 of file MailMessagePoolSender.java.

42  {
43  this.pool.addAll(pool);
44  }

Member Function Documentation

◆ run()

void org.turro.mail.impl.MailMessagePoolSender.run ( )

Definition at line 56 of file MailMessagePoolSender.java.

56  {
57  int i = 1, count = pool.size();
58  for (MailMessage mail : pool) {
59  try {
60  mail.send();
61  Logger.getLogger(MailMessagePool.class.getName()).log(Level.INFO, "Sent mail from {0} to {1}. Subject: {2}",
62  new Object[]{mail.getEmail().getFromAddress().getAddress(),
63  InternetAddress.toString((InternetAddress[]) mail.getEmail().getToAddresses().toArray(new InternetAddress[0])), mail.getSubject()});
64  if(count > 100 && ++i < count) Thread.sleep(100); // sleep only when using thread
65  } catch (MalformedURLException | NamingException | InterruptedException | EmailException ex) {
66  Logger.getLogger(MailMessagePool.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
67  }
68  }
69  pool.clear();
70  if(onFinish != null) {
71  try {
72  onFinish.execute(null);
73  } catch (Exception ex) {
74  Logger.getLogger(MailMessagePool.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
75  }
76  }
77  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ send()

void org.turro.mail.impl.MailMessagePoolSender.send ( Command  onFinish)

Definition at line 46 of file MailMessagePoolSender.java.

46  {
47  this.onFinish = onFinish;
48  if(pool.size() > 100) {
49  new Thread(this).start();
50  } else {
51  run();
52  }
53  }
Here is the call graph for this function:

The documentation for this class was generated from the following file: