|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.mail.Session
public final class Session
OK, so we have a final class in the API with a heck of a lot of implementation required... let's try and figure out what it is meant to do.
It is supposed to collect together properties and defaults so that they can be shared by multiple applications on a desktop; with process isolation and no real concept of shared memory, this seems challenging. These properties and defaults rely on system properties, making management in a app server harder, and on resources loaded from "mail.jar" which may lead to skew between differnet independent implementations of this API.
Method Summary | |
---|---|
void |
addProvider(Provider provider)
Add a provider to the Session managed provider list. |
boolean |
getDebug()
Get the debug setting for this session. |
PrintStream |
getDebugOut()
Return the debug output stream. |
static Session |
getDefaultInstance(Properties properties)
Get the "default" instance assuming no authenticator is required. |
static Session |
getDefaultInstance(Properties properties,
Authenticator authenticator)
Get the "default" session. |
Folder |
getFolder(URLName name)
Return a closed folder for the supplied URLName, or null if it cannot be obtained. |
static Session |
getInstance(Properties properties)
Create a new session initialized with the supplied properties with no authenticator. |
static Session |
getInstance(Properties properties,
Authenticator authenticator)
Create a new session initialized with the supplied properties which uses the supplied authenticator. |
PasswordAuthentication |
getPasswordAuthentication(URLName name)
Get the password authentication associated with a URL |
Properties |
getProperties()
Return the properties object for this Session; this is a live collection. |
String |
getProperty(String property)
Return the specified property. |
Provider |
getProvider(String protocol)
Return the provider for a specific protocol. |
Provider[] |
getProviders()
Return the list of providers available to this application. |
Store |
getStore()
Return a Store for the default protocol defined by the mail.store.protocol property. |
Store |
getStore(Provider provider)
Return the Store specified by the given provider. |
Store |
getStore(String protocol)
Return a Store for the specified protocol. |
Store |
getStore(URLName url)
Return a Store for the protocol specified in the given URL |
Transport |
getTransport()
Return a Transport for the default protocol specified by the mail.transport.protocol property. |
Transport |
getTransport(Address address)
Return a transport for the protocol associated with the type of this address. |
Transport |
getTransport(Provider provider)
Return the Transport specified by a Provider |
Transport |
getTransport(String protocol)
Return a Transport for the specified protocol. |
Transport |
getTransport(URLName name)
Return a transport for the protocol specified in the URL. |
PasswordAuthentication |
requestPasswordAuthentication(InetAddress host,
int port,
String protocol,
String prompt,
String defaultUserName)
Call back to the application supplied authenticator to get the needed username add password. |
void |
setDebug(boolean debug)
Enable debugging for this session. |
void |
setDebugOut(PrintStream out)
Set the output stream where debug information should be sent. |
void |
setPasswordAuthentication(URLName name,
PasswordAuthentication authenticator)
Set the password authentication associated with a URL. |
void |
setProtocolForAddress(String addressType,
String protocol)
Add a mapping between an address type and a protocol used to process that address type. |
void |
setProvider(Provider provider)
Make the supplied Provider the default for its protocol. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static Session getInstance(Properties properties, Authenticator authenticator)
properties
- the session propertiesauthenticator
- an authenticator for callbacks to the user
public static Session getInstance(Properties properties)
properties
- the session properties
getInstance(java.util.Properties, Authenticator)
public static Session getDefaultInstance(Properties properties)
properties
- the session properties
SecurityException
- if the does not have permission to access the default sessionpublic static Session getDefaultInstance(Properties properties, Authenticator authenticator)
properties
- authenticator
-
SecurityException
- if the does not have permission to access the default sessionpublic void setDebug(boolean debug)
debug
- the debug settingpublic boolean getDebug()
public void setDebugOut(PrintStream out)
out
- the stream to write debug information topublic PrintStream getDebugOut()
public Provider[] getProviders()
public Provider getProvider(String protocol) throws NoSuchProviderException
getProviders()
for a entry for the specified protocol.
protocol
- the protocol to get a provider for
NoSuchProviderException
public void setProvider(Provider provider) throws NoSuchProviderException
provider
- the new default Provider
NoSuchProviderException
public Store getStore() throws NoSuchProviderException
NoSuchProviderException
public Store getStore(String protocol) throws NoSuchProviderException
protocol
- the protocol to get a Store for
NoSuchProviderException
- if no provider is defined for the specified protocolpublic Store getStore(URLName url) throws NoSuchProviderException
url
- the URL of the Store
NoSuchProviderException
- if no provider is defined for the specified protocolpublic Store getStore(Provider provider) throws NoSuchProviderException
provider
- the provider to create from
NoSuchProviderException
- if there was a problem creating the Storepublic Folder getFolder(URLName name) throws MessagingException
name
- the location of the folder
NoSuchProviderException
- if there is no provider
MessagingException
- if there was a problem accessing the Storepublic Transport getTransport() throws NoSuchProviderException
mail.transport.protocol
property.
NoSuchProviderException
public Transport getTransport(String protocol) throws NoSuchProviderException
protocol
- the protocol to use
NoSuchProviderException
public Transport getTransport(URLName name) throws NoSuchProviderException
name
- the URL whose scheme specifies the protocol
NoSuchProviderException
public Transport getTransport(Address address) throws NoSuchProviderException
address
- the address we are trying to deliver to
NoSuchProviderException
public Transport getTransport(Provider provider) throws NoSuchProviderException
provider
- the defining Provider
NoSuchProviderException
public void setPasswordAuthentication(URLName name, PasswordAuthentication authenticator)
name
- the urlauthenticator
- the authenticatorpublic PasswordAuthentication getPasswordAuthentication(URLName name)
name
- the URL
public PasswordAuthentication requestPasswordAuthentication(InetAddress host, int port, String protocol, String prompt, String defaultUserName)
host
- the host we are trying to connect to, may be nullport
- the port on that hostprotocol
- the protocol trying to be usedprompt
- a String to show as part of the prompt, may be nulldefaultUserName
- the default username, may be null
public Properties getProperties()
public String getProperty(String property)
property
- the property to get
public void addProvider(Provider provider)
provider
- The new provider to add.public void setProtocolForAddress(String addressType, String protocol)
addressType
- The address type identifier.protocol
- The protocol name mapping.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |