geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r123792 - in geronimo/trunk/modules/mail: . src/java/org/apache/geronimo/mail src/test/org/apache/geronimo/mail
Date Fri, 31 Dec 2004 13:58:13 GMT
Author: adc
Date: Fri Dec 31 05:58:12 2004
New Revision: 123792

URL: http://svn.apache.org/viewcvs?view=rev&rev=123792
Log:
New mail GBean
http://issues.apache.org/jira/browse/GERONIMO-536
Added:
   geronimo/trunk/modules/mail/src/java/org/apache/geronimo/mail/IMAPStoreGBean.java
   geronimo/trunk/modules/mail/src/java/org/apache/geronimo/mail/POP3StoreGBean.java
   geronimo/trunk/modules/mail/src/java/org/apache/geronimo/mail/ProtocolGBean.java
   geronimo/trunk/modules/mail/src/java/org/apache/geronimo/mail/SMTPTransportGBean.java
   geronimo/trunk/modules/mail/src/test/org/apache/geronimo/mail/TestStore.java
   geronimo/trunk/modules/mail/src/test/org/apache/geronimo/mail/TestTransport.java
Modified:
   geronimo/trunk/modules/mail/project.xml
   geronimo/trunk/modules/mail/src/java/org/apache/geronimo/mail/MailGBean.java
   geronimo/trunk/modules/mail/src/test/org/apache/geronimo/mail/MailGBeanTest.java

Modified: geronimo/trunk/modules/mail/project.xml
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/mail/project.xml?view=diff&rev=123792&p1=geronimo/trunk/modules/mail/project.xml&r1=123791&p2=geronimo/trunk/modules/mail/project.xml&r2=123792
==============================================================================
--- geronimo/trunk/modules/mail/project.xml	(original)
+++ geronimo/trunk/modules/mail/project.xml	Fri Dec 31 05:58:12 2004
@@ -96,6 +96,11 @@
             <excludes>
                 <exclude>**/Abstract*.java</exclude>
             </excludes>
+            <resources>
+                <resource>
+                    <directory>${basedir}/src/test-resources</directory>
+                </resource>
+            </resources>
         </unitTest>
     </build>
 </project>

