org.ow2.jonas.mail.internal
Class JOnASMailService

java.lang.Object
  extended by javax.management.NotificationBroadcasterSupport
      extended by org.ow2.jonas.lib.reconfig.ReconfigEmitter
          extended by org.ow2.jonas.lib.service.AbsServiceImpl
              extended by org.ow2.jonas.mail.internal.JOnASMailService
All Implemented Interfaces:
NotificationBroadcaster, NotificationEmitter, MailService, Service

public class JOnASMailService
extends AbsServiceImpl
implements MailService

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 String CLASS
          Mail service configuration parameters (class).
static String FACTORIES
          Mail service configuration parameters (factories).
 
Fields inherited from class org.ow2.jonas.lib.reconfig.ReconfigEmitter
RECONFIG_TYPE, SAVE_RECONFIG_TYPE
 
Fields inherited from interface org.ow2.jonas.mail.MailService
MIMEPART_PROPERTY_TYPE, PROPERTY_NAME, PROPERTY_TYPE, SESSION_PROPERTY_TYPE
 
Constructor Summary
JOnASMailService()
           
 
Method Summary
 void createMailFactory(String factoryName, Properties props)
          Create a mail factory with the specified properties and register it into the registry.
 void createMailFactoryMBean(String name, Properties props, Boolean loadFromFile)
          Create a mail factory with the specified properties and register it into the registry.
protected  void doStart()
          Start the Mail Service.
protected  void doStop()
          Stop the Mail service.
 Integer getCurrentNumberOfMailFactories()
          Gets the total number of mail factories available in JOnAS.
 Integer getCurrentNumberOfMimeMailFactories()
          Gets the integer Number of internet.
 Integer getCurrentNumberOfSessionMailFactories()
          Gets the number of Session mail factories available in JOnAS.
 String getFactoryName(String jndiName)
          Gets the factory name given the jndi name.
 Properties getMailFactoryPropertiesFile(String configFile)
          Gets the mail factory configuration properties from a local file.
 List<String> getMailFactoryPropertiesFiles()
          MBean method.
 List<String> getMimePartMailFactoryPropertiesFiles()
          MBean method.
 List<String> getSessionMailFactoryPropertiesFiles()
          MBean method.
 void recreateJavaMailFactory(JavaMail factory)
          This method is used when a Mail Factory configuration is modified via jonasAdmin.
 void renameJavaMailFactory(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 setFactories(String factories)
           
 void setJmxService(JmxService jmxService)
           
 void setRegistryService(RegistryService registry)
           
 void unbindMailFactories()
          Unregister all the binding factories on the server and in JMX Server.
 void unbindMailFactoryMBean(String factoryName)
          Unregister the factory with the given name.
 
Methods inherited from class org.ow2.jonas.lib.service.AbsServiceImpl
convertToList, doInit, getDomainName, getJonasServerName, getName, getServerProperties, init, isStarted, setName, setServerProperties, start, stop, throwRequirementException, toString
 
Methods inherited from class org.ow2.jonas.lib.reconfig.ReconfigEmitter
initLogger, sendReconfigNotification, sendSaveNotification
 
Methods inherited from class javax.management.NotificationBroadcasterSupport
addNotificationListener, getNotificationInfo, handleNotification, removeNotificationListener, removeNotificationListener, sendNotification
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.ow2.jonas.service.Service
getName, init, isStarted, setName, start, stop
 

Field Detail

FACTORIES

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

See Also:
Constant Field Values

CLASS

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

See Also:
Constant Field Values
Constructor Detail

JOnASMailService

public JOnASMailService()
Method Detail

setFactories

public void setFactories(String factories)
Parameters:
factories - initial (comma separated list) of mail factories.

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(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(String factoryName,
                              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(String name,
                                   Properties props,
                                   Boolean loadFromFile)
                            throws MailServiceException
Create a mail factory with the specified properties and register it into the registry.

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(String factoryName)
                            throws MailServiceException
Unregister the factory with the given name.

Parameters:
factoryName - the name of the factory to unbind.
Throws:
MailServiceException - if the unregistration of the factory failed.

getFactoryName

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

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

getCurrentNumberOfMailFactories

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

Returns:
Integer Total number of mail factories available in JOnAS

getCurrentNumberOfSessionMailFactories

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

Returns:
Integer Number of Session mail factories available in JOnAS

getCurrentNumberOfMimeMailFactories

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

Returns:
Integer Number of internet.MimePartDataSource mail factories available in JOnAS

getMailFactoryPropertiesFile

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

Parameters:
configFile - configuration to use
Returns:
mail factory configuration properties from a local file
Throws:
Exception - if it fails

getMailFactoryPropertiesFiles

public List<String> getMailFactoryPropertiesFiles()
                                           throws Exception
MBean method.

Returns:
the list of properties files describing mail factories found in JONAS_BASE/conf
Throws:
Exception

getMimePartMailFactoryPropertiesFiles

public List<String> getMimePartMailFactoryPropertiesFiles()
                                                   throws Exception
MBean method.

Returns:
the list of properties files describing mail factories found in JONAS_BASE/conf
Throws:
Exception

getSessionMailFactoryPropertiesFiles

public List<String> getSessionMailFactoryPropertiesFiles()
                                                  throws Exception
MBean method.

Returns:
the list of properties files describing mail factories found in JONAS_BASE/conf
Throws:
Exception

setJmxService

public void setJmxService(JmxService jmxService)
Parameters:
jmxService - the jmxService to set

setRegistryService

public void setRegistryService(RegistryService registry)
Parameters:
registry - the registry service to set


Copyright © 2010 OW2 Consortium. All Rights Reserved.