Source Code Cross Referenced for SMTPTransportGBean.java in  » EJB-Server-geronimo » plugins » org » apache » geronimo » mail » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » EJB Server geronimo » plugins » org.apache.geronimo.mail 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         *  Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  See the NOTICE file distributed with
004:         *  this work for additional information regarding copyright ownership.
005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
006:         *  (the "License"); you may not use this file except in compliance with
007:         *  the License.  You may obtain a copy of the License at
008:         *
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *  See the License for the specific language governing permissions and
015:         *  limitations under the License.
016:         */package org.apache.geronimo.mail;
017:
018:        import java.util.Properties;
019:
020:        import org.apache.commons.logging.Log;
021:        import org.apache.commons.logging.LogFactory;
022:
023:        import org.apache.geronimo.gbean.GBeanInfo;
024:        import org.apache.geronimo.gbean.GBeanInfoBuilder;
025:
026:        /**
027:         * A GBean that provides for the configuration of a JavaMail SMTP transport
028:         * protocol.
029:         * <p/>
030:         * SMTP transport properties that are common to all SMTP transports are
031:         * provided via member variables of this class.  Values that are set in the
032:         * individual member variables will override any of the corresponding values
033:         * that have been set in the properties set.
034:         *
035:         * @version $Rev: 486195 $ $Date: 2006-12-12 07:42:02 -0800 (Tue, 12 Dec 2006) $
036:         * @see MailGBean
037:         */
038:        public class SMTPTransportGBean extends ProtocolGBean {
039:
040:            // the SMTP configuration property names
041:            static public final String SMTP_PORT = "mail.smtp.port";
042:            static public final String SMTP_CONNECTION_TIMEOUT = "mail.smtp.connectiontimeout";
043:            static public final String SMTP_TIMEOUT = "mail.smtp.timeout";
044:            static public final String SMTP_FROM = "mail.smtp.from";
045:            static public final String SMTP_AUTH = "mail.smtp.auth";
046:            static public final String SMTP_REALM = "mail.smtp.sasl.realm";
047:            static public final String SMTP_QUITWAIT = "mail.smtp.quitwait";
048:            static public final String SMTP_FACTORY_CLASS = "mail.smtp.socketFactory.class";
049:            static public final String SMTP_FACTORY_FALLBACK = "mail.smtp.socketFactory.fallback";
050:            static public final String SMTP_FACTORY_PORT = "mail.smtp.socketFactory.port";
051:            static public final String SMTP_LOCALHOST = "mail.smtp.localhost";
052:            static public final String SMTP_LOCALADDRESS = "mail.smtp.localaddress";
053:            static public final String SMTP_LOCALPORT = "mail.smtp.localport";
054:            static public final String SMTP_EHLO = "mail.smtp.ehlo";
055:            static public final String SMTP_SUBMITTER = "mail.smtp.submitter";
056:            static public final String SMTP_DSN_NOTIFY = "mail.smtp.dsn.notify";
057:            static public final String SMTP_DSN_RET = "mail.smtp.dsn.ret";
058:            static public final String SMTP_8BITMIME = "mail.smtp.allow8bitmime";
059:            static public final String SMTP_SEND_PARTIAL = "mail.smtp.sendpartial";
060:            static public final String SMTP_REPORT_SUCCESS = "mail.smtp.reportsuccess";
061:            static public final String SMTP_MAIL_EXTENSION = "mail.smtp.mailextension";
062:            static public final String SMTP_STARTTLS_ENABLE = "mail.smtp.starttls.enable";
063:
064:            static public final String GBEAN_EHLO = "ehlo";
065:            static public final String GBEAN_SUBMITTER = "submitter";
066:            static public final String GBEAN_DSN_NOTIFY = "dsnNotify";
067:            static public final String GBEAN_DSN_RET = "dsnRet";
068:            static public final String GBEAN_8BITMIME = "allow8bitmime";
069:            static public final String GBEAN_SEND_PARTIAL = "sendPartical";
070:            static public final String GBEAN_REPORT_SUCCESS = "reportSuccess";
071:            static public final String GBEAN_MAIL_EXTENSION = "mailExtension";
072:            static public final String GBEAN_STARTTLS_ENABLE = "startTLSEnable";
073:
074:            private final Log log = LogFactory.getLog(SMTPTransportGBean.class);
075:
076:            private Integer port;
077:            private Integer connectionTimeout;
078:            private Integer timeout;
079:            private String from;
080:            private String localhost;
081:            private String localaddress;
082:            private Integer localport;
083:            private Boolean ehlo;
084:            private Boolean auth;
085:            private String submitter;
086:            private String dsnNotify;
087:            private String dsnRet;
088:            private Boolean allow8bitmime;
089:            private Boolean sendPartial;
090:            private String saslRealm;
091:            private Boolean quitWait;
092:            private Boolean reportSuccess;
093:            private String socketFactoryClass;
094:            private Boolean socketFactoryFallback;
095:            private Integer socketFactoryPort;
096:            private String mailExtension;
097:            private Boolean startTLSEnable;
098:
099:            /**
100:             * Construct an instance of SMTPTransportGBean
101:             * <p/>
102:             * Values that are set in the individual member variables will override any of
103:             * the corresponding values that have been set in the properties set.
104:             *
105:             * @param objectName            the object name of the protocol
106:             * @param properties            the set of default properties for the protocol
107:             * @param host                  the host the protocol connects to
108:             * @param user                  the default name for the protocol
109:             * @param port                  the SMTP server port
110:             * @param connectionTimeout     the socket connection timeout value in milliseconds
111:             * @param timeout               the socket I/O timeout value in milliseconds
112:             * @param from                  the email address to use for SMTP MAIL command
113:             * @param localhost             the local host name used in the SMTP HELO or EHLO command
114:             * @param localaddress          the local address (host name) to bind to when creating the SMTP socket
115:             * @param localport             the local port number to bind to when creating the SMTP socket
116:             * @param ehlo                  whether an attempt will be made to sign on with the EHLO command
117:             * @param auth                  whether an attempt will be made to authenticate the user using
118:             *                              the AUTH command
119:             * @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
120:             * @param submitter             the submitter to use in the AUTH tag in the MAIL FROM command
121:             * @param dsnNotify             the NOTIFY option to the RCPT command
122:             * @param dsnRet                the RET option to the MAIL command
123:             * @param allow8bitmime         whether encodings are converted to use "8bit" under certain
124:             *                              conditions
125:             * @param sendPartial           whether to send email to valid addresses when others are invalid
126:             * @param saslRealm             the realm to use with DIGEST-MD5 authentication
127:             * @param quitWait              whether the transport will wait for the response to the QUIT command
128:             * @param reportSuccess         whether the transport will include an SMTPAddressSucceededException
129:             *                              for each address that is successful
130:             * @param socketFactoryClass    the class that will be used to create SMTP sockets
131:             * @param socketFactoryFallback whether java.net.Socket class will be created if the specified
132:             *                              socket factory class cannot be created
133:             * @param socketFactoryPort     whether java.net.Socket class will be created if the specified
134:             *                              socket factory class cannot be created
135:             * @param mailExtension         the extension string to append to the MAIL command
136:             */
137:            public SMTPTransportGBean(String objectName, Properties properties,
138:                    String host, String user, Integer port,
139:                    Integer connectionTimeout, Integer timeout, String from,
140:                    String localhost, String localaddress, Integer localport,
141:                    Boolean ehlo, Boolean auth, Boolean startTLSEnable,
142:                    String submitter, String dsnNotify, String dsnRet,
143:                    Boolean allow8bitmime, Boolean sendPartial,
144:                    String saslRealm, Boolean quitWait, Boolean reportSuccess,
145:                    String socketFactoryClass, Boolean socketFactoryFallback,
146:                    Integer socketFactoryPort, String mailExtension) {
147:                super (objectName, "smtp", properties, host, user);
148:
149:                setPort(port);
150:                setConnectionTimeout(connectionTimeout);
151:                setTimeout(timeout);
152:                setFrom(from);
153:                setLocalhost(localhost);
154:                setLocaladdress(localaddress);
155:                setLocalport(localport);
156:                setEhlo(ehlo);
157:                setAuth(auth);
158:                setStartTLSEnable(startTLSEnable);
159:                setSubmitter(submitter);
160:                setDsnNotify(dsnNotify);
161:                setDsnRet(dsnRet);
162:                setAllow8bitmime(allow8bitmime);
163:                setSendPartial(sendPartial);
164:                setSaslRealm(saslRealm);
165:                setQuitWait(quitWait);
166:                setReportSuccess(reportSuccess);
167:                setSocketFactoryClass(socketFactoryClass);
168:                setSocketFactoryFallback(socketFactoryFallback);
169:                setSocketFactoryPort(socketFactoryPort);
170:                setMailExtension(mailExtension);
171:            }
172:
173:            /**
174:             * Returns the SMTP server port to connect to, if the connect() method
175:             * doesn't explicitly specify one.
176:             */
177:            public Integer getPort() {
178:                return port;
179:            }
180:
181:            /**
182:             * Sets the SMTP server port to connect to, if the connect() method
183:             * doesn't explicitly specify one.
184:             * <p/>
185:             * Defaults to 25.
186:             * <p/>
187:             * Values that are set here will override any of the corresponding value
188:             * that has been set in the properties.
189:             *
190:             * @param port the SMTP server port to connect to
191:             */
192:            public void setPort(Integer port) {
193:                this .port = port;
194:            }
195:
196:            /**
197:             * Returns the socket connection timeout value in milliseconds.
198:             */
199:            public Integer getConnectionTimeout() {
200:                return connectionTimeout;
201:            }
202:
203:            /**
204:             * Sets the socket connection timeout value in milliseconds.
205:             * <p/>
206:             * Default is infinite timeout.
207:             * <p/>
208:             * Values that are set here will override any of the corresponding value
209:             * that has been set in the properties.
210:             *
211:             * @param connectionTimeout the socket connection timeout value in milliseconds.
212:             */
213:            public void setConnectionTimeout(Integer connectionTimeout) {
214:                this .connectionTimeout = connectionTimeout;
215:            }
216:
217:            /**
218:             * Returns the socket I/O timeout value in milliseconds.
219:             */
220:            public Integer getTimeout() {
221:                return timeout;
222:            }
223:
224:            /**
225:             * Sets the socket I/O timeout value in milliseconds.
226:             * <p/>
227:             * Default is infinite timeout.
228:             * <p/>
229:             * Values that are set here will override any of the corresponding value
230:             * that has been set in the properties.
231:             *
232:             * @param timeout the socket I/O timeout value in milliseconds
233:             */
234:            public void setTimeout(Integer timeout) {
235:                this .timeout = timeout;
236:            }
237:
238:            /**
239:             * Returns the email address to use for SMTP MAIL command.
240:             */
241:            public String getFrom() {
242:                return from;
243:            }
244:
245:            /**
246:             * Sets the email address to use for SMTP MAIL command
247:             * <p/>
248:             * Email address to use for SMTP MAIL command. This sets the envelope
249:             * return address. Defaults to msg.getFrom() or InternetAddress.getLocalAddress().
250:             * NOTE: mail.smtp.user was previously used for this.
251:             * <p/>
252:             * Values that are set here will override any of the corresponding value
253:             * that has been set in the properties.
254:             *
255:             * @param from the email address to use for SMTP MAIL command
256:             */
257:            public void setFrom(String from) {
258:                this .from = from;
259:            }
260:
261:            /**
262:             * Returns the local host name used in the SMTP HELO or EHLO command.
263:             */
264:            public String getLocalhost() {
265:                return localhost;
266:            }
267:
268:            /**
269:             * Sets the local host name used in the SMTP HELO or EHLO command.
270:             * <p/>
271:             * Local host name used in the SMTP HELO or EHLO command. Defaults to
272:             * InetAddress.getLocalHost().getHostName(). Should not normally need to
273:             * be set if your JDK and your name service are configured properly.
274:             * <p/>
275:             * Values that are set here will override any of the corresponding value
276:             * that has been set in the properties.
277:             *
278:             * @param localhost the local host name used in the SMTP HELO or EHLO command
279:             */
280:            public void setLocalhost(String localhost) {
281:                this .localhost = localhost;
282:            }
283:
284:            /**
285:             * Returns the local address (host name) to bind to when creating the SMTP socket.
286:             */
287:            public String getLocaladdress() {
288:                return localaddress;
289:            }
290:
291:            /**
292:             * Sets the local address (host name) to bind to when creating the SMTP socket.
293:             * <p/>
294:             * Local address (host name) to bind to when creating the SMTP socket.
295:             * Defaults to the address picked by the Socket class. Should not normally
296:             * need to be set, but useful with multi-homed hosts where it's important
297:             * to pick a particular local address to bind to.
298:             * <p/>
299:             * Values that are set here will override any of the corresponding value
300:             * that has been set in the properties.
301:             *
302:             * @param localaddress the local address (host name) to bind to when creating the SMTP socket
303:             */
304:            public void setLocaladdress(String localaddress) {
305:                this .localaddress = localaddress;
306:            }
307:
308:            /**
309:             * Returns the local port number to bind to when creating the SMTP socket.
310:             */
311:            public Integer getLocalport() {
312:                return localport;
313:            }
314:
315:            /**
316:             * Sets the local port number to bind to when creating the SMTP socket.
317:             * <p/>
318:             * Local port number to bind to when creating the SMTP socket. Defaults to
319:             * the port number picked by the Socket class.
320:             * <p/>
321:             * Values that are set here will override any of the corresponding value
322:             * that has been set in the properties.
323:             *
324:             * @param localport the local port number to bind to when creating the SMTP socket
325:             */
326:            public void setLocalport(Integer localport) {
327:                this .localport = localport;
328:            }
329:
330:            /**
331:             * Returns whether an attempt will be made to sign on with the EHLO command.
332:             * <p/>
333:             * If false, do not attempt to sign on with the EHLO command. Normally
334:             * failure of the EHLO command will fallback to the HELO command; this
335:             * property exists only for servers that don't fail EHLO properly or don't
336:             * implement EHLO properly.
337:             */
338:            public Boolean getEhlo() {
339:                return ehlo;
340:            }
341:
342:            /**
343:             * Set whether an attempt will be made to sign on with the EHLO command.
344:             * <p/>
345:             * If false, do not attempt to sign on with the EHLO command. Normally
346:             * failure of the EHLO command will fallback to the HELO command; this
347:             * property exists only for servers that don't fail EHLO properly or don't
348:             * implement EHLO properly.
349:             * <p/>
350:             * Values that are set here will override any of the corresponding value
351:             * that has been set in the properties.
352:             *
353:             * @param ehlo whether an attempt will be made to sign on with the EHLO command
354:             */
355:            public void setEhlo(Boolean ehlo) {
356:                this .ehlo = ehlo;
357:            }
358:
359:            /**
360:             * Returns whether an attempt will be made to authenticate the user using
361:             * the AUTH command.
362:             * <p/>
363:             * Defaults to false.
364:             */
365:            public Boolean getAuth() {
366:                return auth;
367:            }
368:
369:            /**
370:             * Sets whether an attempt will be made to authenticate the user using
371:             * the AUTH command.
372:             * <p/>
373:             * Defaults to false.
374:             * <p/>
375:             * Values that are set here will override any of the corresponding value
376:             * that has been set in the properties.
377:             *
378:             * @param auth whether an attempt will be made to authenticate the user using
379:             *             the AUTH command.
380:             */
381:            public void setAuth(Boolean auth) {
382:                this .auth = auth;
383:            }
384:
385:            /**
386:             * Returns the flag that enables the use of the STARTTLS command (if
387:             * supported by the server) to switch the connection to a TLS-protected
388:             * connection before issuing any login commands.
389:             * <p/>
390:             * If true, enables the use of the STARTTLS command (if supported by the
391:             * server) to switch the connection to a TLS-protected connection before
392:             * issuing any login commands. Note that an appropriate trust store must
393:             * configured so that the client will trust the server's certificate.
394:             * This feature only works on J2SE 1.4 and newer systems. Default is false.
395:             */
396:            public Boolean getStartTLSEnable() {
397:                return startTLSEnable;
398:            }
399:
400:            /**
401:             * Sets 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:             * <p/>
411:             * Values that are set here will override any of the corresponding value
412:             * that has been set in the properties.
413:             *
414:             * @param startTLSEnable the flag that enables the use of the STARTTLS command (if
415:             *                       supported by the server) to switch the connection to a TLS-protected
416:             *                       connection before issuing any login commands
417:             */
418:            public void setStartTLSEnable(Boolean startTLSEnable) {
419:                this .startTLSEnable = startTLSEnable;
420:            }
421:
422:            /**
423:             * Returns the submitter to use in the AUTH tag in the MAIL FROM command.
424:             * <p/>
425:             * Typically used by a mail relay to pass along information about the
426:             * original submitter of the message. See also the setSubmitter method of
427:             * SMTPMessage. Mail clients typically do not use this.
428:             */
429:            public String getSubmitter() {
430:                return submitter;
431:            }
432:
433:            /**
434:             * Sets the submitter to use in the AUTH tag in the MAIL FROM command.
435:             * <p/>
436:             * Typically used by a mail relay to pass along information about the
437:             * original submitter of the message. See also the setSubmitter method of
438:             * SMTPMessage. Mail clients typically do not use this.
439:             * <p/>
440:             * Values that are set here will override any of the corresponding value
441:             * that has been set in the properties.
442:             *
443:             * @param submitter the submitter to use in the AUTH tag in the MAIL FROM command
444:             */
445:            public void setSubmitter(String submitter) {
446:                this .submitter = submitter;
447:            }
448:
449:            /**
450:             * Returns the NOTIFY option to the RCPT command.
451:             * <p/>
452:             * Either NEVER, or some combination of SUCCESS, FAILURE, and DELAY
453:             * (separated by commas).
454:             */
455:            public String getDsnNotify() {
456:                return dsnNotify;
457:            }
458:
459:            /**
460:             * Sets the NOTIFY option to the RCPT command
461:             * <p/>
462:             * Either NEVER, or some combination of SUCCESS, FAILURE, and DELAY
463:             * (separated by commas).
464:             * <p/>
465:             * Values that are set here will override any of the corresponding value
466:             * that has been set in the properties.
467:             *
468:             * @param dsnNotify the NOTIFY option to the RCPT command
469:             */
470:            public void setDsnNotify(String dsnNotify) {
471:                this .dsnNotify = dsnNotify;
472:            }
473:
474:            /**
475:             * Returns the RET option to the MAIL command.
476:             * <p/>
477:             * Either FULL or HDRS.
478:             */
479:            public String getDsnRet() {
480:                return dsnRet;
481:            }
482:
483:            /**
484:             * Sets the RET option to the MAIL command
485:             * <p/>
486:             * Either FULL or HDRS.
487:             * <p/>
488:             * Values that are set here will override any of the corresponding value
489:             * that has been set in the properties.
490:             *
491:             * @param dsnRet the RET option to the MAIL command
492:             */
493:            public void setDsnRet(String dsnRet) {
494:                this .dsnRet = dsnRet;
495:            }
496:
497:            /**
498:             * Returns whether encodings are converted to use "8bit" under certain
499:             * conditions.
500:             * <p/>
501:             * If set to true, and the server supports the 8BITMIME extension, text
502:             * parts of messages that use the "quoted-printable" or "base64" encodings
503:             * are converted to use "8bit" encoding if they follow the RFC2045 rules
504:             * for 8bit text.
505:             */
506:            public Boolean getAllow8bitmime() {
507:                return allow8bitmime;
508:            }
509:
510:            /**
511:             * Sets whether encodings are converted to use "8bit" under certain
512:             * conditions.
513:             * <p/>
514:             * If set to true, and the server supports the 8BITMIME extension, text
515:             * parts of messages that use the "quoted-printable" or "base64" encodings
516:             * are converted to use "8bit" encoding if they follow the RFC2045 rules
517:             * for 8bit text.
518:             * <p/>
519:             * Values that are set here will override any of the corresponding value
520:             * that has been set in the properties.
521:             *
522:             * @param allow8bitmime whether encodings are converted to use "8bit" under certain
523:             *                      conditions
524:             */
525:            public void setAllow8bitmime(Boolean allow8bitmime) {
526:                this .allow8bitmime = allow8bitmime;
527:            }
528:
529:            /**
530:             * Returns whether to send email to valid addresses when others are invalid.
531:             * <p/>
532:             * If set to true, and a message has some valid and some invalid addresses,
533:             * send the message anyway, reporting the partial failure with a
534:             * SendFailedException. If set to false (the default), the message is not
535:             * sent to any of the recipients if there is an invalid recipient address.
536:             */
537:            public Boolean getSendPartial() {
538:                return sendPartial;
539:            }
540:
541:            /**
542:             * Sets whether to send email to valid addresses when others are invalid.
543:             * <p/>
544:             * If set to true, and a message has some valid and some invalid addresses,
545:             * send the message anyway, reporting the partial failure with a
546:             * SendFailedException. If set to false (the default), the message is not
547:             * sent to any of the recipients if there is an invalid recipient address.
548:             * <p/>
549:             * Values that are set here will override any of the corresponding value
550:             * that has been set in the properties.
551:             *
552:             * @param sendPartial whether to send email to valid addresses when others are invalid
553:             */
554:            public void setSendPartial(Boolean sendPartial) {
555:                this .sendPartial = sendPartial;
556:            }
557:
558:            /**
559:             * Returns the realm to use with DIGEST-MD5 authentication.
560:             */
561:            public String getSaslRealm() {
562:                return saslRealm;
563:            }
564:
565:            /**
566:             * Sets the realm to use with DIGEST-MD5 authentication.
567:             * <p/>
568:             * Values that are set here will override any of the corresponding value
569:             * that has been set in the properties.
570:             *
571:             * @param saslRealm the realm to use with DIGEST-MD5 authentication
572:             */
573:            public void setSaslRealm(String saslRealm) {
574:                this .saslRealm = saslRealm;
575:            }
576:
577:            /**
578:             * Returns whether the transport will wait for the response to the QUIT command.
579:             * <p/>
580:             * If set to true, causes the transport to wait for the response to the QUIT
581:             * command. If set to false (the default), the QUIT command is sent and the
582:             * connection is immediately closed.
583:             */
584:            public Boolean getQuitWait() {
585:                return quitWait;
586:            }
587:
588:            /**
589:             * Sets whether the transport will wait for the response to the QUIT command
590:             * <p/>
591:             * If set to true, causes the transport to wait for the response to the QUIT
592:             * command. If set to false (the default), the QUIT command is sent and the
593:             * connection is immediately closed.
594:             * <p/>
595:             * Values that are set here will override any of the corresponding value
596:             * that has been set in the properties.
597:             *
598:             * @param quitWait whether the transport will wait for the response to the QUIT command
599:             */
600:            public void setQuitWait(Boolean quitWait) {
601:                this .quitWait = quitWait;
602:            }
603:
604:            /**
605:             * Returns whether the transport will include an SMTPAddressSucceededException
606:             * for each address that is successful.
607:             * <p/>
608:             * Note also that this will cause a SendFailedException to be thrown from
609:             * the sendMessage method of SMTPTransport even if all addresses were
610:             * correct and the message was sent successfully.
611:             */
612:            public Boolean getReportSuccess() {
613:                return reportSuccess;
614:            }
615:
616:            /**
617:             * Sets whether the transport will include an SMTPAddressSucceededException
618:             * for each address that is successful.
619:             * <p/>
620:             * Note also that this will cause a SendFailedException to be thrown from
621:             * the sendMessage method of SMTPTransport even if all addresses were
622:             * correct and the message was sent successfully.
623:             * <p/>
624:             * Values that are set here will override any of the corresponding value
625:             * that has been set in the properties.
626:             *
627:             * @param reportSuccess whether the transport will include an SMTPAddressSucceededException
628:             *                      for each address that is successful
629:             */
630:            public void setReportSuccess(Boolean reportSuccess) {
631:                this .reportSuccess = reportSuccess;
632:            }
633:
634:            /**
635:             * Returns the class that will be used to create SMTP sockets.
636:             * <p/>
637:             * If set, specifies the name of a class that implements the
638:             * javax.net.SocketFactory interface. This class will be used to create SMTP
639:             * sockets.
640:             */
641:            public String getSocketFactoryClass() {
642:                return socketFactoryClass;
643:            }
644:
645:            /**
646:             * Sets the class that will be used to create SMTP sockets.
647:             * <p/>
648:             * If set, specifies the name of a class that implements the
649:             * javax.net.SocketFactory interface. This class will be used to create SMTP
650:             * sockets.
651:             * <p/>
652:             * Values that are set here will override any of the corresponding value
653:             * that has been set in the properties.
654:             *
655:             * @param socketFactoryClass the class that will be used to create SMTP sockets
656:             */
657:            public void setSocketFactoryClass(String socketFactoryClass) {
658:                this .socketFactoryClass = socketFactoryClass;
659:            }
660:
661:            /**
662:             * Returns whether java.net.Socket class will be created if the specified
663:             * socket factory class cannot be created.
664:             * <p/>
665:             * If set to true, failure to create a socket using the specified socket
666:             * factory class will cause the socket to be created using the
667:             * java.net.Socket class. Defaults to true.
668:             */
669:            public Boolean getSocketFactoryFallback() {
670:                return socketFactoryFallback;
671:            }
672:
673:            /**
674:             * Sets whether java.net.Socket class will be created if the specified
675:             * socket factory class cannot be created.
676:             * <p/>
677:             * If set to true, failure to create a socket using the specified socket
678:             * factory class will cause the socket to be created using the
679:             * java.net.Socket class. Defaults to true.
680:             * <p/>
681:             * Values that are set here will override any of the corresponding value
682:             * that has been set in the properties.
683:             *
684:             * @param socketFactoryFallback whether java.net.Socket class will be created if the specified
685:             *                              socket factory class cannot be created
686:             */
687:            public void setSocketFactoryFallback(Boolean socketFactoryFallback) {
688:                this .socketFactoryFallback = socketFactoryFallback;
689:            }
690:
691:            /**
692:             * Returns the port to connect to when using the specified socket factory.
693:             * <p/>
694:             * Specifies the port to connect to when using the specified socket
695:             * factory. If not set, the default port will be used.
696:             */
697:            public Integer getSocketFactoryPort() {
698:                return socketFactoryPort;
699:            }
700:
701:            /**
702:             * Sets the port to connect to when using the specified socket factory.
703:             * <p/>
704:             * Specifies the port to connect to when using the specified socket
705:             * factory. If not set, the default port will be used.
706:             * <p/>
707:             * Values that are set here will override any of the corresponding value
708:             * that has been set in the properties.
709:             *
710:             * @param socketFactoryPort the port to connect to when using the specified socket factory
711:             */
712:            public void setSocketFactoryPort(Integer socketFactoryPort) {
713:                this .socketFactoryPort = socketFactoryPort;
714:            }
715:
716:            /**
717:             * Returns the extension string to append to the MAIL command.
718:             * <p/>
719:             * Extension string to append to the MAIL command. The extension string
720:             * can be used to specify standard SMTP service extensions as well as
721:             * vendor-specific extensions. Typically the application should use the
722:             * SMTPTransport method supportsExtension to verify that the server
723:             * supports the desired service extension. See RFC 1869 and other RFCs
724:             * that define specific extensions.
725:             */
726:            public String getMailExtension() {
727:                return mailExtension;
728:            }
729:
730:            /**
731:             * Sets the extension string to append to the MAIL command.
732:             * <p/>
733:             * Extension string to append to the MAIL command. The extension string
734:             * can be used to specify standard SMTP service extensions as well as
735:             * vendor-specific extensions. Typically the application should use the
736:             * SMTPTransport method supportsExtension to verify that the server
737:             * supports the desired service extension. See RFC 1869 and other RFCs
738:             * that define specific extensions.
739:             * <p/>
740:             * Values that are set here will override any of the corresponding value
741:             * that has been set in the properties.
742:             *
743:             * @param mailExtension the extension string to append to the MAIL command
744:             */
745:            public void setMailExtension(String mailExtension) {
746:                this .mailExtension = mailExtension;
747:            }
748:
749:            /**
750:             * Add the overrides from the member variables to the properties file.
751:             */
752:            public void addOverrides(Properties props) {
753:                super .addOverrides(props);
754:
755:                if (port != null)
756:                    props.setProperty(SMTP_PORT, port.toString());
757:                if (connectionTimeout != null)
758:                    props.setProperty(SMTP_CONNECTION_TIMEOUT,
759:                            connectionTimeout.toString());
760:                if (timeout != null)
761:                    props.setProperty(SMTP_TIMEOUT, timeout.toString());
762:                if (from != null)
763:                    props.setProperty(SMTP_FROM, from);
764:                if (localhost != null)
765:                    props.setProperty(SMTP_LOCALHOST, localhost);
766:                if (localaddress != null)
767:                    props.setProperty(SMTP_LOCALADDRESS, localaddress);
768:                if (localport != null)
769:                    props.setProperty(SMTP_LOCALPORT, localport.toString());
770:                if (ehlo != null)
771:                    props.setProperty(SMTP_EHLO, ehlo.toString());
772:                if (auth != null)
773:                    props.setProperty(SMTP_AUTH, auth.toString());
774:                if (startTLSEnable != null)
775:                    props.setProperty(SMTP_STARTTLS_ENABLE, startTLSEnable
776:                            .toString());
777:                if (submitter != null)
778:                    props.setProperty(SMTP_SUBMITTER, submitter);
779:                if (dsnNotify != null)
780:                    props.setProperty(SMTP_DSN_NOTIFY, dsnNotify);
781:                if (dsnRet != null)
782:                    props.setProperty(SMTP_DSN_RET, dsnRet);
783:                if (allow8bitmime != null)
784:                    props.setProperty(SMTP_8BITMIME, allow8bitmime.toString());
785:                if (sendPartial != null)
786:                    props
787:                            .setProperty(SMTP_SEND_PARTIAL, sendPartial
788:                                    .toString());
789:                if (saslRealm != null)
790:                    props.setProperty(SMTP_REALM, saslRealm);
791:                if (quitWait != null)
792:                    props.setProperty(SMTP_QUITWAIT, quitWait.toString());
793:                if (reportSuccess != null)
794:                    props.setProperty(SMTP_REPORT_SUCCESS, reportSuccess
795:                            .toString());
796:                if (socketFactoryClass != null)
797:                    props.setProperty(SMTP_FACTORY_CLASS, socketFactoryClass);
798:                if (socketFactoryFallback != null)
799:                    props.setProperty(SMTP_FACTORY_FALLBACK,
800:                            socketFactoryFallback.toString());
801:                if (socketFactoryPort != null)
802:                    props.setProperty(SMTP_FACTORY_PORT, socketFactoryPort
803:                            .toString());
804:                if (mailExtension != null)
805:                    props.setProperty(SMTP_MAIL_EXTENSION, mailExtension);
806:            }
807:
808:            public void doStart() throws Exception {
809:                log.debug("Started " + getObjectName());
810:            }
811:
812:            public void doStop() throws Exception {
813:                log.debug("Stopped " + getObjectName());
814:            }
815:
816:            public void doFail() {
817:                log.warn("Failed " + getObjectName());
818:            }
819:
820:            public static final GBeanInfo GBEAN_INFO;
821:
822:            static {
823:                GBeanInfoBuilder infoFactory = GBeanInfoBuilder
824:                        .createStatic(SMTPTransportGBean.class);
825:
826:                infoFactory.addAttribute(GBEAN_PORT, Integer.class, true);
827:                infoFactory.addAttribute(GBEAN_CONNECTION_TIMEOUT,
828:                        Integer.class, true);
829:                infoFactory.addAttribute(GBEAN_TIMEOUT, Integer.class, true);
830:                infoFactory.addAttribute(GBEAN_AUTH, Boolean.class, true);
831:                infoFactory.addAttribute(GBEAN_STARTTLS_ENABLE, Boolean.class,
832:                        true);
833:                infoFactory.addAttribute(GBEAN_EHLO, Boolean.class, true);
834:                infoFactory.addAttribute(GBEAN_FROM, String.class, true);
835:                infoFactory.addAttribute(GBEAN_LOCALHOST, String.class, true);
836:                infoFactory
837:                        .addAttribute(GBEAN_LOCALADDRESS, String.class, true);
838:                infoFactory.addAttribute(GBEAN_LOCALPORT, Integer.class, true);
839:                infoFactory.addAttribute(GBEAN_REALM, String.class, true);
840:                infoFactory.addAttribute(GBEAN_QUITWAIT, Boolean.class, true);
841:                infoFactory.addAttribute(GBEAN_FACTORY_CLASS, String.class,
842:                        true);
843:                infoFactory.addAttribute(GBEAN_FACTORY_FALLBACK, Boolean.class,
844:                        true);
845:                infoFactory.addAttribute(GBEAN_FACTORY_PORT, Integer.class,
846:                        true);
847:
848:                infoFactory.addAttribute(GBEAN_SUBMITTER, String.class, true);
849:                infoFactory.addAttribute(GBEAN_DSN_NOTIFY, String.class, true);
850:                infoFactory.addAttribute(GBEAN_DSN_RET, String.class, true);
851:                infoFactory.addAttribute(GBEAN_8BITMIME, Boolean.class, true);
852:                infoFactory.addAttribute(GBEAN_SEND_PARTIAL, Boolean.class,
853:                        true);
854:                infoFactory.addAttribute(GBEAN_REPORT_SUCCESS, Boolean.class,
855:                        true);
856:                infoFactory.addAttribute(GBEAN_MAIL_EXTENSION, String.class,
857:                        true);
858:
859:                infoFactory.addAttribute(GBEAN_OBJECTNAME, String.class, false);
860:                infoFactory.addAttribute(GBEAN_PROTOCOL, String.class, true);
861:                infoFactory.addAttribute(GBEAN_PROPERTIES, Properties.class,
862:                        true);
863:                infoFactory.addAttribute(GBEAN_HOST, String.class, true);
864:                infoFactory.addAttribute(GBEAN_USER, String.class, true);
865:                infoFactory.addOperation(GBEAN_ADD_OVERRIDES,
866:                        new Class[] { Properties.class });
867:
868:                infoFactory.setConstructor(new String[] { GBEAN_OBJECTNAME,
869:                        GBEAN_PROPERTIES, GBEAN_HOST, GBEAN_USER, GBEAN_PORT,
870:                        GBEAN_CONNECTION_TIMEOUT, GBEAN_TIMEOUT, GBEAN_FROM,
871:                        GBEAN_LOCALHOST, GBEAN_LOCALADDRESS, GBEAN_LOCALPORT,
872:                        GBEAN_EHLO, GBEAN_AUTH, GBEAN_STARTTLS_ENABLE,
873:                        GBEAN_SUBMITTER, GBEAN_DSN_NOTIFY, GBEAN_DSN_RET,
874:                        GBEAN_8BITMIME, GBEAN_SEND_PARTIAL, GBEAN_REALM,
875:                        GBEAN_QUITWAIT, GBEAN_REPORT_SUCCESS,
876:                        GBEAN_FACTORY_CLASS, GBEAN_FACTORY_FALLBACK,
877:                        GBEAN_FACTORY_PORT, GBEAN_MAIL_EXTENSION });
878:
879:                GBEAN_INFO = infoFactory.getBeanInfo();
880:            }
881:
882:            public static GBeanInfo getGBeanInfo() {
883:                return GBEAN_INFO;
884:            }
885:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.