1 26 27 package org.objectweb.jonas.mail.factory; 28 29 import java.util.Properties ; 31 32 import javax.naming.BinaryRefAddr ; 34 import javax.naming.NamingException ; 35 import javax.naming.Reference ; 36 37 import org.objectweb.util.monolog.api.BasicLevel; 39 40 import org.objectweb.jonas.common.PropDump; 42 import org.objectweb.jonas.common.JNDIUtils; 43 44 49 public class JavaMailSession extends JavaMail { 50 51 54 private static final String FACTORY_TYPE = "javax.mail.Session"; 55 56 57 63 public JavaMailSession(String factoryName, String name, Properties mailProperties) { 64 super(factoryName, name, mailProperties); 65 } 66 67 71 public String getType() { 72 return FACTORY_TYPE; 73 } 74 75 84 public Reference getReference() throws NamingException { 85 86 Reference reference = new Reference (FACTORY_TYPE, 88 "org.objectweb.jonas.mail.factory.JavaMailSessionFactory", 89 null); 90 if (getLogger().isLoggable(BasicLevel.DEBUG)) { 91 PropDump.print("Here are these properties:", getMailSessionProperties(), getLogger(), BasicLevel.DEBUG); 92 } 93 94 byte[] bytes = JNDIUtils.getBytesFromObject(getMailSessionProperties()); 96 if (bytes != null) { 97 reference.add(new BinaryRefAddr ("javaxmailSession.properties", bytes)); 98 } 99 100 bytes = JNDIUtils.getBytesFromObject(getAuthenticationProperties()); 102 if (bytes != null) { 103 reference.add(new BinaryRefAddr ("authentication.properties", bytes)); 104 } 105 106 return reference; 107 108 } 109 110 111 } 112 | Popular Tags |