I'll add that at one point we were experimenting with using a type-parameter to specify the template engine:<div><br></div><div>@Inject</div><div>private Instance<TemplateMailMessage> message;</div><div><br></div>
<div>message.select(new VelocityLiteral()).get().from(...).to(...).send();</div><div><br></div><div>or</div><div><br></div><div>@Inject @Velocity</div><div>private Instance<TemplateMailMessage> message;</div><div><br>
</div><div>message.get().from(...).to(...).send();</div><div><br></div><div>This is an effort to make the template engine a qualifier rather than a secondary interface. [1]</div><div><br></div><div>refer to this revision tree to find the earlier prototype: <a href="https://github.com/seam/mail/tree/fcf45f808391489cb23c848f11f052e22d70c5d3">https://github.com/seam/mail/tree/fcf45f808391489cb23c848f11f052e22d70c5d3</a></div>
<div>discussion: <a href="http://echelog.matzon.dk/logs/browse/seam-dev/1280959200">http://echelog.matzon.dk/logs/browse/seam-dev/1280959200</a> (starts at 16:28:05)</div><div><br></div><div>-Dan</div><div><br></div><div>
[1] <a href="https://github.com/seam/mail/blob/fcf45f808391489cb23c848f11f052e22d70c5d3/impl-base/src/main/java/org/jboss/seam/mail/templating/velocity/VelocityMailMessageImpl.java">https://github.com/seam/mail/blob/fcf45f808391489cb23c848f11f052e22d70c5d3/impl-base/src/main/java/org/jboss/seam/mail/templating/velocity/VelocityMailMessageImpl.java</a><br>
<br><div class="gmail_quote">On Mon, Feb 7, 2011 at 13:57, Dan Allen <span dir="ltr"><<a href="mailto:dan.j.allen@gmail.com">dan.j.allen@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Seam devs,<div><br></div><div>Cody is looking for some feedback on the mail module [1] before he drafts a reference guide and puts the API on ice.</div><div><br></div><div>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).</div>
<div><br></div><div>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.</div>
<div><br></div><div>Is this how you imagined it would be?</div><div><br></div><div>Basic:<br></div><div><br></div><div><div> @Inject</div><div> private Instance<MailMessage> mailMessage;</div></div><div><br></div>
<div><div> @Inject</div><div> private Session session;</div></div><div><br></div><div><div> mailMessage.get()</div><div> .from("Seam Framework", "<a href="mailto:seam@jboss.org" target="_blank">seam@jboss.org</a>")</div>
<div> .to("John Smith", "<a href="mailto:john.smith@acme.com" target="_blank">john.smith@acme.com</a>")</div><div> .subject("Text Message from Seam Mail - " + java.util.UUID.randomUUID().toString())</div>
<div> .textBody(text)</div><div> .send(session);</div></div><div><br></div><div>Velocity:</div><div><br></div><div><div> @Inject</div><div> private Instance<VelocityMailMessage> velocityMailMessage;</div>
</div><div><br></div><div><div> @Inject</div><div> private Session session;</div></div><div><br></div><div><div> velocityMailMessage.get().from("Seam Framework", "<a href="mailto:seam@jboss.org" target="_blank">seam@jboss.org</a>")</div>
<div> .to(person.getName(), person.getEmail())</div><div> .subject("HTML Message from Seam Mail - " + java.util.UUID.randomUUID().toString())</div><div> .templateHTMLFromClassPath("template.html.vm")</div>
<div> .put("version", "Seam 3")</div><div> .importance(MessagePriority.HIGH)</div><div> .addAttachment(new URL("<a href="http://www.seamframework.org/themes/sfwkorg/img/seam_icon_large.png" target="_blank">http://www.seamframework.org/themes/sfwkorg/img/seam_icon_large.png</a>"), "seamLogo.png", ContentDisposition.INLINE);</div>
<div> .send(session);</div></div><div><br></div><div>We look forward to your feedback.</div><div><br></div><div>-Dan</div><div><br></div><div>[1] <a href="http://github.com/seam/mail" target="_blank">http://github.com/seam/mail</a></div>
<div><a href="http://seamframework.org/Seam3/Mail" target="_blank">http://seamframework.org/Seam3/Mail</a><br clear="all"><br>-- <br><div>Dan Allen</div>Principal Software Engineer, Red Hat | Author of Seam in Action<br>
Registered Linux User #231597<br>
<br><div><a href="http://www.google.com/profiles/dan.j.allen#about" target="_blank">http://www.google.com/profiles/dan.j.allen#about</a><br><a href="http://mojavelinux.com" target="_blank">http://mojavelinux.com</a><br><a href="http://mojavelinux.com/seaminaction" target="_blank">http://mojavelinux.com/seaminaction</a><br>
</div><br>
</div>
</blockquote></div><br><br clear="all"><br>-- <br><div>Dan Allen</div>Principal Software Engineer, Red Hat | Author of Seam in Action<br>Registered Linux User #231597<br><br><div><a href="http://www.google.com/profiles/dan.j.allen#about" target="_blank">http://www.google.com/profiles/dan.j.allen#about</a><br>
<a href="http://mojavelinux.com" target="_blank">http://mojavelinux.com</a><br><a href="http://mojavelinux.com/seaminaction" target="_blank">http://mojavelinux.com/seaminaction</a><br></div><br>
</div>