You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by rm...@apache.org on 2014/08/26 20:17:09 UTC

svn commit: r1620683 [4/17] - in /geronimo/specs/trunk: ./ geronimo-javamail_1.5_spec/ geronimo-javamail_1.5_spec/src/ geronimo-javamail_1.5_spec/src/main/ geronimo-javamail_1.5_spec/src/main/java/ geronimo-javamail_1.5_spec/src/main/java/javax/ geroni...

Added: geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/Transport.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/Transport.java?rev=1620683&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/Transport.java (added)
+++ geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/Transport.java Tue Aug 26 18:17:06 2014
@@ -0,0 +1,279 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 javax.mail;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Vector;
+
+import javax.mail.event.TransportEvent;
+import javax.mail.event.TransportListener;
+
+/**
+ * Abstract class modeling a message transport.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class Transport extends Service {
+    /**
+     * Send a message to all recipient addresses the message contains (as returned by {@link Message#getAllRecipients()})
+     * using message transports appropriate for each address. Message addresses are checked during submission,
+     * but there is no guarantee that the ultimate address is valid or that the message will ever be delivered.
+     * <p/>
+     * {@link Message#saveChanges()} will be called before the message is actually sent.
+     *
+     * @param message the message to send
+     * @throws MessagingException if there was a problem sending the message
+     */
+    public static void send(final Message message) throws MessagingException {
+        send(message, message.getAllRecipients());
+    }
+
+    /**
+     * Send a message to all addresses provided irrespective of any recipients contained in the message, 
+     * using message transports appropriate for each address. Message addresses are checked during submission,
+     * but there is no guarantee that the ultimate address is valid or that the message will ever be delivered.
+     * <p/>
+     * {@link Message#saveChanges()} will be called before the message is actually sent.
+     *
+     * @param message   the message to send
+     * @param addresses the addesses to send to
+     * @throws MessagingException if there was a problem sending the message
+     */
+    public static void send(final Message message, final Address[] addresses) throws MessagingException {
+        sendInternal(message, addresses, null, null);
+    }
+    
+    
+    private static void sendInternal(final Message message, final Address[] addresses, final String user, final String password) throws MessagingException {
+        
+        if (addresses == null || addresses.length == 0) {
+            throw new SendFailedException("No recipient addresses");
+        }
+        
+        final Session session = message.session;
+        final Map<Transport, List<Address>> msgsByTransport = new HashMap<Transport, List<Address>>();
+        for (int i = 0; i < addresses.length; i++) {
+            final Address address = addresses[i];
+            final Transport transport = session.getTransport(address);
+            List<Address> addrs = msgsByTransport.get(transport);
+            if (addrs == null) {
+                addrs = new ArrayList<Address>();
+                msgsByTransport.put(transport, addrs);
+            }
+            addrs.add(address);
+        }
+
+        message.saveChanges();
+
+        // Since we might be sending to multiple protocols, we need to catch and process each exception
+        // when we send and then throw a new SendFailedException when everything is done.  Unfortunately, this
+        // also means unwrapping the information in any SendFailedExceptions we receive and building
+        // composite failed list.
+        MessagingException chainedException = null;
+        final List<Address> sentAddresses = new ArrayList<Address>();
+        final List<Address> unsentAddresses = new ArrayList<Address>();
+        final List<Address> invalidAddresses = new ArrayList<Address>();
+
+
+        for (final Iterator<Entry<Transport, List<Address>>> i = msgsByTransport.entrySet().iterator(); i.hasNext();) {
+            final Entry<Transport, List<Address>> entry = i.next();
+            final Transport transport = entry.getKey();
+            final List<Address> addrs = entry.getValue();
+            try {
+                // we MUST connect to the transport before attempting to send.
+                if(user != null) {
+                    transport.connect(user, password);
+                } else {
+                    transport.connect();
+                }
+                transport.sendMessage(message, addrs.toArray(new Address[addrs.size()]));
+                // if we have to throw an exception because of another failure, these addresses need to
+                // be in the valid list.  Since we succeeded here, we can add these now.
+                sentAddresses.addAll(addrs);
+            } catch (final SendFailedException e) {
+                // a true send failure.  The exception contains a wealth of information about
+                // the failures, including a potential chain of exceptions explaining what went wrong.  We're
+                // going to send a new one of these, so we need to merge the information.
+
+                // add this to our exception chain
+                if (chainedException == null) {
+                    chainedException = e;
+                }
+                else {
+                    chainedException.setNextException(e);
+                }
+
+                // now extract each of the address categories from
+                Address[] exAddrs = e.getValidSentAddresses();
+                if (exAddrs != null) {
+                    for (int j = 0; j < exAddrs.length; j++) {
+                        sentAddresses.add(exAddrs[j]);
+                    }
+                }
+
+                exAddrs = e.getValidUnsentAddresses();
+                if (exAddrs != null) {
+                    for (int j = 0; j < exAddrs.length; j++) {
+                        unsentAddresses.add(exAddrs[j]);
+                    }
+                }
+
+                exAddrs = e.getInvalidAddresses();
+                if (exAddrs != null) {
+                    for (int j = 0; j < exAddrs.length; j++) {
+                        invalidAddresses.add(exAddrs[j]);
+                    }
+                }
+
+            } catch (final MessagingException e) {
+                // add this to our exception chain
+                if (chainedException == null) {
+                    chainedException = e;
+                }
+                else {
+                    chainedException.setNextException(e);
+                }
+            }
+            finally {
+                transport.close();
+            }
+        }
+
+        // if we have an exception chain then we need to throw a new exception giving the failure
+        // information.
+        if (chainedException != null) {
+            // if we're only sending to a single transport (common), and we received a SendFailedException
+            // as a result, then we have a fully formed exception already.  Rather than wrap this in another
+            // exception, we can just rethrow the one we have.
+            if (msgsByTransport.size() == 1 && chainedException instanceof SendFailedException) {
+                throw chainedException;
+            }
+
+            // create our lists for notification and exception reporting from this point on.
+            final Address[] sent = sentAddresses.toArray(new Address[0]);
+            final Address[] unsent = unsentAddresses.toArray(new Address[0]);
+            final Address[] invalid = invalidAddresses.toArray(new Address[0]);
+
+            throw new SendFailedException("Send failure", chainedException, sent, unsent, invalid);
+        }
+    }
+
+    
+    /**
+     * Send a message.  The message will be sent to all recipient
+     * addresses specified in the message (as returned from the
+     * Message method getAllRecipients).
+     * The send method calls the saveChanges
+     * method on the message before sending it. 
+     *
+     * Use the specified user name and password to authenticate to
+     * the mail server.
+     *
+     * @param   msg the message to send
+     * @param   user    the user name
+     * @param   password this user's password
+     * @exception   SendFailedException if the message could not
+     *          be sent to some or any of the recipients.
+     * @exception   MessagingException
+     * @see     Message#saveChanges
+     * @see             #send(Message)
+     * @see     javax.mail.SendFailedException
+     * @since       JavaMail 1.5
+     */
+    public static void send(final Message msg,
+        final String user, final String password) throws MessagingException {
+        
+        send(msg, msg.getAllRecipients(), user, password);
+    }
+
+    /**
+     * Send the message to the specified addresses, ignoring any
+     * recipients specified in the message itself. The
+     * send method calls the saveChanges
+     * method on the message before sending it. 
+     *
+     * Use the specified user name and password to authenticate to
+     * the mail server.
+     *
+     * @param   msg the message to send
+     * @param   addresses the addresses to which to send the message
+     * @param   user    the user name
+     * @param   password this user's password
+     * @exception   SendFailedException if the message could not
+     *          be sent to some or any of the recipients.
+     * @exception   MessagingException
+     * @see     Message#saveChanges
+     * @see             #send(Message)
+     * @see     javax.mail.SendFailedException
+     * @since       JavaMail 1.5
+     */
+    public static void send(final Message msg, final Address[] addresses,
+        final String user, final String password) throws MessagingException {
+        
+        sendInternal(msg, addresses, user, password);
+    
+    }
+    
+    
+    /**
+     * Constructor taking Session and URLName parameters required for {@link Service#Service(Session, URLName)}.
+     *
+     * @param session the Session this transport is for
+     * @param name    the location this transport is for
+     */
+    public Transport(final Session session, final URLName name) {
+        super(session, name);
+    }
+
+    /**
+     * Send a message to the supplied addresses using this transport; if any of the addresses are
+     * invalid then a {@link SendFailedException} is thrown. Whether the message is actually sent
+     * to any of the addresses is undefined.
+     * <p/>
+     * Unlike the static {@link #send(Message, Address[])} method, {@link Message#saveChanges()} is
+     * not called. A {@link TransportEvent} will be sent to registered listeners once the delivery
+     * attempt has been made.
+     *
+     * @param message   the message to send
+     * @param addresses list of addresses to send it to
+     * @throws SendFailedException if the send failed
+     * @throws MessagingException  if there was a problem sending the message
+     */
+    public abstract void sendMessage(Message message, Address[] addresses) throws MessagingException;
+
+    private final Vector<TransportListener> transportListeners = new Vector<TransportListener>();
+
+    public void addTransportListener(final TransportListener listener) {
+        transportListeners.add(listener);
+    }
+
+    public void removeTransportListener(final TransportListener listener) {
+        transportListeners.remove(listener);
+    }
+
+    protected void notifyTransportListeners(final int type, final Address[] validSent, final Address[] validUnsent, final Address[] invalid, final Message message) {
+        queueEvent(new TransportEvent(this, type, validSent, validUnsent, invalid, message), transportListeners);
+    }
+}                                                                                            

