00001
00027 package org.objectweb.jonas.mail.factory;
00028
00029
00030 import java.util.Properties;
00031
00032
00033 import javax.naming.BinaryRefAddr;
00034 import javax.naming.NamingException;
00035 import javax.naming.Reference;
00036
00037
00038 import org.objectweb.util.monolog.api.BasicLevel;
00039
00040
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
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
00094 byte[] bytes = JNDIUtils.getBytesFromObject(getMailSessionProperties());
00095 if (bytes != null) {
00096 reference.add(new BinaryRefAddr("javaxmailSession.properties", bytes));
00097 }
00098
00099
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 }