com.openexchange.mail.transport
Class TransportProviderRegistry

java.lang.Object
  extended by com.openexchange.mail.transport.TransportProviderRegistry

public final class TransportProviderRegistry
extends java.lang.Object

TransportProviderRegistry

Author:
Thorben Betten

Method Summary
static TransportProvider getTransportProvider(java.lang.String protocol)
          Gets the transport provider appropriate for specified protocol.
static TransportProvider getTransportProviderBySession(com.openexchange.session.Session session, int accountId)
          Gets the transport provider appropriate for specified session
static TransportProvider getTransportProviderByURL(java.lang.String serverUrl)
          Gets the transport provider appropriate for specified mail server URL.
static boolean registerTransportProvider(java.lang.String protocol, TransportProvider provider)
          Registers a transport provider and performs its start-up actions
static void unregisterAll()
          Unregisters all transport providers
static TransportProvider unregisterTransportProvider(TransportProvider provider)
          Unregisters the transport provider
static TransportProvider unregisterTransportProviderByProtocol(java.lang.String protocol)
          Unregisters the transport provider supporting specified protocol
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getTransportProviderBySession

public static TransportProvider getTransportProviderBySession(com.openexchange.session.Session session,
                                                              int accountId)
                                                       throws MailException
Gets the transport provider appropriate for specified session

Parameters:
session - The session
accountId - The account ID
Returns:
The appropriate transport provider
Throws:
MailException - If no supporting transport provider can be found

getTransportProviderByURL

public static TransportProvider getTransportProviderByURL(java.lang.String serverUrl)
Gets the transport provider appropriate for specified mail server URL.

The given URL should match pattern

 <protocol>://<host>(:<port>)?
 
The protocol should be present. Otherwise the configured fallback is used as protocol.

Parameters:
serverUrl - The transport server URL
Returns:
The appropriate transport provider

getTransportProvider

public static TransportProvider getTransportProvider(java.lang.String protocol)
Gets the transport provider appropriate for specified protocol.

Parameters:
protocol - The mail protocol
Returns:
The appropriate transport provider

registerTransportProvider

public static boolean registerTransportProvider(java.lang.String protocol,
                                                TransportProvider provider)
                                         throws MailException
Registers a transport provider and performs its start-up actions

Parameters:
protocol - The transport protocol's string representation; e.g. "smtp_smtps"
provider - The transport provider to register
Returns:
true if transport provider has been successfully registered and no other transport provider supports the same protocol; otherwise false
Throws:
MailException - If provider's start-up fails

unregisterAll

public static void unregisterAll()
Unregisters all transport providers


unregisterTransportProvider

public static TransportProvider unregisterTransportProvider(TransportProvider provider)
                                                     throws MailException
Unregisters the transport provider

Parameters:
provider - The transport provider to unregister
Returns:
The unregistered transport provider, or null
Throws:
MailException - If provider's shut-down fails

unregisterTransportProviderByProtocol

public static TransportProvider unregisterTransportProviderByProtocol(java.lang.String protocol)
                                                               throws MailException
Unregisters the transport provider supporting specified protocol

Parameters:
protocol - The protocol
Returns:
The unregistered instance of TransportProvider, or null if there was no provider supporting specified protocol
Throws:
MailException - If provider's shut-down fails