Added: geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/UIDFolder.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/UIDFolder.java?rev=1620683&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/UIDFolder.java (added)
+++ geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/UIDFolder.java Tue Aug 26 18:17:06 2014
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 javax.mail;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface UIDFolder {
+    /**
+     * A special value than can be passed as the <code>end</code> parameter to
+     * {@link Folder#getMessages(int, int)} to indicate the last message in this folder.
+     */
+    public static final long LASTUID = -1;
+
+    /**
+     * Get the UID validity value for this Folder.
+     * 
+     * @return The current UID validity value, as a long. 
+     * @exception MessagingException
+     */
+    public abstract long getUIDValidity() throws MessagingException;
+
+    /**
+     * Retrieve a message using the UID rather than the 
+     * message sequence number.  Returns null if the message
+     * doesn't exist.
+     * 
+     * @param uid    The target UID.
+     * 
+     * @return the Message object.  Returns null if the message does
+     *         not exist.
+     * @exception MessagingException
+     */
+    public abstract Message getMessageByUID(long uid)
+            throws MessagingException;
+
+    /**
+     * Get a series of messages using a UID range.  The 
+     * special value LASTUID can be used to mark the 
+     * last available message.
+     * 
+     * @param start  The start of the UID range.
+     * @param end    The end of the UID range.  The special value
+     *               LASTUID can be used to request all messages up
+     *               to the last UID.
+     * 
+     * @return An array containing all of the messages in the 
+     *         range.
+     * @exception MessagingException
+     */
+    public abstract Message[] getMessagesByUID(long start, long end)
+            throws MessagingException;
+
+    /**
+     * Retrieve a set of messages by explicit UIDs.  If 
+     * any message in the list does not exist, null 
+     * will be returned for the corresponding item.
+     * 
+     * @param ids    An array of UID values to be retrieved.
+     * 
+     * @return An array of Message items the same size as the ids
+     *         argument array.  This array will contain null
+     *         entries for any UIDs that do not exist.
+     * @exception MessagingException
+     */
+    public abstract Message[] getMessagesByUID(long[] ids)
+            throws MessagingException;
+
+    /**
+     * Retrieve the UID for a message from this Folder.
+     * The argument Message MUST belong to this Folder
+     * instance, otherwise a NoSuchElementException will 
+     * be thrown.
+     * 
+     * @param message The target message.
+     * 
+     * @return The UID associated with this message.
+     * @exception MessagingException
+     */
+    public abstract long getUID(Message message) throws MessagingException;
+
+    /**
+     * Special profile item used for fetching UID information.
+     */
+    public static class FetchProfileItem extends FetchProfile.Item {
+        public static final FetchProfileItem UID = new FetchProfileItem("UID");
+
+        protected FetchProfileItem(final String name) {
+            super(name);
+        }
+    }
+}

