|
From: Alef A. <al...@jt...> - 2004-03-01 07:01:45
|
Well, you could implement a (beans.factory.)FactoryBean (http://monkeymachine.co.uk/spring/ref/beans.html#beans-factory-lifecycle= -fa ctorybean) here that retrieves your custom session: public class OCSessionFactory implements FactoryBean { public Object getObject() { return OCSession.getInstance(new Properties()); } public Class getObjectType() { return OCSession.class; } } And after that use this to set your own session: <bean id=3D"mailSender" class=3D"org.springframework.mail.javamail.JavaMailSenderImpl"> <property name=3D"session"> <bean class=3D"ourcommunity.util.email.OCSessionFactory"/> </property> </bean> Hope this helps. Alef > -----Original Message----- > From: spr...@li... > [mailto:spr...@li...] On = Behalf > Of Oliver Hutchison > Sent: Monday, March 01, 2004 4:35 AM > To: spr...@li... > Subject: RE: [Springframework-developer] JavaMailSenderImpl >=20 > How would you go about doing this if you don't use JNDI? Is there a = way > in spring to invoke the Session.getInstance method? I'd like to be = able > to have all of the configuration for my MailSender in one place. >=20 > At the moment I've simply extended JavaMailSenderImpl so now my config > looks like this: >=20 > <bean id=3D"javaMailSender" > class=3D"ourcommunity.util.email.OCJavaMailSenderImpl"> > <property > name=3D"host"><value>${oc.mail.server.addr}</value></property> > <property name=3D"javaMailProperties"> > <props> > <prop = key=3D"mail.smtp.dsn.notify">SUCCESS,FAILURE</prop> > <prop key=3D"mail.smtp.dsn.ret">HDRS</prop> > </props> > </property> > </bean> >=20 > And OCJavaMailSenderImpl.java looks like this >=20 > package ourcommunity.util.email; >=20 > import java.util.Properties; > import javax.mail.Session; > import org.springframework.mail.javamail.JavaMailSenderImpl; >=20 > public class OCJavaMailSenderImpl > extends JavaMailSenderImpl > { > public void setJavaMailProperties(Properties props) > { > setSession(Session.getInstance(props)); > } > } >=20 > But it seems to me this would be very useful for others if it was just > part of the standard Spring functionality. >=20 > -----Original Message----- > From: Darren Davison [mailto:da...@da...] > Sent: Monday, 1 March 2004 2:01 PM > To: spr...@li... > Subject: Re: [Springframework-developer] JavaMailSenderImpl >=20 >=20 > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 >=20 > On Monday 01 March 2004 02:42, Oliver Hutchison wrote: > > Hi, > > > > Except for extending JavaMailSenderImpl is there a way to specify > > extra properties that are used to instantiate the Session? >=20 > you can create your own javax.mail.Session object (populated with your > additional properties) and simply pass it to the > JavaMailSenderImpl.setSession(Session) method. This is particularly > handy > if you obtain your session from JNDI. >=20 >=20 >=20 >=20 > ------------------------------------------------------- > SF.Net is sponsored by: Speed Start Your Linux Apps Now. > Build and deploy apps & Web services for Linux with > a free DVD software kit from IBM. Click Now! > http://ads.osdn.com/?ad_id=1356&alloc_id438&op=3Dick > _______________________________________________ > Springframework-developer mailing list > Spr...@li... > https://lists.sourceforge.net/lists/listinfo/springframework-developer |