JavaMailSession.java

00001 
00027 package org.objectweb.jonas.mail.factory;
00028 
00029 //import java
00030 import java.util.Properties;
00031 
00032 //import javax
00033 import javax.naming.BinaryRefAddr;
00034 import javax.naming.NamingException;
00035 import javax.naming.Reference;
00036 
00037 //import objectweb.util
00038 import org.objectweb.util.monolog.api.BasicLevel;
00039 
00040 //import jonas
00041 import org.objectweb.jonas.common.PropDump;
00042 import org.objectweb.jonas.common.JNDIUtils;
00043 
00049 public class JavaMailSession extends JavaMail {
00050 
00054     private static final String FACTORY_TYPE = "javax.mail.Session";
00055 
00056 
00063     public JavaMailSession(String factoryName, String name, Properties mailProperties) {
00064         super(factoryName, name, mailProperties);
00065     }
00066 
00071     public String getType() {
00072         return FACTORY_TYPE;
00073     }
00074 
00084     public Reference getReference() throws NamingException {
00085 
00086        //Build the reference to the factory JMailSessionFactory
00087         Reference reference = new Reference(FACTORY_TYPE,
00088                                             "org.objectweb.jonas.mail.factory.JavaMailSessionFactory",
00089                                             null);
00090 
00091         PropDump.print("Here are these properties:", getMailSessionProperties(), getLogger(), BasicLevel.DEBUG);
00092 
00093         //Give the session properties
00094         byte[] bytes = JNDIUtils.getBytesFromObject(getMailSessionProperties());
00095         if (bytes != null) {
00096             reference.add(new BinaryRefAddr("javaxmailSession.properties", bytes));
00097         }
00098 
00099         //Give the authentication properties
00100         bytes = JNDIUtils.getBytesFromObject(getAuthenticationProperties());
00101         if (bytes != null) {
00102             reference.add(new BinaryRefAddr("authentication.properties", bytes));
00103         }
00104 
00105         return reference;
00106 
00107     }
00108 
00109 
00110 }

Generated on Tue Feb 15 15:05:18 2005 for JOnAS by  doxygen 1.3.9.1