Added: geronimo/trunk/modules/mail/src/java/org/apache/geronimo/mail/IMAPStoreGBean.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/mail/src/java/org/apache/geronimo/mail/IMAPStoreGBean.java?view=auto&rev=123792
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/mail/src/java/org/apache/geronimo/mail/IMAPStoreGBean.java	Fri Dec 31 05:58:12 2004
@@ -0,0 +1,824 @@
+/**
+ *
+ * Copyright 2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.mail;
+
+import java.util.Properties;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.geronimo.gbean.GAttributeInfo;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.gbean.WaitingException;
+
+
+/**
+ * A GBean that provides for the configuration of a JavaMail IMAP message store
+ * protocol.
+ * <p/>
+ * IMAP store properties that are common to all IMAP stores are
+ * provided via member variables of this class.  Values that are set in the
+ * individual member variables will override any of the corresponding values
+ * that have been set in the properties set.
+ *
+ * @version $Rev: $ $Date: $
+ * @see MailGBean
+ */
+public class IMAPStoreGBean extends ProtocolGBean {
+
+    private final Log log = LogFactory.getLog(IMAPStoreGBean.class);
+
+    private Integer port;
+    private Boolean partialFetch;
+    private Integer fetchSize;
+    private Integer connectionTimeout;
+    private Integer timeout;
+    private Integer statusCacheTimeout;
+    private Integer appendBufferSize;
+    private Integer connectionPoolSize;
+    private Integer connectionPoolTimeout;
+    private Boolean separateStoreConnection;
+    private Boolean allowReadOnlySelect;
+    private Boolean authLoginDisable;
+    private Boolean authPlainDisable;
+    private Boolean startTLSEnable;
+    private String localaddress;
+    private Integer localport;
+    private Boolean saslEnable;
+    private String saslMechanisms;
+    private String saslAuthorizationId;
+    private String socketFactoryClass;
+    private Boolean socketFactoryFallback;
+    private Integer socketFactoryPort;
+
+
+    /**
+     * Construct an instance of IMAPStoreGBean
+     * <p/>
+     * Values that are set in the individual member variables will override any of
+     * the corresponding values that have been set in the properties set.
+     *
+     * @param objectName              the object name of the protocol
+     * @param properties              the set of default properties for the protocol
+     * @param host                    the host the protocol connects to
+     * @param user                    the default name for the protocol
+     * @param port                    the IMAP server port
+     * @param partialFetch            whether the IMAP partial-fetch capability should be used
+     * @param fetchSize               the partial fetch size in bytes
+     * @param connectionTimeout       the socket connection timeout value in milliseconds
+     * @param timeout                 the socket I/O timeout value in milliseconds
+     * @param statusCacheTimeout      the timeout value in milliseconds for cache of STATUS command response
+     * @param appendBufferSize        the maximum size of a message to buffer in memory when appending to an IMAP folder
+     * @param connectionPoolSize      the maximum number of available connections in the connection pool
+     * @param connectionPoolTimeout   the timeout value in milliseconds for connection pool connections
+     * @param separateStoreConnection the flag to indicate whether to use a dedicated store connection for store commands
+     * @param allowReadOnlySelect     the flag to indicate whether SELECT commands are read-only
+     * @param authLoginDisable        the flag that prevents use of the non-standard AUTHENTICATE LOGIN command, instead using the plain LOGIN command
+     * @param authPlainDisable        the flag that prevents use of the AUTHENTICATE PLAIN command
+     * @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
+     * @param localaddress            the local address (host name) to bind to when creating the IMAP socket
+     * @param localport               the local port number to bind to when creating the IMAP socket
+     * @param saslEnable              the flag that enables an attempt to use the javax.security.sasl package to choose an authentication mechanism for login
+     * @param saslMechanisms          a space or comma separated list of SASL mechanism names to try to use
+     * @param saslAuthorizationId     the authorization ID to use in the SASL authentication
+     * @param socketFactoryClass      the class that will be used to create IMAP sockets
+     * @param socketFactoryFallback   whether java.net.Socket class will be created if the specified
+     *                                socket factory class cannot be created
+     * @param socketFactoryPort       whether java.net.Socket class will be created if the specified
+     *                                socket factory class cannot be created
+     */
+    public IMAPStoreGBean(String objectName, Properties properties, String host, String user,
+                          Integer port,
+                          Boolean partialFetch,
+                          Integer fetchSize,
+                          Integer connectionTimeout,
+                          Integer timeout,
+                          Integer statusCacheTimeout,
+                          Integer appendBufferSize,
+                          Integer connectionPoolSize,
+                          Integer connectionPoolTimeout,
+                          Boolean separateStoreConnection,
+                          Boolean allowReadOnlySelect,
+                          Boolean authLoginDisable,
+                          Boolean authPlainDisable,
+                          Boolean startTLSEnable,
+                          String localaddress,
+                          Integer localport,
+                          Boolean saslEnable,
+                          String saslMechanisms,
+                          String saslAuthorizationId,
+                          String socketFactoryClass,
+                          Boolean socketFactoryFallback,
+                          Integer socketFactoryPort) {
+        super(objectName, "imap", properties, host, user);
+
+        setPort(port);
+        setPartialFetch(partialFetch);
+        setFetchSize(fetchSize);
+        setConnectionTimeout(connectionTimeout);
+        setTimeout(timeout);
+        setStatusCacheTimeout(statusCacheTimeout);
+        setAppendBufferSize(appendBufferSize);
+        setConnectionPoolSize(connectionPoolSize);
+        setConnectionPoolTimeout(connectionPoolTimeout);
+        setSeparateStoreConnection(separateStoreConnection);
+        setAllowReadOnlySelect(allowReadOnlySelect);
+        setAuthLoginDisable(authLoginDisable);
+        setAuthPlainDisable(authPlainDisable);
+        setStartTLSEnable(startTLSEnable);
+        setLocaladdress(localaddress);
+        setLocalport(localport);
+        setSaslEnable(saslEnable);
+        setSaslMechanisms(saslMechanisms);
+        setSaslAuthorizationId(saslAuthorizationId);
+        setSocketFactoryClass(socketFactoryClass);
+        setSocketFactoryFallback(socketFactoryFallback);
+        setSocketFactoryPort(socketFactoryPort);
+    }
+
+    /**
+     * Returns the IMAP server port to connect to, if the connect() method
+     * doesn't explicitly specify one.
+     */
+    public Integer getPort() {
+        return port;
+    }
+
+    /**
+     * Sets the IMAP server port to connect to, if the connect() method
+     * doesn't explicitly specify one.
+     * <p/>
+     * Defaults to 143.
+     * <p/>
+     * Values that are set here will override any of the corresponding value
+     * that has been set in the properties.
+     *
+     * @param port the IMAP server port to connect to, if the connect() method
+     *             doesn't explicitly specify one
+     */
+    public void setPort(Integer port) {
+        this.port = port;
+    }
+
+    /**
+     * Returns whether the IMAP partial-fetch capability should be used.
+     * <p/>
+     * Controls whether the IMAP partial-fetch capability should be used.
+     * Defaults to true.
+     */
+    public Boolean getPartialFetch() {
+        return partialFetch;
+    }
+
+    /**
+     * Sets whether the IMAP partial-fetch capability should be used.
+     * <p/>
+     * Controls whether the IMAP partial-fetch capability should be used.
+     * Defaults to true.
+     * <p/>
+     * Values that are set here will override any of the corresponding value
+     * that has been set in the properties.
+     *
+     * @param partialFetch whether the IMAP partial-fetch capability should be used
+     */
+    public void setPartialFetch(Boolean partialFetch) {
+        this.partialFetch = partialFetch;
+    }
+
+    /**
+     * Returns the partial fetch size in bytes.
+     * <p/>
+     * Defaults to 16K.
+     */
+    public Integer getFetchSize() {
+        return fetchSize;
+    }
+
+    /**
+     * Sets the partial fetch size in bytes
+     * <p/>
+     * Defaults to 16K.
+     * <p/>
+     * Values that are set here will override any of the corresponding value
+     * that has been set in the properties.
+     *
+     * @param fetchSize the partial fetch size in bytes
+     */
+    public void setFetchSize(Integer fetchSize) {
+        this.fetchSize = fetchSize;
+    }
+
+    /**
+     * Returns the socket connection timeout value in milliseconds.
+     */
+    public Integer getConnectionTimeout() {
+        return connectionTimeout;
+    }
+
+    /**
+     * Sets the socket connection timeout value in milliseconds.
+     * <p/>
+     * Default is infinite timeout.
+     * <p/>
+     * Values that are set here will override any of the corresponding value
+     * that has been set in the properties.
+     *
+     * @param connectionTimeout the socket connection timeout value in milliseconds.
+     */
+    public void setConnectionTimeout(Integer connectionTimeout) {
+        this.connectionTimeout = connectionTimeout;
+    }
+
+    /**
+     * Returns the socket I/O timeout value in milliseconds.
+     */
+    public Integer getTimeout() {
+        return timeout;
+    }
+
+    /**
+     * Sets the socket I/O timeout value in milliseconds.
+     * <p/>
+     * Default is infinite timeout.
+     * <p/>
+     * Values that are set here will override any of the corresponding value
+     * that has been set in the properties.
+     *
+     * @param timeout the socket I/O timeout value in milliseconds
+     */
+    public void setTimeout(Integer timeout) {
+        this.timeout = timeout;
+    }
+
+    /**
+     * Returns the timeout value in milliseconds for cache of STATUS command response.
+     * <p/>
+     * Timeout value in milliseconds for cache of STATUS command response.
+     * Default is 1000 (1 second). Zero disables cache.
+     */
+    public Integer getStatusCacheTimeout() {
+        return statusCacheTimeout;
+    }
+
+    /**
+     * Sets the timeout value in milliseconds for cache of STATUS command response
+     * <p/>
+     * Timeout value in milliseconds for cache of STATUS command response.
+     * Default is 1000 (1 second). Zero disables cache.
+     * <p/>
+     * Values that are set here will override any of the corresponding value
+     * that has been set in the properties.
+     *
+     * @param statusCacheTimeout the timeout value in milliseconds for cache of STATUS command response
+     */
+    public void setStatusCacheTimeout(Integer statusCacheTimeout) {
+        this.statusCacheTimeout = statusCacheTimeout;
+    }
+
+    /**
+     * Returns the maximum size of a message to buffer in memory when appending
+     * to an IMAP folder.
+     * <p/>
+     * Maximum size of a message to buffer in memory when appending to an IMAP
+     * folder. If not set, or set to -1, there is no maximum and all messages
+     * are buffered. If set to 0, no messages are buffered. If set to (e.g.)
+     * 8192, messages of 8K bytes or less are buffered, larger messages are not
+     * buffered. Buffering saves cpu time at the expense of short term memory
+     * usage. If you commonly append very large messages to IMAP mailboxes you
+     * might want to set this to a moderate value (1M or less).
+     */
+    public Integer getAppendBufferSize() {
+        return appendBufferSize;
+    }
+
+    /**
+     * Sets the maximum size of a message to buffer in memory when appending
+     * to an IMAP folder.
+     * <p/>
+     * Maximum size of a message to buffer in memory when appending to an IMAP
+     * folder. If not set, or set to -1, there is no maximum and all messages
+     * are buffered. If set to 0, no messages are buffered. If set to (e.g.)
+     * 8192, messages of 8K bytes or less are buffered, larger messages are not
+     * buffered. Buffering saves cpu time at the expense of short term memory
+     * usage. If you commonly append very large messages to IMAP mailboxes you
+     * might want to set this to a moderate value (1M or less).
+     * <p/>
+     * Values that are set here will override any of the corresponding value
+     * that has been set in the properties.
+     *
+     * @param appendBufferSize the maximum size of a message to buffer in memory when appending
+     *                         to an IMAP folder
+     */
+    public void setAppendBufferSize(Integer appendBufferSize) {
+        this.appendBufferSize = appendBufferSize;
+    }
+
+    /**
+     * Returns the maximum number of available connections in the connection pool.
+     * <p/>
+     * Default is 1.
+     */
+    public Integer getConnectionPoolSize() {
+        return connectionPoolSize;
+    }
+
+    /**
+     * Sets the maximum number of available connections in the connection pool.
+     * <p/>
+     * Default is 1.
+     * <p/>
+     * Values that are set here will override any of the corresponding value
+     * that has been set in the properties.
+     *
+     * @param connectionPoolSize the maximum number of available connections in the connection pool
+     */
+    public void setConnectionPoolSize(Integer connectionPoolSize) {
+        this.connectionPoolSize = connectionPoolSize;
+    }
+
+    /**
+     * Returns the timeout value in milliseconds for connection pool connections.
+     * <p/>
+     * Default is 45000 (45 seconds).
+     */
+    public Integer getConnectionPoolTimeout() {
+        return connectionPoolTimeout;
+    }
+
+    /**
+     * Sets the timeout value in milliseconds for connection pool connections
+     * <p/>
+     * Default is 45000 (45 seconds).
+     * <p/>
+     * Values that are set here will override any of the corresponding value
+     * that has been set in the properties.
+     *
+     * @param connectionPoolTimeout the timeout value in milliseconds for connection pool connections
+     */
+    public void setConnectionPoolTimeout(Integer connectionPoolTimeout) {
+        this.connectionPoolTimeout = connectionPoolTimeout;
+    }
+
+    /**
+     * Returns the flag to indicate whether to use a dedicated store
+     * connection for store commands.
+     * <p/>
+     * Flag to indicate whether to use a dedicated store connection
+     * for store commands. Default is false.
+     */
+    public Boolean getSeparateStoreConnection() {
+        return separateStoreConnection;
+    }
+
+    /**
+     * Sets the flag to indicate whether to use a dedicated store
+     * connection for store commands
+     * <p/>
+     * Flag to indicate whether to use a dedicated store connection
+     * for store commands. Default is false.
+     * <p/>
+     * Values that are set here will override any of the corresponding value
+     * that has been set in the properties.
+     *
+     * @param separateStoreConnection the flag to indicate whether to use a dedicated store
+     *                                connection for store commands
+     */
+    public void setSeparateStoreConnection(Boolean separateStoreConnection) {
+        this.separateStoreConnection = separateStoreConnection;
+    }
+
+    /**
+     * Returns the flag to indicate whether SELECT commands are read-only.
+     * <p/>
+     * If false, attempts to open a folder read/write will fail if the SELECT
+     * command succeeds but indicates that the folder is READ-ONLY. This
+     * sometimes indicates that the folder contents can'tbe changed, but the
+     * flags are per-user and can be changed, such as might be the case for
+     * public shared folders. If true, such open attempts will succeed, allowing
+     * the flags to be changed. The getMode method on the Folder object will
+     * return Folder.READ_ONLY in this case even though the open method specified
+     * Folder.READ_WRITE. Default is false.
+     */
+    public Boolean getAllowReadOnlySelect() {
+        return allowReadOnlySelect;
+    }
+
+    /**
+     * Sets the flag to indicate whether SELECT commands are read-only.
+     * <p/>
+     * If false, attempts to open a folder read/write will fail if the SELECT
+     * command succeeds but indicates that the folder is READ-ONLY. This
+     * sometimes indicates that the folder contents can'tbe changed, but the
+     * flags are per-user and can be changed, such as might be the case for
+     * public shared folders. If true, such open attempts will succeed, allowing
+     * the flags to be changed. The getMode method on the Folder object will
+     * return Folder.READ_ONLY in this case even though the open method specified
+     * Folder.READ_WRITE. Default is false.
+     * <p/>
+     * Values that are set here will override any of the corresponding value
+     * that has been set in the properties.
+     *
+     * @param allowReadOnlySelect the flag to indicate whether SELECT commands are read-only
+     */
+    public void setAllowReadOnlySelect(Boolean allowReadOnlySelect) {
+        this.allowReadOnlySelect = allowReadOnlySelect;
+    }
+
+    /**
+     * Returns the flag that prevents use of the non-standard AUTHENTICATE LOGIN
+     * command, instead using the plain LOGIN command.
+     * <p/>
+     * Default is false.
+     */
+    public Boolean getAuthLoginDisable() {
+        return authLoginDisable;
+    }
+
+    /**
+     * Sets the flag that prevents use of the non-standard AUTHENTICATE LOGIN
+     * command, instead using the plain LOGIN command.
+     * <p/>
+     * Default is false.
+     * <p/>
+     * Values that are set here will override any of the corresponding value
+     * that has been set in the properties.
+     *
+     * @param authLoginDisable the flag that prevents use of the non-standard AUTHENTICATE LOGIN
+     *                         command, instead using the plain LOGIN command
+     */
+    public void setAuthLoginDisable(Boolean authLoginDisable) {
+        this.authLoginDisable = authLoginDisable;
+    }
+
+    /**
+     * Returns the flag that prevents use of the AUTHENTICATE PLAIN command.
+     * <p/>
+     * Default is false.
+     */
+    public Boolean getAuthPlainDisable() {
+        return authPlainDisable;
+    }
+
+    /**
+     * Sets the flag that prevents use of the AUTHENTICATE PLAIN command.
+     * <p/>
+     * Default is false.
+     * <p/>
+     * Values that are set here will override any of the corresponding value
+     * that has been set in the properties.
+     *
+     * @param authPlainDisable the flag that prevents use of the AUTHENTICATE PLAIN command
+     */
+    public void setAuthPlainDisable(Boolean authPlainDisable) {
+        this.authPlainDisable = authPlainDisable;
+    }
+
+    /**
+     * Returns 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.
+     * <p/>
+     * If true, 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. Note that an appropriate trust store must
+     * configured so that the client will trust the server's certificate.
+     * This feature only works on J2SE 1.4 and newer systems. Default is false.
+     */
+    public Boolean getStartTLSEnable() {
+        return startTLSEnable;
+    }
+
+    /**
+     * Sets 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.
+     * <p/>
+     * If true, 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. Note that an appropriate trust store must
+     * configured so that the client will trust the server's certificate.
+     * This feature only works on J2SE 1.4 and newer systems. Default is false.
+     * <p/>
+     * Values that are set here will override any of the corresponding value
+     * that has been set in the properties.
+     *
+     * @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
+     */
+    public void setStartTLSEnable(Boolean startTLSEnable) {
+        this.startTLSEnable = startTLSEnable;
+    }
+
+    /**
+     * Returns the local address (host name) to bind to when creating the IMAP socket.
+     */
+    public String getLocaladdress() {
+        return localaddress;
+    }
+
+    /**
+     * Sets the local address (host name) to bind to when creating the IMAP socket.
+     * <p/>
+     * Local address (host name) to bind to when creating the IMAP socket.
+     * Defaults to the address picked by the Socket class. Should not normally
+     * need to be set, but useful with multi-homed hosts where it's important
+     * to pick a particular local address to bind to.
+     * <p/>
+     * Values that are set here will override any of the corresponding value
+     * that has been set in the properties.
+     *
+     * @param localaddress the local address (host name) to bind to when creating the IMAP socket
+     */
+    public void setLocaladdress(String localaddress) {
+        this.localaddress = localaddress;
+    }
+
+    /**
+     * Returns the local port number to bind to when creating the IMAP socket.
+     */
+    public Integer getLocalport() {
+        return localport;
+    }
+
+    /**
+     * Sets the local port number to bind to when creating the IMAP socket.
+     * <p/>
+     * Local port number to bind to when creating the IMAP socket. Defaults to
+     * the port number picked by the Socket class.
+     * <p/>
+     * Values that are set here will override any of the corresponding value
+     * that has been set in the properties.
+     *
+     * @param localport the local port number to bind to when creating the IMAP socket
+     */
+    public void setLocalport(Integer localport) {
+        this.localport = localport;
+    }
+
+    /**
+     * Returns the flag that enables an attempt to use the javax.security.sasl
+     * package to choose an authentication mechanism for login.
+     * <p/>
+     * Defaults to false.
+     */
+    public Boolean getSaslEnable() {
+        return saslEnable;
+    }
+
+    /**
+     * Sets the flag that enables an attempt to use the javax.security.sasl
+     * package to choose an authentication mechanism for login.
+     * <p/>
+     * Defaults to false.
+     * <p/>
+     * Values that are set here will override any of the corresponding value
+     * that has been set in the properties.
+     *
+     * @param saslEnable the flag that enables an attempt to use the javax.security.sasl
+     *                   package to choose an authentication mechanism for login
+     */
+    public void setSaslEnable(Boolean saslEnable) {
+        this.saslEnable = saslEnable;
+    }
+
+    /**
+     * Returns a space or comma separated list of SASL mechanism names to try to use.
+     */
+    public String getSaslMechanisms() {
+        return saslMechanisms;
+    }
+
+    /**
+     * Sets a space or comma separated list of SASL mechanism names to try to use.
+     * <p/>
+     * Values that are set here will override any of the corresponding value
+     * that has been set in the properties.
+     *
+     * @param saslMechanisms a space or comma separated list of SASL mechanism names to try to use
+     */
+    public void setSaslMechanisms(String saslMechanisms) {
+        this.saslMechanisms = saslMechanisms;
+    }
+
+    /**
+     * Returns the authorization ID to use in the SASL authentication.
+     * <p/>
+     * If not set, the authetication ID (user name) is used.
+     */
+    public String getSaslAuthorizationId() {
+        return saslAuthorizationId;
+    }
+
+    /**
+     * Sets the authorization ID to use in the SASL authentication.
+     * <p/>
+     * If not set, the authetication ID (user name) is used.
+     * <p/>
+     * Values that are set here will override any of the corresponding value
+     * that has been set in the properties.
+     *
+     * @param saslAuthorizationId the authorization ID to use in the SASL authentication
+     */
+    public void setSaslAuthorizationId(String saslAuthorizationId) {
+        this.saslAuthorizationId = saslAuthorizationId;
+    }
+
+    /**
+     * Returns the class that will be used to create IMAP sockets.
+     * <p/>
+     * If set, specifies the name of a class that implements the
+     * javax.net.SocketFactory interface. This class will be used to create IMAP
+     * sockets.
+     */
+    public String getSocketFactoryClass() {
+        return socketFactoryClass;
+    }
+
+    /**
+     * Sets the class that will be used to create SMTP sockets.
+     * <p/>
+     * If set, specifies the name of a class that implements the
+     * javax.net.SocketFactory interface. This class will be used to create SMTP
+     * sockets.
+     * <p/>
+     * Values that are set here will override any of the corresponding value
+     * that has been set in the properties.
+     *
+     * @param socketFactoryClass the class that will be used to create SMTP sockets
+     */
+    public void setSocketFactoryClass(String socketFactoryClass) {
+        this.socketFactoryClass = socketFactoryClass;
+    }
+
+    /**
+     * Returns whether java.net.Socket class will be created if the specified
+     * socket factory class cannot be created.
+     * <p/>
+     * If set to true, failure to create a socket using the specified socket
+     * factory class will cause the socket to be created using the
+     * java.net.Socket class. Defaults to true.
+     */
+    public Boolean getSocketFactoryFallback() {
+        return socketFactoryFallback;
+    }
+
+    /**
+     * Sets whether java.net.Socket class will be created if the specified
+     * socket factory class cannot be created.
+     * <p/>
+     * If set to true, failure to create a socket using the specified socket
+     * factory class will cause the socket to be created using the
+     * java.net.Socket class. Defaults to true.
+     * <p/>
+     * Values that are set here will override any of the corresponding value
+     * that has been set in the properties.
+     *
+     * @param socketFactoryFallback whether java.net.Socket class will be created if the specified
+     *                              socket factory class cannot be created
+     */
+    public void setSocketFactoryFallback(Boolean socketFactoryFallback) {
+        this.socketFactoryFallback = socketFactoryFallback;
+    }
+
+    /**
+     * Returns the port to connect to when using the specified socket factory.
+     * <p/>
+     * Specifies the port to connect to when using the specified socket
+     * factory. If not set, the default port will be used.
+     */
+    public Integer getSocketFactoryPort() {
+        return socketFactoryPort;
+    }
+
+    /**
+     * Sets the port to connect to when using the specified socket factory.
+     * <p/>
+     * Specifies the port to connect to when using the specified socket
+     * factory. If not set, the default port will be used.
+     * <p/>
+     * Values that are set here will override any of the corresponding value
+     * that has been set in the properties.
+     *
+     * @param socketFactoryPort the port to connect to when using the specified socket factory
+     */
+    public void setSocketFactoryPort(Integer socketFactoryPort) {
+        this.socketFactoryPort = socketFactoryPort;
+    }
+
+    /**
+     * Add the overrides from the member variables to the properties file.
+     */
+    public void addOverrides(Properties props) {
+        super.addOverrides(props);
+
+        if (port != null) props.put("mail.imap.port", port);
+        if (partialFetch != null) props.put("mail.imap.partialfetch", partialFetch);
+        if (fetchSize != null) props.put("mail.imap.fetchsize", fetchSize);
+        if (connectionTimeout != null) props.put("mail.imap.connectiontimeout", connectionTimeout);
+        if (timeout != null) props.put("mail.imap.timeout", timeout);
+        if (statusCacheTimeout != null) props.put("mail.imap.statuscachetimeout", statusCacheTimeout);
+        if (appendBufferSize != null) props.put("mail.imap.appendbuffersize", appendBufferSize);
+        if (connectionPoolSize != null) props.put("mail.imap.connectionpoolsize", connectionPoolSize);
+        if (connectionPoolTimeout != null) props.put("mail.imap.connectionpooltimeout", connectionPoolTimeout);
+        if (separateStoreConnection != null) props.put("mail.imap.separatestoreconnection", separateStoreConnection);
+        if (allowReadOnlySelect != null) props.put("mail.imap.allowreadonlyselect", allowReadOnlySelect);
+        if (authLoginDisable != null) props.put("mail.imap.auth.login.disable", authLoginDisable);
+        if (authPlainDisable != null) props.put("mail.imap.auth.plain.disable", authPlainDisable);
+        if (startTLSEnable != null) props.put("mail.imap.auth.starttls.enable", startTLSEnable);
+        if (localaddress != null) props.put("mail.imap.localaddress", localaddress);
+        if (localport != null) props.put("mail.imap.localport", localport);
+        if (saslEnable != null) props.put("mail.imap.sasl.enable", saslEnable);
+        if (saslMechanisms != null) props.put("mail.imap.sasl.mechanisms", saslMechanisms);
+        if (saslAuthorizationId != null) props.put("mail.imap.sasl.authorizationid", saslAuthorizationId);
+        if (socketFactoryClass != null) props.put("mail.imap.socketFactory.class", socketFactoryClass);
+        if (socketFactoryFallback != null) props.put("mail.imap.socketFactory.fallback", socketFactoryFallback);
+        if (socketFactoryPort != null) props.put("mail.imap.socketFactory.port", socketFactoryPort);
+    }
+
+    public void doStart() throws WaitingException, Exception {
+        log.info("Started " + getObjectName());
+    }
+
+    public void doStop() throws WaitingException, Exception {
+        log.info("Stopped " + getObjectName());
+    }
+
+    public void doFail() {
+        log.info("Failed " + getObjectName());
+    }
+
+    public static final GBeanInfo GBEAN_INFO;
+
+    static {
+        GBeanInfoBuilder infoFactory = new GBeanInfoBuilder(IMAPStoreGBean.class, ProtocolGBean.GBEAN_INFO);
+
+        infoFactory.addAttribute(new GAttributeInfo("port", Integer.class.getName(), true, "getPort", "setPort"));
+        infoFactory.addAttribute(new GAttributeInfo("partialFetch", Boolean.class.getName(), true, "getPartialFetch", "setPartialFetch"));
+        infoFactory.addAttribute(new GAttributeInfo("fetchSize", Integer.class.getName(), true, "getFetchSize", "setFetchSize"));
+        infoFactory.addAttribute(new GAttributeInfo("connectionTimeout", Integer.class.getName(), true, "getConnectionTimeout", "setConnectionTimeout"));
+        infoFactory.addAttribute(new GAttributeInfo("timeout", Integer.class.getName(), true, "getTimeout", "setTimeout"));
+        infoFactory.addAttribute(new GAttributeInfo("statusCacheTimeout", Integer.class.getName(), true, "getStatusCacheTimeout", "setStatusCacheTimeout"));
+        infoFactory.addAttribute(new GAttributeInfo("appendBufferSize", Integer.class.getName(), true, "getAppendBufferSize", "setAppendBufferSize"));
+        infoFactory.addAttribute(new GAttributeInfo("connectionPoolSize", Integer.class.getName(), true, "getConnectionPoolSize", "setConnectionPoolSize"));
+        infoFactory.addAttribute(new GAttributeInfo("connectionPoolTimeout", Integer.class.getName(), true, "getConnectionPoolTimeout", "setConnectionPoolTimeout"));
+        infoFactory.addAttribute(new GAttributeInfo("separateStoreConnection", Boolean.class.getName(), true, "getSeparateStoreConnection", "setSeparateStoreConnection"));
+        infoFactory.addAttribute(new GAttributeInfo("allowReadOnlySelect", Boolean.class.getName(), true, "getAllowReadOnlySelect", "setAllowReadOnlySelect"));
+        infoFactory.addAttribute(new GAttributeInfo("authLoginDisable", Boolean.class.getName(), true, "getAuthLoginDisable", "setAuthLoginDisable"));
+        infoFactory.addAttribute(new GAttributeInfo("authPlainDisable", Boolean.class.getName(), true, "getAuthPlainDisable", "setAuthPlainDisable"));
+        infoFactory.addAttribute(new GAttributeInfo("startTLSEnable", Boolean.class.getName(), true, "getStartTLSEnable", "setStartTLSEnable"));
+        infoFactory.addAttribute(new GAttributeInfo("localaddress", String.class.getName(), true, "getLocaladdress", "setLocaladdress"));
+        infoFactory.addAttribute(new GAttributeInfo("localport", Integer.class.getName(), true, "getLocalport", "setLocalport"));
+        infoFactory.addAttribute(new GAttributeInfo("saslEnable", Boolean.class.getName(), true, "getSaslEnable", "setSaslEnable"));
+        infoFactory.addAttribute(new GAttributeInfo("saslMechanisms", String.class.getName(), true, "getSaslMechanisms", "setSaslMechanisms"));
+        infoFactory.addAttribute(new GAttributeInfo("saslAuthorizationId", String.class.getName(), true, "getSaslAuthorizationId", "setSaslAuthorizationId"));
+        infoFactory.addAttribute(new GAttributeInfo("socketFactoryClass", String.class.getName(), true, "getSocketFactoryClass", "setSocketFactoryClass"));
+        infoFactory.addAttribute(new GAttributeInfo("socketFactoryFallback", Boolean.class.getName(), true, "getSocketFactoryFallback", "setSocketFactoryFallback"));
+        infoFactory.addAttribute(new GAttributeInfo("socketFactoryPort", Integer.class.getName(), true, "getSocketFactoryPort", "setSocketFactoryPort"));
+
+        infoFactory.setConstructor(new String[]{"objectName", "properties", "host", "user",
+                                                "port",
+                                                "partialFetch",
+                                                "fetchSize",
+                                                "connectionTimeout",
+                                                "timeout",
+                                                "statusCacheTimeout",
+                                                "appendBufferSize",
+                                                "connectionPoolSize",
+                                                "connectionPoolTimeout",
+                                                "separateStoreConnection",
+                                                "allowReadOnlySelect",
+                                                "authLoginDisable",
+                                                "authPlainDisable",
+                                                "startTLSEnable",
+                                                "localaddress",
+                                                "localport",
+                                                "saslEnable",
+                                                "saslMechanisms",
+                                                "saslAuthorizationId",
+                                                "socketFactoryClass",
+                                                "socketFactoryFallback",
+                                                "socketFactoryPort"});
+
+        GBEAN_INFO = infoFactory.getBeanInfo();
+    }
+
+    public static GBeanInfo getGBeanInfo() {
+        return GBEAN_INFO;
+    }
+}