Added: geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/URLName.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/URLName.java?rev=1620683&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/URLName.java (added)
+++ geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/URLName.java Tue Aug 26 18:17:06 2014
@@ -0,0 +1,323 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 javax.mail;
+
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class URLName {
+    private static final String nonEncodedChars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-.*";
+    
+    private String file;
+    private String host;
+    private String password;
+    private int port;
+    private String protocol;
+    private String ref;
+    private String username;
+    protected String fullURL;
+    private int hashCode;
+
+    public URLName(final String url) {
+        parseString(url);
+    }
+
+    protected void parseString(final String url) {
+        URI uri;
+        try {
+            if (url == null) {
+                uri = null;
+            } else {
+                uri = new URI(url);
+            }
+        } catch (final URISyntaxException e) {
+            uri = null;
+        }
+        if (uri == null) {
+            protocol = null;
+            host = null;
+            port = -1;
+            file = null;
+            ref = null;
+            username = null;
+            password = null;
+            return;
+        }
+
+        protocol = checkBlank(uri.getScheme());
+        host = checkBlank(uri.getHost());
+        port = uri.getPort();
+        file = checkBlank(uri.getPath());
+        // if the file starts with "/", we need to strip that off. 
+        // URL and URLName do not have the same behavior when it comes 
+        // to keeping that there. 
+        if (file != null && file.length() > 1 && file.startsWith("/")) {
+            file = checkBlank(file.substring(1)); 
+        }
+        
+        ref = checkBlank(uri.getFragment());
+        final String userInfo = checkBlank(uri.getUserInfo());
+        if (userInfo == null) {
+            username = null;
+            password = null;
+        } else {
+            final int pos = userInfo.indexOf(':');
+            if (pos == -1) {
+                username = userInfo;
+                password = null;
+            } else {
+                username = userInfo.substring(0, pos);
+                password = userInfo.substring(pos + 1);
+            }
+        }
+        updateFullURL();
+    }
+
+    public URLName(final String protocol, final String host, final int port, final String file, String username, String password) {
+        this.protocol = checkBlank(protocol);
+        this.host = checkBlank(host);
+        this.port = port;
+        if (file == null || file.length() == 0) {
+            this.file = null;
+            ref = null;
+        } else {
+            final int pos = file.indexOf('#');
+            if (pos == -1) {
+                this.file = file;
+                ref = null;
+            } else {
+                this.file = file.substring(0, pos);
+                ref = file.substring(pos + 1);
+            }
+        }
+        this.username = checkBlank(username);
+        if (this.username != null) {
+            this.password = checkBlank(password);
+        } else {
+            this.password = null;
+        }
+        username = encode(username); 
+        password = encode(password); 
+        updateFullURL();
+    }
+
+    public URLName(final URL url) {
+        protocol = checkBlank(url.getProtocol());
+        host = checkBlank(url.getHost());
+        port = url.getPort();
+        file = checkBlank(url.getFile());
+        ref = checkBlank(url.getRef());
+        final String userInfo = checkBlank(url.getUserInfo());
+        if (userInfo == null) {
+            username = null;
+            password = null;
+        } else {
+            final int pos = userInfo.indexOf(':');
+            if (pos == -1) {
+                username = userInfo;
+                password = null;
+            } else {
+                username = userInfo.substring(0, pos);
+                password = userInfo.substring(pos + 1);
+            }
+        }
+        updateFullURL();
+    }
+
+    private static String checkBlank(final String target) {
+        if (target == null || target.length() == 0) {
+            return null;
+        } else {
+            return target;
+        }
+    }
+
+    private void updateFullURL() {
+        hashCode = 0;
+        final StringBuffer buf = new StringBuffer(100);
+        if (protocol != null) {
+            buf.append(protocol).append(':');
+            if (host != null) {
+                buf.append("//");
+                if (username != null) {
+                    buf.append(encode(username));
+                    if (password != null) {
+                        buf.append(':').append(encode(password));
+                    }
+                    buf.append('@');
+                }
+                buf.append(host);
+                if (port != -1) {
+                    buf.append(':').append(port);
+                }
+                if (file != null) {
+                    buf.append('/').append(file);
+                }
+                hashCode = buf.toString().hashCode();
+                if (ref != null) {
+                    buf.append('#').append(ref);
+                }
+            }
+        }
+        fullURL = buf.toString();
+    }
+
+    @Override
+    public boolean equals(final Object o) {
+        if(this == o) {
+        	return true;
+        }
+    	
+    	if (o instanceof URLName == false) {
+            return false;
+        }
+        final URLName other = (URLName) o;
+        // check same protocol - false if either is null
+        if (protocol == null || other.protocol == null || !protocol.equals(other.protocol)) {
+            return false;
+        }
+
+        if (port != other.port) {
+            return false;
+        }
+
+        // check host - false if not (both null or both equal)
+        return areSame(host, other.host) && areSame(file, other.file) && areSame(username, other.username) && areSame(password, other.password);
+    }
+
+    private static boolean areSame(final String s1, final String s2) {
+        if (s1 == null) {
+            return s2 == null;
+        } else {
+            return s1.equals(s2);
+        }
+    }
+
+    @Override
+    public int hashCode() {
+        return hashCode;
+    }
+
+    @Override
+    public String toString() {
+        return fullURL;
+    }
+
+    public String getFile() {
+        return file;
+    }
+
+    public String getHost() {
+        return host;
+    }
+
+    public String getPassword() {
+        return password;
+    }
+
+    public int getPort() {
+        return port;
+    }
+
+    public String getProtocol() {
+        return protocol;
+    }
+
+    public String getRef() {
+        return ref;
+    }
+
+    public URL getURL() throws MalformedURLException {
+        return new URL(fullURL);
+    }
+
+    public String getUsername() {
+        return username;
+    }
+    
+    /**
+     * Perform an HTTP encoding to the username and 
+     * password elements of the URLName.  
+     * 
+     * @param v      The input (uncoded) string.
+     * 
+     * @return The HTTP encoded version of the string. 
+     */
+    private static String encode(final String v) {
+        // make sure we don't operate on a null string
+        if (v == null) {
+            return null; 
+        }
+        boolean needsEncoding = false; 
+        for (int i = 0; i < v.length(); i++) {
+            // not in the list of things that don't need encoding?
+            if (nonEncodedChars.indexOf(v.charAt(i)) == -1) {
+                // got to do this the hard way
+                needsEncoding = true; 
+                break; 
+            }
+        }
+        // just fine the way it is. 
+        if (!needsEncoding) {
+            return v; 
+        }
+        
+        // we know we're going to be larger, but not sure by how much.  
+        // just give a little extra
+        final StringBuffer encoded = new StringBuffer(v.length() + 10);
+            
+        // we get the bytes so that we can have the default encoding applied to 
+        // this string.  This will flag the ones we need to give special processing to. 
+        final byte[] data = v.getBytes(); 
+        
+        for (int i = 0; i < data.length; i++) {
+            // pick this up as a one-byte character The 7-bit ascii ones will be fine 
+            // here. 
+            final char ch = (char)(data[i] & 0xff); 
+            // blanks get special treatment 
+            if (ch == ' ') {
+                encoded.append('+'); 
+            }
+            // not in the list of things that don't need encoding?
+            else if (nonEncodedChars.indexOf(ch) == -1) {
+                // forDigit() uses the lowercase letters for the radix.  The HTML specifications 
+                // require the uppercase letters. 
+                final char firstChar = Character.toUpperCase(Character.forDigit((ch >> 4) & 0xf, 16)); 
+                final char secondChar = Character.toUpperCase(Character.forDigit(ch & 0xf, 16)); 
+                
+                // now append the encoded triplet. 
+                encoded.append('%'); 
+                encoded.append(firstChar); 
+                encoded.append(secondChar); 
+            }
+            else {
+                // just add this one to the buffer 
+                encoded.append(ch); 
+            }
+        }
+        // convert to string form. 
+        return encoded.toString(); 
+    }
+}

