Package com.day.cq.mailer
Interface MessageTemplate<Type>
-
- All Known Subinterfaces:
EmailTemplate<Type>
public interface MessageTemplate<Type>
MessageTemplate it the template a Message of a Mailing is build of. It must be able to build a Message for each recipient. The Message has to be in the format that is able to be send by aMessageGateway
.
As MessageTemplates are likely to access resources, that have a state. Eg. a Session to the Repository, Binary Values or Database access. Therefore the template must be disposed if there is no further use for it.- Since:
- 5.4
- See Also:
Mailing
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Type
buildMessage(Authorizable recipient, UserProperties userProperties)
Builds a personalized message for therecipient
given as argument.void
dispose()
Called if the Template will not be used any longer.java.lang.Class<Type>
getType()
void
put(java.lang.String var, java.lang.String replace)
Adds or overwrites a mapping of this replacer.
-
-
-
Method Detail
-
getType
java.lang.Class<Type> getType()
- Returns:
- indicate the Type the message will be build
-
buildMessage
Type buildMessage(Authorizable recipient, UserProperties userProperties) throws MailingException, RepositoryException
Builds a personalized message for therecipient
given as argument.
In case the Template has beendisposed
anIllegalStateException
is thrown.- Parameters:
recipient
- to build a message foruserProperties
- used to build the message for the recipient.- Returns:
- the message for the given recipient or
null
if the MailingRecipient does not provide sufficient data to build a Message (eg. no e-mail address to build a e-mail Message) - Throws:
MailingException
- in case of an error building the message that is independent of the MailingRecipient eg. access to template storage is in exceptional state.java.lang.IllegalStateException
- in casemethod dispose
has been called before.RepositoryException
- If an error occurs.
-
dispose
void dispose() throws MailingException
Called if the Template will not be used any longer. A subsequent call tobuildMessage
will fail. Implementations can dispose any used Resources eg.Binary Values
, Database access.- Throws:
MailingException
- in case of exception disposing one of the resources
-
put
void put(java.lang.String var, java.lang.String replace)
Adds or overwrites a mapping of this replacer.- Parameters:
var
- name of the variable to mapreplace
- the value of the variable
-
-