Source Code Cross Referenced for SMTPSTransportGBean.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: 594563 $ $Date: 2007-11-13 07:28:52 -0800 (Tue, 13 Nov 2007) $
036:         * @see MailGBean
037:         */
038:        public class SMTPSTransportGBean extends ProtocolGBean {
039:
040:            // the SMTPS configuration property names
041:            static public final String SMTPS_PORT = "mail.smtps.port";
042:            static public final String SMTPS_CONNECTION_TIMEOUT = "mail.smtps.connectiontimeout";
043:            static public final String SMTPS_TIMEOUT = "mail.smtps.timeout";
044:            static public final String SMTPS_FROM = "mail.smtps.from";
045:            static public final String SMTPS_AUTH = "mail.smtps.auth";
046:            static public final String SMTPS_REALM = "mail.smtps.sasl.realm";
047:            static public final String SMTPS_QUITWAIT = "mail.smtps.quitwait";
048:            static public final String SMTPS_FACTORY_CLASS = "mail.smtps.socketFactory.class";
049:            static public final String SMTPS_FACTORY_FALLBACK = "mail.smtps.socketFactory.fallback";
050:            static public final String SMTPS_FACTORY_PORT = "mail.smtps.socketFactory.port";
051:            static public final String SMTPS_LOCALHOST = "mail.smtps.localhost";
052:            static public final String SMTPS_LOCALADDRESS = "mail.smtps.localaddress";
053:            static public final String SMTPS_LOCALPORT = "mail.smtps.localport";
054:            static public final String SMTPS_EHLO = "mail.smtps.ehlo";
055:            static public final String SMTPS_SUBMITTER = "mail.smtps.submitter";
056:            static public final String SMTPS_DSN_NOTIFY = "mail.smtps.dsn.notify";
057:            static public final String SMTPS_DSN_RET = "mail.smtps.dsn.ret";
058:            static public final String SMTPS_8BITMIME = "mail.smtps.allow8bitmime";
059:            static public final String SMTPS_SEND_PARTIAL = "mail.smtps.sendpartial";
060:            static public final String SMTPS_REPORT_SUCCESS = "mail.smtps.reportsuccess";
061:            static public final String SMTPS_MAIL_EXTENSION = "mail.smtps.mailextension";
062:            static public final String SMTPS_STARTTLS_ENABLE = "mail.smtps.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
075:                    .getLog(SMTPSTransportGBean.class);
076:
077:            private Integer port;
078:            private Integer connectionTimeout;
079:            private Integer timeout;
080:            private String from;
081:            private String localhost;
082:            private String localaddress;
083:            private Integer localport;
084:            private Boolean ehlo;
085:            private Boolean auth;
086:            private String submitter;
087:            private String dsnNotify;
088:            private String dsnRet;
089:            private Boolean allow8bitmime;
090:            private Boolean sendPartial;
091:            private String saslRealm;
092:            private Boolean quitWait;
093:            private Boolean reportSuccess;
094:            private String socketFactoryClass;
095:            private Boolean socketFactoryFallback;
096:            private Integer socketFactoryPort;
097:            private String mailExtension;
098:            private Boolean startTLSEnable;
099:
100:            /**
101:             * Construct an instance of SMTPSTransportGBean
102:             * <p/>
103:             * Values that are set in the individual member variables will override any of
104:             * the corresponding values that have been set in the properties set.
105:             *
106:             * @param objectName            the object name of the protocol
107:             * @param properties            the set of default properties for the protocol
108:             * @param host                  the host the protocol connects to
109:             * @param user                  the default name for the protocol
110:             * @param port                  the SMTPS server port
111:             * @param connectionTimeout     the socket connection timeout value in milliseconds
112:             * @param timeout               the socket I/O timeout value in milliseconds
113:             * @param from                  the email address to use for SMTPS MAIL command
114:             * @param localhost             the local host name used in the SMTPS HELO or EHLO command
115:             * @param localaddress          the local address (host name) to bind to when creating the SMTPS socket
116:             * @param localport             the local port number to bind to when creating the SMTPS socket
117:             * @param ehlo                  whether an attempt will be made to sign on with the EHLO command
118:             * @param auth                  whether an attempt will be made to authenticate the user using
119:             *                              the AUTH command
120:             * @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
121:             * @param submitter             the submitter to use in the AUTH tag in the MAIL FROM command
122:             * @param dsnNotify             the NOTIFY option to the RCPT command
123:             * @param dsnRet                the RET option to the MAIL command
124:             * @param allow8bitmime         whether encodings are converted to use "8bit" under certain
125:             *                              conditions
126:             * @param sendPartial           whether to send email to valid addresses when others are invalid
127:             * @param saslRealm             the realm to use with DIGEST-MD5 authentication
128:             * @param quitWait              whether the transport will wait for the response to the QUIT command
129:             * @param reportSuccess         whether the transport will include an SMTPAddressSucceededException
130:             *                              for each address that is successful
131:             * @param socketFactoryClass    the class that will be used to create SMTPS sockets
132:             * @param socketFactoryFallback whether java.net.Socket class will be created if the specified
133:             *                              socket factory class cannot be created
134:             * @param socketFactoryPort     whether java.net.Socket class will be created if the specified
135:             *                              socket factory class cannot be created
136:             * @param mailExtension         the extension string to append to the MAIL command
137:             */
138:            public SMTPSTransportGBean(String objectName,
139:                    Properties properties, String host, String user,
140:                    Integer port, Integer connectionTimeout, Integer timeout,
141:                    String from, String localhost, String localaddress,
142:                    Integer localport, Boolean ehlo, Boolean auth,
143:                    Boolean startTLSEnable, String submitter, String dsnNotify,
144:                    String dsnRet, Boolean allow8bitmime, Boolean sendPartial,
145:                    String saslRealm, Boolean quitWait, Boolean reportSuccess,
146:                    String socketFactoryClass, Boolean socketFactoryFallback,
147:                    Integer socketFactoryPort, String mailExtension) {
148:                super (objectName, "smtps", properties, host, user);
149:
150:                setPort(port);
151:                setConnectionTimeout(connectionTimeout);
152:                setTimeout(timeout);
153:                setFrom(from);
154:                setLocalhost(localhost);
155:                setLocaladdress(localaddress);
156:                setLocalport(localport);
157:                setEhlo(ehlo);
158:                setAuth(auth);
159:                setStartTLSEnable(startTLSEnable);
160:                setSubmitter(submitter);
161:                setDsnNotify(dsnNotify);
162:                setDsnRet(dsnRet);
163:                setAllow8bitmime(allow8bitmime);
164:                setSendPartial(sendPartial);
165:                setSaslRealm(saslRealm);
166:                setQuitWait(quitWait);
167:                setReportSuccess(reportSuccess);
168:                setSocketFactoryClass(socketFactoryClass);
169:                setSocketFactoryFallback(socketFactoryFallback);
170:                setSocketFactoryPort(socketFactoryPort);
171:                setMailExtension(mailExtension);
172:            }
173:
174:            /**
175:             * Returns the SMTP server port to connect to, if the connect() method
176:             * doesn't explicitly specify one.
177:             */
178:            public Integer getPort() {
179:                return port;
180:            }
181:
182:            /**
183:             * Sets the SMTP server port to connect to, if the connect() method
184:             * doesn't explicitly specify one.
185:             * <p/>
186:             * Defaults to 25.
187:             * <p/>
188:             * Values that are set here will override any of the corresponding value
189:             * that has been set in the properties.
190:             *
191:             * @param port the SMTP server port to connect to
192:             */
193:            public void setPort(Integer port) {
194:                this .port = port;
195:            }
196:
197:            /**
198:             * Returns the socket connection timeout value in milliseconds.
199:             */
200:            public Integer getConnectionTimeout() {
201:                return connectionTimeout;
202:            }
203:
204:            /**
205:             * Sets the socket connection timeout value in milliseconds.
206:             * <p/>
207:             * Default is infinite timeout.
208:             * <p/>
209:             * Values that are set here will override any of the corresponding value
210:             * that has been set in the properties.
211:             *
212:             * @param connectionTimeout the socket connection timeout value in milliseconds.
213:             */
214:            public void setConnectionTimeout(Integer connectionTimeout) {
215:                this .connectionTimeout = connectionTimeout;
216:            }
217:
218:            /**
219:             * Returns the socket I/O timeout value in milliseconds.
220:             */
221:            public Integer getTimeout() {
222:                return timeout;
223:            }
224:
225:            /**
226:             * Sets the socket I/O timeout value in milliseconds.
227:             * <p/>
228:             * Default is infinite timeout.
229:             * <p/>
230:             * Values that are set here will override any of the corresponding value
231:             * that has been set in the properties.
232:             *
233:             * @param timeout the socket I/O timeout value in milliseconds
234:             */
235:            public void setTimeout(Integer timeout) {
236:                this .timeout = timeout;
237:            }
238:
239:            /**
240:             * Returns the email address to use for SMTP MAIL command.
241:             */
242:            public String getFrom() {
243:                return from;
244:            }
245:
246:            /**
247:             * Sets the email address to use for SMTP MAIL command
248:             * <p/>
249:             * Email address to use for SMTP MAIL command. This sets the envelope
250:             * return address. Defaults to msg.getFrom() or InternetAddress.getLocalAddress().
251:             * NOTE: mail.smtps.user was previously used for this.
252:             * <p/>
253:             * Values that are set here will override any of the corresponding value
254:             * that has been set in the properties.
255:             *
256:             * @param from the email address to use for SMTP MAIL command
257:             */
258:            public void setFrom(String from) {
259:                this .from = from;
260:            }
261:
262:            /**
263:             * Returns the local host name used in the SMTP HELO or EHLO command.
264:             */
265:            public String getLocalhost() {
266:                return localhost;
267:            }
268:
269:            /**
270:             * Sets the local host name used in the SMTP HELO or EHLO command.
271:             * <p/>
272:             * Local host name used in the SMTP HELO or EHLO command. Defaults to
273:             * InetAddress.getLocalHost().getHostName(). Should not normally need to
274:             * be set if your JDK and your name service are configured properly.
275:             * <p/>
276:             * Values that are set here will override any of the corresponding value
277:             * that has been set in the properties.
278:             *
279:             * @param localhost the local host name used in the SMTP HELO or EHLO command
280:             */
281:            public void setLocalhost(String localhost) {
282:                this .localhost = localhost;
283:            }
284:
285:            /**
286:             * Returns the local address (host name) to bind to when creating the SMTP socket.
287:             */
288:            public String getLocaladdress() {
289:                return localaddress;
290:            }
291:
292:            /**
293:             * Sets the local address (host name) to bind to when creating the SMTP socket.
294:             * <p/>
295:             * Local address (host name) to bind to when creating the SMTP socket.
296:             * Defaults to the address picked by the Socket class. Should not normally
297:             * need to be set, but useful with multi-homed hosts where it's important
298:             * to pick a particular local address to bind to.
299:             * <p/>
300:             * Values that are set here will override any of the corresponding value
301:             * that has been set in the properties.
302:             *
303:             * @param localaddress the local address (host name) to bind to when creating the SMTP socket
304:             */
305:            public void setLocaladdress(String localaddress) {
306:                this .localaddress = localaddress;
307:            }
308:
309:            /**
310:             * Returns the local port number to bind to when creating the SMTP socket.
311:             */
312:            public Integer getLocalport() {
313:                return localport;
314:            }
315:
316:            /**
317:             * Sets the local port number to bind to when creating the SMTP socket.
318:             * <p/>
319:             * Local port number to bind to when creating the SMTP socket. Defaults to
320:             * the port number picked by the Socket class.
321:             * <p/>
322:             * Values that are set here will override any of the corresponding value
323:             * that has been set in the properties.
324:             *
325:             * @param localport the local port number to bind to when creating the SMTP socket
326:             */
327:            public void setLocalport(Integer localport) {
328:                this .localport = localport;
329:            }
330:
331:            /**
332:             * Returns whether an attempt will be made to sign on with the EHLO command.
333:             * <p/>
334:             * If false, do not attempt to sign on with the EHLO command. Normally
335:             * failure of the EHLO command will fallback to the HELO command; this
336:             * property exists only for servers that don't fail EHLO properly or don't
337:             * implement EHLO properly.
338:             */
339:            public Boolean getEhlo() {
340:                return ehlo;
341:            }
342:
343:            /**
344:             * Set whether an attempt will be made to sign on with the EHLO command.
345:             * <p/>
346:             * If false, do not attempt to sign on with the EHLO command. Normally
347:             * failure of the EHLO command will fallback to the HELO command; this
348:             * property exists only for servers that don't fail EHLO properly or don't
349:             * implement EHLO properly.
350:             * <p/>
351:             * Values that are set here will override any of the corresponding value
352:             * that has been set in the properties.
353:             *
354:             * @param ehlo whether an attempt will be made to sign on with the EHLO command
355:             */
356:            public void setEhlo(Boolean ehlo) {
357:                this .ehlo = ehlo;
358:            }
359:
360:            /**
361:             * Returns whether an attempt will be made to authenticate the user using
362:             * the AUTH command.
363:             * <p/>
364:             * Defaults to false.
365:             */
366:            public Boolean getAuth() {
367:                return auth;
368:            }
369:
370:            /**
371:             * Sets whether an attempt will be made to authenticate the user using
372:             * the AUTH command.
373:             * <p/>
374:             * Defaults to false.
375:             * <p/>
376:             * Values that are set here will override any of the corresponding value
377:             * that has been set in the properties.
378:             *
379:             * @param auth whether an attempt will be made to authenticate the user using
380:             *             the AUTH command.
381:             */
382:            public void setAuth(Boolean auth) {
383:                this .auth = auth;
384:            }
385:
386:            /**
387:             * Returns the flag that enables the use of the STARTTLS command (if
388:             * supported by the server) to switch the connection to a TLS-protected
389:             * connection before issuing any login commands.
390:             * <p/>
391:             * If true, enables the use of the STARTTLS command (if supported by the
392:             * server) to switch the connection to a TLS-protected connection before
393:             * issuing any login commands. Note that an appropriate trust store must
394:             * configured so that the client will trust the server's certificate.
395:             * This feature only works on J2SE 1.4 and newer systems. Default is false.
396:             */
397:            public Boolean getStartTLSEnable() {
398:                return startTLSEnable;
399:            }
400:
401:            /**
402:             * Sets the flag that enables the use of the STARTTLS command (if
403:             * supported by the server) to switch the connection to a TLS-protected
404:             * connection before issuing any login commands.
405:             * <p/>
406:             * If true, enables the use of the STARTTLS command (if supported by the
407:             * server) to switch the connection to a TLS-protected connection before
408:             * issuing any login commands. Note that an appropriate trust store must
409:             * configured so that the client will trust the server's certificate.
410:             * This feature only works on J2SE 1.4 and newer systems. Default is false.
411:             * <p/>
412:             * Values that are set here will override any of the corresponding value
413:             * that has been set in the properties.
414:             *
415:             * @param startTLSEnable the flag that enables the use of the STARTTLS command (if
416:             *                       supported by the server) to switch the connection to a TLS-protected
417:             *                       connection before issuing any login commands
418:             */
419:            public void setStartTLSEnable(Boolean startTLSEnable) {
420:                this .startTLSEnable = startTLSEnable;
421:            }
422:
423:            /**
424:             * Returns the submitter to use in the AUTH tag in the MAIL FROM command.
425:             * <p/>
426:             * Typically used by a mail relay to pass along information about the
427:             * original submitter of the message. See also the setSubmitter method of
428:             * SMTPMessage. Mail clients typically do not use this.
429:             */
430:            public String getSubmitter() {
431:                return submitter;
432:            }
433:
434:            /**
435:             * Sets the submitter to use in the AUTH tag in the MAIL FROM command.
436:             * <p/>
437:             * Typically used by a mail relay to pass along information about the
438:             * original submitter of the message. See also the setSubmitter method of
439:             * SMTPMessage. Mail clients typically do not use this.
440:             * <p/>
441:             * Values that are set here will override any of the corresponding value
442:             * that has been set in the properties.
443:             *
444:             * @param submitter the submitter to use in the AUTH tag in the MAIL FROM command
445:             */
446:            public void setSubmitter(String submitter) {
447:                this .submitter = submitter;
448:            }
449:
450:            /**
451:             * Returns the NOTIFY option to the RCPT command.
452:             * <p/>
453:             * Either NEVER, or some combination of SUCCESS, FAILURE, and DELAY
454:             * (separated by commas).
455:             */
456:            public String getDsnNotify() {
457:                return dsnNotify;
458:            }
459:
460:            /**
461:             * Sets the NOTIFY option to the RCPT command
462:             * <p/>
463:             * Either NEVER, or some combination of SUCCESS, FAILURE, and DELAY
464:             * (separated by commas).
465:             * <p/>
466:             * Values that are set here will override any of the corresponding value
467:             * that has been set in the properties.
468:             *
469:             * @param dsnNotify the NOTIFY option to the RCPT command
470:             */
471:            public void setDsnNotify(String dsnNotify) {
472:                this .dsnNotify = dsnNotify;
473:            }
474:
475:            /**
476:             * Returns the RET option to the MAIL command.
477:             * <p/>
478:             * Either FULL or HDRS.
479:             */
480:            public String getDsnRet() {
481:                return dsnRet;
482:            }
483:
484:            /**
485:             * Sets the RET option to the MAIL command
486:             * <p/>
487:             * Either FULL or HDRS.
488:             * <p/>
489:             * Values that are set here will override any of the corresponding value
490:             * that has been set in the properties.
491:             *
492:             * @param dsnRet the RET option to the MAIL command
493:             */
494:            public void setDsnRet(String dsnRet) {
495:                this .dsnRet = dsnRet;
496:            }
497:
498:            /**
499:             * Returns whether encodings are converted to use "8bit" under certain
500:             * conditions.
501:             * <p/>
502:             * If set to true, and the server supports the 8BITMIME extension, text
503:             * parts of messages that use the "quoted-printable" or "base64" encodings
504:             * are converted to use "8bit" encoding if they follow the RFC2045 rules
505:             * for 8bit text.
506:             */
507:            public Boolean getAllow8bitmime() {
508:                return allow8bitmime;
509:            }
510:
511:            /**
512:             * Sets whether encodings are converted to use "8bit" under certain
513:             * conditions.
514:             * <p/>
515:             * If set to true, and the server supports the 8BITMIME extension, text
516:             * parts of messages that use the "quoted-printable" or "base64" encodings
517:             * are converted to use "8bit" encoding if they follow the RFC2045 rules
518:             * for 8bit text.
519:             * <p/>
520:             * Values that are set here will override any of the corresponding value
521:             * that has been set in the properties.
522:             *
523:             * @param allow8bitmime whether encodings are converted to use "8bit" under certain
524:             *                      conditions
525:             */
526:            public void setAllow8bitmime(Boolean allow8bitmime) {
527:                this .allow8bitmime = allow8bitmime;
528:            }
529:
530:            /**
531:             * Returns whether to send email to valid addresses when others are invalid.
532:             * <p/>
533:             * If set to true, and a message has some valid and some invalid addresses,
534:             * send the message anyway, reporting the partial failure with a
535:             * SendFailedException. If set to false (the default), the message is not
536:             * sent to any of the recipients if there is an invalid recipient address.
537:             */
538:            public Boolean getSendPartial() {
539:                return sendPartial;
540:            }
541:
542:            /**
543:             * Sets whether to send email to valid addresses when others are invalid.
544:             * <p/>
545:             * If set to true, and a message has some valid and some invalid addresses,
546:             * send the message anyway, reporting the partial failure with a
547:             * SendFailedException. If set to false (the default), the message is not
548:             * sent to any of the recipients if there is an invalid recipient address.
549:             * <p/>
550:             * Values that are set here will override any of the corresponding value
551:             * that has been set in the properties.
552:             *
553:             * @param sendPartial whether to send email to valid addresses when others are invalid
554:             */
555:            public void setSendPartial(Boolean sendPartial) {
556:                this .sendPartial = sendPartial;
557:            }
558:
559:            /**
560:             * Returns the realm to use with DIGEST-MD5 authentication.
561:             */
562:            public String getSaslRealm() {
563:                return saslRealm;
564:            }
565:
566:            /**
567:             * Sets the realm to use with DIGEST-MD5 authentication.
568:             * <p/>
569:             * Values that are set here will override any of the corresponding value
570:             * that has been set in the properties.
571:             *
572:             * @param saslRealm the realm to use with DIGEST-MD5 authentication
573:             */
574:            public void setSaslRealm(String saslRealm) {
575:                this .saslRealm = saslRealm;
576:            }
577:
578:            /**
579:             * Returns whether the transport will wait for the response to the QUIT command.
580:             * <p/>
581:             * If set to true, causes the transport to wait for the response to the QUIT
582:             * command. If set to false (the default), the QUIT command is sent and the
583:             * connection is immediately closed.
584:             */
585:            public Boolean getQuitWait() {
586:                return quitWait;
587:            }
588:
589:            /**
590:             * Sets whether the transport will wait for the response to the QUIT command
591:             * <p/>
592:             * If set to true, causes the transport to wait for the response to the QUIT
593:             * command. If set to false (the default), the QUIT command is sent and the
594:             * connection is immediately closed.
595:             * <p/>
596:             * Values that are set here will override any of the corresponding value
597:             * that has been set in the properties.
598:             *
599:             * @param quitWait whether the transport will wait for the response to the QUIT command
600:             */
601:            public void setQuitWait(Boolean quitWait) {
602:                this .quitWait = quitWait;
603:            }
604:
605:            /**
606:             * Returns whether the transport will include an SMTPAddressSucceededException
607:             * for each address that is successful.
608:             * <p/>
609:             * Note also that this will cause a SendFailedException to be thrown from
610:             * the sendMessage method of SMTPTransport even if all addresses were
611:             * correct and the message was sent successfully.
612:             */
613:            public Boolean getReportSuccess() {
614:                return reportSuccess;
615:            }
616:
617:            /**
618:             * Sets whether the transport will include an SMTPAddressSucceededException
619:             * for each address that is successful.
620:             * <p/>
621:             * Note also that this will cause a SendFailedException to be thrown from
622:             * the sendMessage method of SMTPTransport even if all addresses were
623:             * correct and the message was sent successfully.
624:             * <p/>
625:             * Values that are set here will override any of the corresponding value
626:             * that has been set in the properties.
627:             *
628:             * @param reportSuccess whether the transport will include an SMTPAddressSucceededException
629:             *                      for each address that is successful
630:             */
631:            public void setReportSuccess(Boolean reportSuccess) {
632:                this .reportSuccess = reportSuccess;
633:            }
634:
635:            /**
636:             * Returns the class that will be used to create SMTP sockets.
637:             * <p/>
638:             * If set, specifies the name of a class that implements the
639:             * javax.net.SocketFactory interface. This class will be used to create SMTP
640:             * sockets.
641:             */
642:            public String getSocketFactoryClass() {
643:                return socketFactoryClass;
644:            }
645:
646:            /**
647:             * Sets the class that will be used to create SMTP sockets.
648:             * <p/>
649:             * If set, specifies the name of a class that implements the
650:             * javax.net.SocketFactory interface. This class will be used to create SMTP
651:             * sockets.
652:             * <p/>
653:             * Values that are set here will override any of the corresponding value
654:             * that has been set in the properties.
655:             *
656:             * @param socketFactoryClass the class that will be used to create SMTP sockets
657:             */
658:            public void setSocketFactoryClass(String socketFactoryClass) {
659:                this .socketFactoryClass = socketFactoryClass;
660:            }
661:
662:            /**
663:             * Returns whether java.net.Socket class will be created if the specified
664:             * socket factory class cannot be created.
665:             * <p/>
666:             * If set to true, failure to create a socket using the specified socket
667:             * factory class will cause the socket to be created using the
668:             * java.net.Socket class. Defaults to true.
669:             */
670:            public Boolean getSocketFactoryFallback() {
671:                return socketFactoryFallback;
672:            }
673:
674:            /**
675:             * Sets whether java.net.Socket class will be created if the specified
676:             * socket factory class cannot be created.
677:             * <p/>
678:             * If set to true, failure to create a socket using the specified socket
679:             * factory class will cause the socket to be created using the
680:             * java.net.Socket class. Defaults to true.
681:             * <p/>
682:             * Values that are set here will override any of the corresponding value
683:             * that has been set in the properties.
684:             *
685:             * @param socketFactoryFallback whether java.net.Socket class will be created if the specified
686:             *                              socket factory class cannot be created
687:             */
688:            public void setSocketFactoryFallback(Boolean socketFactoryFallback) {
689:                this .socketFactoryFallback = socketFactoryFallback;
690:            }
691:
692:            /**
693:             * Returns the port to connect to when using the specified socket factory.
694:             * <p/>
695:             * Specifies the port to connect to when using the specified socket
696:             * factory. If not set, the default port will be used.
697:             */
698:            public Integer getSocketFactoryPort() {
699:                return socketFactoryPort;
700:            }
701:
702:            /**
703:             * Sets the port to connect to when using the specified socket factory.
704:             * <p/>
705:             * Specifies the port to connect to when using the specified socket
706:             * factory. If not set, the default port will be used.
707:             * <p/>
708:             * Values that are set here will override any of the corresponding value
709:             * that has been set in the properties.
710:             *
711:             * @param socketFactoryPort the port to connect to when using the specified socket factory
712:             */
713:            public void setSocketFactoryPort(Integer socketFactoryPort) {
714:                this .socketFactoryPort = socketFactoryPort;
715:            }
716:
717:            /**
718:             * Returns the extension string to append to the MAIL command.
719:             * <p/>
720:             * Extension string to append to the MAIL command. The extension string
721:             * can be used to specify standard SMTP service extensions as well as
722:             * vendor-specific extensions. Typically the application should use the
723:             * SMTPTransport method supportsExtension to verify that the server
724:             * supports the desired service extension. See RFC 1869 and other RFCs
725:             * that define specific extensions.
726:             */
727:            public String getMailExtension() {
728:                return mailExtension;
729:            }
730:
731:            /**
732:             * Sets 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:             * <p/>
741:             * Values that are set here will override any of the corresponding value
742:             * that has been set in the properties.
743:             *
744:             * @param mailExtension the extension string to append to the MAIL command
745:             */
746:            public void setMailExtension(String mailExtension) {
747:                this .mailExtension = mailExtension;
748:            }
749:
750:            /**
751:             * Add the overrides from the member variables to the properties file.
752:             */
753:            public void addOverrides(Properties props) {
754:                super .addOverrides(props);
755:
756:                if (port != null)
757:                    props.setProperty(SMTPS_PORT, port.toString());
758:                if (connectionTimeout != null)
759:                    props.setProperty(SMTPS_CONNECTION_TIMEOUT,
760:                            connectionTimeout.toString());
761:                if (timeout != null)
762:                    props.setProperty(SMTPS_TIMEOUT, timeout.toString());
763:                if (from != null)
764:                    props.setProperty(SMTPS_FROM, from);
765:                if (localhost != null)
766:                    props.setProperty(SMTPS_LOCALHOST, localhost);
767:                if (localaddress != null)
768:                    props.setProperty(SMTPS_LOCALADDRESS, localaddress);
769:                if (localport != null)
770:                    props.setProperty(SMTPS_LOCALPORT, localport.toString());
771:                if (ehlo != null)
772:                    props.setProperty(SMTPS_EHLO, ehlo.toString());
773:                if (auth != null)
774:                    props.setProperty(SMTPS_AUTH, auth.toString());
775:                if (startTLSEnable != null)
776:                    props.setProperty(SMTPS_STARTTLS_ENABLE, startTLSEnable
777:                            .toString());
778:                if (submitter != null)
779:                    props.setProperty(SMTPS_SUBMITTER, submitter);
780:                if (dsnNotify != null)
781:                    props.setProperty(SMTPS_DSN_NOTIFY, dsnNotify.toString());
782:                if (dsnRet != null)
783:                    props.setProperty(SMTPS_DSN_RET, dsnRet.toString());
784:                if (allow8bitmime != null)
785:                    props.setProperty(SMTPS_8BITMIME, allow8bitmime.toString());
786:                if (sendPartial != null)
787:                    props.setProperty(SMTPS_SEND_PARTIAL, sendPartial
788:                            .toString());
789:                if (saslRealm != null)
790:                    props.setProperty(SMTPS_REALM, saslRealm);
791:                if (quitWait != null)
792:                    props.setProperty(SMTPS_QUITWAIT, quitWait.toString());
793:                if (reportSuccess != null)
794:                    props.setProperty(SMTPS_REPORT_SUCCESS, reportSuccess
795:                            .toString());
796:                if (socketFactoryClass != null)
797:                    props.setProperty(SMTPS_FACTORY_CLASS, socketFactoryClass);
798:                if (socketFactoryFallback != null)
799:                    props.setProperty(SMTPS_FACTORY_FALLBACK,
800:                            socketFactoryFallback.toString());
801:                if (socketFactoryPort != null)
802:                    props.setProperty(SMTPS_FACTORY_PORT, socketFactoryPort
803:                            .toString());
804:                if (mailExtension != null)
805:                    props.setProperty(SMTPS_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(SMTPSTransportGBean.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.