Added: geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/ConnectionAdapter.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/ConnectionAdapter.java?rev=1620683&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/ConnectionAdapter.java (added)
+++ geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/ConnectionAdapter.java Tue Aug 26 18:17:06 2014
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 javax.mail.event;
+
+/**
+ * An adaptor that receives connection events.
+ * This is a default implementation where the handlers perform no action.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class ConnectionAdapter implements ConnectionListener {
+    public void closed(final ConnectionEvent event) {
+    }
+
+    public void disconnected(final ConnectionEvent event) {
+    }
+
+    public void opened(final ConnectionEvent event) {
+    }
+}

Added: geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/ConnectionEvent.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/ConnectionEvent.java?rev=1620683&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/ConnectionEvent.java (added)
+++ geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/ConnectionEvent.java Tue Aug 26 18:17:06 2014
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 javax.mail.event;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ConnectionEvent extends MailEvent {
+	
+	private static final long serialVersionUID = -1855480171284792957L;
+	
+    /**
+     * A connection was opened.
+     */
+    public static final int OPENED = 1;
+
+    /**
+     * A connection was disconnected.
+     */
+    public static final int DISCONNECTED = 2;
+
+    /**
+     * A connection was closed.
+     */
+    public static final int CLOSED = 3;
+
+    protected int type;
+
+    public ConnectionEvent(final Object source, final int type) {
+        super(source);
+        this.type = type;
+    }
+
+    public int getType() {
+        return type;
+    }
+
+    @Override
+    public void dispatch(final Object listener) {
+        // assume that it is the right listener type
+        final ConnectionListener l = (ConnectionListener) listener;
+        switch (type) {
+        case OPENED:
+            l.opened(this);
+            break;
+        case DISCONNECTED:
+            l.disconnected(this);
+            break;
+        case CLOSED:
+            l.closed(this);
+            break;
+        default:
+            throw new IllegalArgumentException("Invalid type " + type);
+        }
+    }
+}

