KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > mail > SMTPSTransportGBean


1 /**
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17 package org.apache.geronimo.mail;
18
19 import java.util.Properties JavaDoc;
20
21 import org.apache.commons.logging.Log;
22 import org.apache.commons.logging.LogFactory;
23
24 import org.apache.geronimo.gbean.GBeanInfo;
25 import org.apache.geronimo.gbean.GBeanInfoBuilder;
26
27 /**
28  * A GBean that provides for the configuration of a JavaMail SMTP transport
29  * protocol.
30  * <p/>
31  * SMTP transport properties that are common to all SMTP transports are
32  * provided via member variables of this class. Values that are set in the
33  * individual member variables will override any of the corresponding values
34  * that have been set in the properties set.
35  *
36  * @version $Rev: 486195 $ $Date: 2006-12-12 10:42:02 -0500 (Tue, 12 Dec 2006) $
37  * @see MailGBean
38  */

39 public class SMTPSTransportGBean extends ProtocolGBean {
40
41     // the SMTPS configuration property names
42
static public final String JavaDoc SMTPS_PORT = "mail.smtp.port";
43     static public final String JavaDoc SMTPS_CONNECTION_TIMEOUT = "mail.smtp.connectiontimeout";
44     static public final String JavaDoc SMTPS_TIMEOUT = "mail.smtp.timeout";
45     static public final String JavaDoc SMTPS_FROM = "mail.smtp.from";
46     static public final String JavaDoc SMTPS_AUTH = "mail.smtp.auth";
47     static public final String JavaDoc SMTPS_REALM = "mail.smtp.sasl.realm";
48     static public final String JavaDoc SMTPS_QUITWAIT = "mail.smtp.quitwait";
49     static public final String JavaDoc SMTPS_FACTORY_CLASS = "mail.smtp.socketFactory.class";
50     static public final String JavaDoc SMTPS_FACTORY_FALLBACK = "mail.smtp.socketFactory.fallback";
51     static public final String JavaDoc SMTPS_FACTORY_PORT = "mail.smtp.socketFactory.port";
52     static public final String JavaDoc SMTPS_LOCALHOST = "mail.smtp.localhost";
53     static public final String JavaDoc SMTPS_LOCALADDRESS = "mail.smtp.localaddress";
54     static public final String JavaDoc SMTPS_LOCALPORT = "mail.smtp.localport";
55     static public final String JavaDoc SMTPS_EHLO = "mail.smtp.ehlo";
56     static public final String JavaDoc SMTPS_SUBMITTER = "mail.smtp.submitter";
57     static public final String JavaDoc SMTPS_DSN_NOTIFY = "mail.smtp.dsn.notify";
58     static public final String JavaDoc SMTPS_DSN_RET = "mail.smtp.dsn.ret";
59     static public final String JavaDoc SMTPS_8BITMIME = "mail.smtp.allow8bitmime";
60     static public final String JavaDoc SMTPS_SEND_PARTIAL = "mail.smtp.sendpartial";
61     static public final String JavaDoc SMTPS_REPORT_SUCCESS = "mail.smtp.reportsuccess";
62     static public final String JavaDoc SMTPS_MAIL_EXTENSION = "mail.smtp.mailextension";
63     static public final String JavaDoc SMTPS_STARTTLS_ENABLE = "mail.smtp.starttls.enable";
64
65     static public final String JavaDoc GBEAN_EHLO = "ehlo";
66     static public final String JavaDoc GBEAN_SUBMITTER = "submitter";
67     static public final String JavaDoc GBEAN_DSN_NOTIFY = "dsnNotify";
68     static public final String JavaDoc GBEAN_DSN_RET = "dsnRet";
69     static public final String JavaDoc GBEAN_8BITMIME = "allow8bitmime";
70     static public final String JavaDoc GBEAN_SEND_PARTIAL = "sendPartical";
71     static public final String JavaDoc GBEAN_REPORT_SUCCESS = "reportSuccess";
72     static public final String JavaDoc GBEAN_MAIL_EXTENSION = "mailExtension";
73     static public final String JavaDoc GBEAN_STARTTLS_ENABLE = "startTLSEnable";
74
75     private final Log log = LogFactory.getLog(SMTPSTransportGBean.class);
76
77     private Integer JavaDoc port;
78     private Integer JavaDoc connectionTimeout;
79     private Integer JavaDoc timeout;
80     private String JavaDoc from;
81     private String JavaDoc localhost;
82     private String JavaDoc localaddress;
83     private Integer JavaDoc localport;
84     private Boolean JavaDoc ehlo;
85     private Boolean JavaDoc auth;
86     private String JavaDoc submitter;
87     private String JavaDoc dsnNotify;
88     private String JavaDoc dsnRet;
89     private Boolean JavaDoc allow8bitmime;
90     private Boolean JavaDoc sendPartial;
91     private String JavaDoc saslRealm;
92     private Boolean JavaDoc quitWait;
93     private Boolean JavaDoc reportSuccess;
94     private String JavaDoc socketFactoryClass;
95     private Boolean JavaDoc socketFactoryFallback;
96     private Integer JavaDoc socketFactoryPort;
97     private String JavaDoc mailExtension;
98     private Boolean JavaDoc startTLSEnable;
99
100
101     /**
102      * Construct an instance of SMTPSTransportGBean
103      * <p/>
104      * Values that are set in the individual member variables will override any of
105      * the corresponding values that have been set in the properties set.
106      *
107      * @param objectName the object name of the protocol
108      * @param properties the set of default properties for the protocol
109      * @param host the host the protocol connects to
110      * @param user the default name for the protocol
111      * @param port the SMTPS server port
112      * @param connectionTimeout the socket connection timeout value in milliseconds
113      * @param timeout the socket I/O timeout value in milliseconds
114      * @param from the email address to use for SMTPS MAIL command
115      * @param localhost the local host name used in the SMTPS HELO or EHLO command
116      * @param localaddress the local address (host name) to bind to when creating the SMTPS socket
117      * @param localport the local port number to bind to when creating the SMTPS socket
118      * @param ehlo whether an attempt will be made to sign on with the EHLO command
119      * @param auth whether an attempt will be made to authenticate the user using
120      * the AUTH command
121      * @param startTLSEnable the flag that enables the use of the STARTTLS command (if supported by the server) to switch the connection to a TLS-protected connection before issuing any login commands
122      * @param submitter the submitter to use in the AUTH tag in the MAIL FROM command
123      * @param dsnNotify the NOTIFY option to the RCPT command
124      * @param dsnRet the RET option to the MAIL command
125      * @param allow8bitmime whether encodings are converted to use "8bit" under certain
126      * conditions
127      * @param sendPartial whether to send email to valid addresses when others are invalid
128      * @param saslRealm the realm to use with DIGEST-MD5 authentication
129      * @param quitWait whether the transport will wait for the response to the QUIT command
130      * @param reportSuccess whether the transport will include an SMTPAddressSucceededException
131      * for each address that is successful
132      * @param socketFactoryClass the class that will be used to create SMTPS sockets
133      * @param socketFactoryFallback whether java.net.Socket class will be created if the specified
134      * socket factory class cannot be created
135      * @param socketFactoryPort whether java.net.Socket class will be created if the specified
136      * socket factory class cannot be created
137      * @param mailExtension the extension string to append to the MAIL command
138      */

139     public SMTPSTransportGBean(String JavaDoc objectName, Properties JavaDoc properties, String JavaDoc host, String JavaDoc user,
140                               Integer JavaDoc port,
141                               Integer JavaDoc connectionTimeout,
142                               Integer JavaDoc timeout,
143                               String JavaDoc from,
144                               String JavaDoc localhost,
145                               String JavaDoc localaddress,
146                               Integer JavaDoc localport,
147                               Boolean JavaDoc ehlo,
148                               Boolean JavaDoc auth,
149                               Boolean JavaDoc startTLSEnable,
150                               String JavaDoc submitter,
151                               String JavaDoc dsnNotify,
152                               String JavaDoc dsnRet,
153                               Boolean JavaDoc allow8bitmime,
154                               Boolean JavaDoc sendPartial,
155                               String JavaDoc saslRealm,
156                               Boolean JavaDoc quitWait,
157                               Boolean JavaDoc reportSuccess,
158                               String JavaDoc socketFactoryClass,
159                               Boolean JavaDoc socketFactoryFallback,
160                               Integer JavaDoc socketFactoryPort,
161                               String JavaDoc mailExtension) {
162         super(objectName, "smtps", properties, host, user);
163
164         setPort(port);
165         setConnectionTimeout(connectionTimeout);
166         setTimeout(timeout);
167         setFrom(from);
168         setLocalhost(localhost);
169         setLocaladdress(localaddress);
170         setLocalport(localport);
171         setEhlo(ehlo);
172         setAuth(auth);
173         setStartTLSEnable(startTLSEnable);
174         setSubmitter(submitter);
175         setDsnNotify(dsnNotify);
176         setDsnRet(dsnRet);
177         setAllow8bitmime(allow8bitmime);
178         setSendPartial(sendPartial);
179         setSaslRealm(saslRealm);
180         setQuitWait(quitWait);
181         setReportSuccess(reportSuccess);
182         setSocketFactoryClass(socketFactoryClass);
183         setSocketFactoryFallback(socketFactoryFallback);
184         setSocketFactoryPort(socketFactoryPort);
185         setMailExtension(mailExtension);
186     }
187
188     /**
189      * Returns the SMTP server port to connect to, if the connect() method
190      * doesn't explicitly specify one.
191      */

192     public Integer JavaDoc getPort() {
193         return port;
194     }
195
196     /**
197      * Sets the SMTP server port to connect to, if the connect() method
198      * doesn't explicitly specify one.
199      * <p/>
200      * Defaults to 25.
201      * <p/>
202      * Values that are set here will override any of the corresponding value
203      * that has been set in the properties.
204      *
205      * @param port the SMTP server port to connect to
206      */

207     public void setPort(Integer JavaDoc port) {
208         this.port = port;
209     }
210
211     /**
212      * Returns the socket connection timeout value in milliseconds.
213      */

214     public Integer JavaDoc getConnectionTimeout() {
215         return connectionTimeout;
216     }
217
218     /**
219      * Sets the socket connection timeout value in milliseconds.
220      * <p/>
221      * Default is infinite timeout.
222      * <p/>
223      * Values that are set here will override any of the corresponding value
224      * that has been set in the properties.
225      *
226      * @param connectionTimeout the socket connection timeout value in milliseconds.
227      */

228     public void setConnectionTimeout(Integer JavaDoc connectionTimeout) {
229         this.connectionTimeout = connectionTimeout;
230     }
231
232     /**
233      * Returns the socket I/O timeout value in milliseconds.
234      */

235     public Integer JavaDoc getTimeout() {
236         return timeout;
237     }
238
239     /**
240      * Sets the socket I/O timeout value in milliseconds.
241      * <p/>
242      * Default is infinite timeout.
243      * <p/>
244      * Values that are set here will override any of the corresponding value
245      * that has been set in the properties.
246      *
247      * @param timeout the socket I/O timeout value in milliseconds
248      */

249     public void setTimeout(Integer JavaDoc timeout) {
250         this.timeout = timeout;
251     }
252
253     /**
254      * Returns the email address to use for SMTP MAIL command.
255      */

256     public String JavaDoc getFrom() {
257         return from;
258     }
259
260     /**
261      * Sets the email address to use for SMTP MAIL command
262      * <p/>
263      * Email address to use for SMTP MAIL command. This sets the envelope
264      * return address. Defaults to msg.getFrom() or InternetAddress.getLocalAddress().
265      * NOTE: mail.smtp.user was previously used for this.
266      * <p/>
267      * Values that are set here will override any of the corresponding value
268      * that has been set in the properties.
269      *
270      * @param from the email address to use for SMTP MAIL command
271      */

272     public void setFrom(String JavaDoc from) {
273         this.from = from;
274     }
275
276     /**
277      * Returns the local host name used in the SMTP HELO or EHLO command.
278      */

279     public String JavaDoc getLocalhost() {
280         return localhost;
281     }
282
283     /**
284      * Sets the local host name used in the SMTP HELO or EHLO command.
285      * <p/>
286      * Local host name used in the SMTP HELO or EHLO command. Defaults to
287      * InetAddress.getLocalHost().getHostName(). Should not normally need to
288      * be set if your JDK and your name service are configured properly.
289      * <p/>
290      * Values that are set here will override any of the corresponding value
291      * that has been set in the properties.
292      *
293      * @param localhost the local host name used in the SMTP HELO or EHLO command
294      */

295     public void setLocalhost(String JavaDoc localhost) {
296         this.localhost = localhost;
297     }
298
299     /**
300      * Returns the local address (host name) to bind to when creating the SMTP socket.
301      */

302     public String JavaDoc getLocaladdress() {
303         return localaddress;
304     }
305
306     /**
307      * Sets the local address (host name) to bind to when creating the SMTP socket.
308      * <p/>
309      * Local address (host name) to bind to when creating the SMTP socket.
310      * Defaults to the address picked by the Socket class. Should not normally
311      * need to be set, but useful with multi-homed hosts where it's important
312      * to pick a particular local address to bind to.
313      * <p/>
314      * Values that are set here will override any of the corresponding value
315      * that has been set in the properties.
316      *
317      * @param localaddress the local address (host name) to bind to when creating the SMTP socket
318      */

319     public void setLocaladdress(String JavaDoc localaddress) {
320         this.localaddress = localaddress;
321     }
322
323     /**
324      * Returns the local port number to bind to when creating the SMTP socket.
325      */

326     public Integer JavaDoc getLocalport() {
327         return localport;
328     }
329
330     /**
331      * Sets the local port number to bind to when creating the SMTP socket.
332      * <p/>
333      * Local port number to bind to when creating the SMTP socket. Defaults to
334      * the port number picked by the Socket class.
335      * <p/>
336      * Values that are set here will override any of the corresponding value
337      * that has been set in the properties.
338      *
339      * @param localport the local port number to bind to when creating the SMTP socket
340      */

341     public void setLocalport(Integer JavaDoc localport) {
342         this.localport = localport;
343     }
344
345     /**
346      * Returns whether an attempt will be made to sign on with the EHLO command.
347      * <p/>
348      * If false, do not attempt to sign on with the EHLO command. Normally
349      * failure of the EHLO command will fallback to the HELO command; this
350      * property exists only for servers that don't fail EHLO properly or don't
351      * implement EHLO properly.
352      */

353     public Boolean JavaDoc getEhlo() {
354         return ehlo;
355     }
356
357     /**
358      * Set whether an attempt will be made to sign on with the EHLO command.
359      * <p/>
360      * If false, do not attempt to sign on with the EHLO command. Normally
361      * failure of the EHLO command will fallback to the HELO command; this
362      * property exists only for servers that don't fail EHLO properly or don't
363      * implement EHLO properly.
364      * <p/>
365      * Values that are set here will override any of the corresponding value
366      * that has been set in the properties.
367      *
368      * @param ehlo whether an attempt will be made to sign on with the EHLO command
369      */

370     public void setEhlo(Boolean JavaDoc ehlo) {
371         this.ehlo = ehlo;
372     }
373
374     /**
375      * Returns whether an attempt will be made to authenticate the user using
376      * the AUTH command.
377      * <p/>
378      * Defaults to false.
379      */

380     public Boolean JavaDoc getAuth() {
381         return auth;
382     }
383
384     /**
385      * Sets whether an attempt will be made to authenticate the user using
386      * the AUTH command.
387      * <p/>
388      * Defaults to false.
389      * <p/>
390      * Values that are set here will override any of the corresponding value
391      * that has been set in the properties.
392      *
393      * @param auth whether an attempt will be made to authenticate the user using
394      * the AUTH command.
395      */

396     public void setAuth(Boolean JavaDoc auth) {
397         this.auth = auth;
398     }
399
400     /**
401      * Returns the flag that enables the use of the STARTTLS command (if
402      * supported by the server) to switch the connection to a TLS-protected
403      * connection before issuing any login commands.
404      * <p/>
405      * If true, enables the use of the STARTTLS command (if supported by the
406      * server) to switch the connection to a TLS-protected connection before
407      * issuing any login commands. Note that an appropriate trust store must
408      * configured so that the client will trust the server's certificate.
409      * This feature only works on J2SE 1.4 and newer systems. Default is false.
410      */

411     public Boolean JavaDoc getStartTLSEnable() {
412         return startTLSEnable;
413     }
414
415     /**
416      * Sets the flag that enables the use of the STARTTLS command (if
417      * supported by the server) to switch the connection to a TLS-protected
418      * connection before issuing any login commands.
419      * <p/>
420      * If true, enables the use of the STARTTLS command (if supported by the
421      * server) to switch the connection to a TLS-protected connection before
422      * issuing any login commands. Note that an appropriate trust store must
423      * configured so that the client will trust the server's certificate.
424      * This feature only works on J2SE 1.4 and newer systems. Default is false.
425      * <p/>
426      * Values that are set here will override any of the corresponding value
427      * that has been set in the properties.
428      *
429      * @param startTLSEnable the flag that enables the use of the STARTTLS command (if
430      * supported by the server) to switch the connection to a TLS-protected
431      * connection before issuing any login commands
432      */

433     public void setStartTLSEnable(Boolean JavaDoc startTLSEnable) {
434         this.startTLSEnable = startTLSEnable;
435     }
436
437     /**
438      * Returns the submitter to use in the AUTH tag in the MAIL FROM command.
439      * <p/>
440      * Typically used by a mail relay to pass along information about the
441      * original submitter of the message. See also the setSubmitter method of
442      * SMTPMessage. Mail clients typically do not use this.
443      */

444     public String JavaDoc getSubmitter() {
445         return submitter;
446     }
447
448     /**
449      * Sets the submitter to use in the AUTH tag in the MAIL FROM command.
450      * <p/>
451      * Typically used by a mail relay to pass along information about the
452      * original submitter of the message. See also the setSubmitter method of
453      * SMTPMessage. Mail clients typically do not use this.
454      * <p/>
455      * Values that are set here will override any of the corresponding value
456      * that has been set in the properties.
457      *
458      * @param submitter the submitter to use in the AUTH tag in the MAIL FROM command
459      */

460     public void setSubmitter(String JavaDoc submitter) {
461         this.submitter = submitter;
462     }
463
464     /**
465      * Returns the NOTIFY option to the RCPT command.
466      * <p/>
467      * Either NEVER, or some combination of SUCCESS, FAILURE, and DELAY
468      * (separated by commas).
469      */

470     public String JavaDoc getDsnNotify() {
471         return dsnNotify;
472     }
473
474     /**
475      * Sets the NOTIFY option to the RCPT command
476      * <p/>
477      * Either NEVER, or some combination of SUCCESS, FAILURE, and DELAY
478      * (separated by commas).
479      * <p/>
480      * Values that are set here will override any of the corresponding value
481      * that has been set in the properties.
482      *
483      * @param dsnNotify the NOTIFY option to the RCPT command
484      */

485     public void setDsnNotify(String JavaDoc dsnNotify) {
486         this.dsnNotify = dsnNotify;
487     }
488
489     /**
490      * Returns the RET option to the MAIL command.
491      * <p/>
492      * Either FULL or HDRS.
493      */

494     public String JavaDoc getDsnRet() {
495         return dsnRet;
496     }
497
498     /**
499      * Sets the RET option to the MAIL command
500      * <p/>
501      * Either FULL or HDRS.
502      * <p/>
503      * Values that are set here will override any of the corresponding value
504      * that has been set in the properties.
505      *
506      * @param dsnRet the RET option to the MAIL command
507      */

508     public void setDsnRet(String JavaDoc dsnRet) {
509         this.dsnRet = dsnRet;
510     }
511
512     /**
513      * Returns whether encodings are converted to use "8bit" under certain
514      * conditions.
515      * <p/>
516      * If set to true, and the server supports the 8BITMIME extension, text
517      * parts of messages that use the "quoted-printable" or "base64" encodings
518      * are converted to use "8bit" encoding if they follow the RFC2045 rules
519      * for 8bit text.
520      */

521     public Boolean JavaDoc getAllow8bitmime() {
522         return allow8bitmime;
523     }
524
525     /**
526      * Sets whether encodings are converted to use "8bit" under certain
527      * conditions.
528      * <p/>
529      * If set to true, and the server supports the 8BITMIME extension, text
530      * parts of messages that use the "quoted-printable" or "base64" encodings
531      * are converted to use "8bit" encoding if they follow the RFC2045 rules
532      * for 8bit text.
533      * <p/>
534      * Values that are set here will override any of the corresponding value
535      * that has been set in the properties.
536      *
537      * @param allow8bitmime whether encodings are converted to use "8bit" under certain
538      * conditions
539      */

540     public void setAllow8bitmime(Boolean JavaDoc allow8bitmime) {
541         this.allow8bitmime = allow8bitmime;
542     }
543
544     /**
545      * Returns whether to send email to valid addresses when others are invalid.
546      * <p/>
547      * If set to true, and a message has some valid and some invalid addresses,
548      * send the message anyway, reporting the partial failure with a
549      * SendFailedException. If set to false (the default), the message is not
550      * sent to any of the recipients if there is an invalid recipient address.
551      */

552     public Boolean JavaDoc getSendPartial() {
553         return sendPartial;
554     }
555
556     /**
557      * Sets whether to send email to valid addresses when others are invalid.
558      * <p/>
559      * If set to true, and a message has some valid and some invalid addresses,
560      * send the message anyway, reporting the partial failure with a
561      * SendFailedException. If set to false (the default), the message is not
562      * sent to any of the recipients if there is an invalid recipient address.
563      * <p/>
564      * Values that are set here will override any of the corresponding value
565      * that has been set in the properties.
566      *
567      * @param sendPartial whether to send email to valid addresses when others are invalid
568      */

569     public void setSendPartial(Boolean JavaDoc sendPartial) {
570         this.sendPartial = sendPartial;
571     }
572
573     /**
574      * Returns the realm to use with DIGEST-MD5 authentication.
575      */

576     public String JavaDoc getSaslRealm() {
577         return saslRealm;
578     }
579
580     /**
581      * Sets the realm to use with DIGEST-MD5 authentication.
582      * <p/>
583      * Values that are set here will override any of the corresponding value
584      * that has been set in the properties.
585      *
586      * @param saslRealm the realm to use with DIGEST-MD5 authentication
587      */

588     public void setSaslRealm(String JavaDoc saslRealm) {
589         this.saslRealm = saslRealm;
590     }
591
592     /**
593      * Returns whether the transport will wait for the response to the QUIT command.
594      * <p/>
595      * If set to true, causes the transport to wait for the response to the QUIT
596      * command. If set to false (the default), the QUIT command is sent and the
597      * connection is immediately closed.
598      */

599     public Boolean JavaDoc getQuitWait() {
600         return quitWait;
601     }
602
603     /**
604      * Sets whether the transport will wait for the response to the QUIT command
605      * <p/>
606      * If set to true, causes the transport to wait for the response to the QUIT
607      * command. If set to false (the default), the QUIT command is sent and the
608      * connection is immediately closed.
609      * <p/>
610      * Values that are set here will override any of the corresponding value
611      * that has been set in the properties.
612      *
613      * @param quitWait whether the transport will wait for the response to the QUIT command
614      */

615     public void setQuitWait(Boolean JavaDoc quitWait) {
616         this.quitWait = quitWait;
617     }
618
619     /**
620      * Returns whether the transport will include an SMTPAddressSucceededException
621      * for each address that is successful.
622      * <p/>
623      * Note also that this will cause a SendFailedException to be thrown from
624      * the sendMessage method of SMTPTransport even if all addresses were
625      * correct and the message was sent successfully.
626      */

627     public Boolean JavaDoc getReportSuccess() {
628         return reportSuccess;
629     }
630
631     /**
632      * Sets whether the transport will include an SMTPAddressSucceededException
633      * for each address that is successful.
634      * <p/>
635      * Note also that this will cause a SendFailedException to be thrown from
636      * the sendMessage method of SMTPTransport even if all addresses were
637      * correct and the message was sent successfully.
638      * <p/>
639      * Values that are set here will override any of the corresponding value
640      * that has been set in the properties.
641      *
642      * @param reportSuccess whether the transport will include an SMTPAddressSucceededException
643      * for each address that is successful
644      */

645     public void setReportSuccess(Boolean JavaDoc reportSuccess) {
646         this.reportSuccess = reportSuccess;
647     }
648
649     /**
650      * Returns the class that will be used to create SMTP sockets.
651      * <p/>
652      * If set, specifies the name of a class that implements the
653      * javax.net.SocketFactory interface. This class will be used to create SMTP
654      * sockets.
655      */

656     public String JavaDoc getSocketFactoryClass() {
657         return socketFactoryClass;
658     }
659
660     /**
661      * Sets the class that will be used to create SMTP sockets.
662      * <p/>
663      * If set, specifies the name of a class that implements the
664      * javax.net.SocketFactory interface. This class will be used to create SMTP
665      * sockets.
666      * <p/>
667      * Values that are set here will override any of the corresponding value
668      * that has been set in the properties.
669      *
670      * @param socketFactoryClass the class that will be used to create SMTP sockets
671      */

672     public void setSocketFactoryClass(String JavaDoc socketFactoryClass) {
673         this.socketFactoryClass = socketFactoryClass;
674     }
675
676     /**
677      * Returns whether java.net.Socket class will be created if the specified
678      * socket factory class cannot be created.
679      * <p/>
680      * If set to true, failure to create a socket using the specified socket
681      * factory class will cause the socket to be created using the
682      * java.net.Socket class. Defaults to true.
683      */

684     public Boolean JavaDoc getSocketFactoryFallback() {
685         return socketFactoryFallback;
686     }
687
688     /**
689      * Sets whether java.net.Socket class will be created if the specified
690      * socket factory class cannot be created.
691      * <p/>
692      * If set to true, failure to create a socket using the specified socket
693      * factory class will cause the socket to be created using the
694      * java.net.Socket class. Defaults to true.
695      * <p/>
696      * Values that are set here will override any of the corresponding value
697      * that has been set in the properties.
698      *
699      * @param socketFactoryFallback whether java.net.Socket class will be created if the specified
700      * socket factory class cannot be created
701      */

702     public void setSocketFactoryFallback(Boolean JavaDoc socketFactoryFallback) {
703         this.socketFactoryFallback = socketFactoryFallback;
704     }
705
706     /**
707      * Returns the port to connect to when using the specified socket factory.
708      * <p/>
709      * Specifies the port to connect to when using the specified socket
710      * factory. If not set, the default port will be used.
711      */

712     public Integer JavaDoc getSocketFactoryPort() {
713         return socketFactoryPort;
714     }
715
716     /**
717      * Sets the port to connect to when using the specified socket factory.
718      * <p/>
719      * Specifies the port to connect to when using the specified socket
720      * factory. If not set, the default port will be used.
721      * <p/>
722      * Values that are set here will override any of the corresponding value
723      * that has been set in the properties.
724      *
725      * @param socketFactoryPort the port to connect to when using the specified socket factory
726      */

727     public void setSocketFactoryPort(Integer JavaDoc socketFactoryPort) {
728         this.socketFactoryPort = socketFactoryPort;
729     }
730
731     /**
732      * Returns the extension string to append to the MAIL command.
733      * <p/>
734      * Extension string to append to the MAIL command. The extension string
735      * can be used to specify standard SMTP service extensions as well as
736      * vendor-specific extensions. Typically the application should use the
737      * SMTPTransport method supportsExtension to verify that the server
738      * supports the desired service extension. See RFC 1869 and other RFCs
739      * that define specific extensions.
740      */

741     public String JavaDoc getMailExtension() {
742         return mailExtension;
743     }
744
745     /**
746      * Sets the extension string to append to the MAIL command.
747      * <p/>
748      * Extension string to append to the MAIL command. The extension string
749      * can be used to specify standard SMTP service extensions as well as
750      * vendor-specific extensions. Typically the application should use the
751      * SMTPTransport method supportsExtension to verify that the server
752      * supports the desired service extension. See RFC 1869 and other RFCs
753      * that define specific extensions.
754      * <p/>
755      * Values that are set here will override any of the corresponding value
756      * that has been set in the properties.
757      *
758      * @param mailExtension the extension string to append to the MAIL command
759      */

760     public void setMailExtension(String JavaDoc mailExtension) {
761         this.mailExtension = mailExtension;
762     }
763
764     /**
765      * Add the overrides from the member variables to the properties file.
766      */

767     public void addOverrides(Properties JavaDoc props) {
768         super.addOverrides(props);
769
770         if (port != null) props.setProperty(SMTPS_PORT, port.toString());
771         if (connectionTimeout != null) props.setProperty(SMTPS_CONNECTION_TIMEOUT, connectionTimeout.toString());
772         if (timeout != null) props.setProperty(SMTPS_TIMEOUT, timeout.toString());
773         if (from != null) props.setProperty(SMTPS_FROM, from);
774         if (localhost != null) props.setProperty(SMTPS_LOCALHOST, localhost);
775         if (localaddress != null) props.setProperty(SMTPS_LOCALADDRESS, localaddress);
776         if (localport != null) props.setProperty(SMTPS_LOCALPORT, localport.toString());
777         if (ehlo != null) props.setProperty(SMTPS_EHLO, ehlo.toString());
778         if (auth != null) props.setProperty(SMTPS_AUTH, auth.toString());
779         if (startTLSEnable != null) props.setProperty(SMTPS_STARTTLS_ENABLE, startTLSEnable.toString());
780         if (submitter != null) props.setProperty(SMTPS_SUBMITTER, submitter);
781         if (dsnNotify != null) props.setProperty(SMTPS_DSN_NOTIFY, dsnNotify.toString());
782         if (dsnRet != null) props.setProperty(SMTPS_DSN_RET, dsnRet.toString());
783         if (allow8bitmime != null) props.setProperty(SMTPS_8BITMIME, allow8bitmime.toString());
784         if (sendPartial != null) props.setProperty(SMTPS_SEND_PARTIAL, sendPartial.toString());
785         if (saslRealm != null) props.setProperty(SMTPS_REALM, saslRealm);
786         if (quitWait != null) props.setProperty(SMTPS_QUITWAIT, quitWait.toString());
787         if (reportSuccess != null) props.setProperty(SMTPS_REPORT_SUCCESS, reportSuccess.toString());
788         if (socketFactoryClass != null) props.setProperty(SMTPS_FACTORY_CLASS, socketFactoryClass);
789         if (socketFactoryFallback != null) props.setProperty(SMTPS_FACTORY_FALLBACK, socketFactoryFallback.toString());
790         if (socketFactoryPort != null) props.setProperty(SMTPS_FACTORY_PORT, socketFactoryPort.toString());
791         if (mailExtension != null) props.setProperty(SMTPS_MAIL_EXTENSION, mailExtension);
792     }
793
794     public void doStart() throws Exception JavaDoc {
795         log.debug("Started " + getObjectName());
796     }
797
798     public void doStop() throws Exception JavaDoc {
799         log.debug("Stopped " + getObjectName());
800     }
801
802     public void doFail() {
803         log.warn("Failed " + getObjectName());
804     }
805
806     public static final GBeanInfo GBEAN_INFO;
807
808     static {
809         GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(SMTPSTransportGBean.class);
810
811         infoFactory.addAttribute(GBEAN_PORT, Integer JavaDoc.class, true);
812         infoFactory.addAttribute(GBEAN_CONNECTION_TIMEOUT, Integer JavaDoc.class, true);
813         infoFactory.addAttribute(GBEAN_TIMEOUT, Integer JavaDoc.class, true);
814         infoFactory.addAttribute(GBEAN_AUTH, Boolean JavaDoc.class, true);
815         infoFactory.addAttribute(GBEAN_STARTTLS_ENABLE, Boolean JavaDoc.class, true);
816         infoFactory.addAttribute(GBEAN_EHLO, Boolean JavaDoc.class, true);
817         infoFactory.addAttribute(GBEAN_FROM, String JavaDoc.class, true);
818         infoFactory.addAttribute(GBEAN_LOCALHOST, String JavaDoc.class, true);
819         infoFactory.addAttribute(GBEAN_LOCALADDRESS, String JavaDoc.class, true);
820         infoFactory.addAttribute(GBEAN_LOCALPORT, Integer JavaDoc.class, true);
821         infoFactory.addAttribute(GBEAN_REALM, String JavaDoc.class, true);
822         infoFactory.addAttribute(GBEAN_QUITWAIT, Boolean JavaDoc.class, true);
823         infoFactory.addAttribute(GBEAN_FACTORY_CLASS, String JavaDoc.class, true);
824         infoFactory.addAttribute(GBEAN_FACTORY_FALLBACK, Boolean JavaDoc.class, true);
825         infoFactory.addAttribute(GBEAN_FACTORY_PORT, Integer JavaDoc.class, true);
826
827         infoFactory.addAttribute(GBEAN_SUBMITTER, String JavaDoc.class, true);
828         infoFactory.addAttribute(GBEAN_DSN_NOTIFY, String JavaDoc.class, true);
829         infoFactory.addAttribute(GBEAN_DSN_RET, String JavaDoc.class, true);
830         infoFactory.addAttribute(GBEAN_8BITMIME, Boolean JavaDoc.class, true);
831         infoFactory.addAttribute(GBEAN_SEND_PARTIAL, Boolean JavaDoc.class, true);
832         infoFactory.addAttribute(GBEAN_REPORT_SUCCESS, Boolean JavaDoc.class, true);
833         infoFactory.addAttribute(GBEAN_MAIL_EXTENSION, String JavaDoc.class, true);
834
835         infoFactory.addAttribute(GBEAN_OBJECTNAME, String JavaDoc.class, false);
836         infoFactory.addAttribute(GBEAN_PROTOCOL, String JavaDoc.class, true);
837         infoFactory.addAttribute(GBEAN_PROPERTIES, Properties JavaDoc.class, true);
838         infoFactory.addAttribute(GBEAN_HOST, String JavaDoc.class, true);
839         infoFactory.addAttribute(GBEAN_USER, String JavaDoc.class, true);
840         infoFactory.addOperation(GBEAN_ADD_OVERRIDES, new Class JavaDoc[]{Properties JavaDoc.class});
841
842         infoFactory.setConstructor(new String JavaDoc[]{GBEAN_OBJECTNAME, GBEAN_PROPERTIES, GBEAN_HOST, GBEAN_USER,
843                                                 GBEAN_PORT,
844                                                 GBEAN_CONNECTION_TIMEOUT,
845                                                 GBEAN_TIMEOUT,
846                                                 GBEAN_FROM,
847                                                 GBEAN_LOCALHOST,
848                                                 GBEAN_LOCALADDRESS,
849                                                 GBEAN_LOCALPORT,
850                                                 GBEAN_EHLO,
851                                                 GBEAN_AUTH,
852                                                 GBEAN_STARTTLS_ENABLE,
853                                                 GBEAN_SUBMITTER,
854                                                 GBEAN_DSN_NOTIFY,
855                                                 GBEAN_DSN_RET,
856                                                 GBEAN_8BITMIME,
857                                                 GBEAN_SEND_PARTIAL,
858                                                 GBEAN_REALM,
859                                                 GBEAN_QUITWAIT,
860                                                 GBEAN_REPORT_SUCCESS,
861                                                 GBEAN_FACTORY_CLASS,
862                                                 GBEAN_FACTORY_FALLBACK,
863                                                 GBEAN_FACTORY_PORT,
864                                                 GBEAN_MAIL_EXTENSION});
865
866         GBEAN_INFO = infoFactory.getBeanInfo();
867     }
868
869     public static GBeanInfo getGBeanInfo() {
870         return GBEAN_INFO;
871     }
872 }
873
874
Popular Tags