-
1. Re: change mail server at runtime??
kapitanpetko Dec 2, 2009 3:02 AM (in response to deanhiller2000)MailSession is application scoped, so once it is created, it is used until you restart your application. You can try to override it and make it event scoped. Then it should be re-created on every call, and you can read configuration in the @Create method. Mail is actually sent by the UIMessage component, the renderer just gives it kick :). Look at UIMessage.java for details.
HTH
-
2. Re: change mail server at runtime??
deanhiller2000 Dec 14, 2009 4:48 PM (in response to deanhiller2000)How do you
override
it? We tried many things and even went down the path of reflection but unfortunately, the javax.mail.Session is in the http Session instead of the seam bean otherwise our reflection might have worked :(. Any ideas how to override?thanks,
Dean -
3. Re: change mail server at runtime??
kapitanpetko Dec 15, 2009 4:34 AM (in response to deanhiller2000)Well you can try to make event scoped, not 100% sure if this will work though. Something like:
@Name("org.jboss.seam.mail.mailSession") @Install(precedence = APPLICATION, classDependencies = "javax.mail.Session") @Scope(EVENT) @BypassInterceptors public class MyMailSession extends MailSession { private Session session; @Create public void create() { // read hostname from DB, etc. setupMailSession(); } @Unwrap public Session getSession() { return session; } }
Or if this fails, keep it application scoped and do your thing in @Unwarp:
@Name("org.jboss.seam.mail.mailSession") @Install(precedence = APPLICATION, classDependencies = "javax.mail.Session") @Scope(APPLICATION) @BypassInterceptors public class MyMailSession extends MailSession { @Unwrap public Session getSession() { return createSession(); } }
Should be effectively the same thing -- every time you render UIMessage you should get a new session, configured any way you like.
All this is off the top of my head, so beware :)HTH