<br><br><div class="gmail_quote">On Mon, Feb 7, 2011 at 11:57 AM, Dan Allen <span dir="ltr">&lt;<a href="mailto:dan.j.allen@gmail.com">dan.j.allen@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); 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&#39;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&#39;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&#39;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&lt;MailMessage&gt; 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(&quot;Seam Framework&quot;, &quot;<a href="mailto:seam@jboss.org" target="_blank">seam@jboss.org</a>&quot;)</div>


<div>         .to(&quot;John Smith&quot;, &quot;<a href="mailto:john.smith@acme.com" target="_blank">john.smith@acme.com</a>&quot;)</div><div>         .subject(&quot;Text Message from Seam Mail - &quot; + 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&lt;VelocityMailMessage&gt; velocityMailMessage;</div>


</div><div><br></div><div><div>   @Inject</div><div>   private Session session;</div></div><div><br></div><div><div>   velocityMailMessage.get().from(&quot;Seam Framework&quot;, &quot;<a href="mailto:seam@jboss.org" target="_blank">seam@jboss.org</a>&quot;)</div>


<div>         .to(person.getName(), person.getEmail())</div><div>         .subject(&quot;HTML Message from Seam Mail - &quot; + java.util.UUID.randomUUID().toString())</div><div>         .templateHTMLFromClassPath(&quot;template.html.vm&quot;)</div>


<div>         .put(&quot;version&quot;, &quot;Seam 3&quot;)</div><div>         .importance(MessagePriority.HIGH)</div><div>         .addAttachment(new URL(&quot;<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>&quot;), &quot;seamLogo.png&quot;, 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>
<br>_______________________________________________<br>
seam-dev mailing list<br>
<a href="mailto:seam-dev@lists.jboss.org">seam-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/seam-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/seam-dev</a><br>
<br></blockquote></div>Thanks, Cody.<br><br>I am user and abuser, not a contributor.  But this has been a pain point for me on <a href="http://2.2.0.ga/" target="_blank">2.2.0.GA</a>  I like this. I do have some constructive criticisms.<br>

<br>1. javax.mail.Session is final and cannot be mocked.  An official 
wrapper would be awesome! So if I try to mock this, this would happen<br><br>@Test<br>
public void testBasicEmail() {<br>
     Instance ins = createMock(Instance.class)<br>
     MailMessage message = createMock(Message.class)<br>
     expect(ins.get()).andReturn(<div>mailMessage)<br>
     Session session = createMock(Session.class); //RuntimeException , Session is final, and static (grrr)<br>
}<br>
<br><br>2. The Builder pattern you have and sending should be two 
different things.  The reason is that as a Seam power user, I really 
want to mock out the session and the message, and although it looks like
 you can do with this here, it seems that I would have a hard time 
still. Furthermore I likely won&#39;t use the builder like you have planned 
here.<br>
<br>I likely would use your library like this:  The mailMessage being 
injected would come from an outside factory that uses your builder or a 
mock.    That MailMessage I assume will be an interface, that way it 
wouldn&#39;t matter if the source is from Velocity, JSF transformation, XSLT
 transformation, JSON Transformation or some other fun stuff. ;)<br>
<br>   @Inject @NewAccountMessage<br><div>   private Instance&lt;MailMessage&gt; mailMessage;  <br></div>

<div><br></div><div><div>   @Inject</div><div>   private MailSession 
mailSession; //MailSession is an adapter, be nice it be an interface.  
This would be wrap the poorly engineered javax.mail.Session class.<br><br>   public void doIt() {<br>
       //doSomeOtherStuff<br>       mailSession.send(mailMessage)<br>   }<br>    <br><br></div></div>My 2c. Thanks Cody! ;)</div>