Added: geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/ConnectionListener.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/ConnectionListener.java?rev=1620683&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/ConnectionListener.java (added)
+++ geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/ConnectionListener.java Tue Aug 26 18:17:06 2014
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 javax.mail.event;
+
+import java.util.EventListener;
+
+/**
+ * Listener for handling connection events.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ConnectionListener extends EventListener {
+    /**
+     * Called when a connection is opened.
+     */
+    public abstract void opened(ConnectionEvent event);
+
+    /**
+     * Called when a connection is disconnected.
+     */
+    public abstract void disconnected(ConnectionEvent event);
+
+    /**
+     * Called when a connection is closed.
+     */
+    public abstract void closed(ConnectionEvent event);
+}

Added: geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/FolderAdapter.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/FolderAdapter.java?rev=1620683&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/FolderAdapter.java (added)
+++ geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/FolderAdapter.java Tue Aug 26 18:17:06 2014
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 javax.mail.event;
+
+/**
+ * An adaptor that receives connection events.
+ * This is a default implementation where the handlers perform no action.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class FolderAdapter implements FolderListener {
+    public void folderCreated(final FolderEvent event) {
+    }
+
+    public void folderDeleted(final FolderEvent event) {
+    }
+
+    public void folderRenamed(final FolderEvent event) {
+    }
+}

Added: geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/FolderEvent.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/FolderEvent.java?rev=1620683&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/FolderEvent.java (added)
+++ geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/FolderEvent.java Tue Aug 26 18:17:06 2014
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 javax.mail.event;
+
+import javax.mail.Folder;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class FolderEvent extends MailEvent {
+	
+	private static final long serialVersionUID = 5278131310563694307L;
+	
+    public static final int CREATED = 1;
+    public static final int DELETED = 2;
+    public static final int RENAMED = 3;
+
+    protected transient Folder folder;
+    protected transient Folder newFolder;
+    protected int type;
+
+    /**
+     * Constructor used for RENAMED events.
+     *
+     * @param source the source of the event
+     * @param oldFolder the folder that was renamed
+     * @param newFolder the folder with the new name
+     * @param type the event type
+     */
+    public FolderEvent(final Object source, final Folder oldFolder, final Folder newFolder, final int type) {
+        super(source);
+        folder = oldFolder;
+        this.newFolder = newFolder;
+        this.type = type;
+    }
+
+    /**
+     * Constructor other events.
+     *
+     * @param source the source of the event
+     * @param folder the folder affected
+     * @param type the event type
+     */
+    public FolderEvent(final Object source, final Folder folder, final int type) {
+        this(source, folder, null, type);
+    }
+
+    @Override
+    public void dispatch(final Object listener) {
+        final FolderListener l = (FolderListener) listener;
+        switch (type) {
+        case CREATED:
+            l.folderCreated(this);
+            break;
+        case DELETED:
+            l.folderDeleted(this);
+            break;
+        case RENAMED:
+            l.folderRenamed(this);
+            break;
+        default:
+            throw new IllegalArgumentException("Invalid type " + type);
+        }
+    }
+
+    /**
+     * Return the affected folder.
+     * @return the affected folder
+     */
+    public Folder getFolder() {
+        return folder;
+    }
+
+    /**
+     * Return the new folder; only applicable to RENAMED events.
+     * @return the new folder
+     */
+    public Folder getNewFolder() {
+        return newFolder;
+    }
+
+    /**
+     * Return the event type.
+     * @return the event type
+     */
+    public int getType() {
+        return type;
+    }
+}

