org.objectweb.jonas.mail.factory
Class JMail

java.lang.Object
  |
  +--org.objectweb.jonas.mail.factory.JMail
All Implemented Interfaces:
JMailMBean, javax.naming.Referenceable, java.io.Serializable
Direct Known Subclasses:
JMailMimePartDS, JMailSession

public abstract class JMail
extends java.lang.Object
implements java.io.Serializable, javax.naming.Referenceable, JMailMBean

This class implements JOnAS mail factory objects. It gets the properties from mail factory properties file and build a properties object for the Session.

Author:
Florent Benoit, Ludovic Bert Contributor(s): Adriana Danes : Refactor code: rename the management methods (use straightforward names, as they are to be used in a Management Console) Markus Karg : Change the JOnAS mail factory initialisation strategy in order to allow any initialisation parameters for a javax.mail.Session object (not only a known set pf initialisation parameters as before).
See Also:
Serialized Form

Field Summary
protected  java.util.Properties authenticationProperties
          Properties for the authentication.
protected static org.objectweb.util.monolog.api.Logger logger
          The logger used in JOnAS
protected  java.util.Properties mailSessionProperties
          Properties for the javax.mail.Session object.
 
Constructor Summary
JMail(java.lang.String factoryName, java.lang.String name, java.util.Properties mailProperties)
          Constructor of a JMail Object with the given name and properties.
 
Method Summary
 java.lang.String _getFactoryName()
          Return the name of this mail factory
 java.lang.String _getName()
          Return the jndi name of this object
abstract  java.lang.String _getType()
          Return the type of the factory
 java.util.Properties getAuthenticationProperties()
          Get the authentication properties.
protected  byte[] getBytesFromObject(java.lang.Object obj)
          Return an array of byte from a given object
 java.lang.String getFactoryName()
          Get the name of the factory.
 java.lang.String getFactoryType()
          Get the type of the factory.
 java.lang.String getName()
          Get the jndi name of the factory.
abstract  javax.naming.Reference getReference()
          Retrieves the Reference of the object.
 java.util.Properties getSessionProperties()
          Get the session properties.
 void setAuthenticationProperties(java.util.Properties props)
          Set the authentication properties.
 void setName(java.lang.String name)
          Set the jndi name of the factory.
 void setSessionProperties(java.util.Properties props)
          Set the session properties.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static org.objectweb.util.monolog.api.Logger logger
The logger used in JOnAS

mailSessionProperties

protected java.util.Properties mailSessionProperties
Properties for the javax.mail.Session object. Keep only the values used for configuring the javax.mail.Session object.

authenticationProperties

protected java.util.Properties authenticationProperties
Properties for the authentication.
Constructor Detail

JMail

public JMail(java.lang.String factoryName,
             java.lang.String name,
             java.util.Properties mailProperties)
Constructor of a JMail Object with the given name and properties.
Parameters:
factoryName - the name of the factory.
name - the jndi name.
mailProperties - properties for configuring and manageing this object.
Method Detail

_getName

public java.lang.String _getName()
Return the jndi name of this object
Returns:
jndi name of this Jmail.

_getFactoryName

public java.lang.String _getFactoryName()
Return the name of this mail factory
Returns:
name of this mail factory.

_getType

public abstract java.lang.String _getType()
Return the type of the factory
Returns:
the type of the mail factory

getReference

public abstract javax.naming.Reference getReference()
                                             throws javax.naming.NamingException
Retrieves the Reference of the object. The Reference contains the factory used to create this object and the optional parameters used to configure the factory.
Specified by:
getReference in interface javax.naming.Referenceable
Returns:
the non-null Reference of the object.
Throws:
javax.naming.NamingException - if a naming exception was encountered while retrieving the reference.

getBytesFromObject

protected byte[] getBytesFromObject(java.lang.Object obj)
Return an array of byte from a given object
Parameters:
obj - the object from which we must extract the bytes.
Returns:
the byte[] from an object

getFactoryName

public java.lang.String getFactoryName()
Get the name of the factory.
Specified by:
getFactoryName in interface JMailMBean
Returns:
the name of the mail factory (the ressource name as defined in jonas.properties)

getName

public java.lang.String getName()
Get the jndi name of the factory.
Specified by:
getName in interface JMailMBean
Returns:
the jndi name of the mail factory. Should be equal to the one provided in the JOnAS specific Deployment Descriptor of the EJBs using the Mail Service.

setName

public void setName(java.lang.String name)
Set the jndi name of the factory.
Specified by:
setName in interface JMailMBean
Parameters:
jndi - name of the mail factory. Give the name provided in the JOnAS specific Deployment Descriptor of the EJBs using the Mail Service.

getFactoryType

public java.lang.String getFactoryType()
Get the type of the factory.
Specified by:
getFactoryType in interface JMailMBean
Returns:
type of the mail factory.
Throws:
java.rmi.RemoteException - if rmi call failed.

getAuthenticationProperties

public java.util.Properties getAuthenticationProperties()
Get the authentication properties.
Specified by:
getAuthenticationProperties in interface JMailMBean
Returns:
properties of the authentication.

setAuthenticationProperties

public void setAuthenticationProperties(java.util.Properties props)
Set the authentication properties.
Specified by:
setAuthenticationProperties in interface JMailMBean
Parameters:
props - the authentication properties.

getSessionProperties

public java.util.Properties getSessionProperties()
Get the session properties.
Specified by:
getSessionProperties in interface JMailMBean
Returns:
the properties of Session.

setSessionProperties

public void setSessionProperties(java.util.Properties props)
Set the session properties.
Specified by:
setSessionProperties in interface JMailMBean
Parameters:
props - the session properties.