Source Code Cross Referenced for POP3StoreGBean.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 POP3 message store
028:         * protocol.
029:         * <p/>
030:         * POP3 store properties that are common to all POP3 stores 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 POP3StoreGBean extends ProtocolGBean {
039:
040:            // the POP3 configuration property names
041:            static public final String POP3_PORT = "mail.pop3.port";
042:            static public final String POP3_CONNECTION_TIMEOUT = "mail.pop3.connectiontimeout";
043:            static public final String POP3_TIMEOUT = "mail.pop3.timeout";
044:            static public final String POP3_FACTORY_CLASS = "mail.pop3.socketFactory.class";
045:            static public final String POP3_FACTORY_FALLBACK = "mail.pop3.socketFactory.fallback";
046:            static public final String POP3_FACTORY_PORT = "mail.pop3.socketFactory.port";
047:            static public final String POP3_LOCALHOST = "mail.pop3.localhost";
048:            static public final String POP3_LOCALADDRESS = "mail.pop3.localaddress";
049:            static public final String POP3_LOCALPORT = "mail.pop3.localport";
050:            static public final String POP3_RESET = "mail.pop3.resetbeforequit";
051:            static public final String POP3_MESSAGE_CLASS = "mail.pop3.message.class";
052:            static public final String POP3_APOP = "mail.pop3.apop.enable";
053:
054:            static public final String GBEAN_RESET = "rsetBeforeQuit";
055:            static public final String GBEAN_APOP = "apopEnable";
056:            static public final String GBEAN_MESSAGE_CLASS = "messageClass";
057:
058:            private final Log log = LogFactory.getLog(POP3StoreGBean.class);
059:
060:            private Integer port;
061:            private Integer connectionTimeout;
062:            private Integer timeout;
063:            private Boolean rsetBeforeQuit;
064:            private String messageClass;
065:            private String localaddress;
066:            private Integer localport;
067:            private Boolean apopEnable;
068:            private String socketFactoryClass;
069:            private Boolean socketFactoryFallback;
070:            private Integer socketFactoryPort;
071:
072:            /**
073:             * Construct an instance of POP3StoreGBean
074:             * <p/>
075:             * Values that are set in the individual member variables will override any of
076:             * the corresponding values that have been set in the properties set.
077:             *
078:             * @param objectName            the object name of the protocol
079:             * @param properties            the set of default properties for the protocol
080:             * @param host                  the host the protocol connects to
081:             * @param user                  the default name for the protocol
082:             * @param port                  the POP3 server port
083:             * @param connectionTimeout     the socket connection timeout value in milliseconds
084:             * @param timeout               the socket I/O timeout value in milliseconds
085:             * @param rsetBeforeQuit        whether an attempt will be made send a POP3 RSET command when closing
086:             *                              the folder, before sending the QUIT command
087:             * @param messageClass          the class name of a subclass of com.sun.mail.pop3.POP3Message
088:             * @param localaddress          the local address (host name) to bind to when creating the POP3 socket
089:             * @param localport             the local port number to bind to when creating the POP3 socket
090:             * @param apopEnable            whether to use APOP instead of USER/PASS to login to the POP3 server,
091:             *                              if the POP3 server supports APOP
092:             * @param socketFactoryClass    the class that will be used to create POP3 sockets
093:             * @param socketFactoryFallback whether java.net.Socket class will be created if the specified
094:             *                              socket factory class cannot be created
095:             * @param socketFactoryPort     whether java.net.Socket class will be created if the specified
096:             *                              socket factory class cannot be created
097:             */
098:            public POP3StoreGBean(String objectName, Properties properties,
099:                    String host, String user, Integer port,
100:                    Integer connectionTimeout, Integer timeout,
101:                    Boolean rsetBeforeQuit, String messageClass,
102:                    String localaddress, Integer localport, Boolean apopEnable,
103:                    String socketFactoryClass, Boolean socketFactoryFallback,
104:                    Integer socketFactoryPort) {
105:                super (objectName, "pop3", properties, host, user);
106:
107:                setPort(port);
108:                setConnectionTimeout(connectionTimeout);
109:                setTimeout(timeout);
110:                setRsetBeforeQuit(rsetBeforeQuit);
111:                setMessageClass(messageClass);
112:                setLocaladdress(localaddress);
113:                setLocalport(localport);
114:                setApopEnable(apopEnable);
115:                setSocketFactoryClass(socketFactoryClass);
116:                setSocketFactoryFallback(socketFactoryFallback);
117:                setSocketFactoryPort(socketFactoryPort);
118:            }
119:
120:            /**
121:             * Returns the POP3 server port to connect to, if the connect() method
122:             * doesn't explicitly specify one.
123:             * <p/>
124:             * Defaults to 110.
125:             */
126:            public Integer getPort() {
127:                return port;
128:            }
129:
130:            /**
131:             * Sets the POP3 server port to connect to, if the connect() method
132:             * doesn't explicitly specify one.
133:             * <p/>
134:             * Defaults to 110.
135:             * <p/>
136:             * Values that are set here will override any of the corresponding value
137:             * that has been set in the properties.
138:             *
139:             * @param port the POP3 server port to connect to, if the connect() method
140:             *             doesn't explicitly specify one
141:             */
142:            public void setPort(Integer port) {
143:                this .port = port;
144:            }
145:
146:            /**
147:             * Returns the socket connection timeout value in milliseconds.
148:             */
149:            public Integer getConnectionTimeout() {
150:                return connectionTimeout;
151:            }
152:
153:            /**
154:             * Sets the socket connection timeout value in milliseconds.
155:             * <p/>
156:             * Default is infinite timeout.
157:             * <p/>
158:             * Values that are set here will override any of the corresponding value
159:             * that has been set in the properties.
160:             *
161:             * @param connectionTimeout the socket connection timeout value in milliseconds.
162:             */
163:            public void setConnectionTimeout(Integer connectionTimeout) {
164:                this .connectionTimeout = connectionTimeout;
165:            }
166:
167:            /**
168:             * Returns the socket I/O timeout value in milliseconds.
169:             */
170:            public Integer getTimeout() {
171:                return timeout;
172:            }
173:
174:            /**
175:             * Sets the socket I/O timeout value in milliseconds.
176:             * <p/>
177:             * Default is infinite timeout.
178:             * <p/>
179:             * Values that are set here will override any of the corresponding value
180:             * that has been set in the properties.
181:             *
182:             * @param timeout the socket I/O timeout value in milliseconds
183:             */
184:            public void setTimeout(Integer timeout) {
185:                this .timeout = timeout;
186:            }
187:
188:            /**
189:             * Returns whether an attempt will be made send a POP3 RSET command when
190:             * closing the folder, before sending the QUIT command.
191:             * <p/>
192:             * Send a POP3 RSET command when closing the folder, before sending the
193:             * QUIT command. Useful with POP3 servers that implicitly mark all
194:             * messages that are read as "deleted"; this will prevent such messages
195:             * from being deleted and expunged unless the client requests so. Default
196:             * is false.
197:             */
198:            public Boolean getRsetBeforeQuit() {
199:                return rsetBeforeQuit;
200:            }
201:
202:            /**
203:             * Sets whether an attempt will be made send a POP3 RSET command when
204:             * closing the folder, before sending the QUIT command.
205:             * <p/>
206:             * Send a POP3 RSET command when closing the folder, before sending the
207:             * QUIT command. Useful with POP3 servers that implicitly mark all messages
208:             * that are read as "deleted"; this will prevent such messages from being
209:             * deleted and expunged unless the client requests so. Default is false.
210:             * <p/>
211:             * Values that are set here will override any of the corresponding value
212:             * that has been set in the properties.
213:             *
214:             * @param rsetBeforeQuit whether an attempt will be made send a POP3 RSET command when
215:             *                       closing the folder, before sending the QUIT command
216:             */
217:            public void setRsetBeforeQuit(Boolean rsetBeforeQuit) {
218:                this .rsetBeforeQuit = rsetBeforeQuit;
219:            }
220:
221:            /**
222:             * Returns the class name of a subclass of com.sun.mail.pop3.POP3Message.
223:             * <p/>
224:             * Class name of a subclass of com.sun.mail.pop3.POP3Message. The subclass
225:             * can be used to handle (for example) non-standard Content-Type headers.
226:             * The subclass must have a public constructor of the form
227:             * MyPOP3Message(Folder f, int msgno) throws MessagingException.
228:             */
229:            public String getMessageClass() {
230:                return messageClass;
231:            }
232:
233:            /**
234:             * Sets the class name of a subclass of com.sun.mail.pop3.POP3Message.
235:             * <p/>
236:             * Class name of a subclass of com.sun.mail.pop3.POP3Message. The subclass
237:             * can be used to handle (for example) non-standard Content-Type headers.
238:             * The subclass must have a public constructor of the form
239:             * MyPOP3Message(Folder f, int msgno) throws MessagingException.
240:             * <p/>
241:             * Values that are set here will override any of the corresponding value
242:             * that has been set in the properties.
243:             *
244:             * @param messageClass the class name of a subclass of com.sun.mail.pop3.POP3Message.
245:             */
246:            public void setMessageClass(String messageClass) {
247:                this .messageClass = messageClass;
248:            }
249:
250:            /**
251:             * Returns the local address (host name) to bind to when creating the POP3 socket.
252:             */
253:            public String getLocaladdress() {
254:                return localaddress;
255:            }
256:
257:            /**
258:             * Sets the local address (host name) to bind to when creating the POP3 socket.
259:             * <p/>
260:             * Local address (host name) to bind to when creating the POP3 socket.
261:             * Defaults to the address picked by the Socket class. Should not normally
262:             * need to be set, but useful with multi-homed hosts where it's important
263:             * to pick a particular local address to bind to.
264:             * <p/>
265:             * Values that are set here will override any of the corresponding value
266:             * that has been set in the properties.
267:             *
268:             * @param localaddress the local address (host name) to bind to when creating the POP3 socket
269:             */
270:            public void setLocaladdress(String localaddress) {
271:                this .localaddress = localaddress;
272:            }
273:
274:            /**
275:             * Returns the local port number to bind to when creating the POP3 socket.
276:             */
277:            public Integer getLocalport() {
278:                return localport;
279:            }
280:
281:            /**
282:             * Sets the local port number to bind to when creating the POP3 socket.
283:             * <p/>
284:             * Local port number to bind to when creating the POP3 socket. Defaults to
285:             * the port number picked by the Socket class.
286:             * <p/>
287:             * Values that are set here will override any of the corresponding value
288:             * that has been set in the properties.
289:             *
290:             * @param localport the local port number to bind to when creating the POP3 socket
291:             */
292:            public void setLocalport(Integer localport) {
293:                this .localport = localport;
294:            }
295:
296:            /**
297:             * Returns whether to use APOP instead of USER/PASS to login to the POP3
298:             * server, if the POP3 server supports APOP.
299:             * <p/>
300:             * If set to true, use APOP instead of USER/PASS to login to the POP3
301:             * server, if the POP3 server supports APOP. APOP sends a digest of the
302:             * password rather than the clear text password. Defaults to false.
303:             */
304:            public Boolean isApopEnable() {
305:                return apopEnable;
306:            }
307:
308:            /**
309:             * Sets whether to use APOP instead of USER/PASS to login to the POP3
310:             * server, if the POP3 server supports APOP.
311:             * <p/>
312:             * If set to true, use APOP instead of USER/PASS to login to the POP3
313:             * server, if the POP3 server supports APOP. APOP sends a digest of the
314:             * password rather than the clear text password. Defaults to false.
315:             *
316:             * @param apopEnable whether to use APOP instead of USER/PASS to login to the POP3
317:             *                   server, if the POP3 server supports APOP
318:             */
319:            public void setApopEnable(Boolean apopEnable) {
320:                this .apopEnable = apopEnable;
321:            }
322:
323:            /**
324:             * Returns the class that will be used to create POP3 sockets.
325:             * <p/>
326:             * If set, specifies the name of a class that implements the
327:             * javax.net.SocketFactory interface. This class will be used to create POP3
328:             * sockets.
329:             */
330:            public String getSocketFactoryClass() {
331:                return socketFactoryClass;
332:            }
333:
334:            /**
335:             * Sets the class that will be used to create POP3 sockets.
336:             * <p/>
337:             * If set, specifies the name of a class that implements the
338:             * javax.net.SocketFactory interface. This class will be used to create POP3
339:             * sockets.
340:             * <p/>
341:             * Values that are set here will override any of the corresponding value
342:             * that has been set in the properties.
343:             *
344:             * @param socketFactoryClass the class that will be used to create POP3 sockets
345:             */
346:            public void setSocketFactoryClass(String socketFactoryClass) {
347:                this .socketFactoryClass = socketFactoryClass;
348:            }
349:
350:            /**
351:             * Returns whether java.net.Socket class will be created if the specified
352:             * socket factory class cannot be created.
353:             * <p/>
354:             * If set to true, failure to create a socket using the specified socket
355:             * factory class will cause the socket to be created using the
356:             * java.net.Socket class. Defaults to true.
357:             */
358:            public Boolean isSocketFactoryFallback() {
359:                return socketFactoryFallback;
360:            }
361:
362:            /**
363:             * Sets whether java.net.Socket class will be created if the specified
364:             * socket factory class cannot be created.
365:             * <p/>
366:             * If set to true, failure to create a socket using the specified socket
367:             * factory class will cause the socket to be created using the
368:             * java.net.Socket class. Defaults to true.
369:             * <p/>
370:             * Values that are set here will override any of the corresponding value
371:             * that has been set in the properties.
372:             *
373:             * @param socketFactoryFallback whether java.net.Socket class will be created if the specified
374:             *                              socket factory class cannot be created
375:             */
376:            public void setSocketFactoryFallback(Boolean socketFactoryFallback) {
377:                this .socketFactoryFallback = socketFactoryFallback;
378:            }
379:
380:            /**
381:             * Returns the port to connect to when using the specified socket factory.
382:             * <p/>
383:             * Specifies the port to connect to when using the specified socket
384:             * factory. If not set, the default port will be used.
385:             */
386:            public Integer getSocketFactoryPort() {
387:                return socketFactoryPort;
388:            }
389:
390:            /**
391:             * Sets the port to connect to when using the specified socket factory.
392:             * <p/>
393:             * Specifies the port to connect to when using the specified socket
394:             * factory. If not set, the default port will be used.
395:             * <p/>
396:             * Values that are set here will override any of the corresponding value
397:             * that has been set in the properties.
398:             *
399:             * @param socketFactoryPort the port to connect to when using the specified socket factory
400:             */
401:            public void setSocketFactoryPort(Integer socketFactoryPort) {
402:                this .socketFactoryPort = socketFactoryPort;
403:            }
404:
405:            /**
406:             * Add the overrides from the member variables to the properties file.
407:             */
408:            public void addOverrides(Properties props) {
409:                super .addOverrides(props);
410:
411:                if (port != null)
412:                    props.setProperty(POP3_PORT, port.toString());
413:                if (connectionTimeout != null)
414:                    props.setProperty(POP3_CONNECTION_TIMEOUT,
415:                            connectionTimeout.toString());
416:                if (timeout != null)
417:                    props.setProperty(POP3_TIMEOUT, timeout.toString());
418:                if (rsetBeforeQuit != null)
419:                    props.setProperty(POP3_RESET, rsetBeforeQuit.toString());
420:                if (messageClass != null)
421:                    props.setProperty(POP3_MESSAGE_CLASS, messageClass);
422:                if (localaddress != null)
423:                    props.setProperty(POP3_LOCALADDRESS, localaddress);
424:                if (localport != null)
425:                    props.setProperty(POP3_LOCALPORT, localport.toString());
426:                if (apopEnable != null)
427:                    props.setProperty(POP3_APOP, apopEnable.toString());
428:                if (socketFactoryClass != null)
429:                    props.setProperty(POP3_FACTORY_CLASS, socketFactoryClass);
430:                if (socketFactoryFallback != null)
431:                    props.setProperty(POP3_FACTORY_FALLBACK,
432:                            socketFactoryFallback.toString());
433:                if (socketFactoryPort != null)
434:                    props.setProperty(POP3_FACTORY_PORT, socketFactoryPort
435:                            .toString());
436:            }
437:
438:            public void doStart() throws Exception {
439:                log.debug("Started " + getObjectName());
440:            }
441:
442:            public void doStop() throws Exception {
443:                log.debug("Stopped " + getObjectName());
444:            }
445:
446:            public void doFail() {
447:                log.warn("Failed " + getObjectName());
448:            }
449:
450:            public static final GBeanInfo GBEAN_INFO;
451:
452:            static {
453:                GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(
454:                        POP3StoreGBean.class, ProtocolGBean.GBEAN_INFO);
455:
456:                infoFactory.addAttribute(GBEAN_PORT, Integer.class, true);
457:                infoFactory.addAttribute(GBEAN_CONNECTION_TIMEOUT,
458:                        Integer.class, true);
459:                infoFactory.addAttribute(GBEAN_TIMEOUT, Integer.class, true);
460:                infoFactory.addAttribute(GBEAN_RESET, Boolean.class, true);
461:                infoFactory.addAttribute(GBEAN_MESSAGE_CLASS, String.class,
462:                        true);
463:                infoFactory
464:                        .addAttribute(GBEAN_LOCALADDRESS, String.class, true);
465:                infoFactory.addAttribute(GBEAN_LOCALPORT, Integer.class, true);
466:                infoFactory.addAttribute(GBEAN_APOP, Boolean.class, true);
467:                infoFactory.addAttribute(GBEAN_FACTORY_CLASS, String.class,
468:                        true);
469:                infoFactory.addAttribute(GBEAN_FACTORY_FALLBACK, Boolean.class,
470:                        true);
471:                infoFactory.addAttribute(GBEAN_FACTORY_PORT, Integer.class,
472:                        true);
473:
474:                infoFactory.addAttribute(GBEAN_OBJECTNAME, String.class, false);
475:                infoFactory.addAttribute(GBEAN_PROTOCOL, String.class, true);
476:                infoFactory.addAttribute(GBEAN_PROPERTIES, Properties.class,
477:                        true);
478:                infoFactory.addAttribute(GBEAN_HOST, String.class, true);
479:                infoFactory.addAttribute(GBEAN_USER, String.class, true);
480:                infoFactory.addOperation(GBEAN_ADD_OVERRIDES,
481:                        new Class[] { Properties.class });
482:
483:                infoFactory.setConstructor(new String[] { GBEAN_OBJECTNAME,
484:                        GBEAN_PROPERTIES, GBEAN_HOST, GBEAN_USER, GBEAN_PORT,
485:                        GBEAN_CONNECTION_TIMEOUT, GBEAN_TIMEOUT, GBEAN_RESET,
486:                        GBEAN_MESSAGE_CLASS, GBEAN_LOCALADDRESS,
487:                        GBEAN_LOCALPORT, GBEAN_APOP, GBEAN_FACTORY_CLASS,
488:                        GBEAN_FACTORY_FALLBACK, GBEAN_FACTORY_PORT });
489:
490:                GBEAN_INFO = infoFactory.getBeanInfo();
491:            }
492:
493:            public static GBeanInfo getGBeanInfo() {
494:                return GBEAN_INFO;
495:            }
496:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.