[seam-dev] Is this the mail API you always wanted?

Dan Allen dan.j.allen at gmail.com
Mon Feb 7 15:16:49 EST 2011


I'll add that at one point we were experimenting with using a type-parameter
to specify the template engine:

@Inject
private Instance<TemplateMailMessage> message;

message.select(new VelocityLiteral()).get().from(...).to(...).send();

or

@Inject @Velocity
private Instance<TemplateMailMessage> message;

message.get().from(...).to(...).send();

This is an effort to make the template engine a qualifier rather than a
secondary interface. [1]

refer to this revision tree to find the earlier prototype:
https://github.com/seam/mail/tree/fcf45f808391489cb23c848f11f052e22d70c5d3
discussion: http://echelog.matzon.dk/logs/browse/seam-dev/1280959200 (starts
at 16:28:05)

-Dan

[1]
https://github.com/seam/mail/blob/fcf45f808391489cb23c848f11f052e22d70c5d3/impl-base/src/main/java/org/jboss/seam/mail/templating/velocity/VelocityMailMessageImpl.java

On Mon, Feb 7, 2011 at 13:57, Dan Allen <dan.j.allen at gmail.com> wrote:

> Seam devs,
>
> Cody is looking for some feedback on the mail module [1] before he drafts a
> reference guide and puts the API on ice.
>
> Seam mail is important because, let's face it, the Java Mail API needs a
> makeover. Thankfully, the CDI programming model offers the necessary hooks
> to create a modernized mail API capable of deep integration with the Java EE
> platform (specifically the Java Mail API and container-managed sessions).
>
> Seam Mail offers a fluent API that makes sending e-mail in Java a painless
> experience. But an e-mail is nothing without the content. That's why Seam
> Mail offers several templating options, such as Velocity, as well as an
> extensible template SPI, to allow you to select your templating solution of
> choice. With Seam Mail, you'll be sending e-mail from your application in no
> time.
>
> Is this how you imagined it would be?
>
> Basic:
>
>    @Inject
>    private Instance<MailMessage> mailMessage;
>
>    @Inject
>    private Session session;
>
>    mailMessage.get()
>          .from("Seam Framework", "seam at jboss.org")
>          .to("John Smith", "john.smith at acme.com")
>          .subject("Text Message from Seam Mail - " +
> java.util.UUID.randomUUID().toString())
>          .textBody(text)
>          .send(session);
>
> Velocity:
>
>    @Inject
>    private Instance<VelocityMailMessage> velocityMailMessage;
>
>    @Inject
>    private Session session;
>
>    velocityMailMessage.get().from("Seam Framework", "seam at jboss.org")
>          .to(person.getName(), person.getEmail())
>          .subject("HTML Message from Seam Mail - " +
> java.util.UUID.randomUUID().toString())
>          .templateHTMLFromClassPath("template.html.vm")
>          .put("version", "Seam 3")
>          .importance(MessagePriority.HIGH)
>          .addAttachment(new URL("
> http://www.seamframework.org/themes/sfwkorg/img/seam_icon_large.png"),
> "seamLogo.png", ContentDisposition.INLINE);
>          .send(session);
>
> We look forward to your feedback.
>
> -Dan
>
> [1] http://github.com/seam/mail
> http://seamframework.org/Seam3/Mail
>
> --
> Dan Allen
> Principal Software Engineer, Red Hat | Author of Seam in Action
> Registered Linux User #231597
>
> http://www.google.com/profiles/dan.j.allen#about
> http://mojavelinux.com
> http://mojavelinux.com/seaminaction
>
>


-- 
Dan Allen
Principal Software Engineer, Red Hat | Author of Seam in Action
Registered Linux User #231597

http://www.google.com/profiles/dan.j.allen#about
http://mojavelinux.com
http://mojavelinux.com/seaminaction
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/seam-dev/attachments/20110207/9445b24b/attachment.html 


More information about the seam-dev mailing list