An abstract messaging service (store or transport).
addConnectionListener
public void addConnectionListener(ConnectionListener l)
Adds a listener for connection events on this service.
close
public void close()
throws MessagingException
Closes this service, terminating any underlying connections.
connect
public void connect()
throws MessagingException
Connects to this service.
If additional information is required, the provider can determine them
from session properties or via a callback to the UI.
connect
public void connect(String user,
String password)
throws MessagingException
Connects to this service.
This method provides a simple authentication scheme requiring a
username and password. The host is determined from the inital URLName.
user
- the usernamepassword
- the password
connect
public void connect(String host,
String user,
String password)
throws MessagingException
Connects to this service using the specified details.
This method provides a simple authentication scheme requiring a
username and password.
host
- the host to connect touser
- the usernamepassword
- the password
connect
public void connect(String host,
int port,
String user,
String password)
throws MessagingException
Connects to this service using the specified details.
This method provides a simple authentication scheme requiring a
username and password.
host
- the host to connect toport
- the port to use (-1 for the default port)user
- the usernamepassword
- the password
getURLName
public URLName getURLName()
Return a URLName representing this service. The password field will not
be returned.
isConnected
public boolean isConnected()
Indicates whether this service is currently connected.
notifyConnectionListeners
protected void notifyConnectionListeners(int type)
Notify all connection listeners.
protocolConnect
protected boolean protocolConnect(String host,
int port,
String user,
String password)
throws MessagingException
Provider implementation for a service.
This method should return
false
if authentication fails,
due to the username or password being unavailable or incorrect, or may
throw
AuthenticationFailedException
for further details.
In the case of failures not related to authentication, such as an
invalid configuration or network error, this method should throw an
appropriate
MessagingException
.
host
- the name of the host to connect toport
- the port to use (-1 for the default port)user
- the usernamepassword
- the password
- true on success, false if authentication failed
queueEvent
protected void queueEvent(MailEvent event,
Vector vector)
Adds the event and vector of listeners to be notified.
removeConnectionListener
public void removeConnectionListener(ConnectionListener l)
Removes a connection event listener.
setConnected
protected void setConnected(boolean connected)
Sets the connection state of this service.
setURLName
protected void setURLName(URLName url)
Set the URLName representing this service.
This method is called when the service has successfully connected.
toString
public String toString()
Returns getURLName.toString
if this service has a URLName,
otherwise returns the default toString
.