You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by jl...@apache.org on 2006/03/08 18:51:45 UTC

svn commit: r384283 - in /geronimo/specs/trunk/geronimo-spec-javamail/src/main/java: javax/mail/Message.java javax/mail/Service.java org/apache/geronimo/mail/util/SessionUtil.java

Author: jlaskowski
Date: Wed Mar  8 09:51:44 2006
New Revision: 384283

URL: http://svn.apache.org/viewcvs?rev=384283&view=rev
Log:
GERONIMO-1707 java.mail.Message is not initializing the session information with the Folder constructors

Modified:
    geronimo/specs/trunk/geronimo-spec-javamail/src/main/java/javax/mail/Message.java
    geronimo/specs/trunk/geronimo-spec-javamail/src/main/java/javax/mail/Service.java
    geronimo/specs/trunk/geronimo-spec-javamail/src/main/java/org/apache/geronimo/mail/util/SessionUtil.java

Modified: geronimo/specs/trunk/geronimo-spec-javamail/src/main/java/javax/mail/Message.java
URL: http://svn.apache.org/viewcvs/geronimo/specs/trunk/geronimo-spec-javamail/src/main/java/javax/mail/Message.java?rev=384283&r1=384282&r2=384283&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-spec-javamail/src/main/java/javax/mail/Message.java (original)
+++ geronimo/specs/trunk/geronimo-spec-javamail/src/main/java/javax/mail/Message.java Wed Mar  8 09:51:44 2006
@@ -98,6 +98,8 @@
     protected Message(Folder folder, int msgnum) {
         this.folder = folder;
         this.msgnum = msgnum;
+        // make sure we copy the session information from the folder.
+        this.session = folder.getStore().getSession();
     }
 
     /**

Modified: geronimo/specs/trunk/geronimo-spec-javamail/src/main/java/javax/mail/Service.java
URL: http://svn.apache.org/viewcvs/geronimo/specs/trunk/geronimo-spec-javamail/src/main/java/javax/mail/Service.java?rev=384283&r1=384282&r2=384283&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-spec-javamail/src/main/java/javax/mail/Service.java (original)
+++ geronimo/specs/trunk/geronimo-spec-javamail/src/main/java/javax/mail/Service.java Wed Mar  8 09:51:44 2006
@@ -359,4 +359,15 @@
         connectionListeners.clear();
         super.finalize();
     }
+
+
+    /**
+     * Package scope utility method to allow Message instances
+     * access to the Service's session.
+     *
+     * @return The Session the service is associated with.
+     */
+    Session getSession() {
+        return session;
+    }
 }

Modified: geronimo/specs/trunk/geronimo-spec-javamail/src/main/java/org/apache/geronimo/mail/util/SessionUtil.java
URL: http://svn.apache.org/viewcvs/geronimo/specs/trunk/geronimo-spec-javamail/src/main/java/org/apache/geronimo/mail/util/SessionUtil.java?rev=384283&r1=384282&r2=384283&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-spec-javamail/src/main/java/org/apache/geronimo/mail/util/SessionUtil.java (original)
+++ geronimo/specs/trunk/geronimo-spec-javamail/src/main/java/org/apache/geronimo/mail/util/SessionUtil.java Wed Mar  8 09:51:44 2006
@@ -32,13 +32,33 @@
      *
      * @param session The attached session.
      * @param name    The name of the property.
+     *
+     * @return The property value (returns null if the property has not been set).
+     */
+    static public String getProperty(Session session, String name) {
+        // occasionally, we get called with a null session if an object is not attached to
+        // a session.  In that case, treat this like an unknown parameter.
+        if (session == null) {
+            return null;
+        }
+
+        return session.getProperty(name);
+    }
+
+
+    /**
+     * Get a property associated with this mail session.  Returns
+     * the provided default if it doesn't exist.
+     *
+     * @param session The attached session.
+     * @param name    The name of the property.
      * @param defaultValue
      *                The default value to return if the property doesn't exist.
      *
      * @return The property value (returns defaultValue if the property has not been set).
      */
     static public String getProperty(Session session, String name, String defaultValue) {
-        String result = session.getProperty(name);
+        String result = getProperty(session, name);
         if (result == null) {
             return defaultValue;
         }
@@ -57,7 +77,7 @@
      *         other value (including null).
      */
     static public boolean isPropertyTrue(Session session, String name) {
-        String property = session.getProperty(name);
+        String property = getProperty(session, name);
         if (property != null) {
             return property.equals("true");
         }
@@ -75,7 +95,7 @@
      *         other value (including null).
      */
     static public boolean isPropertyFalse(Session session, String name) {
-        String property = session.getProperty(name);
+        String property = getProperty(session, name);
         if (property != null) {
             return property.equals("false");
         }
@@ -94,7 +114,7 @@
      * @return The property value converted to an int.
      */
     static public int getIntProperty(Session session, String name, int defaultValue) {
-        String result = session.getProperty(name);
+        String result = getProperty(session, name);
         if (result != null) {
             try {
                 // convert into an int value.
@@ -119,7 +139,7 @@
      * @return The property value converted to a boolean.
      */
     static public boolean getBooleanProperty(Session session, String name, boolean defaultValue) {
-        String result = session.getProperty(name);
+        String result = getProperty(session, name);
         if (result != null) {
             return Boolean.valueOf(result).booleanValue();
         }