Added: geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/FolderListener.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/FolderListener.java?rev=1620683&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/FolderListener.java (added)
+++ geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/FolderListener.java Tue Aug 26 18:17:06 2014
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 javax.mail.event;
+
+import java.util.EventListener;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface FolderListener extends EventListener {
+    public abstract void folderCreated(FolderEvent event);
+
+    public abstract void folderDeleted(FolderEvent event);
+
+    public abstract void folderRenamed(FolderEvent event);
+}

Added: geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/MailEvent.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/MailEvent.java?rev=1620683&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/MailEvent.java (added)
+++ geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/MailEvent.java Tue Aug 26 18:17:06 2014
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 javax.mail.event;
+
+import java.util.EventObject;
+
+/**
+ * Common base class for mail events.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class MailEvent extends EventObject {
+	
+	private static final long serialVersionUID = 1846275636325456631L;
+	
+    public MailEvent(final Object source) {
+        super(source);
+    }
+
+    public abstract void dispatch(Object listener);
+}

Added: geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/MessageChangedEvent.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/MessageChangedEvent.java?rev=1620683&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/MessageChangedEvent.java (added)
+++ geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/MessageChangedEvent.java Tue Aug 26 18:17:06 2014
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 javax.mail.event;
+
+import javax.mail.Message;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class MessageChangedEvent extends MailEvent {
+	
+	private static final long serialVersionUID = -4974972972105535108L;
+	
+    /**
+     * The message's flags changed.
+     */
+    public static final int FLAGS_CHANGED = 1;
+
+    /**
+     * The messages envelope changed.
+     */
+    public static final int ENVELOPE_CHANGED = 2;
+
+    protected transient Message msg;
+    protected int type;
+
+    /**
+     * Constructor.
+     *
+     * @param source the folder that owns the message
+     * @param type the event type
+     * @param message the affected message
+     */
+    public MessageChangedEvent(final Object source, final int type, final Message message) {
+        super(source);
+        msg = message;
+        this.type = type;
+    }
+
+    @Override
+    public void dispatch(final Object listener) {
+        final MessageChangedListener l = (MessageChangedListener) listener;
+        l.messageChanged(this);
+    }
+
+    /**
+     * Return the affected message.
+     * @return the affected message
+     */
+    public Message getMessage() {
+        return msg;
+    }
+
+    /**
+     * Return the type of change.
+     * @return the event type
+     */
+    public int getMessageChangeType() {
+        return type;
+    }
+}

Added: geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/MessageChangedListener.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/MessageChangedListener.java?rev=1620683&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/MessageChangedListener.java (added)
+++ geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/MessageChangedListener.java Tue Aug 26 18:17:06 2014
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 javax.mail.event;
+
+import java.util.EventListener;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface MessageChangedListener extends EventListener {
+    public abstract void messageChanged(MessageChangedEvent event);
+}

