View Javadoc

1   package com.ozacc.mail.spring;
2   
3   import java.io.File;
4   
5   import org.springframework.beans.factory.config.AbstractFactoryBean;
6   
7   import com.ozacc.mail.Mail;
8   import com.ozacc.mail.MailBuildException;
9   import com.ozacc.mail.XMLMailBuilder;
10  
11  /***
12   * Spring¤ÎÀßÄ?¥Õ¥¡¥¤¥?¤Ç»ØÄꤵ¤?¤¿¥úÁ±¡¼¥·¥ç¥ó¤ÎXML¥Õ¥¡¥¤¥?¤«¤éMail¥¤¥ó¥¹¥¿¥ó¥¹¤òÀ¸À®¤¹¤?FactoryBean¡£
13   * ¥Ç¥Õ¥©¥?¥È¤Ç¤Ï¡¢singleton¥×¥úÁѥƥ£¤Ïfalse¤ËÀßÄꤵ¤?¤Þ¤¹¡£
14   * 
15   * @author Tomohiro Otsuka
16   * @version $Id: XMLMailFactoryBean.java,v 1.1 2004/09/05 17:25:32 otsuka Exp $
17   */
18  public class XMLMailFactoryBean extends AbstractFactoryBean {
19  
20  	private String classPath;
21  
22  	private String filePath;
23  
24  	private XMLMailBuilder mailBuilder;
25  
26  	/***
27  	 * ¥³¥ó¥¹¥È¥é¥¯¥¿¡£
28  	 */
29  	public XMLMailFactoryBean() {
30  		mailBuilder = XMLMailBuilder.getInstance();
31  		setSingleton(false);
32  	}
33  
34  	/***
35  	 * @see org.springframework.beans.factory.config.AbstractFactoryBean#createInstance()
36  	 */
37  	protected Object createInstance() throws Exception {
38  		if (getClass() != null) {
39  			return mailBuilder.buildMail(getClassPath());
40  		}
41  		if (getFilePath() != null) {
42  			return mailBuilder.buildMail(new File(filePath));
43  		}
44  
45  		throw new MailBuildException("Mail¥¤¥ó¥¹¥¿¥ó¥¹¤ÎÀ¸À®¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£XML¥Ç¡¼¥¿¤Î¥úÁ±¡¼¥·¥ç¥ó¤¬»ØÄꤵ¤?¤Æ¤¤¤Þ¤»¤ó¡£");
46  	}
47  
48  	/***
49  	 * @see org.springframework.beans.factory.FactoryBean#getObjectType()
50  	 */
51  	public Class getObjectType() {
52  		return Mail.class;
53  	}
54  
55  	/***
56  	 * @return Returns the classPath.
57  	 */
58  	public String getClassPath() {
59  		return classPath;
60  	}
61  
62  	/***
63  	 * @param classPath The classPath to set.
64  	 */
65  	public void setClassPath(String classPath) {
66  		this.classPath = classPath;
67  	}
68  
69  	/***
70  	 * @return Returns the filePath.
71  	 */
72  	public String getFilePath() {
73  		return filePath;
74  	}
75  
76  	/***
77  	 * @param filePath The filePath to set.
78  	 */
79  	public void setFilePath(String filePath) {
80  		this.filePath = filePath;
81  	}
82  }