|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object magoffin.matt.ma2.aop.AbstractMailTemplateInterceptor
public abstract class AbstractMailTemplateInterceptor
Base class for mail merge interceptors.
This interceptor serves as a base for email interceptors using
templated email content (mail merge). The invoke(MethodInvocation)
method performs the following steps:
getInitialModel(MethodInvocation)
. This method must
return a non-null Map to use for the model data for the mail merge.Joinpoint.proceed()
.postProcessModel(MethodInvocation, Map, Object)
, passing
the model Map previously returned and the result of the method invocation.getLocale(MethodInvocation, Map, Object)
.MailMergeHelper.sendMerge(Locale, ClassLoader, Map, SimpleMailMessage)
to perform the mail merge and send the email.The configurable properties of this class are:
MailMergeHelper
instance to use for
sending the mail merge.
Field Summary | |
---|---|
protected org.apache.commons.logging.Log |
log
Class level log. |
Constructor Summary | |
---|---|
AbstractMailTemplateInterceptor()
|
Method Summary | |
---|---|
protected abstract java.util.Map<java.lang.String,java.lang.Object> |
getInitialModel(org.aopalliance.intercept.MethodInvocation invocation)
Get an initial Map object to use for the model data for the mail merge. |
protected java.util.Locale |
getLocale(org.aopalliance.intercept.MethodInvocation invocation,
java.util.Map<java.lang.String,java.lang.Object> model,
java.lang.Object result)
Get the locale for the email message. |
MailMergeHelper |
getMailMergeSupport()
|
java.lang.Object |
invoke(org.aopalliance.intercept.MethodInvocation invocation)
|
protected abstract org.springframework.mail.SimpleMailMessage |
postProcessModel(org.aopalliance.intercept.MethodInvocation invocation,
java.util.Map<java.lang.String,java.lang.Object> model,
java.lang.Object result)
Get a SimpleMailMessage object based on the result of the method invocation. |
void |
setMailMergeSupport(MailMergeHelper mailMergeSupport)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final org.apache.commons.logging.Log log
Constructor Detail |
---|
public AbstractMailTemplateInterceptor()
Method Detail |
---|
public final java.lang.Object invoke(org.aopalliance.intercept.MethodInvocation invocation) throws java.lang.Throwable
invoke
in interface org.aopalliance.intercept.MethodInterceptor
java.lang.Throwable
protected java.util.Locale getLocale(org.aopalliance.intercept.MethodInvocation invocation, java.util.Map<java.lang.String,java.lang.Object> model, java.lang.Object result)
This implementation simply returns Locale.getDefault()
. Extending
implementations can use the invocation and invocation result to provide
a custom Locale as deisred.
invocation
- the current method invocationmodel
- the modelresult
- the resut of the current modthod invocation
protected abstract java.util.Map<java.lang.String,java.lang.Object> getInitialModel(org.aopalliance.intercept.MethodInvocation invocation)
invocation
- the current method invocation
protected abstract org.springframework.mail.SimpleMailMessage postProcessModel(org.aopalliance.intercept.MethodInvocation invocation, java.util.Map<java.lang.String,java.lang.Object> model, java.lang.Object result)
You can use the MailMergeHelper instance's
MailMergeHelper.getMessageTemplate()
method to obtain a mail message
template, and use the
SimpleMailMessage.SimpleMailMessage(org.springframework.mail.SimpleMailMessage)
copy constructor to create the SimpleMailMessage to return here. Most likely the
only property you'll need to set on the result if the to
property.
invocation
- the current method invocationmodel
- the model Mapresult
- the method invocation result object
to
propertypublic MailMergeHelper getMailMergeSupport()
public void setMailMergeSupport(MailMergeHelper mailMergeSupport)
mailMergeSupport
- The mailMergeSupport to set.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |