org.objectweb.jonas.mail
Class MailServiceImpl

java.lang.Object
  extended by javax.management.NotificationBroadcasterSupport
      extended by org.objectweb.jonas.management.ReconfigDispatcher
          extended by org.objectweb.jonas.service.AbsServiceImpl
              extended by org.objectweb.jonas.mail.MailServiceImpl
All Implemented Interfaces:
javax.management.NotificationBroadcaster, javax.management.NotificationEmitter, MailService, MailServiceImplMBean, ReconfigDispatcherMBean, Service

public class MailServiceImpl
extends AbsServiceImpl
implements MailService, MailServiceImplMBean

This class provides an implementation of the javaMail service.

Author:
Florent Benoit, Ludovic Bert Contributor(s): Adriana Danes : - Make possible to change configuration of a JOnAS mail factory object. - Make possible to change the JNDI name of a JOnAS mail factory object.

Field Summary
static java.lang.String CLASS
          Mail service configuration parameters (class)
protected  java.lang.String domainName
           
static java.lang.String FACTORIES
          Mail service configuration parameters (factories)
static java.lang.String MIMEPART_PROPERTY_TYPE
           
static java.lang.String PROPERTY_NAME
          JOnAS-specific properties (name)
static java.lang.String PROPERTY_TYPE
          JOnAS-specific properties (type)
protected  java.lang.String serverName
           
static java.lang.String SESSION_PROPERTY_TYPE
           
 
Fields inherited from class org.objectweb.jonas.management.ReconfigDispatcher
RECONFIG_TYPE, SAVE_RECONFIG_TYPE
 
Constructor Summary
MailServiceImpl()
           
 
Method Summary
 void createMailFactory(java.lang.String factoryName, java.util.Properties props)
          Create a mail factory with the specified properties and register it into the registry.
 void createMailFactoryMBean(java.lang.String name, java.util.Properties props, java.lang.Boolean loadFromFile)
          Create a mail factory with the specified properties and register it into the registry.
protected  void doInit(javax.naming.Context ctx)
          Init the Mail service.
protected  void doStart()
          Start the Mail Service.
protected  void doStop()
          Stop the Mail service.
 java.lang.Integer getCurrentNumberOfMailFactories()
          Gets the total number of mail factories available in JOnAS
 java.lang.Integer getCurrentNumberOfMimeMailFactories()
          Gets the integer Number of internet
 java.lang.Integer getCurrentNumberOfSessionMailFactories()
          Gets the number of Session mail factories available in JOnAS
 java.lang.String getFactoryName(java.lang.String jndiName)
          Gets the factory name given the jndi name.
 java.util.Properties getMailFactoryPropertiesFile(java.lang.String configFile)
          Gets the mail factory configuration properties from a local file
 java.util.List getMailFactoryPropertiesFiles()
          MBean method:
 java.util.List getMimePartMailFactoryPropertiesFiles()
          MBean method:
 java.util.List getSessionMailFactoryPropertiesFiles()
          MBean method:
 void recreateJavaMailFactory(JavaMail factory)
          This method is used when a Mail Factory configuration is modified via jonasAdmin.
 void renameJavaMailFactory(java.lang.String oldName, JavaMail factory)
          This method is used when a particular Mail Factory configuration operation is done via jonasAdmin : when the JNDI name of this resource is modified.
 void unbindMailFactories()
          Unregister all the binding factories on the server and in JMX Server.
 void unbindMailFactoryMBean(java.lang.String factoryName)
          Unregister the factory with the given name.
 
Methods inherited from class org.objectweb.jonas.service.AbsServiceImpl
getDomainName, getJonasServerName, getName, init, isStarted, setName, start, stop
 
Methods inherited from class org.objectweb.jonas.management.ReconfigDispatcher
addNotificationListener, getFilter, getHandback, getListener, getNotificationInfo, initLogger, removeNotificationListener, sendReconfigNotification, sendSaveNotification
 
Methods inherited from class javax.management.NotificationBroadcasterSupport
handleNotification, removeNotificationListener, sendNotification
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.objectweb.jonas.service.Service
getName, init, isStarted, setName, start, stop
 

Field Detail

serverName

protected java.lang.String serverName

domainName

protected java.lang.String domainName

PROPERTY_NAME

public static final java.lang.String PROPERTY_NAME
JOnAS-specific properties (name)

See Also:
Constant Field Values

PROPERTY_TYPE

public static final java.lang.String PROPERTY_TYPE
JOnAS-specific properties (type)

See Also:
Constant Field Values

SESSION_PROPERTY_TYPE

public static final java.lang.String SESSION_PROPERTY_TYPE
See Also:
Constant Field Values

MIMEPART_PROPERTY_TYPE

public static final java.lang.String MIMEPART_PROPERTY_TYPE
See Also:
Constant Field Values

FACTORIES

public static final java.lang.String FACTORIES
Mail service configuration parameters (factories)

See Also:
Constant Field Values

CLASS

public static final java.lang.String CLASS
Mail service configuration parameters (class)

See Also:
Constant Field Values
Constructor Detail

MailServiceImpl

public MailServiceImpl()
Method Detail

doInit

protected void doInit(javax.naming.Context ctx)
               throws ServiceException
Init the Mail service.

Specified by:
doInit in class AbsServiceImpl
Parameters:
ctx - the configuration of the Ear service.
Throws:
ServiceException - if the initialization failed.

doStart

protected void doStart()
                throws ServiceException
Start the Mail Service.

Specified by:
doStart in class AbsServiceImpl
Throws:
ServiceException - if the initialization failed.

doStop

protected void doStop()
               throws ServiceException
