Hi,
Sending Email is sometimes take a few seconds.
So I propose the treatment of the sending work by thread.
In order to do that we need Actable interface and ActionWorker
package org.apache.turbine.util;
public interface Actable
{
public void doAction() throws Exception;
}
package org.apache.turbine.util;
public class ActionWorker implements Runnable
{
private Actable actor = null;
public ActionWorker( Actable actor)
{
this.actor = actor;
}
public void run()
{
try {
if( actor == null ) {
return;
}
actor.doAction();
}
catch(Exception e) {
org.apache.turbine.util.Log.error ( "Error running a ActionWorker : " + e);
}
}
}
Email.java
Line 85
- public abstract class Email
+ public abstract class Email implements Actable
Line 441
- }
+ public void doAction () throws Exception
+ {
+ send();
+ }
+ }
How to use
Email email = new SimpleEmail();
email.addTo(toaddress , "");
email.setFrom(fromaddress, ");
ActionWorker worker = new ActionWorker(email);
Thread thread = new Thread(worker);
thread.start();
Thanks
youngho
���r��z۫n)ޢyb��(�H��� ��&N�����r��z۫n)ޡ���p��"�h��(�'���a���
0���j�!����o�����4�+-�x��oϮ��zk#�|(�H��� ��&