Modified: geronimo/trunk/modules/mail/src/java/org/apache/geronimo/mail/MailGBean.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/mail/src/java/org/apache/geronimo/mail/MailGBean.java?view=diff&rev=123792&p1=geronimo/trunk/modules/mail/src/java/org/apache/geronimo/mail/MailGBean.java&r1=123791&p2=geronimo/trunk/modules/mail/src/java/org/apache/geronimo/mail/MailGBean.java&r2=123792
==============================================================================
--- geronimo/trunk/modules/mail/src/java/org/apache/geronimo/mail/MailGBean.java	(original)
+++ geronimo/trunk/modules/mail/src/java/org/apache/geronimo/mail/MailGBean.java	Fri Dec 31 05:58:12 2004
@@ -18,11 +18,14 @@
 
 import javax.mail.Authenticator;
 import javax.mail.Session;
+import java.util.Collection;
+import java.util.Iterator;
 import java.util.Properties;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
+import org.apache.geronimo.gbean.GAttributeInfo;
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.gbean.GBeanLifecycle;
@@ -31,72 +34,316 @@
 
 /**
  * GBean that provides access to JavaMail Sessions.
+ * <p/>
+ * This GBean is used to generate JavaMail Sessions.  JavaMail properties that
+ * are common to all JavaMail Sessions are provided via member variables of this
+ * class.
  *
  * @version $Rev: $ $Date: $
+ * @see ProtocolGBean
+ * @see SMTPTransportGBean
+ * @see POP3StoreGBean
+ * @see IMAPStoreGBean
  */
 public class MailGBean implements GBeanLifecycle {
 
     private final Log log = LogFactory.getLog(MailGBean.class);
 
-    private boolean useDefault = false;
-    private Properties properties = new Properties();
+    private final String objectName;
+    private final Collection protocols;
+    private Boolean useDefault;
+    private Properties properties;
     private Authenticator authenticator;
+    private String storeProtocol;
+    private String transportProtocol;
+    private String host;
+    private String user;
+    private Boolean debug;
+
+
+    /**
+     * Construct an instance of MailGBean
+     * <p/>
+     * Values that are set in the individual member variables will override any of
+     * the corresponding values that have been set in the properties set.
+     *
+     * @param protocols         the set of protocol GBeans that contain protocol specific configurations
+     * @param useDefault        whether this GBean will return default Sessions or not
+     * @param properties        the set of default properties for the protocols
+     * @param authenticator     the authenticator object
+     * @param storeProtocol     the store protocol that Sessions created from this GBean will return
+     * @param transportProtocol the transport protocol that Sessions created from this GBean will return
+     * @param host              the default Mail server
+     * @param user              the username to provide when connecting to a Mail server
+     * @param debug             the debug setting for Sessions created from this GBean
+     */
+    public MailGBean(String objectName, Collection protocols, Boolean useDefault, Properties properties, Authenticator authenticator,
+                     String storeProtocol, String transportProtocol, String host, String user, Boolean debug) {
+        this.objectName = objectName;
+        this.protocols = protocols;
+        setUseDefault(useDefault);
+        this.properties = (properties == null ? new Properties() : properties);
+        setAuthenticator(authenticator);
+        setStoreProtocol(storeProtocol);
+        setTransportProtocol(transportProtocol);
+        setHost(host);
+        setUser(user);
+        setDebug(debug);
 
+    }
+
+    /**
+     * Returns the GBean name of this Mail GBean
+     */
+    public String getObjectName() {
+        return objectName;
+    }
+
+    /**
+     * Returns the set of protocol GBeans that contain protocol specific configurations.
+     */
+    public Collection getProtocols() {
+        return protocols;
+    }
 
-    public boolean getUseDefault() {
+    /**
+     * Returns whether this GBean will return default Sessions or not.
+     */
+    public Boolean getUseDefault() {
         return useDefault;
     }
 
-    public void setUseDefault(boolean useDefault) {
+    /**
+     * Sets whether this GBean will return default Sessions or not,
+     *
+     * @param useDefault whether this GBean will return default Sessions or not
+     */
+    public void setUseDefault(Boolean useDefault) {
         this.useDefault = useDefault;
     }
 
+    /**
+     * Returns the set of default properties for the protocols.
+     * <p/>
+     * Note: Proerties that are set here will override the properties that are
+     * set in the protocol GBeans.
+     */
     public Properties getProperties() {
         return properties;
     }
 
+    /**
+     * Sets the set of default properties for the protocols.
+     * <p/>
+     * Note: Proerties that are set here will override the properties that are
+     * set in the protocol GBeans.
+     *
+     * @param properties the set of default properties for the protocols
+     */
     public void setProperties(Properties properties) {
         this.properties = properties;
     }
 
+    /**
+     * Returns the authenticator object.
+     * <p/>
+     * Used only if a new Session object is created. Otherwise, it must match
+     * the Authenticator used to create the Session.
+     */
     public Authenticator getAuthenticator() {
         return authenticator;
     }
 
+    /**
+     * Sets the authenticator object.
+     * <p/>
+     * Used only if a new Session object is created. Otherwise, it must match
+     * the Authenticator used to create the Session.
+     *
+     * @param authenticator the authenticator object
+     */
     public void setAuthenticator(Authenticator authenticator) {
         this.authenticator = authenticator;
     }
 
+    /**
+     * Returns the store protocol that Sessions created from this GBean will return.
+     * <p/>
+     * Specifies the default Message Access Protocol. The Session.getStore()
+     * method returns a Store object that implements this protocol. The client
+     * can override this property and explicitly specify the protocol with the
+     * Session.getStore(String protocol) method.
+     */
+    public String getStoreProtocol() {
+        return storeProtocol;
+    }
+
+    /**
+     * Sets the store protocol that Sessions created from this GBean will return.
+     * <p/>
+     * Specifies the default Message Access Protocol. The Session.getStore()
+     * method returns a Store object that implements this protocol. The client
+     * can override this property and explicitly specify the protocol with the
+     * Session.getStore(String protocol) method.
+     * <p/>
+     * Values that are set here will override any of the corresponding value
+     * that has been set in the properties.
+     *
+     * @param storeProtocol the store protocol that Sessions created from this GBean will return
+     */
+    public void setStoreProtocol(String storeProtocol) {
+        this.storeProtocol = storeProtocol;
+    }
+
+    /**
+     * Returns the transport protocol that Sessions created from this GBean will return.
+     * <p/>
+     * Specifies the default Transport Protocol. The Session.getTransport()
+     * method returns a Transport object that implements this protocol. The
+     * client can override this property and explicitly specify the protocol
+     * by using Session.getTransport(String protocol) method.
+     */
+    public String getTransportProtocol() {
+        return transportProtocol;
+    }
+
+    /**
+     * Sets the transport protocol that Sessions created from this GBean will return.
+     * <p/>
+     * Specifies the default Transport Protocol. The Session.getTransport()
+     * method returns a Transport object that implements this protocol. The
+     * client can override this property and explicitly specify the protocol
+     * by using Session.getTransport(String protocol) method.
+     * <p/>
+     * Values that are set here will override any of the corresponding value
+     * that has been set in the properties.
+     *
+     * @param transportProtocol the transport protocol that Sessions created from this GBean will return
+     */
+    public void setTransportProtocol(String transportProtocol) {
+        this.transportProtocol = transportProtocol;
+    }
+
+    /**
+     * Returns the default Mail server.
+     * <p/>
+     * Specifies the default Mail server. The Store and Transport object’s
+     * connect methods use this property, if the protocolspecific host property
+     * is absent, to locate the target host.
+     */
+    public String getHost() {
+        return host;
+    }
+
+    /**
+     * Sets the default Mail server.
+     * <p/>
+     * Specifies the default Mail server. The Store and Transport object’s
+     * connect methods use this property, if the protocolspecific host property
+     * is absent, to locate the target host.
+     * <p/>
+     * Values that are set here will override any of the corresponding value
+     * that has been set in the properties.
+     *
+     * @param host the default Mail server
+     */
+    public void setHost(String host) {
+        this.host = host;
+    }
+
+    /**
+     * Returns the username to provide when connecting to a Mail server.
+     * <p/>
+     * Specifies the username to provide when connecting to a Mail server. The
+     * Store and Transport object’s connect methods use this property, if the
+     * protocolspecific username property is absent, to obtain the username.
+     */
+    public String getUser() {
+        return user;
+    }
+
+    /**
+     * Sets the username to provide when connecting to a Mail server.
+     * <p/>
+     * Specifies the username to provide when connecting to a Mail server. The
+     * Store and Transport object’s connect methods use this property, if the
+     * protocolspecific username property is absent, to obtain the username.
+     * <p/>
+     * Values that are set here will override any of the corresponding value
+     * that has been set in the properties.
+     *
+     * @param user the username to provide when connecting to a Mail server
+     */
+    public void setUser(String user) {
+        this.user = user;
+    }
+
+    /**
+     * Returns the debug setting for Sessions created from this GBean.
+     */
+    public Boolean isDebug() {
+        return debug;
+    }
+
+    /**
+     * Sets the debug setting for Sessions created from this GBean.
+     * <p/>
+     * Values that are set here will override any of the corresponding value
+     * that has been set in the properties.
+     *
+     * @param debug the debug setting for Sessions created from this GBean
+     */
+    public void setDebug(Boolean debug) {
+        this.debug = debug;
+    }
+
     public Object $getResource() {
-        if (useDefault) {
+        Properties props = new Properties(properties);
+
+        if (protocols != null) {
+            for (Iterator iter = protocols.iterator(); iter.hasNext();) {
+                ProtocolGBean protocol = (ProtocolGBean) iter.next();
+                protocol.addOverrides(props);
+            }
+        }
+
+        props.putAll(properties);
+
+        if (storeProtocol != null) props.put("mail.store.protocol", storeProtocol);
+        if (transportProtocol != null) props.put("mail.transport.protocol", transportProtocol);
+        if (host != null) props.put("mail.host", host);
+        if (user != null) props.put("mail.user", user);
+        if (debug != null) props.put("mail.debug", debug);
+
+        if (Boolean.TRUE.equals(useDefault)) {
             if (authenticator == null) {
-                return Session.getDefaultInstance(properties);
+                return Session.getDefaultInstance(props);
             } else {
-                return Session.getDefaultInstance(properties, authenticator);
+                return Session.getDefaultInstance(props, authenticator);
             }
         } else {
             if (authenticator == null) {
-                return Session.getInstance(properties);
+                return Session.getInstance(props);
             } else {
-                return Session.getInstance(properties, authenticator);
+                return Session.getInstance(props, authenticator);
             }
         }
     }
 
     public void doStart() throws WaitingException, Exception {
-        log.info("Started - will return "
-                 + (useDefault ? "default" : "new")
-                 + " instance "
+        log.info("Started " + objectName + " - will return "
+                 + (Boolean.TRUE.equals(useDefault) ? "default" : "new")
+                 + " JavaMail Session "
                  + (authenticator == null ? "without" : "with")
                  + " authenticator");
     }
 
     public void doStop() throws WaitingException, Exception {
-        log.info("Stopped");
+        log.info("Stopped " + objectName);
     }
 
     public void doFail() {
-        log.info("Failed");
+        log.info("Failed " + objectName);
     }
 
     public static final GBeanInfo GBEAN_INFO;
@@ -104,10 +351,29 @@
     static {
         GBeanInfoBuilder infoFactory = new GBeanInfoBuilder(MailGBean.class);
 
-        infoFactory.addAttribute("useDefault", Boolean.TYPE, true);
-        infoFactory.addAttribute("properties", Properties.class, true);
+        infoFactory.addAttribute(new GAttributeInfo("objectName", String.class.getName(), false, "getObjectName", null));
+        infoFactory.addReference("Protocols", ProtocolGBean.class);
+        infoFactory.addAttribute(new GAttributeInfo("useDefault", Boolean.class.getName(), true, "getUseDefault", "setUseDefault"));
+        infoFactory.addAttribute(new GAttributeInfo("properties", Properties.class.getName(), true, "getProperties", "setProperties"));
         infoFactory.addReference("Authenticator", Authenticator.class);
+        infoFactory.addAttribute(new GAttributeInfo("storeProtocol", String.class.getName(), true, "getStoreProtocol", "setStoreProtocol"));
+        infoFactory.addAttribute(new GAttributeInfo("transportProtocol", String.class.getName(), true, "getTransportProtocol", "setTransportProtocol"));
+        infoFactory.addAttribute(new GAttributeInfo("host", String.class.getName(), true, "getHost", "setHost"));
+        infoFactory.addAttribute(new GAttributeInfo("user", String.class.getName(), true, "getUser", "setUser"));
+        infoFactory.addAttribute(new GAttributeInfo("debug", Boolean.class.getName(), true, "isDebug", "setDebug"));
         infoFactory.addOperation("$getResource");
+        infoFactory.addOperation("getProtocols");
+
+        infoFactory.setConstructor(new String[]{"objectName",
+                                                "Protocols",
+                                                "useDefault",
+                                                "properties",
+                                                "Authenticator",
+                                                "storeProtocol",
+                                                "transportProtocol",
+                                                "host",
+                                                "user",
+                                                "debug"});
 
         GBEAN_INFO = infoFactory.getBeanInfo();
     }

Added: geronimo/trunk/modules/mail/src/java/org/apache/geronimo/mail/POP3StoreGBean.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/mail/src/java/org/apache/geronimo/mail/POP3StoreGBean.java?view=auto&rev=123792
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/mail/src/java/org/apache/geronimo/mail/POP3StoreGBean.java	Fri Dec 31 05:58:12 2004
@@ -0,0 +1,464 @@
+/**
+ *
+ * Copyright 2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.mail;
+
+import java.util.Properties;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.geronimo.gbean.GAttributeInfo;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.gbean.WaitingException;
+
+
+/**
+ * A GBean that provides for the configuration of a JavaMail POP3 message store
+ * protocol.
+ * <p/>
+ * POP3 store properties that are common to all POP3 stores are
+ * provided via member variables of this class.  Values that are set in the
+ * individual member variables will override any of the corresponding values
+ * that have been set in the properties set.
+ *
+ * @version $Rev: $ $Date: $
+ * @see MailGBean
+ */
+public class POP3StoreGBean extends ProtocolGBean {
+
+    private final Log log = LogFactory.getLog(POP3StoreGBean.class);
+
+    private Integer port;
+    private Integer connectionTimeout;
+    private Integer timeout;
+    private Boolean rsetBeforeQuit;
+    private String messageClass;
+    private String localaddress;
+    private Integer localport;
+    private Boolean apopEnable;
+    private String socketFactoryClass;
+    private Boolean socketFactoryFallback;
+    private Integer socketFactoryPort;
+
+
+    /**
+     * Construct an instance of POP3StoreGBean
+     * <p/>
+     * Values that are set in the individual member variables will override any of
+     * the corresponding values that have been set in the properties set.
+     *
+     * @param objectName            the object name of the protocol
+     * @param properties            the set of default properties for the protocol
+     * @param host                  the host the protocol connects to
+     * @param user                  the default name for the protocol
+     * @param port                  the POP3 server port
+     * @param connectionTimeout     the socket connection timeout value in milliseconds
+     * @param timeout               the socket I/O timeout value in milliseconds
+     * @param rsetBeforeQuit        whether an attempt will be made send a POP3 RSET command when closing
+     *                              the folder, before sending the QUIT command
+     * @param messageClass          the class name of a subclass of com.sun.mail.pop3.POP3Message
+     * @param localaddress          the local address (host name) to bind to when creating the POP3 socket
+     * @param localport             the local port number to bind to when creating the POP3 socket
+     * @param apopEnable            whether to use APOP instead of USER/PASS to login to the POP3 server,
+     *                              if the POP3 server supports APOP
+     * @param socketFactoryClass    the class that will be used to create POP3 sockets
+     * @param socketFactoryFallback whether java.net.Socket class will be created if the specified
+     *                              socket factory class cannot be created
+     * @param socketFactoryPort     whether java.net.Socket class will be created if the specified
+     *                              socket factory class cannot be created
+     */
+    public POP3StoreGBean(String objectName, Properties properties, String host, String user,
+                          Integer port,
+                          Integer connectionTimeout,
+                          Integer timeout,
+                          Boolean rsetBeforeQuit,
+                          String messageClass,
+                          String localaddress,
+                          Integer localport,
+                          Boolean apopEnable,
+                          String socketFactoryClass,
+                          Boolean socketFactoryFallback,
+                          Integer socketFactoryPort) {
+        super(objectName, "pop3", properties, host, user);
+
+        setPort(port);
+        setConnectionTimeout(connectionTimeout);
+        setTimeout(timeout);
+        setRsetBeforeQuit(rsetBeforeQuit);
+        setMessageClass(messageClass);
+        setLocaladdress(localaddress);
+        setLocalport(localport);
+        setApopEnable(apopEnable);
+        setSocketFactoryClass(socketFactoryClass);
+        setSocketFactoryFallback(socketFactoryFallback);
+        setSocketFactoryPort(socketFactoryPort);
+    }
+
+    /**
+     * Returns the POP3 server port to connect to, if the connect() method
+     * doesn't explicitly specify one.
+     * <p/>
+     * Defaults to 110.
+     */
+    public Integer getPort() {
+        return port;
+    }
+
+    /**
+     * Sets the POP3 server port to connect to, if the connect() method
+     * doesn't explicitly specify one.
+     * <p/>
+     * Defaults to 110.
+     * <p/>
+     * Values that are set here will override any of the corresponding value
+     * that has been set in the properties.
+     *
+     * @param port the POP3 server port to connect to, if the connect() method
+     *             doesn't explicitly specify one
+     */
+    public void setPort(Integer port) {
+        this.port = port;
+    }
+
+    /**
+     * Returns the socket connection timeout value in milliseconds.
+     */
+    public Integer getConnectionTimeout() {
+        return connectionTimeout;
+    }
+
+    /**
+     * Sets the socket connection timeout value in milliseconds.
+     * <p/>
+     * Default is infinite timeout.
+     * <p/>
+     * Values that are set here will override any of the corresponding value
+     * that has been set in the properties.
+     *
+     * @param connectionTimeout the socket connection timeout value in milliseconds.
+     */
+    public void setConnectionTimeout(Integer connectionTimeout) {
+        this.connectionTimeout = connectionTimeout;
+    }
+
+    /**
+     * Returns the socket I/O timeout value in milliseconds.
+     */
+    public Integer getTimeout() {
+        return timeout;
+    }
+
+    /**
+     * Sets the socket I/O timeout value in milliseconds.
+     * <p/>
+     * Default is infinite timeout.
+     * <p/>
+     * Values that are set here will override any of the corresponding value
+     * that has been set in the properties.
+     *
+     * @param timeout the socket I/O timeout value in milliseconds
+     */
+    public void setTimeout(Integer timeout) {
+        this.timeout = timeout;
+    }
+
+    /**
+     * Returns whether an attempt will be made send a POP3 RSET command when
+     * closing the folder, before sending the QUIT command.
+     * <p/>
+     * Send a POP3 RSET command when closing the folder, before sending the
+     * QUIT command. Useful with POP3 servers that implicitly mark all
+     * messages that are read as "deleted"; this will prevent such messages
+     * from being deleted and expunged unless the client requests so. Default
+     * is false.
+     */
+    public Boolean getRsetBeforeQuit() {
+        return rsetBeforeQuit;
+    }
+
+    /**
+     * Sets whether an attempt will be made send a POP3 RSET command when
+     * closing the folder, before sending the QUIT command.
+     * <p/>
+     * Send a POP3 RSET command when closing the folder, before sending the
+     * QUIT command. Useful with POP3 servers that implicitly mark all messages
+     * that are read as "deleted"; this will prevent such messages from being
+     * deleted and expunged unless the client requests so. Default is false.
+     * <p/>
+     * Values that are set here will override any of the corresponding value
+     * that has been set in the properties.
+     *
+     * @param rsetBeforeQuit whether an attempt will be made send a POP3 RSET command when
+     *                       closing the folder, before sending the QUIT command
+     */
+    public void setRsetBeforeQuit(Boolean rsetBeforeQuit) {
+        this.rsetBeforeQuit = rsetBeforeQuit;
+    }
+
+    /**
+     * Returns the class name of a subclass of com.sun.mail.pop3.POP3Message.
+     * <p/>
+     * Class name of a subclass of com.sun.mail.pop3.POP3Message. The subclass
+     * can be used to handle (for example) non-standard Content-Type headers.
+     * The subclass must have a public constructor of the form
+     * MyPOP3Message(Folder f, int msgno) throws MessagingException.
+     */
+    public String getMessageClass() {
+        return messageClass;
+    }
+
+    /**
+     * Sets the class name of a subclass of com.sun.mail.pop3.POP3Message.
+     * <p/>
+     * Class name of a subclass of com.sun.mail.pop3.POP3Message. The subclass
+     * can be used to handle (for example) non-standard Content-Type headers.
+     * The subclass must have a public constructor of the form
+     * MyPOP3Message(Folder f, int msgno) throws MessagingException.
+     * <p/>
+     * Values that are set here will override any of the corresponding value
+     * that has been set in the properties.
+     *
+     * @param messageClass the class name of a subclass of com.sun.mail.pop3.POP3Message.
+     */
+    public void setMessageClass(String messageClass) {
+        this.messageClass = messageClass;
+    }
+
+    /**
+     * Returns the local address (host name) to bind to when creating the POP3 socket.
+     */
+    public String getLocaladdress() {
+        return localaddress;
+    }
+
+    /**
+     * Sets the local address (host name) to bind to when creating the POP3 socket.
+     * <p/>
+     * Local address (host name) to bind to when creating the POP3 socket.
+     * Defaults to the address picked by the Socket class. Should not normally
+     * need to be set, but useful with multi-homed hosts where it's important
+     * to pick a particular local address to bind to.
+     * <p/>
+     * Values that are set here will override any of the corresponding value
+     * that has been set in the properties.
+     *
+     * @param localaddress the local address (host name) to bind to when creating the POP3 socket
+     */
+    public void setLocaladdress(String localaddress) {
+        this.localaddress = localaddress;
+    }
+
+    /**
+     * Returns the local port number to bind to when creating the POP3 socket.
+     */
+    public Integer getLocalport() {
+        return localport;
+    }
+
+    /**
+     * Sets the local port number to bind to when creating the POP3 socket.
+     * <p/>
+     * Local port number to bind to when creating the POP3 socket. Defaults to
+     * the port number picked by the Socket class.
+     * <p/>
+     * Values that are set here will override any of the corresponding value
+     * that has been set in the properties.
+     *
+     * @param localport the local port number to bind to when creating the POP3 socket
+     */
+    public void setLocalport(Integer localport) {
+        this.localport = localport;
+    }
+
+    /**
+     * Returns whether to use APOP instead of USER/PASS to login to the POP3
+     * server, if the POP3 server supports APOP.
+     * <p/>
+     * If set to true, use APOP instead of USER/PASS to login to the POP3
+     * server, if the POP3 server supports APOP. APOP sends a digest of the
+     * password rather than the clear text password. Defaults to false.
+     */
+    public Boolean isApopEnable() {
+        return apopEnable;
+    }
+
+    /**
+     * Sets whether to use APOP instead of USER/PASS to login to the POP3
+     * server, if the POP3 server supports APOP.
+     * <p/>
+     * If set to true, use APOP instead of USER/PASS to login to the POP3
+     * server, if the POP3 server supports APOP. APOP sends a digest of the
+     * password rather than the clear text password. Defaults to false.
+     *
+     * @param apopEnable whether to use APOP instead of USER/PASS to login to the POP3
+     *                   server, if the POP3 server supports APOP
+     */
+    public void setApopEnable(Boolean apopEnable) {
+        this.apopEnable = apopEnable;
+    }
+
+    /**
+     * Returns the class that will be used to create POP3 sockets.
+     * <p/>
+     * If set, specifies the name of a class that implements the
+     * javax.net.SocketFactory interface. This class will be used to create POP3
+     * sockets.
+     */
+    public String getSocketFactoryClass() {
+        return socketFactoryClass;
+    }
+
+    /**
+     * Sets the class that will be used to create POP3 sockets.
+     * <p/>
+     * If set, specifies the name of a class that implements the
+     * javax.net.SocketFactory interface. This class will be used to create POP3
+     * sockets.
+     * <p/>
+     * Values that are set here will override any of the corresponding value
+     * that has been set in the properties.
+     *
+     * @param socketFactoryClass the class that will be used to create POP3 sockets
+     */
+    public void setSocketFactoryClass(String socketFactoryClass) {
+        this.socketFactoryClass = socketFactoryClass;
+    }
+
+    /**
+     * Returns whether java.net.Socket class will be created if the specified
+     * socket factory class cannot be created.
+     * <p/>
+     * If set to true, failure to create a socket using the specified socket
+     * factory class will cause the socket to be created using the
+     * java.net.Socket class. Defaults to true.
+     */
+    public Boolean isSocketFactoryFallback() {
+        return socketFactoryFallback;
+    }
+
+    /**
+     * Sets whether java.net.Socket class will be created if the specified
+     * socket factory class cannot be created.
+     * <p/>
+     * If set to true, failure to create a socket using the specified socket
+     * factory class will cause the socket to be created using the
+     * java.net.Socket class. Defaults to true.
+     * <p/>
+     * Values that are set here will override any of the corresponding value
+     * that has been set in the properties.
+     *
+     * @param socketFactoryFallback whether java.net.Socket class will be created if the specified
+     *                              socket factory class cannot be created
+     */
+    public void setSocketFactoryFallback(Boolean socketFactoryFallback) {
+        this.socketFactoryFallback = socketFactoryFallback;
+    }
+
+    /**
+     * Returns the port to connect to when using the specified socket factory.
+     * <p/>
+     * Specifies the port to connect to when using the specified socket
+     * factory. If not set, the default port will be used.
+     */
+    public Integer getSocketFactoryPort() {
+        return socketFactoryPort;
+    }
+
+    /**
+     * Sets the port to connect to when using the specified socket factory.
+     * <p/>
+     * Specifies the port to connect to when using the specified socket
+     * factory. If not set, the default port will be used.
+     * <p/>
+     * Values that are set here will override any of the corresponding value
+     * that has been set in the properties.
+     *
+     * @param socketFactoryPort the port to connect to when using the specified socket factory
+     */
+    public void setSocketFactoryPort(Integer socketFactoryPort) {
+        this.socketFactoryPort = socketFactoryPort;
+    }
+
+    /**
+     * Add the overrides from the member variables to the properties file.
+     */
+    public void addOverrides(Properties props) {
+        super.addOverrides(props);
+
+        if (port != null) props.put("mail.pop3.port", port);
+        if (connectionTimeout != null) props.put("mail.pop3.connectiontimeout", connectionTimeout);
+        if (timeout != null) props.put("mail.pop3.timeout", timeout);
+        if (rsetBeforeQuit != null) props.put("mail.pop3.rsetbeforequit", rsetBeforeQuit);
+        if (messageClass != null) props.put("mail.pop3.message.class", messageClass);
+        if (localaddress != null) props.put("mail.pop3.localaddress", localaddress);
+        if (localport != null) props.put("mail.pop3.localport", localport);
+        if (apopEnable != null) props.put("mail.pop3.apop.enable", apopEnable);
+        if (socketFactoryClass != null) props.put("mail.pop3.socketFactory.class", socketFactoryClass);
+        if (socketFactoryFallback != null) props.put("mail.pop3.socketFactory.fallback", socketFactoryFallback);
+        if (socketFactoryPort != null) props.put("mail.pop3.socketFactory.port", socketFactoryPort);
+    }
+
+    public void doStart() throws WaitingException, Exception {
+        log.info("Started " + getObjectName());
+    }
+
+    public void doStop() throws WaitingException, Exception {
+        log.info("Stopped " + getObjectName());
+    }
+
+    public void doFail() {
+        log.info("Failed " + getObjectName());
+    }
+
+    public static final GBeanInfo GBEAN_INFO;
+
+    static {
+        GBeanInfoBuilder infoFactory = new GBeanInfoBuilder(POP3StoreGBean.class, ProtocolGBean.GBEAN_INFO);
+
+        infoFactory.addAttribute(new GAttributeInfo("port", Integer.class.getName(), true, "getPort", "setPort"));
+        infoFactory.addAttribute(new GAttributeInfo("connectionTimeout", Integer.class.getName(), true, "getConnectionTimeout", "setConnectionTimeout"));
+        infoFactory.addAttribute(new GAttributeInfo("timeout", Integer.class.getName(), true, "getTimeout", "setTimeout"));
+        infoFactory.addAttribute(new GAttributeInfo("rsetBeforeQuit", Boolean.class.getName(), true, "getRsetBeforeQuit", "setRsetBeforeQuit"));
+        infoFactory.addAttribute(new GAttributeInfo("messageClass", String.class.getName(), true, "getMessageClass", "setMessageClass"));
+        infoFactory.addAttribute(new GAttributeInfo("localaddress", String.class.getName(), true, "getLocaladdress", "setLocaladdress"));
+        infoFactory.addAttribute(new GAttributeInfo("localport", Integer.class.getName(), true, "getLocalport", "setLocalport"));
+        infoFactory.addAttribute(new GAttributeInfo("apopEnable", Boolean.class.getName(), true, "getApopEnable", "setApopEnable"));
+        infoFactory.addAttribute(new GAttributeInfo("socketFactoryClass", String.class.getName(), true, "getSocketFactoryClass", "setSocketFactoryClass"));
+        infoFactory.addAttribute(new GAttributeInfo("socketFactoryFallback", Boolean.class.getName(), true, "getSocketFactoryFallback", "setSocketFactoryFallback"));
+        infoFactory.addAttribute(new GAttributeInfo("socketFactoryPort", Integer.class.getName(), true, "getSocketFactoryPort", "setSocketFactoryPort"));
+
+        infoFactory.setConstructor(new String[]{"objectName", "properties", "host", "user",
+                                                "port",
+                                                "connectionTimeout",
+                                                "timeout",
+                                                "rsetBeforeQuit",
+                                                "messageClass",
+                                                "localaddress",
+                                                "localport",
+                                                "apopEnable",
+                                                "socketFactoryClass",
+                                                "socketFactoryFallback",
+                                                "socketFactoryPort"});
+
+        GBEAN_INFO = infoFactory.getBeanInfo();
+    }
+
+    public static GBeanInfo getGBeanInfo() {
+        return GBEAN_INFO;
+    }
+}

Added: geronimo/trunk/modules/mail/src/java/org/apache/geronimo/mail/ProtocolGBean.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/mail/src/java/org/apache/geronimo/mail/ProtocolGBean.java?view=auto&rev=123792
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/mail/src/java/org/apache/geronimo/mail/ProtocolGBean.java	Fri Dec 31 05:58:12 2004
@@ -0,0 +1,188 @@
+/**
+ *
+ * Copyright 2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.mail;
+
+import java.util.Properties;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.geronimo.gbean.GAttributeInfo;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.gbean.GBeanLifecycle;
+import org.apache.geronimo.gbean.WaitingException;
+
+
+/**
+ * A generic GBean that provides for the configuration of a JavaMail protocol.
+ * <p/>
+ * Values that are set in the individual member variables will override any of
+ * the corresponding values that have been set in the properties set.
+ *
+ * @version $Rev: $ $Date: $
+ */
+public class ProtocolGBean implements GBeanLifecycle {
+
+    private final Log log = LogFactory.getLog(ProtocolGBean.class);
+
+    private final String objectName;
+    private Properties properties;
+    private final String protocol;
+    private String host;
+    private String user;
+
+    /**
+     * Construct an instance of ProtocolGBean
+     */
+    public ProtocolGBean() {
+        this.objectName = null;
+        this.protocol = null;
+        this.properties = null;
+    }
+
+    /**
+     * Construct an instance of ProtocolGBean
+     * <p/>
+     * Values that are set in the individual member variables will override any of
+     * the corresponding values that have been set in the properties set.
+     *
+     * @param objectName the object name of the protocol
+     * @param protocol   the name of the protocol
+     * @param properties the set of default properties for the protocol
+     * @param host       the host the protocol connects to
+     * @param user       the default name for the protocol
+     */
+    public ProtocolGBean(String objectName, String protocol, Properties properties, String host, String user) {
+        assert protocol != null;
+
+        this.objectName = objectName;
+        this.protocol = protocol;
+        this.properties = (properties == null ? new Properties() : properties);
+        this.host = host;
+        this.user = user;
+    }
+
+    /**
+     * Returns the object name of this protocol GBean
+     */
+    public String getObjectName() {
+        return objectName;
+    }
+
+    /**
+     * Returns the set of default properties for the protocol.
+     * <p/>
+     * Values that are set in the individual member variables will override any of
+     * the corresponding values that have been set in the properties set.
+     */
+    public Properties getProperties() {
+        return properties;
+    }
+
+    /**
+     * Sets the set of default properties for the protocol.
+     * <p/>
+     * Values that are set in the individual member variables will override any of
+     * the corresponding values that have been set in the properties set.
+     *
+     * @param properties set of default properties for the protocol
+     */
+    public void setProperties(Properties properties) {
+        this.properties = properties;
+    }
+
+    /**
+     * Returns the name of the protocol
+     */
+    public String getProtocol() {
+        return protocol;
+    }
+
+    /**
+     * Returns the host the protocol connects to.
+     */
+    public String getHost() {
+        return host;
+    }
+
+    /**
+     * Set the host the protocol connects to.
+     *
+     * @param host the host the protocol connects to
+     */
+    public void setHost(String host) {
+        this.host = host;
+    }
+
+    /**
+     * Returns the default user name for the protocol.
+     */
+    public String getUser() {
+        return user;
+    }
+
+    /**
+     * Sets the default user name for the protocol.
+     *
+     * @param user the default user name for the protocol
+     */
+    public void setUser(String user) {
+        this.user = user;
+    }
+
+    /**
+     * Add the overrides from the member variables to the properties file.
+     */
+    public void addOverrides(Properties props) {
+        if (host != null) props.put("mail." + protocol + ".host", host);
+        if (user != null) props.put("mail." + protocol + ".user", user);
+    }
+
+    public void doStart() throws WaitingException, Exception {
+        log.info("Started " + objectName);
+    }
+
+    public void doStop() throws WaitingException, Exception {
+        log.info("Stopped " + objectName);
+    }
+
+    public void doFail() {
+        log.info("Failed " + objectName);
+    }
+
+    public static final GBeanInfo GBEAN_INFO;
+
+    static {
+        GBeanInfoBuilder infoFactory = new GBeanInfoBuilder(ProtocolGBean.class);
+
+        infoFactory.addAttribute(new GAttributeInfo("objectName", String.class.getName(), false, "getObjectName", null));
+        infoFactory.addAttribute(new GAttributeInfo("protocol", String.class.getName(), true, "getProtocol", null));
+        infoFactory.addAttribute(new GAttributeInfo("properties", Properties.class.getName(), true, "getProperties", "setProperties"));
+        infoFactory.addAttribute(new GAttributeInfo("host", String.class.getName(), true, "getHost", "setHost"));
+        infoFactory.addAttribute(new GAttributeInfo("user", String.class.getName(), true, "getUser", "setUser"));
+        infoFactory.addOperation("addOverrides", new Class[]{Properties.class});
+
+        infoFactory.setConstructor(new String[]{"objectName", "protocol", "properties", "host", "user"});
+
+        GBEAN_INFO = infoFactory.getBeanInfo();
+    }
+
+    public static GBeanInfo getGBeanInfo() {
+        return GBEAN_INFO;
+    }
+}

Added: geronimo/trunk/modules/mail/src/java/org/apache/geronimo/mail/SMTPTransportGBean.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/mail/src/java/org/apache/geronimo/mail/SMTPTransportGBean.java?view=auto&rev=123792
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/mail/src/java/org/apache/geronimo/mail/SMTPTransportGBean.java	Fri Dec 31 05:58:12 2004
@@ -0,0 +1,789 @@
+/**
+ *
+ * Copyright 2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.mail;
+
+import java.util.Properties;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.geronimo.gbean.GAttributeInfo;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.gbean.WaitingException;
+
+
+/**
+ * A GBean that provides for the configuration of a JavaMail SMTP transport
+ * protocol.
+ * <p/>
+ * SMTP transport properties that are common to all SMTP transports are
+ * provided via member variables of this class.  Values that are set in the
+ * individual member variables will override any of the corresponding values
+ * that have been set in the properties set.
+ *
+ * @version $Rev: $ $Date: $
+ * @see MailGBean
+ */
+public class SMTPTransportGBean extends ProtocolGBean {
+
+    private final Log log = LogFactory.getLog(SMTPTransportGBean.class);
+
+    private Integer port;
+    private Integer connectionTimeout;
+    private Integer timeout;
+    private String from;
+    private String localhost;
+    private String localaddress;
+    private Integer localport;
+    private Boolean ehlo;
+    private Boolean auth;
+    private String submitter;
+    private String dsnNotify;
+    private String dsnRet;
+    private Boolean allow8bitmime;
+    private Boolean sendPartial;
+    private String saslRealm;
+    private Boolean quitWait;
+    private Boolean reportSuccess;
+    private String socketFactoryClass;
+    private Boolean socketFactoryFallback;
+    private Integer socketFactoryPort;
+    private String mailExtension;
+
+
+    /**
+     * Construct an instance of SMTPTransportGBean
+     * <p/>
+     * Values that are set in the individual member variables will override any of
+     * the corresponding values that have been set in the properties set.
+     *
+     * @param objectName            the object name of the protocol
+     * @param properties            the set of default properties for the protocol
+     * @param host                  the host the protocol connects to
+     * @param user                  the default name for the protocol
+     * @param port                  the SMTP server port
+     * @param connectionTimeout     the socket connection timeout value in milliseconds
+     * @param timeout               the socket I/O timeout value in milliseconds
+     * @param from                  the email address to use for SMTP MAIL command
+     * @param localhost             the local host name used in the SMTP HELO or EHLO command
+     * @param localaddress          the local address (host name) to bind to when creating the SMTP socket
+     * @param localport             the local port number to bind to when creating the SMTP socket
+     * @param ehlo                  whether an attempt will be made to sign on with the EHLO command
+     * @param auth                  whether an attempt will be made to authenticate the user using
+     *                              the AUTH command
+     * @param submitter             the submitter to use in the AUTH tag in the MAIL FROM command
+     * @param dsnNotify             the NOTIFY option to the RCPT command
+     * @param dsnRet                the RET option to the MAIL command
+     * @param allow8bitmime         whether encodings are converted to use "8bit" under certain
+     *                              conditions
+     * @param sendPartial           whether to send email to valid addresses when others are invalid
+     * @param saslRealm             the realm to use with DIGEST-MD5 authentication
+     * @param quitWait              whether the transport will wait for the response to the QUIT command
+     * @param reportSuccess         whether the transport will include an SMTPAddressSucceededException
+     *                              for each address that is successful
+     * @param socketFactoryClass    the class that will be used to create SMTP sockets
+     * @param socketFactoryFallback whether java.net.Socket class will be created if the specified
+     *                              socket factory class cannot be created
+     * @param socketFactoryPort     whether java.net.Socket class will be created if the specified
+     *                              socket factory class cannot be created
+     * @param mailExtension         the extension string to append to the MAIL command
+     */
+    public SMTPTransportGBean(String objectName, Properties properties, String host, String user,
+                              Integer port,
+                              Integer connectionTimeout,
+                              Integer timeout,
+                              String from,
+                              String localhost,
+                              String localaddress,
+                              Integer localport,
+                              Boolean ehlo,
+                              Boolean auth,
+                              String submitter,
+                              String dsnNotify,
+                              String dsnRet,
+                              Boolean allow8bitmime,
+                              Boolean sendPartial,
+                              String saslRealm,
+                              Boolean quitWait,
+                              Boolean reportSuccess,
+                              String socketFactoryClass,
+                              Boolean socketFactoryFallback,
+                              Integer socketFactoryPort,
+                              String mailExtension) {
+        super(objectName, "smtp", properties, host, user);
+
+        setPort(port);
+        setConnectionTimeout(connectionTimeout);
+        setTimeout(timeout);
+        setFrom(from);
+        setLocalhost(localhost);
+        setLocaladdress(localaddress);
+        setLocalport(localport);
+        setEhlo(ehlo);
+        setAuth(auth);
+        setSubmitter(submitter);
+        setDsnNotify(dsnNotify);
+        setDsnRet(dsnRet);
+        setAllow8bitmime(allow8bitmime);
+        setSendPartial(sendPartial);
+        setSaslRealm(saslRealm);
+        setQuitWait(quitWait);
+        setReportSuccess(reportSuccess);
+        setSocketFactoryClass(socketFactoryClass);
+        setSocketFactoryFallback(socketFactoryFallback);
+        setSocketFactoryPort(socketFactoryPort);
+        setMailExtension(mailExtension);
+    }
+
+    /**
+     * Returns the SMTP server port to connect to, if the connect() method
+     * doesn't explicitly specify one.
+     */
+    public Integer getPort() {
+        return port;
+    }
+
+    /**
+     * Sets the SMTP server port to connect to, if the connect() method
+     * doesn't explicitly specify one.
+     * <p/>
+     * Defaults to 25.
+     * <p/>
+     * Values that are set here will override any of the corresponding value
+     * that has been set in the properties.
+     *
+     * @param port the SMTP server port to connect to
+     */
+    public void setPort(Integer port) {
+        this.port = port;
+    }
+
+    /**
+     * Returns the socket connection timeout value in milliseconds.
+     */
+    public Integer getConnectionTimeout() {
+        return connectionTimeout;
+    }
+
+    /**
+     * Sets the socket connection timeout value in milliseconds.
+     * <p/>
+     * Default is infinite timeout.
+     * <p/>
+     * Values that are set here will override any of the corresponding value
+     * that has been set in the properties.
+     *
+     * @param connectionTimeout the socket connection timeout value in milliseconds.
+     */
+    public void setConnectionTimeout(Integer connectionTimeout) {
+        this.connectionTimeout = connectionTimeout;
+    }
+
+    /**
+     * Returns the socket I/O timeout value in milliseconds.
+     */
+    public Integer getTimeout() {
+        return timeout;
+    }
+
+    /**
+     * Sets the socket I/O timeout value in milliseconds.
+     * <p/>
+     * Default is infinite timeout.
+     * <p/>
+     * Values that are set here will override any of the corresponding value
+     * that has been set in the properties.
+     *
+     * @param timeout the socket I/O timeout value in milliseconds
+     */
+    public void setTimeout(Integer timeout) {
+        this.timeout = timeout;
+    }
+
+    /**
+     * Returns the email address to use for SMTP MAIL command.
+     */
+    public String getFrom() {
+        return from;
+    }
+
+    /**
+     * Sets the email address to use for SMTP MAIL command
+     * <p/>
+     * Email address to use for SMTP MAIL command. This sets the envelope
+     * return address. Defaults to msg.getFrom() or InternetAddress.getLocalAddress().
+     * NOTE: mail.smtp.user was previously used for this.
+     * <p/>
+     * Values that are set here will override any of the corresponding value
+     * that has been set in the properties.
+     *
+     * @param from the email address to use for SMTP MAIL command
+     */
+    public void setFrom(String from) {
+        this.from = from;
+    }
+
+    /**
+     * Returns the local host name used in the SMTP HELO or EHLO command.
+     */
+    public String getLocalhost() {
+        return localhost;
+    }
+
+    /**
+     * Sets the local host name used in the SMTP HELO or EHLO command.
+     * <p/>
+     * Local host name used in the SMTP HELO or EHLO command. Defaults to
+     * InetAddress.getLocalHost().getHostName(). Should not normally need to
+     * be set if your JDK and your name service are configured properly.
+     * <p/>
+     * Values that are set here will override any of the corresponding value
+     * that has been set in the properties.
+     *
+     * @param localhost the local host name used in the SMTP HELO or EHLO command
+     */
+    public void setLocalhost(String localhost) {
+        this.localhost = localhost;
+    }
+
+    /**
+     * Returns the local address (host name) to bind to when creating the SMTP socket.
+     */
+    public String getLocaladdress() {
+        return localaddress;
+    }
+
+    /**
+     * Sets the local address (host name) to bind to when creating the SMTP socket.
+     * <p/>
+     * Local address (host name) to bind to when creating the SMTP socket.
+     * Defaults to the address picked by the Socket class. Should not normally
+     * need to be set, but useful with multi-homed hosts where it's important
+     * to pick a particular local address to bind to.
+     * <p/>
+     * Values that are set here will override any of the corresponding value
+     * that has been set in the properties.
+     *
+     * @param localaddress the local address (host name) to bind to when creating the SMTP socket
+     */
+    public void setLocaladdress(String localaddress) {
+        this.localaddress = localaddress;
+    }
+
+    /**
+     * Returns the local port number to bind to when creating the SMTP socket.
+     */
+    public Integer getLocalport() {
+        return localport;
+    }
+
+    /**
+     * Sets the local port number to bind to when creating the SMTP socket.
+     * <p/>
+     * Local port number to bind to when creating the SMTP socket. Defaults to
+     * the port number picked by the Socket class.
+     * <p/>
+     * Values that are set here will override any of the corresponding value
+     * that has been set in the properties.
+     *
+     * @param localport the local port number to bind to when creating the SMTP socket
+     */
+    public void setLocalport(Integer localport) {
+        this.localport = localport;
+    }
+
+    /**
+     * Returns whether an attempt will be made to sign on with the EHLO command.
+     * <p/>
+     * If false, do not attempt to sign on with the EHLO command. Normally
+     * failure of the EHLO command will fallback to the HELO command; this
+     * property exists only for servers that don't fail EHLO properly or don't
+     * implement EHLO properly.
+     */
+    public Boolean getEhlo() {
+        return ehlo;
+    }
+
+    /**
+     * Set whether an attempt will be made to sign on with the EHLO command.
+     * <p/>
+     * If false, do not attempt to sign on with the EHLO command. Normally
+     * failure of the EHLO command will fallback to the HELO command; this
+     * property exists only for servers that don't fail EHLO properly or don't
+     * implement EHLO properly.
+     * <p/>
+     * Values that are set here will override any of the corresponding value
+     * that has been set in the properties.
+     *
+     * @param ehlo whether an attempt will be made to sign on with the EHLO command
+     */
+    public void setEhlo(Boolean ehlo) {
+        this.ehlo = ehlo;
+    }
+
+    /**
+     * Returns whether an attempt will be made to authenticate the user using
+     * the AUTH command.
+     * <p/>
+     * Defaults to false.
+     */
+    public Boolean getAuth() {
+        return auth;
+    }
+
+    /**
+     * Sets whether an attempt will be made to authenticate the user using
+     * the AUTH command.
+     * <p/>
+     * Defaults to false.
+     * <p/>
+     * Values that are set here will override any of the corresponding value
+     * that has been set in the properties.
+     *
+     * @param auth whether an attempt will be made to authenticate the user using
+     *             the AUTH command.
+     */
+    public void setAuth(Boolean auth) {
+        this.auth = auth;
+    }
+
+    /**
+     * Returns the submitter to use in the AUTH tag in the MAIL FROM command.
+     * <p/>
+     * Typically used by a mail relay to pass along information about the
+     * original submitter of the message. See also the setSubmitter method of
+     * SMTPMessage. Mail clients typically do not use this.
+     */
+    public String getSubmitter() {
+        return submitter;
+    }
+
+    /**
+     * Sets the submitter to use in the AUTH tag in the MAIL FROM command.
+     * <p/>
+     * Typically used by a mail relay to pass along information about the
+     * original submitter of the message. See also the setSubmitter method of
+     * SMTPMessage. Mail clients typically do not use this.
+     * <p/>
+     * Values that are set here will override any of the corresponding value
+     * that has been set in the properties.
+     *
+     * @param submitter the submitter to use in the AUTH tag in the MAIL FROM command
+     */
+    public void setSubmitter(String submitter) {
+        this.submitter = submitter;
+    }
+
+    /**
+     * Returns the NOTIFY option to the RCPT command.
+     * <p/>
+     * Either NEVER, or some combination of SUCCESS, FAILURE, and DELAY
+     * (separated by commas).
+     */
+    public String getDsnNotify() {
+        return dsnNotify;
+    }
+
+    /**
+     * Sets the NOTIFY option to the RCPT command
+     * <p/>
+     * Either NEVER, or some combination of SUCCESS, FAILURE, and DELAY
+     * (separated by commas).
+     * <p/>
+     * Values that are set here will override any of the corresponding value
+     * that has been set in the properties.
+     *
+     * @param dsnNotify the NOTIFY option to the RCPT command
+     */
+    public void setDsnNotify(String dsnNotify) {
+        this.dsnNotify = dsnNotify;
+    }
+
+    /**
+     * Returns the RET option to the MAIL command.
+     * <p/>
+     * Either FULL or HDRS.
+     */
+    public String getDsnRet() {
+        return dsnRet;
+    }
+
+    /**
+     * Sets the RET option to the MAIL command
+     * <p/>
+     * Either FULL or HDRS.
+     * <p/>
+     * Values that are set here will override any of the corresponding value
+     * that has been set in the properties.
+     *
+     * @param dsnRet the RET option to the MAIL command
+     */
+    public void setDsnRet(String dsnRet) {
+        this.dsnRet = dsnRet;
+    }
+
+    /**
+     * Returns whether encodings are converted to use "8bit" under certain
+     * conditions.
+     * <p/>
+     * If set to true, and the server supports the 8BITMIME extension, text
+     * parts of messages that use the "quoted-printable" or "base64" encodings
+     * are converted to use "8bit" encoding if they follow the RFC2045 rules
+     * for 8bit text.
+     */
+    public Boolean getAllow8bitmime() {
+        return allow8bitmime;
+    }
+
+    /**
+     * Sets whether encodings are converted to use "8bit" under certain
+     * conditions.
+     * <p/>
+     * If set to true, and the server supports the 8BITMIME extension, text
+     * parts of messages that use the "quoted-printable" or "base64" encodings
+     * are converted to use "8bit" encoding if they follow the RFC2045 rules
+     * for 8bit text.
+     * <p/>
+     * Values that are set here will override any of the corresponding value
+     * that has been set in the properties.
+     *
+     * @param allow8bitmime whether encodings are converted to use "8bit" under certain
+     *                      conditions
+     */
+    public void setAllow8bitmime(Boolean allow8bitmime) {
+        this.allow8bitmime = allow8bitmime;
+    }
+
+    /**
+     * Returns whether to send email to valid addresses when others are invalid.
+     * <p/>
+     * If set to true, and a message has some valid and some invalid addresses,
+     * send the message anyway, reporting the partial failure with a
+     * SendFailedException. If set to false (the default), the message is not
+     * sent to any of the recipients if there is an invalid recipient address.
+     */
+    public Boolean getSendPartial() {
+        return sendPartial;
+    }
+
+    /**
+     * Sets whether to send email to valid addresses when others are invalid.
+     * <p/>
+     * If set to true, and a message has some valid and some invalid addresses,
+     * send the message anyway, reporting the partial failure with a
+     * SendFailedException. If set to false (the default), the message is not
+     * sent to any of the recipients if there is an invalid recipient address.
+     * <p/>
+     * Values that are set here will override any of the corresponding value
+     * that has been set in the properties.
+     *
+     * @param sendPartial whether to send email to valid addresses when others are invalid
+     */
+    public void setSendPartial(Boolean sendPartial) {
+        this.sendPartial = sendPartial;
+    }
+
+    /**
+     * Returns the realm to use with DIGEST-MD5 authentication.
+     */
+    public String getSaslRealm() {
+        return saslRealm;
+    }
+
+    /**
+     * Sets the realm to use with DIGEST-MD5 authentication.
+     * <p/>
+     * Values that are set here will override any of the corresponding value
+     * that has been set in the properties.
+     *
+     * @param saslRealm the realm to use with DIGEST-MD5 authentication
+     */
+    public void setSaslRealm(String saslRealm) {
+        this.saslRealm = saslRealm;
+    }
+
+    /**
+     * Returns whether the transport will wait for the response to the QUIT command.
+     * <p/>
+     * If set to true, causes the transport to wait for the response to the QUIT
+     * command. If set to false (the default), the QUIT command is sent and the
+     * connection is immediately closed.
+     */
+    public Boolean getQuitWait() {
+        return quitWait;
+    }
+
+    /**
+     * Sets whether the transport will wait for the response to the QUIT command
+     * <p/>
+     * If set to true, causes the transport to wait for the response to the QUIT
+     * command. If set to false (the default), the QUIT command is sent and the
+     * connection is immediately closed.
+     * <p/>
+     * Values that are set here will override any of the corresponding value
+     * that has been set in the properties.
+     *
+     * @param quitWait whether the transport will wait for the response to the QUIT command
+     */
+    public void setQuitWait(Boolean quitWait) {
+        this.quitWait = quitWait;
+    }
+
+    /**
+     * Returns whether the transport will include an SMTPAddressSucceededException
+     * for each address that is successful.
+     * <p/>
+     * Note also that this will cause a SendFailedException to be thrown from
+     * the sendMessage method of SMTPTransport even if all addresses were
+     * correct and the message was sent successfully.
+     */
+    public Boolean getReportSuccess() {
+        return reportSuccess;
+    }
+
+    /**
+     * Sets whether the transport will include an SMTPAddressSucceededException
+     * for each address that is successful.
+     * <p/>
+     * Note also that this will cause a SendFailedException to be thrown from
+     * the sendMessage method of SMTPTransport even if all addresses were
+     * correct and the message was sent successfully.
+     * <p/>
+     * Values that are set here will override any of the corresponding value
+     * that has been set in the properties.
+     *
+     * @param reportSuccess whether the transport will include an SMTPAddressSucceededException
+     *                      for each address that is successful
+     */
+    public void setReportSuccess(Boolean reportSuccess) {
+        this.reportSuccess = reportSuccess;
+    }
+
+    /**
+     * Returns the class that will be used to create SMTP sockets.
+     * <p/>
+     * If set, specifies the name of a class that implements the
+     * javax.net.SocketFactory interface. This class will be used to create SMTP
+     * sockets.
+     */
+    public String getSocketFactoryClass() {
+        return socketFactoryClass;
+    }
+
+    /**
+     * Sets the class that will be used to create SMTP sockets.
+     * <p/>
+     * If set, specifies the name of a class that implements the
+     * javax.net.SocketFactory interface. This class will be used to create SMTP
+     * sockets.
+     * <p/>
+     * Values that are set here will override any of the corresponding value
+     * that has been set in the properties.
+     *
+     * @param socketFactoryClass the class that will be used to create SMTP sockets
+     */
+    public void setSocketFactoryClass(String socketFactoryClass) {
+        this.socketFactoryClass = socketFactoryClass;
+    }
+
+    /**
+     * Returns whether java.net.Socket class will be created if the specified
+     * socket factory class cannot be created.
+     * <p/>
+     * If set to true, failure to create a socket using the specified socket
+     * factory class will cause the socket to be created using the
+     * java.net.Socket class. Defaults to true.
+     */
+    public Boolean getSocketFactoryFallback() {
+        return socketFactoryFallback;
+    }
+
+    /**
+     * Sets whether java.net.Socket class will be created if the specified
+     * socket factory class cannot be created.
+     * <p/>
+     * If set to true, failure to create a socket using the specified socket
+     * factory class will cause the socket to be created using the
+     * java.net.Socket class. Defaults to true.
+     * <p/>
+     * Values that are set here will override any of the corresponding value
+     * that has been set in the properties.
+     *
+     * @param socketFactoryFallback whether java.net.Socket class will be created if the specified
+     *                              socket factory class cannot be created
+     */
+    public void setSocketFactoryFallback(Boolean socketFactoryFallback) {
+        this.socketFactoryFallback = socketFactoryFallback;
+    }
+
+    /**
+     * Returns the port to connect to when using the specified socket factory.
+     * <p/>
+     * Specifies the port to connect to when using the specified socket
+     * factory. If not set, the default port will be used.
+     */
+    public Integer getSocketFactoryPort() {
+        return socketFactoryPort;
+    }
+
+    /**
+     * Sets the port to connect to when using the specified socket factory.
+     * <p/>
+     * Specifies the port to connect to when using the specified socket
+     * factory. If not set, the default port will be used.
+     * <p/>
+     * Values that are set here will override any of the corresponding value
+     * that has been set in the properties.
+     *
+     * @param socketFactoryPort the port to connect to when using the specified socket factory
+     */
+    public void setSocketFactoryPort(Integer socketFactoryPort) {
+        this.socketFactoryPort = socketFactoryPort;
+    }
+
+    /**
+     * Returns the extension string to append to the MAIL command.
+     * <p/>
+     * Extension string to append to the MAIL command. The extension string
+     * can be used to specify standard SMTP service extensions as well as
+     * vendor-specific extensions. Typically the application should use the
+     * SMTPTransport method supportsExtension to verify that the server
+     * supports the desired service extension. See RFC 1869 and other RFCs
+     * that define specific extensions.
+     */
+    public String getMailExtension() {
+        return mailExtension;
+    }
+
+    /**
+     * Sets the extension string to append to the MAIL command.
+     * <p/>
+     * Extension string to append to the MAIL command. The extension string
+     * can be used to specify standard SMTP service extensions as well as
+     * vendor-specific extensions. Typically the application should use the
+     * SMTPTransport method supportsExtension to verify that the server
+     * supports the desired service extension. See RFC 1869 and other RFCs
+     * that define specific extensions.
+     * <p/>
+     * Values that are set here will override any of the corresponding value
+     * that has been set in the properties.
+     *
+     * @param mailExtension the extension string to append to the MAIL command
+     */
+    public void setMailExtension(String mailExtension) {
+        this.mailExtension = mailExtension;
+    }
+
+    /**
+     * Add the overrides from the member variables to the properties file.
+     */
+    public void addOverrides(Properties props) {
+        super.addOverrides(props);
+
+        if (port != null) props.put("mail.smtp.port", port);
+        if (connectionTimeout != null) props.put("mail.smtp.connectiontimeout", connectionTimeout);
+        if (timeout != null) props.put("mail.smtp.timeout", timeout);
+        if (from != null) props.put("mail.smtp.from", from);
+        if (localhost != null) props.put("mail.smtp.localhost", localhost);
+        if (localaddress != null) props.put("mail.smtp.localaddress", localaddress);
+        if (localport != null) props.put("mail.smtp.localport", localport);
+        if (ehlo != null) props.put("mail.smtp.ehlo", ehlo);
+        if (auth != null) props.put("mail.smtp.auth", auth);
+        if (submitter != null) props.put("mail.smtp.submitter", submitter);
+        if (dsnNotify != null) props.put("mail.smtp.dsn.notify", dsnNotify);
+        if (dsnRet != null) props.put("mail.smtp.dsn.ret", dsnRet);
+        if (allow8bitmime != null) props.put("mail.smtp.allow8bitmime", allow8bitmime);
+        if (sendPartial != null) props.put("mail.smtp.sendpartial", sendPartial);
+        if (saslRealm != null) props.put("mail.smtp.sasl.realm", saslRealm);
+        if (quitWait != null) props.put("mail.smtp.quitwait", quitWait);
+        if (reportSuccess != null) props.put("mail.smtp.reportsuccess", reportSuccess);
+        if (socketFactoryClass != null) props.put("mail.smtp.socketFactory.class", socketFactoryClass);
+        if (socketFactoryFallback != null) props.put("mail.smtp.socketFactory.fallback", socketFactoryFallback);
+        if (socketFactoryPort != null) props.put("mail.smtp.socketFactory.port", socketFactoryPort);
+        if (mailExtension != null) props.put("mail.smtp.mailextension", mailExtension);
+    }
+
+    public void doStart() throws WaitingException, Exception {
+        log.info("Started " + getObjectName());
+    }
+
+    public void doStop() throws WaitingException, Exception {
+        log.info("Stopped " + getObjectName());
+    }
+
+    public void doFail() {
+        log.info("Failed " + getObjectName());
+    }
+
+    public static final GBeanInfo GBEAN_INFO;
+
+    static {
+        GBeanInfoBuilder infoFactory = new GBeanInfoBuilder(SMTPTransportGBean.class, ProtocolGBean.GBEAN_INFO);
+
+        infoFactory.addAttribute(new GAttributeInfo("port", Integer.class.getName(), true, "getPort", "setPort"));
+        infoFactory.addAttribute(new GAttributeInfo("connectionTimeout", Integer.class.getName(), true, "getConnectionTimeout", "setConnectionTimeout"));
+        infoFactory.addAttribute(new GAttributeInfo("timeout", Integer.class.getName(), true, "getTimeout", "setTimeout"));
+        infoFactory.addAttribute(new GAttributeInfo("from", String.class.getName(), true, "getFrom", "setFrom"));
+        infoFactory.addAttribute(new GAttributeInfo("localhost", String.class.getName(), true, "getLocalhost", "setLocalhost"));
+        infoFactory.addAttribute(new GAttributeInfo("localaddress", String.class.getName(), true, "getLocaladdress", "setLocaladdress"));
+        infoFactory.addAttribute(new GAttributeInfo("localport", Integer.class.getName(), true, "getLocalport", "setLocalport"));
+        infoFactory.addAttribute(new GAttributeInfo("ehlo", Boolean.class.getName(), true, "getEhlo", "setEhlo"));
+        infoFactory.addAttribute(new GAttributeInfo("auth", Boolean.class.getName(), true, "getAuth", "setAuth"));
+        infoFactory.addAttribute(new GAttributeInfo("submitter", String.class.getName(), true, "getSubmitter", "setSubmitter"));
+        infoFactory.addAttribute(new GAttributeInfo("dsnNotify", String.class.getName(), true, "getDsnNotify", "setDsnNotify"));
+        infoFactory.addAttribute(new GAttributeInfo("dsnRet", String.class.getName(), true, "getDsnRet", "setDsnRet"));
+        infoFactory.addAttribute(new GAttributeInfo("allow8bitmime", Boolean.class.getName(), true, "getAllow8bitmime", "setAllow8bitmime"));
+        infoFactory.addAttribute(new GAttributeInfo("sendPartial", Boolean.class.getName(), true, "getSendPartial", "setSendPartial"));
+        infoFactory.addAttribute(new GAttributeInfo("saslRealm", String.class.getName(), true, "getSaslRealm", "setSaslRealm"));
+        infoFactory.addAttribute(new GAttributeInfo("quitWait", Boolean.class.getName(), true, "getQuitWait", "setQuitWait"));
+        infoFactory.addAttribute(new GAttributeInfo("reportSuccess", Boolean.class.getName(), true, "getReportSuccess", "setReportSuccess"));
+        infoFactory.addAttribute(new GAttributeInfo("socketFactoryClass", String.class.getName(), true, "getSocketFactoryClass", "setSocketFactoryClass"));
+        infoFactory.addAttribute(new GAttributeInfo("socketFactoryFallback", Boolean.class.getName(), true, "getSocketFactoryFallback", "setSocketFactoryFallback"));
+        infoFactory.addAttribute(new GAttributeInfo("socketFactoryPort", Integer.class.getName(), true, "getSocketFactoryPort", "setSocketFactoryPort"));
+        infoFactory.addAttribute(new GAttributeInfo("mailExtension", String.class.getName(), true, "getMailExtension", "setMailExtension"));
+
+        infoFactory.setConstructor(new String[]{"objectName", "properties", "host", "user",
+                                                "port",
+                                                "connectionTimeout",
+                                                "timeout",
+                                                "from",
+                                                "localhost",
+                                                "localaddress",
+                                                "localport",
+                                                "ehlo",
+                                                "auth",
+                                                "submitter",
+                                                "dsnNotify",
+                                                "dsnRet",
+                                                "allow8bitmime",
+                                                "sendPartial",
+                                                "saslRealm",
+                                                "quitWait",
+                                                "reportSuccess",
+                                                "socketFactoryClass",
+                                                "socketFactoryFallback",
+                                                "socketFactoryPort",
+                                                "mailExtension"});
+
+        GBEAN_INFO = infoFactory.getBeanInfo();
+    }
+
+    public static GBeanInfo getGBeanInfo() {
+        return GBEAN_INFO;
+    }
+}

Modified: geronimo/trunk/modules/mail/src/test/org/apache/geronimo/mail/MailGBeanTest.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/mail/src/test/org/apache/geronimo/mail/MailGBeanTest.java?view=diff&rev=123792&p1=geronimo/trunk/modules/mail/src/test/org/apache/geronimo/mail/MailGBeanTest.java&r1=123791&p2=geronimo/trunk/modules/mail/src/test/org/apache/geronimo/mail/MailGBeanTest.java&r2=123792
==============================================================================
--- geronimo/trunk/modules/mail/src/test/org/apache/geronimo/mail/MailGBeanTest.java	(original)
+++ geronimo/trunk/modules/mail/src/test/org/apache/geronimo/mail/MailGBeanTest.java	Fri Dec 31 05:58:12 2004
@@ -16,11 +16,15 @@
  */
 package org.apache.geronimo.mail;
 
-import java.util.Properties;
 import javax.mail.Session;
+import javax.mail.Store;
+import javax.mail.Transport;
 import javax.management.ObjectName;
+import java.util.Collection;
+import java.util.Properties;
 
 import junit.framework.TestCase;
+
 import org.apache.geronimo.gbean.jmx.GBeanMBean;
 import org.apache.geronimo.kernel.Kernel;
 
@@ -32,35 +36,208 @@
 
     private Kernel kernel;
     private ObjectName mailName;
+    private ObjectName protocolName;
     private static final String KERNEL_NAME = "testKernel";
 
-    public void testProxy() throws Exception {
+    public void testProperties() throws Exception {
+        Properties properties = new Properties();
+        properties.put("mail.store.protocol", "test");
+        properties.put("mail.transport.protocol", "test");
+
+        GBeanMBean cmf = new GBeanMBean(MailGBean.getGBeanInfo());
+        cmf.setAttribute("useDefault", new Boolean(true));
+        cmf.setAttribute("properties", properties);
+
+        mailName = ObjectName.getInstance("geronimo.server:J2EEServer=geronimo,J2EEApplication=null,J2EEType=JavaMailResource,name=default");
+
+        kernel.loadGBean(mailName, cmf);
+        kernel.startGBean(mailName);
+
         Object proxy = kernel.invoke(mailName, "$getResource");
 
         assertNotNull(proxy);
         assertTrue(proxy instanceof Session);
 
-//        Store store = ((Session) proxy).getStore();
-//        assertNotNull(store);
+        Store store = ((Session) proxy).getStore();
+        assertNotNull(store);
+        assertTrue(store instanceof TestStore);
+
+        Transport transport = ((Session) proxy).getTransport();
+        assertNotNull(transport);
+        assertTrue(transport instanceof TestTransport);
 
         kernel.stopGBean(mailName);
     }
 
-    protected void setUp() throws Exception {
-        kernel = new Kernel(KERNEL_NAME, "test.domain");
-        kernel.boot();
+    public void testDefaultOverrides() throws Exception {
+        Properties properties = new Properties();
+        properties.put("mail.store.protocol", "POOKIE");
+        properties.put("mail.transport.protocol", "BEAR");
 
         GBeanMBean cmf = new GBeanMBean(MailGBean.getGBeanInfo());
         cmf.setAttribute("useDefault", new Boolean(true));
-        cmf.setAttribute("properties", new Properties());
+        cmf.setAttribute("properties", properties);
+        cmf.setAttribute("storeProtocol", "test");
+        cmf.setAttribute("transportProtocol", "test");
+
         mailName = ObjectName.getInstance("geronimo.server:J2EEServer=geronimo,J2EEApplication=null,J2EEType=JavaMailResource,name=default");
+
         kernel.loadGBean(mailName, cmf);
+        kernel.startGBean(mailName);
+
+        Object proxy = kernel.invoke(mailName, "$getResource");
+
+        assertNotNull(proxy);
+        assertTrue(proxy instanceof Session);
+
+        Store store = ((Session) proxy).getStore();
+        assertNotNull(store);
+        assertTrue(store instanceof TestStore);
+
+        Transport transport = ((Session) proxy).getTransport();
+        assertNotNull(transport);
+        assertTrue(transport instanceof TestTransport);
 
+        kernel.stopGBean(mailName);
+    }
+
+    public void testSMTPOverrides() throws Exception {
+        Properties properties = new Properties();
+        properties.put("mail.store.protocol", "POOKIE");
+        properties.put("mail.transport.protocol", "BEAR");
+        properties.put("mail.smtp.ehlo", "true");
+
+        GBeanMBean cmf = new GBeanMBean(MailGBean.getGBeanInfo());
+        cmf.setReferencePattern("Protocols", new ObjectName("geronimo.server:J2EEServer=geronimo,J2EEApplication=null,type=JavaMailProtocol,*"));
+        cmf.setAttribute("useDefault", new Boolean(true));
+        cmf.setAttribute("properties", properties);
+        cmf.setAttribute("storeProtocol", "test");
+        cmf.setAttribute("transportProtocol", "test");
+
+        mailName = ObjectName.getInstance("geronimo.server:J2EEServer=geronimo,J2EEApplication=null,J2EEType=JavaMailResource,name=default");
+
+        kernel.loadGBean(mailName, cmf);
         kernel.startGBean(mailName);
+
+        GBeanMBean smtp = new GBeanMBean(SMTPTransportGBean.getGBeanInfo());
+
+        protocolName = ObjectName.getInstance("geronimo.server:J2EEServer=geronimo,J2EEApplication=null,type=JavaMailProtocol,name=smtp");
+
+        kernel.loadGBean(protocolName, smtp);
+        kernel.startGBean(protocolName);
+
+        Collection protocols = (Collection) kernel.invoke(mailName, "getProtocols");
+        int size = protocols.size();
+        Object proxy = kernel.invoke(mailName, "$getResource");
+
+        assertNotNull(proxy);
+        assertTrue(proxy instanceof Session);
+
+        Store store = ((Session) proxy).getStore();
+        assertNotNull(store);
+        assertTrue(store instanceof TestStore);
+
+        Transport transport = ((Session) proxy).getTransport();
+        assertNotNull(transport);
+        assertTrue(transport instanceof TestTransport);
+
+        TestTransport testTransport = (TestTransport) transport;
+        assertFalse(testTransport.isEHLO());
+
+        kernel.stopGBean(protocolName);
+        kernel.stopGBean(mailName);
     }
 
-    protected void tearDown() throws Exception {
+    public void testPOP3Overrides() throws Exception {
+        Properties properties = new Properties();
+        properties.put("mail.store.protocol", "POOKIE");
+        properties.put("mail.transport.protocol", "BEAR");
+        properties.put("mail.pop3.ehlo", "true");
+
+        GBeanMBean cmf = new GBeanMBean(MailGBean.getGBeanInfo());
+        cmf.setReferencePattern("Protocols", new ObjectName("geronimo.server:J2EEServer=geronimo,J2EEApplication=null,type=JavaMailProtocol,*"));
+        cmf.setAttribute("useDefault", new Boolean(true));
+        cmf.setAttribute("properties", properties);
+        cmf.setAttribute("storeProtocol", "test");
+        cmf.setAttribute("transportProtocol", "test");
+
+        mailName = ObjectName.getInstance("geronimo.server:J2EEServer=geronimo,J2EEApplication=null,J2EEType=JavaMailResource,name=default");
+
+        kernel.loadGBean(mailName, cmf);
+        kernel.startGBean(mailName);
+
+        GBeanMBean pop3 = new GBeanMBean(SMTPTransportGBean.getGBeanInfo());
+
+        protocolName = ObjectName.getInstance("geronimo.server:J2EEServer=geronimo,J2EEApplication=null,type=JavaMailProtocol,name=pop3");
+
+        kernel.loadGBean(protocolName, pop3);
+        kernel.startGBean(protocolName);
+
+        Object proxy = kernel.invoke(mailName, "$getResource");
+
+        assertNotNull(proxy);
+        assertTrue(proxy instanceof Session);
+
+        Store store = ((Session) proxy).getStore();
+        assertNotNull(store);
+        assertTrue(store instanceof TestStore);
+
+        Transport transport = ((Session) proxy).getTransport();
+        assertNotNull(transport);
+        assertTrue(transport instanceof TestTransport);
+
+        kernel.stopGBean(protocolName);
         kernel.stopGBean(mailName);
+    }
+
+    public void testIMAPOverrides() throws Exception {
+        Properties properties = new Properties();
+        properties.put("mail.store.protocol", "POOKIE");
+        properties.put("mail.transport.protocol", "BEAR");
+        properties.put("mail.imap.ehlo", "true");
+
+        GBeanMBean cmf = new GBeanMBean(MailGBean.getGBeanInfo());
+        cmf.setReferencePattern("Protocols", new ObjectName("geronimo.server:J2EEServer=geronimo,J2EEApplication=null,type=JavaMailProtocol,*"));
+        cmf.setAttribute("useDefault", new Boolean(true));
+        cmf.setAttribute("properties", properties);
+        cmf.setAttribute("storeProtocol", "test");
+        cmf.setAttribute("transportProtocol", "test");
+
+        mailName = ObjectName.getInstance("geronimo.server:J2EEServer=geronimo,J2EEApplication=null,J2EEType=JavaMailResource,name=default");
+
+        kernel.loadGBean(mailName, cmf);
+        kernel.startGBean(mailName);
+
+        GBeanMBean imap = new GBeanMBean(IMAPStoreGBean.getGBeanInfo());
+
+        protocolName = ObjectName.getInstance("geronimo.server:J2EEServer=geronimo,J2EEApplication=null,type=JavaMailProtocol,name=imap");
+
+        kernel.loadGBean(protocolName, imap);
+        kernel.startGBean(protocolName);
+
+        Object proxy = kernel.invoke(mailName, "$getResource");
+
+        assertNotNull(proxy);
+        assertTrue(proxy instanceof Session);
+
+        Store store = ((Session) proxy).getStore();
+        assertNotNull(store);
+        assertTrue(store instanceof TestStore);
+
+        Transport transport = ((Session) proxy).getTransport();
+        assertNotNull(transport);
+        assertTrue(transport instanceof TestTransport);
+
+        kernel.stopGBean(protocolName);
+        kernel.stopGBean(mailName);
+    }
+
+    protected void setUp() throws Exception {
+        kernel = new Kernel(KERNEL_NAME, "test.domain");
+        kernel.boot();
+    }
+
+    protected void tearDown() throws Exception {
         kernel.shutdown();
     }
 }

Added: geronimo/trunk/modules/mail/src/test/org/apache/geronimo/mail/TestStore.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/mail/src/test/org/apache/geronimo/mail/TestStore.java?view=auto&rev=123792
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/mail/src/test/org/apache/geronimo/mail/TestStore.java	Fri Dec 31 05:58:12 2004
@@ -0,0 +1,46 @@
+/**
+ *
+ * Copyright 2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.mail;
+
+import javax.mail.Folder;
+import javax.mail.MessagingException;
+import javax.mail.Session;
+import javax.mail.Store;
+import javax.mail.URLName;
+
+
+/**
+ * @version $Rev: $ $Date: $
+ */
+public class TestStore extends Store {
+
+    public TestStore(Session session, URLName urlName) {
+        super(session, urlName);
+    }
+
+    public Folder getDefaultFolder() throws MessagingException {
+        return null;
+    }
+
+    public Folder getFolder(String s) throws MessagingException {
+        return null;
+    }
+
+    public Folder getFolder(URLName urlName) throws MessagingException {
+        return null;
+    }
+}

Added: geronimo/trunk/modules/mail/src/test/org/apache/geronimo/mail/TestTransport.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/mail/src/test/org/apache/geronimo/mail/TestTransport.java?view=auto&rev=123792
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/mail/src/test/org/apache/geronimo/mail/TestTransport.java	Fri Dec 31 05:58:12 2004
@@ -0,0 +1,42 @@
+/**
+ *
+ * Copyright 2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.mail;
+
+import javax.mail.Address;
+import javax.mail.Message;
+import javax.mail.MessagingException;
+import javax.mail.Session;
+import javax.mail.Transport;
+import javax.mail.URLName;
+
+
+/**
+ * @version $Rev: $ $Date: $
+ */
+public class TestTransport extends Transport {
+
+    public TestTransport(Session session, URLName name) {
+        super(session, name);
+    }
+
+    public void sendMessage(Message message, Address[] addresses) throws MessagingException {
+    }
+
+    public boolean isEHLO() {
+        return "true".equals(session.getProperties().getProperty("mail.smtp.ehlo"));
+    }
+}

Mime
View raw message