Stop the Mail service.

Specified by:
doStop in class AbsServiceImpl
Throws:
ServiceException - if the stop failed.

recreateJavaMailFactory

public void recreateJavaMailFactory(JavaMail factory)
                             throws MailServiceException
This method is used when a Mail Factory configuration is modified via jonasAdmin. In this case, the updated JavaMail object (JavaMailSession or JavaMailMimePartDS object) must be rebound in JNDI

Specified by:
recreateJavaMailFactory in interface MailService
Parameters:
factory - the factory
Throws:
MailServiceException - if the recreation of the factory failed.

renameJavaMailFactory

public void renameJavaMailFactory(java.lang.String oldName,
                                  JavaMail factory)
                           throws MailServiceException
This method is used when a particular Mail Factory configuration operation is done via jonasAdmin : when the JNDI name of this resource is modified. In this case, the initial JavaMail object (JavaMailSession or JavaMailMimePartDS object) must be unbound and the updated JavaMail object must be reloaded. Also, the Mail Service private data structures must be updated.

Specified by:
renameJavaMailFactory in interface MailService
Parameters:
oldName - old name of the factory
factory - the new factory
Throws:
MailServiceException - if the rename of the the factory failed.

createMailFactory

public void createMailFactory(java.lang.String factoryName,
                              java.util.Properties props)
                       throws MailServiceException
Create a mail factory with the specified properties and register it into the registry.

Specified by:
createMailFactory in interface MailService
Parameters:
factoryName - name of the factory to create
props - the properties used to configure the mail factory.
Throws:
MailServiceException - if the creation or the registration of the factory failed.

createMailFactoryMBean

public void createMailFactoryMBean(java.lang.String name,
                                   java.util.Properties props,
                                   java.lang.Boolean loadFromFile)
                            throws MailServiceException
Create a mail factory with the specified properties and register it into the registry.

Specified by:
createMailFactoryMBean in interface MailServiceImplMBean
Parameters:
name - the mail factory name
props - the properties used to configure the mail factory.
loadFromFile - true if the mail factory is loaded from a .properties file
Throws:
MailServiceException - if the creation or the registration of the factory failed.
MailServiceException

unbindMailFactories

public void unbindMailFactories()
                         throws MailServiceException
Unregister all the binding factories on the server and in JMX Server.

Specified by:
unbindMailFactories in interface MailService
Throws:
MailServiceException - if the unregistration of the factories failed.

unbindMailFactoryMBean

public void unbindMailFactoryMBean(java.lang.String factoryName)
                            throws MailServiceException
Unregister the factory with the given name.

Specified by:
unbindMailFactoryMBean in interface MailServiceImplMBean
Parameters:
factoryName - the name of the factory to unbind.
Throws:
MailServiceException - if the unregistration of the factory failed.

getFactoryName

public java.lang.String getFactoryName(java.lang.String jndiName)
Gets the factory name given the jndi name. Null is returned if the given name is not binded.

Parameters:
jndiName - the jndi name
Returns:
the factory name given the jndi name. Null is returned if the given name is not binded.

getCurrentNumberOfMailFactories

public java.lang.Integer getCurrentNumberOfMailFactories()
Gets the total number of mail factories available in JOnAS

Specified by:
getCurrentNumberOfMailFactories in interface MailServiceImplMBean
Returns:
Integer Total number of mail factories available in JOnAS

getCurrentNumberOfSessionMailFactories

public java.lang.Integer getCurrentNumberOfSessionMailFactories()
Gets the number of Session mail factories available in JOnAS

Specified by:
getCurrentNumberOfSessionMailFactories in interface MailServiceImplMBean
Returns:
Integer Number of Session mail factories available in JOnAS

getCurrentNumberOfMimeMailFactories

public java.lang.Integer getCurrentNumberOfMimeMailFactories()
Gets the integer Number of internet

Specified by:
getCurrentNumberOfMimeMailFactories in interface MailServiceImplMBean
Returns:
Integer Number of internet.MimePartDataSource mail factories available in JOnAS

getMailFactoryPropertiesFile

public java.util.Properties getMailFactoryPropertiesFile(java.lang.String configFile)
                                                  throws java.lang.Exception
Gets the mail factory configuration properties from a local file

Specified by:
getMailFactoryPropertiesFile in interface MailServiceImplMBean
Parameters:
configFile - configuration to use
Returns:
mail factory configuration properties from a local file
Throws:
java.lang.Exception - if it fails

getMailFactoryPropertiesFiles

public java.util.List getMailFactoryPropertiesFiles()
                                             throws java.lang.Exception
MBean method:

Specified by:
getMailFactoryPropertiesFiles in interface MailServiceImplMBean
Returns:
the list of properties files describing mail factories found in JONAS_BASE/conf
Throws:
java.lang.Exception - if the list can't be returned

getMimePartMailFactoryPropertiesFiles

public java.util.List getMimePartMailFactoryPropertiesFiles()
                                                     throws java.lang.Exception
MBean method:

Specified by:
getMimePartMailFactoryPropertiesFiles in interface MailServiceImplMBean
Returns:
the list of properties files describing mail factories found in JONAS_BASE/conf
Throws:
java.lang.Exception - if the list can't be returned

getSessionMailFactoryPropertiesFiles

public java.util.List getSessionMailFactoryPropertiesFiles()
                                                    throws java.lang.Exception
MBean method:

Specified by:
getSessionMailFactoryPropertiesFiles in interface MailServiceImplMBean
Returns:
the list of properties files describing mail factories found in JONAS_BASE/conf
Throws:
java.lang.Exception - if the list can't be returned