Added: geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/MessageCountAdapter.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/MessageCountAdapter.java?rev=1620683&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/MessageCountAdapter.java (added)
+++ geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/MessageCountAdapter.java Tue Aug 26 18:17:06 2014
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 javax.mail.event;
+
+/**
+ * An adaptor that receives message count events.
+ * This is a default implementation where the handlers perform no action.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class MessageCountAdapter implements MessageCountListener {
+    public void messagesAdded(final MessageCountEvent event) {
+    }
+
+    public void messagesRemoved(final MessageCountEvent event) {
+    }
+}

Added: geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/MessageCountEvent.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/MessageCountEvent.java?rev=1620683&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/MessageCountEvent.java (added)
+++ geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/MessageCountEvent.java Tue Aug 26 18:17:06 2014
@@ -0,0 +1,116 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 javax.mail.event;
+
+import javax.mail.Folder;
+import javax.mail.Message;
+
+/**
+ * Event indicating a change in the number of messages in a folder.
+ *
+ * @version $Rev$ $Date$
+ */
+public class MessageCountEvent extends MailEvent {
+	
+	private static final long serialVersionUID = -7447022340837897369L;
+	
+    /**
+     * Messages were added to the folder.
+     */
+    public static final int ADDED = 1;
+
+    /**
+     * Messages were removed from the folder.
+     */
+    public static final int REMOVED = 2;
+
+    /**
+     * The affected messages.
+     */
+    protected transient Message msgs[];
+
+    /**
+     * The event type.
+     */
+    protected int type;
+
+    /**
+     * If true, then messages were expunged from the folder by this client
+     * and message numbers reflect the deletion; if false, then the change
+     * was the result of an expunge by a different client.
+     */
+    protected boolean removed;
+
+    /**
+     * Construct a new event.
+     *
+     * @param folder   the folder containing the messages
+     * @param type     the event type
+     * @param removed  indicator of whether messages were expunged by this client
+     * @param messages the affected messages
+     */
+    public MessageCountEvent(final Folder folder, final int type, final boolean removed, final Message messages[]) {
+        super(folder);
+        this.msgs = messages;
+        this.type = type;
+        this.removed = removed;
+    }
+
+    /**
+     * Return the event type.
+     *
+     * @return the event type
+     */
+    public int getType() {
+        return type;
+    }
+
+    /**
+     * @return whether this event was the result of an expunge by this client
+     * @see MessageCountEvent#removed
+     */
+    public boolean isRemoved() {
+        return removed;
+    }
+
+    /**
+     * Return the affected messages.
+     *
+     * @return the affected messages
+     */
+    public Message[] getMessages() {
+        return msgs;
+    }
+
+    @Override
+    public void dispatch(final Object listener) {
+        final MessageCountListener l = (MessageCountListener) listener;
+        switch (type) {
+        case ADDED:
+            l.messagesAdded(this);
+            break;
+        case REMOVED:
+            l.messagesRemoved(this);
+            break;
+        default:
+            throw new IllegalArgumentException("Invalid type " + type);
+        }
+    }
+}

Added: geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/MessageCountListener.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/MessageCountListener.java?rev=1620683&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/MessageCountListener.java (added)
+++ geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/MessageCountListener.java Tue Aug 26 18:17:06 2014
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 javax.mail.event;
+
+import java.util.EventListener;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface MessageCountListener extends EventListener {
+    public abstract void messagesAdded(MessageCountEvent event);
+
+    public abstract void messagesRemoved(MessageCountEvent event);
+}

Added: geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/StoreEvent.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/StoreEvent.java?rev=1620683&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/StoreEvent.java (added)
+++ geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/StoreEvent.java Tue Aug 26 18:17:06 2014
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 javax.mail.event;
+
+import javax.mail.Store;
+
+/**
+ * Event representing motifications from the Store connection.
+ *
+ * @version $Rev$ $Date$
+ */
+public class StoreEvent extends MailEvent {
+	
+	private static final long serialVersionUID = 1938704919992515330L;
+	
+    /**
+     * Indicates that this message is an alert.
+     */
+    public static final int ALERT = 1;
+
+    /**
+     * Indicates that this message is a notice.
+     */
+    public static final int NOTICE = 2;
+
+    /**
+     * The message type.
+     */
+    protected int type;
+
+    /**
+     * The text to be presented to the user.
+     */
+    protected String message;
+
+    /**
+     * Construct a new event.
+     *
+     * @param store   the Store that initiated the notification
+     * @param type    the message type
+     * @param message the text to be presented to the user
+     */
+    public StoreEvent(final Store store, final int type, final String message) {
+        super(store);
+        this.type = type;
+        this.message = message;
+    }
+
+    /**
+     * Return the message type.
+     *
+     * @return the message type
+     */
+    public int getMessageType() {
+        return type;
+    }
+
+    /**
+     * Return the text to be displayed to the user.
+     *
+     * @return the text to be displayed to the user
+     */
+    public String getMessage() {
+        return message;
+    }
+
+    @Override
+    public void dispatch(final Object listener) {
+        ((StoreListener) listener).notification(this);
+    }
+}

Added: geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/StoreListener.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/StoreListener.java?rev=1620683&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/StoreListener.java (added)
+++ geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/StoreListener.java Tue Aug 26 18:17:06 2014
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 javax.mail.event;
+
+import java.util.EventListener;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface StoreListener extends EventListener {
+    public abstract void notification(StoreEvent event);
+}

