Jeremy Boynes wrote:
Neal Sanche wrote:
Well, I've looked through the source and found the
org.apache.geronimo.mail module. It seems to contain a few GBeans and
some tests. The tests are mostly empty. How would I create an SMTP
transport session from my code?
The easiest way is to define a resource reference in the standard
deployment descriptor:
<resource-ref>
<res-ref-name>mail/MailSession</res-ref-name>
<res-type>javax.mail.Session</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
You can then look up the resource with code like:
javax.mail.Session sess = (Session)
new InitialContext().lookup("java:comp/env/mail/MailSession");
We don't provide a default session but you can define one using a
GBean in your deployment plan:
<gbean name="mail/MailSession"
class="org.apache.geronimo.mail.SMTPTransportGBean">
<attribute name="host">mail.example.com</attribute>
</gbean>
Other attributes can be set as appropriate; I think we support all the
"standard" mail.smtp ones and non-standard ones can be set through the
"properties" attribute.
Okay, so, since I'm a bit of an XDoclet nut, still, I've done the
following to add the resource ref to one of my SLSB beans:
@ejb.resource-ref
description="JavaMail Resource"
res-ref-name="mail/MailSession"
res-type="javax.mail.Session"
res-auth="Container"
res-sharing-scope="Shareable"
Which ends up adding the following lines to my ejb-jar.xml file:
<resource-ref >
<description><![CDATA[JavaMail Resource]]></description>
<res-ref-name>mail/MailSession</res-ref-name>
<res-type>javax.mail.Session</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
Which is all good. Now, which deployment plan do I add the resource ref
to? I loked for gbean in the schemas and found that it can live in the
geronimo-application.xml under my module definitions. Is that the
correct place to put it in order to use it from within a SLSB?
Thanks Jeremy,
-Neal