A messaging service is created from a Session and is
named using a URLName. A service must be connected
before it can be used. Connection events are sent to reflect
its connection status.
| Modifier and Type | Field and Description |
|---|---|
| private boolean | |
| private final Vector | |
| protected boolean | debug
Debug flag for this service. |
| private final EventQueue | q
The queue of events to be delivered. |
| protected Session | session
The session from which this service was created. |
| protected volatile URLName | url
The |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public void | addConnectionListener(ConnectionListener
the Listener for Connection events l)Add a listener for Connection events on this service. |
| public synchronized void | |
| public void | |
| public void | |
| public void | |
| public synchronized void | |
| protected void | finalize()
Overrides java. |
| pack-priv EventQueue | |
| pack-priv Session | |
| public URLName | Returns: the URLName representing this serviceReturn a URLName representing this service. |
| public synchronized boolean | Returns: true if the service is connected, false if it is not connectedIs this service currently connected? |
| protected void | |
| protected boolean | Returns: true if connection successful, false if authentication failedthe name of the host to connect to host, int the port to use (-1 means use default port) port, String the name of the user to login as user, String the user's password password)The service implementation should override this method to perform the actual protocol-specific connection attempt. |
| protected void | queueEvent(MailEvent
the event event, Vector<? extends EventListener> the vector of listeners vector)Add the event and vector of listeners to the queue to be delivered. |
| public void | |
| protected synchronized void | setConnected(boolean
true if the service is connected,
false if it is not connected connected)Set the connection state of this service. |
| protected void | |
| public String | toString()
Overrides java. getURLName.toString() if this service has a URLName,
otherwise it will return the default toString.
|
| connected | back to summary |
|---|---|
| private boolean connected | |
| connectionListeners | back to summary |
|---|---|
| private final Vector<ConnectionListener> connectionListeners | |
| debug | back to summary |
|---|---|
| protected boolean debug Debug flag for this service. Set from the session's debug flag when this service is created. | |
| q | back to summary |
|---|---|
| private final EventQueue q The queue of events to be delivered. | |
| session | back to summary |
|---|---|
| protected Session session The session from which this service was created. | |
| url | back to summary |
|---|---|
| protected volatile URLName url The | |
| Service | back to summary |
|---|---|
| protected Service(Session session, URLName urlname) Constructor. | |
| addConnectionListener | back to summary |
|---|---|
| public void addConnectionListener(ConnectionListener l) Add a listener for Connection events on this service. The default implementation provided here adds this listener to an internal list of ConnectionListeners.
| |
| close | back to summary |
|---|---|
| public synchronized void close() throws MessagingException Implements java. Close this service and terminate its connection. A close ConnectionEvent is delivered to any ConnectionListeners. Any Messaging components (Folders, Messages, etc.) belonging to this service are invalid after this service is closed. Note that the service is closed even if this method terminates abnormally by throwing a MessagingException.
This implementation uses
| |
| connect | back to summary |
|---|---|
| public void connect() throws MessagingException A generic connect method that takes no parameters. Subclasses can implement the appropriate authentication schemes. Subclasses that need additional information might want to use some properties or might get it interactively using a popup window.
If the connection is successful, an "open" Most clients should just call this method to connect to the service. It is an error to connect to an already connected service.
The implementation provided here simply calls the following
| |
| connect | back to summary |
|---|---|
| public void connect(String host, String user, String password) throws MessagingException Connect to the specified address. This method provides a simple authentication scheme that requires a username and password.
If the connection is successful, an "open" It is an error to connect to an already connected service.
The implementation in the Service class will collect defaults
for the host, user, and password from the session, from the
On a successful connection, the
If the username passed in is null, a default value will be chosen
as described above.
If the password passed in is null and this is the first successful
connection to this service, the user name and the password
collected from the user will be saved as defaults for subsequent
connection attempts to this same service when using other Service object
instances (the connection information is typically always saved within
a particular Service object instance). The password is saved using the
Session method
| |
| connect | back to summary |
|---|---|
| public void connect(String user, String password) throws MessagingException Connect to the current host using the specified username
and password. This method is equivalent to calling the
| |
| connect | back to summary |
|---|---|
| public synchronized void connect(String host, int port, String user, String password) throws MessagingException Similar to connect(host, user, password) except a specific port can be specified.
| |
| finalize | back to summary |
|---|---|
| protected void finalize() throws Throwable Overrides java. Stop the event dispatcher thread so the queue can be garbage collected.
| |
| getEventQueue | back to summary |
|---|---|
| pack-priv EventQueue getEventQueue() Package private method to allow Folder to get the EventQueue for a Store. | |
| getSession | back to summary |
|---|---|
| pack-priv Session getSession() Package private method to allow Folder to get the Session for a Store. | |
| getURLName | back to summary |
|---|---|
| public URLName getURLName() Return a URLName representing this service. The returned URLName does not include the password field. Subclasses should only override this method if their URLName does not follow the standard format.
The implementation in the Service class returns (usually a copy of)
the | |
| isConnected | back to summary |
|---|---|
| public synchronized boolean isConnected() Is this service currently connected? This implementation uses a private boolean field to store the connection state. This method returns the value of that field. Subclasses may want to override this method to verify that any connection to the message store is still alive.
| |
| notifyConnectionListeners | back to summary |
|---|---|
| protected void notifyConnectionListeners(int type) Notify all ConnectionListeners. Service implementations are expected to use this method to broadcast connection events. The provided default implementation queues the event into an internal event queue. An event dispatcher thread dequeues events from the queue and dispatches them to the registered ConnectionListeners. Note that the event dispatching occurs in a separate thread, thus avoiding potential deadlock problems.
| |
| protocolConnect | back to summary |
|---|---|
| protected boolean protocolConnect(String host, int port, String user, String password) throws MessagingException The service implementation should override this method to
perform the actual protocol-specific connection attempt.
The default implementation of the
The
The
| |
| queueEvent | back to summary |
|---|---|
| protected void queueEvent(MailEvent event, Vector<? extends EventListener> vector) Add the event and vector of listeners to the queue to be delivered.
| |
| removeConnectionListener | back to summary |
|---|---|
| public void removeConnectionListener(ConnectionListener l) Remove a Connection event listener. The default implementation provided here removes this listener from the internal list of ConnectionListeners.
| |
| setConnected | back to summary |
|---|---|
| protected synchronized void setConnected(boolean connected) Set the connection state of this service. The connection state
will automatically be set by the service implementation during the
The implementation in this class merely sets the private field
returned by the
| |
| setURLName | back to summary |
|---|---|
| protected void setURLName(URLName url) Set the URLName representing this service.
Normally used to update the
Subclasses should only override this method if their
URL does not follow the standard format. In particular,
subclasses should override this method if their URL
does not require all the possible fields supported by
The implementation in the Service class simply sets the
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Return
| |