org.objectweb.jonas.mail
Class MailServiceImpl

java.lang.Object
  |
  +--org.objectweb.jonas.service.AbsServiceImpl
        |
        +--org.objectweb.jonas.mail.MailServiceImpl
All Implemented Interfaces:
MailService, MailServiceImplMBean, 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
           
static java.lang.String FACTORIES
           
 
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)
          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()
           
 java.lang.Integer getCurrentNumberOfMimeMailFactories()
           
 java.lang.Integer getCurrentNumberOfSessionMailFactories()
           
 java.lang.String getFactoryName(java.lang.String jndiName)
           
 java.util.Properties getMailFactoryPropertiesFile(java.lang.String configFile)
           
 void recreateMailFactory(JMail factory)
          This method is used when a Mail Factory configuration is modified via Jadmin.
 void renameMailFactory(java.lang.String oldName, JMail factory)
          This method is used when a particular Mail Factory configuration operation is done via Jadmin : when the JNDI name of this ressource 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
getName, init, isStarted, setName, start, stop
 
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

FACTORIES

public static final java.lang.String FACTORIES

CLASS

public static final java.lang.String CLASS
Constructor Detail

MailServiceImpl

public MailServiceImpl()
Method Detail

doInit

protected void doInit(javax.naming.Context ctx)
               throws ServiceException
Init the Mail service.
Overrides:
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.
Overrides:
doStart in class AbsServiceImpl
Throws:
ServiceException - if the initialization failed.

doStop

protected void doStop()
               throws ServiceException
Stop the Mail service.
Overrides:
doStop in class AbsServiceImpl
Throws:
ServiceException - if the stop failed.

recreateMailFactory

public void recreateMailFactory(JMail factory)
                         throws MailServiceException
This method is used when a Mail Factory configuration is modified via Jadmin. In this case, the updated JMail object (JMailSession or JMailMimePartDS object) must be rebound in JNDI
Specified by:
recreateMailFactory in interface MailService

renameMailFactory

public void renameMailFactory(java.lang.String oldName,
                              JMail factory)
                       throws MailServiceException
This method is used when a particular Mail Factory configuration operation is done via Jadmin : when the JNDI name of this ressource is modified. In this case, the initial JMail object (JMailSession or JMailMimePartDS object) must be unbound and the updated JMail object must be reloaded. Also, the Mail Service private data structures must be updated.
Specified by:
renameMailFactory in interface MailService

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:
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)
                            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.
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:
java.rmi.RemoteException - if rmi call failed.
MailServiceException - if the unregistration of the factory failed.

getFactoryName

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

getCurrentNumberOfMailFactories

public java.lang.Integer getCurrentNumberOfMailFactories()
Specified by:
getCurrentNumberOfMailFactories in interface MailServiceImplMBean
Returns:
Integer Total number of mail factories available in JOnAS

getCurrentNumberOfSessionMailFactories

public java.lang.Integer getCurrentNumberOfSessionMailFactories()
Specified by:
getCurrentNumberOfSessionMailFactories in interface MailServiceImplMBean
Returns:
Integer Number of Session mail factories available in JOnAS

getCurrentNumberOfMimeMailFactories

public java.lang.Integer getCurrentNumberOfMimeMailFactories()
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
Specified by:
getMailFactoryPropertiesFile in interface MailServiceImplMBean
Returns:
mail factory configuration properties from a local file