Modifier and Type | Field and Description |
---|---|
protected boolean |
debug
Debug flag for this service, set from the Session's debug flag.
|
protected Session |
session
The session from which this service was created.
|
protected URLName |
url
The URLName of this service
|
Modifier | Constructor and Description |
---|---|
protected |
Service(Session session,
URLName url)
Construct a new Service.
|
Modifier and Type | Method and Description |
---|---|
void |
addConnectionListener(ConnectionListener listener) |
void |
close()
Close this service and terminate its physical connection.
|
void |
connect()
A generic connect method that takes no parameters allowing subclasses
to implement an appropriate authentication scheme.
|
void |
connect(java.lang.String host,
int port,
java.lang.String user,
java.lang.String password)
Connect to the specified host at the specified port using a simple username/password authenticaion scheme.
|
void |
connect(java.lang.String user,
java.lang.String password)
Connect to the specified host using a simple username/password authenticaion scheme
and the default host and port.
|
void |
connect(java.lang.String host,
java.lang.String user,
java.lang.String password)
Connect to the specified host using a simple username/password authenticaion scheme
and the default port.
|
protected void |
finalize() |
URLName |
getURLName()
Return a copy of the URLName representing this service with the password and file information removed.
|
boolean |
isConnected()
Check if this service is currently connected.
|
protected void |
notifyConnectionListeners(int type) |
protected boolean |
protocolConnect(java.lang.String host,
int port,
java.lang.String user,
java.lang.String password)
Attempt the protocol-specific connection; subclasses should override this to establish
a connection in the appropriate manner.
|
protected void |
queueEvent(MailEvent event,
java.util.Vector listeners) |
void |
removeConnectionListener(ConnectionListener listener) |
protected void |
setConnected(boolean connected)
Notification to subclasses that the connection state has changed.
|
protected void |
setURLName(URLName url)
Set the url field.
|
java.lang.String |
toString() |
protected Session session
protected URLName url
protected boolean debug
public void connect() throws MessagingException
connect(null, null, null)
AuthenticationFailedException
- if authentication failsMessagingException
- for other failurespublic void connect(java.lang.String host, java.lang.String user, java.lang.String password) throws MessagingException
connect(host, -1, user, password)
host
- the host to connect touser
- the user namepassword
- the user's passwordAuthenticationFailedException
- if authentication failsMessagingException
- for other failurespublic void connect(java.lang.String user, java.lang.String password) throws MessagingException
connect(host, -1, user, password)
user
- the user namepassword
- the user's passwordAuthenticationFailedException
- if authentication failsMessagingException
- for other failurespublic void connect(java.lang.String host, int port, java.lang.String user, java.lang.String password) throws MessagingException
host
- the host to connect toport
- the port to connect to; pass -1 to use the default for the protocoluser
- the user namepassword
- the user's passwordAuthenticationFailedException
- if authentication failsMessagingException
- for other failuresjava.lang.IllegalStateException
- if this service is already connectedprotected boolean protocolConnect(java.lang.String host, int port, java.lang.String user, java.lang.String password) throws MessagingException
connect(String, int, String, String)
method to
reattempt the connection after trying to obtain user and password information from the user.
Alternatively it may throw a AuthenticatedFailedException to abandon the conection attempt.host
- port
- user
- password
- AuthenticationFailedException
- if authentication failsMessagingException
- for other failurespublic boolean isConnected()
protected void setConnected(boolean connected)
connected
- the connection statepublic void close() throws MessagingException
MessagingException
- if there were errors closing; the connection is still closedpublic URLName getURLName()
protected void setURLName(URLName url)
url
- the new valuepublic void addConnectionListener(ConnectionListener listener)
public void removeConnectionListener(ConnectionListener listener)
protected void notifyConnectionListeners(int type)
public java.lang.String toString()
toString
in class java.lang.Object
protected void queueEvent(MailEvent event, java.util.Vector listeners)
protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable