To elaborate a little further, here is a little of the approach I use.
I develop in eclipse and I use subversion for SCM. I set up a new eclipse
project and used svn externals to link to common code that shared
between applications -- MySpringBean for example in the following:
// imports....;
public class MyMailet extends GenericMailet {
protected MySpringBean mySpringBean;
// other stuff
public void init(MailetConfig config) throws MessagingException {
super.init(config);
log("------- init begin -------");
ClassPathXmlApplicationContext appContext = new
ClassPathXmlApplicationContext(
new String[] {
"applicationContext-service.xml",
"applicationContext-hibernate.xml"}
);
mySpringBean = (MySpringBean) appContext.getBean("mySpringBean");
log("------- init end -------");
}
public void service(Mail mail) throws MessagingException {
try {
log("------- servicing new message -------");
mySpringBean.DoIt(mail);
} catch (Exception e) {
log("Error: ", e);
}
log("-------------------------------------");
}
// other stuff...
}
The mailet I developed is pretty simple but it does use hibernate to
persist the objects. my applicationContext-service.xml and
applicationContext-hibernate.xml files contain my bean definitions
and all this gets jar'd up (including the xml files) and I stick
it in ${james_home}/lib
Then in my james config, I add:
<mailet match="[EMAIL PROTECTED]" class="MyMailet"/>
There may be better ways to go but I hope this helps a little more or helps
someone else facing this. Sometimes just knowing it can be done is enough!
-- Bud
-----Original Message-----
From: Gary Jarrel [mailto:[EMAIL PROTECTED]
Sent: Friday, April 20, 2007 3:10 AM
To: [email protected]
Subject: Spring and Mailets
Hi All
Is there any best practices on having Spring inject objects into the
mailets?
Thank you!
Gary
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]