KickJava   Java API By Example, From Geeks To Geeks.

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


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

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

39 public class IMAPStoreGBean extends ProtocolGBean {
40
41     // the IMAP configuration property names
42
static public final String JavaDoc IMAP_PORT = "mail.imap.port";
43     static public final String JavaDoc IMAP_CONNECTION_TIMEOUT = "mail.imap.connectiontimeout";
44     static public final String JavaDoc IMAP_TIMEOUT = "mail.imap.timeout";
45     static public final String JavaDoc IMAP_FACTORY_CLASS = "mail.imap.socketFactory.class";
46     static public final String JavaDoc IMAP_FACTORY_FALLBACK = "mail.imap.socketFactory.fallback";
47     static public final String JavaDoc IMAP_FACTORY_PORT = "mail.imap.socketFactory.port";
48     static public final String JavaDoc IMAP_LOCALHOST = "mail.imap.localhost";
49     static public final String JavaDoc IMAP_LOCALADDRESS = "mail.imap.localaddress";
50     static public final String JavaDoc IMAP_LOCALPORT = "mail.imap.localport";
51     static public final String JavaDoc IMAP_PARTIAL_FETCH = "mail.imap.partialfetch";
52     static public final String JavaDoc IMAP_FETCH_SIZE = "mail.imap.fetchsize";
53     static public final String JavaDoc IMAP_STATUS_TIMEOUT = "mail.imap.statuscachetimeout";
54     static public final String JavaDoc IMAP_APPEND_SIZE = "mail.imap.appendbuffersize";
55     static public final String JavaDoc IMAP_POOL_SIZE = "mail.imap.connectionpoolsize";
56     static public final String JavaDoc IMAP_POOL_TIMEOUT = "mail.imap.connectionpooltimeout";
57     static public final String JavaDoc IMAP_SEPARATE_STORE_CONNECTION = "mail.imap.separatestoreconnection";
58     static public final String JavaDoc IMAP_READONLY_SELECT = "mail.imap.alloreadonlyselect";
59     static public final String JavaDoc IMAP_LOGIN_DISABLE = "mail.imap.auth.login.disable";
60     static public final String JavaDoc IMAP_PLAIN_DISABLE = "mail.imap.auth.plain.disable";
61     static public final String JavaDoc IMAP_STARTTLS_ENABLE = "mail.imap.auth.starttls.enable";
62     static public final String JavaDoc IMAP_SASL_ENABLE = "mail.imap.sasl.enable";
63     static public final String JavaDoc IMAP_SASL_MECHANISMS = "mail.imap.sasl.mechanisms";
64     static public final String JavaDoc IMAP_SASL_AUTHORIZATIONID = "mail.imap.sasl.authorizationid";
65
66
67     // the GBEAN property names
68
static public final String JavaDoc GBEAN_PARTIAL_FETCH = "partialFetch";
69     static public final String JavaDoc GBEAN_FETCH_SIZE = "fetchSize";
70     static public final String JavaDoc GBEAN_STATUS_TIMEOUT = "statusCacheTimeout";
71     static public final String JavaDoc GBEAN_APPEND_SIZE = "appendBufferSize";
72     static public final String JavaDoc GBEAN_POOL_SIZE = "connectionPoolSize";
73     static public final String JavaDoc GBEAN_POOL_TIMEOUT = "connectionPoolTimeout";
74     static public final String JavaDoc GBEAN_SEPARATE_STORE_CONNECTION = "separateStoreConnection";
75     static public final String JavaDoc GBEAN_READONLY_SELECT = "allowReadOnlySelect";
76     static public final String JavaDoc GBEAN_LOGIN_DISABLE = "authLoginDisable";
77     static public final String JavaDoc GBEAN_PLAIN_DISABLE = "authPlainDisable";
78     static public final String JavaDoc GBEAN_STARTTLS_ENABLE = "startTLSEnable";
79     static public final String JavaDoc GBEAN_SASL_ENABLE = "saslEnable";
80     static public final String JavaDoc GBEAN_SASL_MECHANISMS = "saslMechanisms";
81     static public final String JavaDoc GBEAN_SASL_AUTHORIZATIONID = "saslAuthorizationId";
82
83     private final Log log = LogFactory.getLog(IMAPStoreGBean.class);
84
85     private Integer JavaDoc port;
86     private Boolean JavaDoc partialFetch;
87     private Integer JavaDoc fetchSize;
88     private Integer JavaDoc connectionTimeout;
89     private Integer JavaDoc timeout;
90     private Integer JavaDoc statusCacheTimeout;
91     private Integer JavaDoc appendBufferSize;
92     private Integer JavaDoc connectionPoolSize;
93     private Integer JavaDoc connectionPoolTimeout;
94     private Boolean JavaDoc separateStoreConnection;
95     private Boolean JavaDoc allowReadOnlySelect;
96     private Boolean JavaDoc authLoginDisable;
97     private Boolean JavaDoc authPlainDisable;
98     private Boolean JavaDoc startTLSEnable;
99     private String JavaDoc localaddress;
100     private Integer JavaDoc localport;
101     private Boolean JavaDoc saslEnable;
102     private String JavaDoc saslMechanisms;
103     private String JavaDoc saslAuthorizationId;
104     private String JavaDoc socketFactoryClass;
105     private Boolean JavaDoc socketFactoryFallback;
106     private Integer JavaDoc socketFactoryPort;
107
108
109     /**
110      * Construct an instance of IMAPStoreGBean
111      * <p/>
112      * Values that are set in the individual member variables will override any of
113      * the corresponding values that have been set in the properties set.
114      *
115      * @param objectName the object name of the protocol
116      * @param properties the set of default properties for the protocol
117      * @param host the host the protocol connects to
118      * @param user the default name for the protocol
119      * @param port the IMAP server port
120      * @param partialFetch whether the IMAP partial-fetch capability should be used
121      * @param fetchSize the partial fetch size in bytes
122      * @param connectionTimeout the socket connection timeout value in milliseconds
123      * @param timeout the socket I/O timeout value in milliseconds
124      * @param statusCacheTimeout the timeout value in milliseconds for cache of STATUS command response
125      * @param appendBufferSize the maximum size of a message to buffer in memory when appending to an IMAP folder
126      * @param connectionPoolSize the maximum number of available connections in the connection pool
127      * @param connectionPoolTimeout the timeout value in milliseconds for connection pool connections
128      * @param separateStoreConnection the flag to indicate whether to use a dedicated store connection for store commands
129      * @param allowReadOnlySelect the flag to indicate whether SELECT commands are read-only
130      * @param authLoginDisable the flag that prevents use of the non-standard AUTHENTICATE LOGIN command, instead using the plain LOGIN command
131      * @param authPlainDisable the flag that prevents use of the AUTHENTICATE PLAIN command
132      * @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
133      * @param localaddress the local address (host name) to bind to when creating the IMAP socket
134      * @param localport the local port number to bind to when creating the IMAP socket
135      * @param saslEnable the flag that enables an attempt to use the javax.security.sasl package to choose an authentication mechanism for login
136      * @param saslMechanisms a space or comma separated list of SASL mechanism names to try to use
137      * @param saslAuthorizationId the authorization ID to use in the SASL authentication
138      * @param socketFactoryClass the class that will be used to create IMAP sockets
139      * @param socketFactoryFallback whether java.net.Socket class will be created if the specified
140      * socket factory class cannot be created
141      * @param socketFactoryPort whether java.net.Socket class will be created if the specified
142      * socket factory class cannot be created
143      */

144     public IMAPStoreGBean(String JavaDoc objectName, Properties JavaDoc properties, String JavaDoc host, String JavaDoc user,
145                           Integer JavaDoc port,
146                           Boolean JavaDoc partialFetch,
147                           Integer JavaDoc fetchSize,
148                           Integer JavaDoc connectionTimeout,
149                           Integer JavaDoc timeout,
150                           Integer JavaDoc statusCacheTimeout,
151                           Integer JavaDoc appendBufferSize,
152                           Integer JavaDoc connectionPoolSize,
153                           Integer JavaDoc connectionPoolTimeout,
154                           Boolean JavaDoc separateStoreConnection,
155                           Boolean JavaDoc allowReadOnlySelect,
156                           Boolean JavaDoc authLoginDisable,
157                           Boolean JavaDoc authPlainDisable,
158                           Boolean JavaDoc startTLSEnable,
159                           String JavaDoc localaddress,
160                           Integer JavaDoc localport,
161                           Boolean JavaDoc saslEnable,
162                           String JavaDoc saslMechanisms,
163                           String JavaDoc saslAuthorizationId,
164                           String JavaDoc socketFactoryClass,
165                           Boolean JavaDoc socketFactoryFallback,
166                           Integer JavaDoc socketFactoryPort) {
167         super(objectName, "imap", properties, host, user);
168
169         setPort(port);
170         setPartialFetch(partialFetch);
171         setFetchSize(fetchSize);
172         setConnectionTimeout(connectionTimeout);
173         setTimeout(timeout);
174         setStatusCacheTimeout(statusCacheTimeout);
175         setAppendBufferSize(appendBufferSize);
176         setConnectionPoolSize(connectionPoolSize);
177         setConnectionPoolTimeout(connectionPoolTimeout);
178         setSeparateStoreConnection(separateStoreConnection);
179         setAllowReadOnlySelect(allowReadOnlySelect);
180         setAuthLoginDisable(authLoginDisable);
181         setAuthPlainDisable(authPlainDisable);
182         setStartTLSEnable(startTLSEnable);
183         setLocaladdress(localaddress);
184         setLocalport(localport);
185         setSaslEnable(saslEnable);
186         setSaslMechanisms(saslMechanisms);
187         setSaslAuthorizationId(saslAuthorizationId);
188         setSocketFactoryClass(socketFactoryClass);
189         setSocketFactoryFallback(socketFactoryFallback);
190         setSocketFactoryPort(socketFactoryPort);
191     }
192
193     /**
194      * Returns the IMAP server port to connect to, if the connect() method
195      * doesn't explicitly specify one.
196      */

197     public Integer JavaDoc getPort() {
198         return port;
199     }
200
201     /**
202      * Sets the IMAP server port to connect to, if the connect() method
203      * doesn't explicitly specify one.
204      * <p/>
205      * Defaults to 143.
206      * <p/>
207      * Values that are set here will override any of the corresponding value
208      * that has been set in the properties.
209      *
210      * @param port the IMAP server port to connect to, if the connect() method
211      * doesn't explicitly specify one
212      */

213     public void setPort(Integer JavaDoc port) {
214         this.port = port;
215     }
216
217     /**
218      * Returns whether the IMAP partial-fetch capability should be used.
219      * <p/>
220      * Controls whether the IMAP partial-fetch capability should be used.
221      * Defaults to true.
222      */

223     public Boolean JavaDoc getPartialFetch() {
224         return partialFetch;
225     }
226
227     /**
228      * Sets whether the IMAP partial-fetch capability should be used.
229      * <p/>
230      * Controls whether the IMAP partial-fetch capability should be used.
231      * Defaults to true.
232      * <p/>
233      * Values that are set here will override any of the corresponding value
234      * that has been set in the properties.
235      *
236      * @param partialFetch whether the IMAP partial-fetch capability should be used
237      */

238     public void setPartialFetch(Boolean JavaDoc partialFetch) {
239         this.partialFetch = partialFetch;
240     }
241
242     /**
243      * Returns the partial fetch size in bytes.
244      * <p/>
245      * Defaults to 16K.
246      */

247     public Integer JavaDoc getFetchSize() {
248         return fetchSize;
249     }
250
251     /**
252      * Sets the partial fetch size in bytes
253      * <p/>
254      * Defaults to 16K.
255      * <p/>
256      * Values that are set here will override any of the corresponding value
257      * that has been set in the properties.
258      *
259      * @param fetchSize the partial fetch size in bytes
260      */

261     public void setFetchSize(Integer JavaDoc fetchSize) {
262         this.fetchSize = fetchSize;
263     }
264
265     /**
266      * Returns the socket connection timeout value in milliseconds.
267      */

268     public Integer JavaDoc getConnectionTimeout() {
269         return connectionTimeout;
270     }
271
272     /**
273      * Sets the socket connection timeout value in milliseconds.
274      * <p/>
275      * Default is infinite timeout.
276      * <p/>
277      * Values that are set here will override any of the corresponding value
278      * that has been set in the properties.
279      *
280      * @param connectionTimeout the socket connection timeout value in milliseconds.
281      */

282     public void setConnectionTimeout(Integer JavaDoc connectionTimeout) {
283         this.connectionTimeout = connectionTimeout;
284     }
285
286     /**
287      * Returns the socket I/O timeout value in milliseconds.
288      */

289     public Integer JavaDoc getTimeout() {
290         return timeout;
291     }
292
293     /**
294      * Sets the socket I/O timeout value in milliseconds.
295      * <p/>
296      * Default is infinite timeout.
297      * <p/>
298      * Values that are set here will override any of the corresponding value
299      * that has been set in the properties.
300      *
301      * @param timeout the socket I/O timeout value in milliseconds
302      */

303     public void setTimeout(Integer JavaDoc timeout) {
304         this.timeout = timeout;
305     }
306
307     /**
308      * Returns the timeout value in milliseconds for cache of STATUS command response.
309      * <p/>
310      * Timeout value in milliseconds for cache of STATUS command response.
311      * Default is 1000 (1 second). Zero disables cache.
312      */

313     public Integer JavaDoc getStatusCacheTimeout() {
314         return statusCacheTimeout;
315     }
316
317     /**
318      * Sets the timeout value in milliseconds for cache of STATUS command response
319      * <p/>
320      * Timeout value in milliseconds for cache of STATUS command response.
321      * Default is 1000 (1 second). Zero disables cache.
322      * <p/>
323      * Values that are set here will override any of the corresponding value
324      * that has been set in the properties.
325      *
326      * @param statusCacheTimeout the timeout value in milliseconds for cache of STATUS command response
327      */

328     public void setStatusCacheTimeout(Integer JavaDoc statusCacheTimeout) {
329         this.statusCacheTimeout = statusCacheTimeout;
330     }
331
332     /**
333      * Returns the maximum size of a message to buffer in memory when appending
334      * to an IMAP folder.
335      * <p/>
336      * Maximum size of a message to buffer in memory when appending to an IMAP
337      * folder. If not set, or set to -1, there is no maximum and all messages
338      * are buffered. If set to 0, no messages are buffered. If set to (e.g.)
339      * 8192, messages of 8K bytes or less are buffered, larger messages are not
340      * buffered. Buffering saves cpu time at the expense of short term memory
341      * usage. If you commonly append very large messages to IMAP mailboxes you
342      * might want to set this to a moderate value (1M or less).
343      */

344     public Integer JavaDoc getAppendBufferSize() {
345         return appendBufferSize;
346     }
347
348     /**
349      * Sets the maximum size of a message to buffer in memory when appending
350      * to an IMAP folder.
351      * <p/>
352      * Maximum size of a message to buffer in memory when appending to an IMAP
353      * folder. If not set, or set to -1, there is no maximum and all messages
354      * are buffered. If set to 0, no messages are buffered. If set to (e.g.)
355      * 8192, messages of 8K bytes or less are buffered, larger messages are not
356      * buffered. Buffering saves cpu time at the expense of short term memory
357      * usage. If you commonly append very large messages to IMAP mailboxes you
358      * might want to set this to a moderate value (1M or less).
359      * <p/>
360      * Values that are set here will override any of the corresponding value
361      * that has been set in the properties.
362      *
363      * @param appendBufferSize the maximum size of a message to buffer in memory when appending
364      * to an IMAP folder
365      */

366     public void setAppendBufferSize(Integer JavaDoc appendBufferSize) {
367         this.appendBufferSize = appendBufferSize;
368     }
369
370     /**
371      * Returns the maximum number of available connections in the connection pool.
372      * <p/>
373      * Default is 1.
374      */

375     public Integer JavaDoc getConnectionPoolSize() {
376         return connectionPoolSize;
377     }
378
379     /**
380      * Sets the maximum number of available connections in the connection pool.
381      * <p/>
382      * Default is 1.
383      * <p/>
384      * Values that are set here will override any of the corresponding value
385      * that has been set in the properties.
386      *
387      * @param connectionPoolSize the maximum number of available connections in the connection pool
388      */

389     public void setConnectionPoolSize(Integer JavaDoc connectionPoolSize) {
390         this.connectionPoolSize = connectionPoolSize;
391     }
392
393     /**
394      * Returns the timeout value in milliseconds for connection pool connections.
395      * <p/>
396      * Default is 45000 (45 seconds).
397      */

398     public Integer JavaDoc getConnectionPoolTimeout() {
399         return connectionPoolTimeout;
400     }
401
402     /**
403      * Sets the timeout value in milliseconds for connection pool connections
404      * <p/>
405      * Default is 45000 (45 seconds).
406      * <p/>
407      * Values that are set here will override any of the corresponding value
408      * that has been set in the properties.
409      *
410      * @param connectionPoolTimeout the timeout value in milliseconds for connection pool connections
411      */

412     public void setConnectionPoolTimeout(Integer JavaDoc connectionPoolTimeout) {
413         this.connectionPoolTimeout = connectionPoolTimeout;
414     }
415
416     /**
417      * Returns the flag to indicate whether to use a dedicated store
418      * connection for store commands.
419      * <p/>
420      * Flag to indicate whether to use a dedicated store connection
421      * for store commands. Default is false.
422      */

423     public Boolean JavaDoc getSeparateStoreConnection() {
424         return separateStoreConnection;
425     }
426
427     /**
428      * Sets the flag to indicate whether to use a dedicated store
429      * connection for store commands
430      * <p/>
431      * Flag to indicate whether to use a dedicated store connection
432      * for store commands. Default is false.
433      * <p/>
434      * Values that are set here will override any of the corresponding value
435      * that has been set in the properties.
436      *
437      * @param separateStoreConnection the flag to indicate whether to use a dedicated store
438      * connection for store commands
439      */

440     public void setSeparateStoreConnection(Boolean JavaDoc separateStoreConnection) {
441         this.separateStoreConnection = separateStoreConnection;
442     }
443
444     /**
445      * Returns the flag to indicate whether SELECT commands are read-only.
446      * <p/>
447      * If false, attempts to open a folder read/write will fail if the SELECT
448      * command succeeds but indicates that the folder is READ-ONLY. This
449      * sometimes indicates that the folder contents can'tbe changed, but the
450      * flags are per-user and can be changed, such as might be the case for
451      * public shared folders. If true, such open attempts will succeed, allowing
452      * the flags to be changed. The getMode method on the Folder object will
453      * return Folder.READ_ONLY in this case even though the open method specified
454      * Folder.READ_WRITE. Default is false.
455      */

456     public Boolean JavaDoc getAllowReadOnlySelect() {
457         return allowReadOnlySelect;
458     }
459
460     /**
461      * Sets the flag to indicate whether SELECT commands are read-only.
462      * <p/>
463      * If false, attempts to open a folder read/write will fail if the SELECT
464      * command succeeds but indicates that the folder is READ-ONLY. This
465      * sometimes indicates that the folder contents can'tbe changed, but the
466      * flags are per-user and can be changed, such as might be the case for
467      * public shared folders. If true, such open attempts will succeed, allowing
468      * the flags to be changed. The getMode method on the Folder object will
469      * return Folder.READ_ONLY in this case even though the open method specified
470      * Folder.READ_WRITE. Default is false.
471      * <p/>
472      * Values that are set here will override any of the corresponding value
473      * that has been set in the properties.
474      *
475      * @param allowReadOnlySelect the flag to indicate whether SELECT commands are read-only
476      */

477     public void setAllowReadOnlySelect(Boolean JavaDoc allowReadOnlySelect) {
478         this.allowReadOnlySelect = allowReadOnlySelect;
479     }
480
481     /**
482      * Returns the flag that prevents use of the non-standard AUTHENTICATE LOGIN
483      * command, instead using the plain LOGIN command.
484      * <p/>
485      * Default is false.
486      */

487     public Boolean JavaDoc getAuthLoginDisable() {
488         return authLoginDisable;
489     }
490
491     /**
492      * Sets the flag that prevents use of the non-standard AUTHENTICATE LOGIN
493      * command, instead using the plain LOGIN command.
494      * <p/>
495      * Default is false.
496      * <p/>
497      * Values that are set here will override any of the corresponding value
498      * that has been set in the properties.
499      *
500      * @param authLoginDisable the flag that prevents use of the non-standard AUTHENTICATE LOGIN
501      * command, instead using the plain LOGIN command
502      */

503     public void setAuthLoginDisable(Boolean JavaDoc authLoginDisable) {
504         this.authLoginDisable = authLoginDisable;
505     }
506
507     /**
508      * Returns the flag that prevents use of the AUTHENTICATE PLAIN command.
509      * <p/>
510      * Default is false.
511      */

512     public Boolean JavaDoc getAuthPlainDisable() {
513         return authPlainDisable;
514     }
515
516     /**
517      * Sets the flag that prevents use of the AUTHENTICATE PLAIN command.
518      * <p/>
519      * Default is false.
520      * <p/>
521      * Values that are set here will override any of the corresponding value
522      * that has been set in the properties.
523      *
524      * @param authPlainDisable the flag that prevents use of the AUTHENTICATE PLAIN command
525      */

526     public void setAuthPlainDisable(Boolean JavaDoc authPlainDisable) {
527         this.authPlainDisable = authPlainDisable;
528     }
529
530     /**
531      * Returns the flag that enables the use of the STARTTLS command (if
532      * supported by the server) to switch the connection to a TLS-protected
533      * connection before issuing any login commands.
534      * <p/>
535      * If true, enables the use of the STARTTLS command (if supported by the
536      * server) to switch the connection to a TLS-protected connection before
537      * issuing any login commands. Note that an appropriate trust store must
538      * configured so that the client will trust the server's certificate.
539      * This feature only works on J2SE 1.4 and newer systems. Default is false.
540      */

541     public Boolean JavaDoc getStartTLSEnable() {
542         return startTLSEnable;
543     }
544
545     /**
546      * Sets the flag that enables the use of the STARTTLS command (if
547      * supported by the server) to switch the connection to a TLS-protected
548      * connection before issuing any login commands.
549      * <p/>
550      * If true, enables the use of the STARTTLS command (if supported by the
551      * server) to switch the connection to a TLS-protected connection before
552      * issuing any login commands. Note that an appropriate trust store must
553      * configured so that the client will trust the server's certificate.
554      * This feature only works on J2SE 1.4 and newer systems. Default is false.
555      * <p/>
556      * Values that are set here will override any of the corresponding value
557      * that has been set in the properties.
558      *
559      * @param startTLSEnable the flag that enables the use of the STARTTLS command (if
560      * supported by the server) to switch the connection to a TLS-protected
561      * connection before issuing any login commands
562      */

563     public void setStartTLSEnable(Boolean JavaDoc startTLSEnable) {
564         this.startTLSEnable = startTLSEnable;
565     }
566
567     /**
568      * Returns the local address (host name) to bind to when creating the IMAP socket.
569      */

570     public String JavaDoc getLocaladdress() {
571         return localaddress;
572     }
573
574     /**
575      * Sets the local address (host name) to bind to when creating the IMAP socket.
576      * <p/>
577      * Local address (host name) to bind to when creating the IMAP socket.
578      * Defaults to the address picked by the Socket class. Should not normally
579      * need to be set, but useful with multi-homed hosts where it's important
580      * to pick a particular local address to bind to.
581      * <p/>
582      * Values that are set here will override any of the corresponding value
583      * that has been set in the properties.
584      *
585      * @param localaddress the local address (host name) to bind to when creating the IMAP socket
586      */

587     public void setLocaladdress(String JavaDoc localaddress) {
588         this.localaddress = localaddress;
589     }
590
591     /**
592      * Returns the local port number to bind to when creating the IMAP socket.
593      */

594     public Integer JavaDoc getLocalport() {
595         return localport;
596     }
597
598     /**
599      * Sets the local port number to bind to when creating the IMAP socket.
600      * <p/>
601      * Local port number to bind to when creating the IMAP socket. Defaults to
602      * the port number picked by the Socket class.
603      * <p/>
604      * Values that are set here will override any of the corresponding value
605      * that has been set in the properties.
606      *
607      * @param localport the local port number to bind to when creating the IMAP socket
608      */

609     public void setLocalport(Integer JavaDoc localport) {
610         this.localport = localport;
611     }
612
613     /**
614      * Returns the flag that enables an attempt to use the javax.security.sasl
615      * package to choose an authentication mechanism for login.
616      * <p/>
617      * Defaults to false.
618      */

619     public Boolean JavaDoc getSaslEnable() {
620         return saslEnable;
621     }
622
623     /**
624      * Sets the flag that enables an attempt to use the javax.security.sasl
625      * package to choose an authentication mechanism for login.
626      * <p/>
627      * Defaults to false.
628      * <p/>
629      * Values that are set here will override any of the corresponding value
630      * that has been set in the properties.
631      *
632      * @param saslEnable the flag that enables an attempt to use the javax.security.sasl
633      * package to choose an authentication mechanism for login
634      */

635     public void setSaslEnable(Boolean JavaDoc saslEnable) {
636         this.saslEnable = saslEnable;
637     }
638
639     /**
640      * Returns a space or comma separated list of SASL mechanism names to try to use.
641      */

642     public String JavaDoc getSaslMechanisms() {
643         return saslMechanisms;
644     }
645
646     /**
647      * Sets a space or comma separated list of SASL mechanism names to try to use.
648      * <p/>
649      * Values that are set here will override any of the corresponding value
650      * that has been set in the properties.
651      *
652      * @param saslMechanisms a space or comma separated list of SASL mechanism names to try to use
653      */

654     public void setSaslMechanisms(String JavaDoc saslMechanisms) {
655         this.saslMechanisms = saslMechanisms;
656     }
657
658     /**
659      * Returns the authorization ID to use in the SASL authentication.
660      * <p/>
661      * If not set, the authetication ID (user name) is used.
662      */

663     public String JavaDoc getSaslAuthorizationId() {
664         return saslAuthorizationId;
665     }
666
667     /**
668      * Sets the authorization ID to use in the SASL authentication.
669      * <p/>
670      * If not set, the authetication ID (user name) is used.
671      * <p/>
672      * Values that are set here will override any of the corresponding value
673      * that has been set in the properties.
674      *
675      * @param saslAuthorizationId the authorization ID to use in the SASL authentication
676      */

677     public void setSaslAuthorizationId(String JavaDoc saslAuthorizationId) {
678         this.saslAuthorizationId = saslAuthorizationId;
679     }
680
681     /**
682      * Returns the class that will be used to create IMAP sockets.
683      * <p/>
684      * If set, specifies the name of a class that implements the
685      * javax.net.SocketFactory interface. This class will be used to create IMAP
686      * sockets.
687      */

688     public String JavaDoc getSocketFactoryClass() {
689         return socketFactoryClass;
690     }
691
692     /**
693      * Sets the class that will be used to create SMTP sockets.
694      * <p/>
695      * If set, specifies the name of a class that implements the
696      * javax.net.SocketFactory interface. This class will be used to create SMTP
697      * sockets.
698      * <p/>
699      * Values that are set here will override any of the corresponding value
700      * that has been set in the properties.
701      *
702      * @param socketFactoryClass the class that will be used to create SMTP sockets
703      */

704     public void setSocketFactoryClass(String JavaDoc socketFactoryClass) {
705         this.socketFactoryClass = socketFactoryClass;
706     }
707
708     /**
709      * Returns whether java.net.Socket class will be created if the specified
710      * socket factory class cannot be created.
711      * <p/>
712      * If set to true, failure to create a socket using the specified socket
713      * factory class will cause the socket to be created using the
714      * java.net.Socket class. Defaults to true.
715      */

716     public Boolean JavaDoc getSocketFactoryFallback() {
717         return socketFactoryFallback;
718     }
719
720     /**
721      * Sets whether java.net.Socket class will be created if the specified
722      * socket factory class cannot be created.
723      * <p/>
724      * If set to true, failure to create a socket using the specified socket
725      * factory class will cause the socket to be created using the
726      * java.net.Socket class. Defaults to true.
727      * <p/>
728      * Values that are set here will override any of the corresponding value
729      * that has been set in the properties.
730      *
731      * @param socketFactoryFallback whether java.net.Socket class will be created if the specified
732      * socket factory class cannot be created
733      */

734     public void setSocketFactoryFallback(Boolean JavaDoc socketFactoryFallback) {
735         this.socketFactoryFallback = socketFactoryFallback;
736     }
737
738     /**
739      * Returns the port to connect to when using the specified socket factory.
740      * <p/>
741      * Specifies the port to connect to when using the specified socket
742      * factory. If not set, the default port will be used.
743      */

744     public Integer JavaDoc getSocketFactoryPort() {
745         return socketFactoryPort;
746     }
747
748     /**
749      * Sets the port to connect to when using the specified socket factory.
750      * <p/>
751      * Specifies the port to connect to when using the specified socket
752      * factory. If not set, the default port will be used.
753      * <p/>
754      * Values that are set here will override any of the corresponding value
755      * that has been set in the properties.
756      *
757      * @param socketFactoryPort the port to connect to when using the specified socket factory
758      */

759     public void setSocketFactoryPort(Integer JavaDoc socketFactoryPort) {
760         this.socketFactoryPort = socketFactoryPort;
761     }
762
763     /**
764      * Add the overrides from the member variables to the properties file.
765      */

766     public void addOverrides(Properties JavaDoc props) {
767         super.addOverrides(props);
768
769         if (port != null) props.setProperty(IMAP_PORT, port.toString());
770         if (partialFetch != null) props.setProperty(IMAP_PARTIAL_FETCH, partialFetch.toString());
771         if (fetchSize != null) props.setProperty(IMAP_FETCH_SIZE, fetchSize.toString());
772         if (connectionTimeout != null) props.setProperty(IMAP_CONNECTION_TIMEOUT, connectionTimeout.toString());
773         if (timeout != null) props.setProperty(IMAP_TIMEOUT, timeout.toString());
774         if (statusCacheTimeout != null) props.setProperty(IMAP_STATUS_TIMEOUT, statusCacheTimeout.toString());
775         if (appendBufferSize != null) props.setProperty(IMAP_APPEND_SIZE, appendBufferSize.toString());
776         if (connectionPoolSize != null) props.setProperty(IMAP_POOL_SIZE, connectionPoolSize.toString());
777         if (connectionPoolTimeout != null) props.setProperty(IMAP_POOL_TIMEOUT, connectionPoolTimeout.toString());
778         if (separateStoreConnection != null) props.setProperty(IMAP_SEPARATE_STORE_CONNECTION, separateStoreConnection.toString());
779         if (allowReadOnlySelect != null) props.setProperty(IMAP_READONLY_SELECT, allowReadOnlySelect.toString());
780         if (authLoginDisable != null) props.setProperty(IMAP_LOGIN_DISABLE, authLoginDisable.toString());
781         if (authPlainDisable != null) props.setProperty(IMAP_PLAIN_DISABLE, authPlainDisable.toString());
782         if (startTLSEnable != null) props.setProperty(IMAP_STARTTLS_ENABLE, startTLSEnable.toString());
783         if (localaddress != null) props.setProperty(IMAP_LOCALADDRESS, localaddress);
784         if (localport != null) props.setProperty(IMAP_LOCALPORT, localport.toString());
785         if (saslEnable != null) props.setProperty(IMAP_SASL_ENABLE, saslEnable.toString());
786         if (saslMechanisms != null) props.setProperty(IMAP_SASL_MECHANISMS, saslMechanisms);
787         if (saslAuthorizationId != null) props.setProperty(IMAP_SASL_AUTHORIZATIONID, saslAuthorizationId);
788         if (socketFactoryClass != null) props.setProperty(IMAP_FACTORY_CLASS, socketFactoryClass);
789         if (socketFactoryFallback != null) props.setProperty(IMAP_FACTORY_FALLBACK, socketFactoryFallback.toString());
790         if (socketFactoryPort != null) props.setProperty(IMAP_FACTORY_PORT, socketFactoryPort.toString());
791     }
792
793     public void doStart() throws Exception JavaDoc {
794         log.debug("Started " + getObjectName());
795     }
796
797     public void doStop() throws Exception JavaDoc {
798         log.debug("Stopped " + getObjectName());
799     }
800
801     public void doFail() {
802         log.warn("Failed " + getObjectName());
803     }
804
805     public static final GBeanInfo GBEAN_INFO;
806
807     static {
808         GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(IMAPStoreGBean.class, ProtocolGBean.GBEAN_INFO);
809
810         infoFactory.addAttribute(GBEAN_PORT, Integer JavaDoc.class, true);
811         infoFactory.addAttribute(GBEAN_CONNECTION_TIMEOUT, Integer JavaDoc.class, true);
812         infoFactory.addAttribute(GBEAN_TIMEOUT, Integer JavaDoc.class, true);
813         infoFactory.addAttribute(GBEAN_LOCALADDRESS, String JavaDoc.class, true);
814         infoFactory.addAttribute(GBEAN_LOCALPORT, Integer JavaDoc.class, true);
815         infoFactory.addAttribute(GBEAN_FACTORY_CLASS, String JavaDoc.class, true);
816         infoFactory.addAttribute(GBEAN_FACTORY_FALLBACK, Boolean JavaDoc.class, true);
817         infoFactory.addAttribute(GBEAN_FACTORY_PORT, Integer JavaDoc.class, true);
818         infoFactory.addAttribute(GBEAN_PARTIAL_FETCH, Boolean JavaDoc.class, true);
819         infoFactory.addAttribute(GBEAN_FETCH_SIZE, Integer JavaDoc.class, true);
820         infoFactory.addAttribute(GBEAN_STATUS_TIMEOUT, Integer JavaDoc.class, true);
821         infoFactory.addAttribute(GBEAN_APPEND_SIZE, Integer JavaDoc.class, true);
822         infoFactory.addAttribute(GBEAN_POOL_SIZE, Integer JavaDoc.class, true);
823         infoFactory.addAttribute(GBEAN_POOL_TIMEOUT, Integer JavaDoc.class, true);
824         infoFactory.addAttribute(GBEAN_SEPARATE_STORE_CONNECTION, Boolean JavaDoc.class, true);
825         infoFactory.addAttribute(GBEAN_READONLY_SELECT, Boolean JavaDoc.class, true);
826         infoFactory.addAttribute(GBEAN_LOGIN_DISABLE, Boolean JavaDoc.class, true);
827         infoFactory.addAttribute(GBEAN_PLAIN_DISABLE, Boolean JavaDoc.class, true);
828         infoFactory.addAttribute(GBEAN_STARTTLS_ENABLE, Boolean JavaDoc.class, true);
829         infoFactory.addAttribute(GBEAN_SASL_ENABLE, Boolean JavaDoc.class, true);
830         infoFactory.addAttribute(GBEAN_SASL_MECHANISMS, String JavaDoc.class, true);
831         infoFactory.addAttribute(GBEAN_SASL_AUTHORIZATIONID, String JavaDoc.class, true);
832
833         infoFactory.addAttribute(GBEAN_OBJECTNAME, String JavaDoc.class, false);
834         infoFactory.addAttribute(GBEAN_PROTOCOL, String JavaDoc.class, true);
835         infoFactory.addAttribute(GBEAN_PROPERTIES, Properties JavaDoc.class, true);
836         infoFactory.addAttribute(GBEAN_HOST, String JavaDoc.class, true);
837         infoFactory.addAttribute(GBEAN_USER, String JavaDoc.class, true);
838         infoFactory.addOperation(GBEAN_ADD_OVERRIDES, new Class JavaDoc[]{Properties JavaDoc.class});
839
840         infoFactory.setConstructor(new String JavaDoc[]{GBEAN_OBJECTNAME, GBEAN_PROPERTIES, GBEAN_HOST, GBEAN_USER,
841                                                 GBEAN_PORT,
842                                                 GBEAN_PARTIAL_FETCH,
843                                                 GBEAN_FETCH_SIZE,
844                                                 GBEAN_CONNECTION_TIMEOUT,
845                                                 GBEAN_TIMEOUT,
846                                                 GBEAN_STATUS_TIMEOUT,
847                                                 GBEAN_APPEND_SIZE,
848                                                 GBEAN_POOL_SIZE,
849                                                 GBEAN_POOL_TIMEOUT,
850                                                 GBEAN_SEPARATE_STORE_CONNECTION,
851                                                 GBEAN_READONLY_SELECT,
852                                                 GBEAN_LOGIN_DISABLE,
853                                                 GBEAN_PLAIN_DISABLE,
854                                                 GBEAN_STARTTLS_ENABLE,
855                                                 GBEAN_LOCALADDRESS,
856                                                 GBEAN_LOCALPORT,
857                                                 GBEAN_SASL_ENABLE,
858                                                 GBEAN_SASL_MECHANISMS,
859                                                 GBEAN_SASL_AUTHORIZATIONID,
860                                                 GBEAN_FACTORY_CLASS,
861                                                 GBEAN_FACTORY_FALLBACK,
862                                                 GBEAN_FACTORY_PORT});
863
864         GBEAN_INFO = infoFactory.getBeanInfo();
865     }
866
867     public static GBeanInfo getGBeanInfo() {
868         return GBEAN_INFO;
869     }
870 }
871
Popular Tags