KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > mx4j > tools > mail > SMTPMBean


1 /*
2  * Copyright (C) The MX4J Contributors.
3  * All rights reserved.
4  *
5  * This software is distributed under the terms of the MX4J License version 1.0.
6  * See the terms of the MX4J License in the documentation provided with this software.
7  */

8
9 package mx4j.tools.mail;
10
11 import javax.management.ObjectName JavaDoc;
12
13 /**
14  * Management Interface of a SMTP MBean.
15  * <p/>
16  * This MBean is meant to send a mail given certain situation. It may be used to listen to a monitor
17  * or timer and send a mail.
18  * <p/>
19  * To use it you need to add to your classpath the mail.jar from the JavaMail API and the activation.jar
20  * from the Java Activation Framework.
21  * <p/>
22  * Besides you need to configure all the required fields, at least the serverHost and To fields and if your server
23  * requires login also the serverUsername and serverPassword fields
24  * <p/>
25  * The subject and content fields are subject to keyword expansions, i.e. some keyworks put between $ signs will
26  * be exapnded this can be used to give a more informative message. The current available expansions are
27  * <p/>
28  * $date$ -> Current date formatted with locale format
29  * $time$ -> Current tim formatted with locale format
30  * $datetime$ -> Current date and time formatted with locale format
31  * $notification$ -> Notification type
32  * $observed$ -> ObjectName of the observed object
33  * $objectname$ -> This MBean's objectname
34  *
35  * @version $Revision: 1.4 $
36  */

37 public interface SMTPMBean
38 {
39    /**
40     * Gets the MBean's objectname which is being listened
41     */

42    public ObjectName JavaDoc getObservedObject();
43
44    /**
45     * Sets the observed object. It is expected that the observed MBean is a NotificationBroadcster
46     * On the contrary the MBean will not be listening to events
47     */

48    public void setObservedObject(ObjectName JavaDoc targetMBeanName);
49
50    /**
51     * Returns the notification which will trigger the mail sending
52     */

53    public String JavaDoc getNotificationName();
54
55    /**
56     * Sets the notification name which will trigger the mail sending. If it is null any notification
57     * will trigger a mail
58     */

59    public void setNotificationName(String JavaDoc notificationName);
60
61    /**
62     * Gets the server's host as name or IP
63     */

64    public String JavaDoc getServerHost();
65
66    /**
67     * Sets the server's host, it can be set as name or IP
68     */

69    public void setServerHost(String JavaDoc host);
70
71    /**
72     * Sets the server's port.
73     */

74    public void setServerPort(int port);
75
76    /**
77     * Gets the server's port, by default is 25
78     */

79    public int getServerPort();
80
81    /**
82     * Sets server's username, use with setLoginToServer(true)
83     */

84    public void setServerUsername(String JavaDoc username);
85
86    /**
87     * Gets the username to log to the server
88     */

89    public String JavaDoc getServerUsername();
90
91    /**
92     * Sets server's passowrd, use with setLoginToServer(true) and setServerUsername
93     */

94    public void setServerPassword(String JavaDoc password);
95
96    /**
97     * Sets whether to login to the SMTP server
98     */

99    public void setLoginToServer(boolean login);
100
101    /**
102     * Indicates whether login to the SMTP server will be attpemted
103     */

104    public boolean isLoginToServer();
105
106    /**
107     * Sets the send timeout, by default it is 10 secs
108     */

109    public void setTimeout(int timeout);
110
111    /**
112     * Returns the timeout used when sending mails
113     */

114    public int getTimeout();
115
116    /**
117     * Gets the from address attached to mails
118     */

119    public String JavaDoc getFromAddress();
120
121    /**
122     * Sets the form address set to mail
123     */

124    public void setFromAddress(String JavaDoc fromAddress);
125
126    /**
127     * Gets the from name presented on the mail
128     */

129    public String JavaDoc getFromName();
130
131    /**
132     * Sets the from name presented on the mail
133     */

134    public void setFromName(String JavaDoc fromName);
135
136    /**
137     * Gets the MIME type set to the mail
138     */

139    public String JavaDoc getMimeType();
140
141    /**
142     * Sets the MIME type, by default it is text/plain
143     */

144    public void setMimeType(String JavaDoc mimeType);
145
146    /**
147     * Gets a comma separated list of addresses set in the TO field
148     */

149    public String JavaDoc getTo();
150
151    /**
152     * Sets a comma separated list of address which will go in the TO mail field
153     */

154    public void setTo(String JavaDoc toAddresses);
155
156    /**
157     * Gets a comma separated list of addresses set in the BCC field
158     */

159    public String JavaDoc getBCC();
160
161    /**
162     * Sets a comma separated list of address which will go in the BCC mail field
163     */

164    public void setBCC(String JavaDoc bccAddresses);
165
166    /**
167     * Gets a comma separated list of addresses set in the CC field
168     */

169    public String JavaDoc getCC();
170
171    /**
172     * Sets a comma separated list of address which will go in the CC mail field
173     */

174    public void setCC(String JavaDoc ccAddresses);
175
176    /**
177     * Gets the mail subject
178     */

179    public String JavaDoc getSubject();
180
181    /**
182     * Sets the mail's subject, by default is Empty subject. The subject field can contain keyword expansion
183     */

184    public void setSubject(String JavaDoc subject);
185
186    /**
187     * Returns the content of the mail
188     */

189    public String JavaDoc getContent();
190
191    /**
192     * Sets the content of the mail
193     */

194    public void setContent(String JavaDoc content);
195
196    /**
197     * This will directly execute the send mail. It can be used to manually testing the MBean or direct execution
198     */

199    public void sendMail();
200
201 }
202
Popular Tags