Added: geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/TransportAdapter.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/TransportAdapter.java?rev=1620683&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/TransportAdapter.java (added)
+++ geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/TransportAdapter.java Tue Aug 26 18:17:06 2014
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 javax.mail.event;
+
+/**
+ * An adaptor that receives transport events.
+ * This is a default implementation where the handlers perform no action.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class TransportAdapter implements TransportListener {
+    public void messageDelivered(final TransportEvent event) {
+    }
+
+    public void messageNotDelivered(final TransportEvent event) {
+    }
+
+    public void messagePartiallyDelivered(final TransportEvent event) {
+    }
+}

Added: geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/TransportEvent.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/TransportEvent.java?rev=1620683&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/TransportEvent.java (added)
+++ geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/TransportEvent.java Tue Aug 26 18:17:06 2014
@@ -0,0 +1,131 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 javax.mail.event;
+
+import javax.mail.Address;
+import javax.mail.Message;
+import javax.mail.Transport;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class TransportEvent extends MailEvent {
+	
+	private static final long serialVersionUID = -4729852364684273073L;
+	
+    /**
+     * Indicates that the message has successfully been delivered to all
+     * recipients.
+     */
+    public static final int MESSAGE_DELIVERED = 1;
+
+    /**
+     * Indicates that no messages could be delivered.
+     */
+    public static final int MESSAGE_NOT_DELIVERED = 2;
+
+    /**
+     * Indicates that some of the messages were successfully delivered
+     * but that some failed.
+     */
+    public static final int MESSAGE_PARTIALLY_DELIVERED = 3;
+
+    /**
+     * The event type.
+     */
+    protected int type;
+
+    /**
+     * Addresses to which the message was successfully delivered.
+     */
+    protected transient Address[] validSent;
+
+    /**
+     * Addresses which are valid but to which the message was not sent.
+     */
+    protected transient Address[] validUnsent;
+
+    /**
+     * Addresses that are invalid.
+     */
+    protected transient Address[] invalid;
+
+    /**
+     * The message associated with this event.
+     */
+    protected transient Message msg;
+
+    /**
+     * Construct a new event,
+     *
+     * @param transport   the transport attempting to deliver the message
+     * @param type        the event type
+     * @param validSent   addresses to which the message was successfully delivered
+     * @param validUnsent addresses which are valid but to which the message was not sent
+     * @param invalid     invalid addresses
+     * @param message     the associated message
+     */
+    public TransportEvent(final Transport transport, final int type, final Address[] validSent, final Address[] validUnsent, final Address[] invalid, final Message message) {
+        super(transport);
+        this.type = type;
+        this.validSent = validSent;
+        this.validUnsent = validUnsent;
+        this.invalid = invalid;
+        this.msg = message;
+    }
+
+    public Address[] getValidSentAddresses() {
+        return validSent;
+    }
+
+    public Address[] getValidUnsentAddresses() {
+        return validUnsent;
+    }
+
+    public Address[] getInvalidAddresses() {
+        return invalid;
+    }
+
+    public Message getMessage() {
+        return msg;
+    }
+
+    public int getType() {
+        return type;
+    }
+
+    @Override
+    public void dispatch(final Object listener) {
+        final TransportListener l = (TransportListener) listener;
+        switch (type) {
+        case MESSAGE_DELIVERED:
+            l.messageDelivered(this);
+            break;
+        case MESSAGE_NOT_DELIVERED:
+            l.messageNotDelivered(this);
+            break;
+        case MESSAGE_PARTIALLY_DELIVERED:
+            l.messagePartiallyDelivered(this);
+            break;
+        default:
+            throw new IllegalArgumentException("Invalid type " + type);
+        }
+    }
+}

Added: geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/TransportListener.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/TransportListener.java?rev=1620683&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/TransportListener.java (added)
+++ geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/event/TransportListener.java Tue Aug 26 18:17:06 2014
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 javax.mail.event;
+
+import java.util.EventListener;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface TransportListener extends EventListener {
+    public abstract void messageDelivered(TransportEvent event);
+
+    public abstract void messageNotDelivered(TransportEvent event);
+
+    public abstract void messagePartiallyDelivered(TransportEvent event);
+}

Added: geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/internet/AddressException.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/internet/AddressException.java?rev=1620683&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/internet/AddressException.java (added)
+++ geronimo/specs/trunk/geronimo-javamail_1.5_spec/src/main/java/javax/mail/internet/AddressException.java Tue Aug 26 18:17:06 2014
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 javax.mail.internet;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class AddressException extends ParseException {
+	
+	private static final long serialVersionUID = 9134583443539323120L;
+	
+    protected int pos;
+    protected String ref;
+
+    public AddressException() {
+        this(null);
+    }
+
+    public AddressException(final String message) {
+        this(message, null);
+    }
+
+    public AddressException(final String message, final String ref) {
+        this(message, null, -1);
+    }
+
+    public AddressException(final String message, final String ref, final int pos) {
+        super(message);
+        this.ref = ref;
+        this.pos = pos;
+    }
+
+    public String getRef() {
+        return ref;
+    }
+
+    public int getPos() {
+        return pos;
+    }
+
+    @Override
+    public String toString() {
+        return super.toString() + " (" + ref + "," + pos + ")";
+    }
+}