<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd">
<!--NewPage-->
<HTML>
<HEAD>
<!-- Generated by javadoc on Wed Jun 25 00:04:08 PDT 2003 -->
<TITLE>
JavaMail API documentation: Class  Service
</TITLE>
<LINK REL ="stylesheet" TYPE="text/css" HREF="../../stylesheet.css" TITLE="Style">
</HEAD>
<BODY BGCOLOR="white">

<!-- ========== START OF NAVBAR ========== -->
<A NAME="navbar_top"><!-- --></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_top_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3">
  <TR ALIGN="center" VALIGN="top">
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="class-use/Service.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
  </TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>

<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;<A HREF="../../javax/mail/Provider.Type.html"><B>PREV CLASS</B></A>&nbsp;
&nbsp;<A HREF="../../javax/mail/Session.html"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
  <A HREF="../../index.html" TARGET="_top"><B>FRAMES</B></A>  &nbsp;
&nbsp;<A HREF="Service.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
  SUMMARY: &nbsp;INNER&nbsp;|&nbsp;<A HREF="#field_summary">FIELD</A>&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL: &nbsp;<A HREF="#field_detail">FIELD</A>&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<!-- =========== END OF NAVBAR =========== -->

<HR>
<!-- ======== START OF CLASS DATA ======== -->
<H2>
<FONT SIZE="-1">
javax.mail</FONT>
<BR>
Class  Service</H2>
<PRE>
java.lang.Object
  |
  +--<B>javax.mail.Service</B>
</PRE>
<DL>
<DT><B>Direct Known Subclasses:</B> <DD><A HREF="../../javax/mail/Store.html">Store</A>, <A HREF="../../javax/mail/Transport.html">Transport</A></DD>
</DL>
<HR>
<DL>
<DT>public abstract class <B>Service</B><DT>extends java.lang.Object</DL>

<P>
An abstract class that contains the functionality
 common to messaging services, such as stores and transports. <p>
 A messaging service is created from a <code>Session</code> and is
 named using a <code>URLName</code>.  A service must be connected
 before it can be used.  Connection events are sent to reflect
 its connection status.
<P>
<HR>

<P>
<!-- ======== INNER CLASS SUMMARY ======== -->


<!-- =========== FIELD SUMMARY =========== -->

<A NAME="field_summary"><!-- --></A>
<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=2><FONT SIZE="+2">
<B>Field Summary</B></FONT></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>protected &nbsp;boolean</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../javax/mail/Service.html#debug">debug</A></B></CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Debug flag for this service.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>protected &nbsp;<A HREF="../../javax/mail/Session.html">Session</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../javax/mail/Service.html#session">session</A></B></CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The session from which this service was created.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>protected &nbsp;<A HREF="../../javax/mail/URLName.html">URLName</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../javax/mail/Service.html#url">url</A></B></CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The <code>URLName</code> of this service.</TD>
</TR>
</TABLE>
&nbsp;
<!-- ======== CONSTRUCTOR SUMMARY ======== -->

<A NAME="constructor_summary"><!-- --></A>
<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=2><FONT SIZE="+2">
<B>Constructor Summary</B></FONT></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>protected </CODE></FONT></TD>
<TD><CODE><B><A HREF="../../javax/mail/Service.html#Service(javax.mail.Session, javax.mail.URLName)">Service</A></B>(<A HREF="../../javax/mail/Session.html">Session</A>&nbsp;session,
        <A HREF="../../javax/mail/URLName.html">URLName</A>&nbsp;urlname)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Constructor.</TD>
</TR>
</TABLE>
&nbsp;
<!-- ========== METHOD SUMMARY =========== -->

<A NAME="method_summary"><!-- --></A>
<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=2><FONT SIZE="+2">
<B>Method Summary</B></FONT></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../javax/mail/Service.html#addConnectionListener(javax.mail.event.ConnectionListener)">addConnectionListener</A></B>(<A HREF="../../javax/mail/event/ConnectionListener.html">ConnectionListener</A>&nbsp;l)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Add a listener for Connection events on this service.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../javax/mail/Service.html#close()">close</A></B>()</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Close this service and terminate its connection.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../javax/mail/Service.html#connect()">connect</A></B>()</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;A generic connect method that takes no parameters.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../javax/mail/Service.html#connect(java.lang.String, int, java.lang.String, java.lang.String)">connect</A></B>(java.lang.String&nbsp;host,
        int&nbsp;port,
        java.lang.String&nbsp;user,
        java.lang.String&nbsp;password)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Similar to connect(host, user, password) except a specific port
 can be specified.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../javax/mail/Service.html#connect(java.lang.String, java.lang.String, java.lang.String)">connect</A></B>(java.lang.String&nbsp;host,
        java.lang.String&nbsp;user,
        java.lang.String&nbsp;password)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Connect to the specified address.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>protected &nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../javax/mail/Service.html#finalize()">finalize</A></B>()</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Stop the event dispatcher thread so the queue can be garbage collected.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../javax/mail/URLName.html">URLName</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../javax/mail/Service.html#getURLName()">getURLName</A></B>()</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Return a URLName representing this service.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;boolean</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../javax/mail/Service.html#isConnected()">isConnected</A></B>()</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Is this service currently connected? </TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>protected &nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../javax/mail/Service.html#notifyConnectionListeners(int)">notifyConnectionListeners</A></B>(int&nbsp;type)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Notify all ConnectionListeners.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>protected &nbsp;boolean</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../javax/mail/Service.html#protocolConnect(java.lang.String, int, java.lang.String, java.lang.String)">protocolConnect</A></B>(java.lang.String&nbsp;host,
                int&nbsp;port,
                java.lang.String&nbsp;user,
                java.lang.String&nbsp;password)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The service implementation should override this method to
 perform the actual protocol-specific connection attempt.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>protected &nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../javax/mail/Service.html#queueEvent(javax.mail.event.MailEvent, java.util.Vector)">queueEvent</A></B>(<A HREF="../../javax/mail/event/MailEvent.html">MailEvent</A>&nbsp;event,
           java.util.Vector&nbsp;vector)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Add the event and vector of listeners to the queue to be delivered.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../javax/mail/Service.html#removeConnectionListener(javax.mail.event.ConnectionListener)">removeConnectionListener</A></B>(<A HREF="../../javax/mail/event/ConnectionListener.html">ConnectionListener</A>&nbsp;l)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Remove a Connection event listener.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>protected &nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../javax/mail/Service.html#setConnected(boolean)">setConnected</A></B>(boolean&nbsp;connected)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Set the connection state of this service.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>protected &nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../javax/mail/Service.html#setURLName(javax.mail.URLName)">setURLName</A></B>(<A HREF="../../javax/mail/URLName.html">URLName</A>&nbsp;url)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Set the URLName representing this service.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../javax/mail/Service.html#toString()">toString</A></B>()</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Return <code>getURLName.toString()</code> if this service has a URLName,
 otherwise it will return the default <code>toString</code>.</TD>
</TR>
</TABLE>
&nbsp;<A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A>
<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
<TD><B>Methods inherited from class java.lang.Object</B></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE>clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait</CODE></TD>
</TR>
</TABLE>
&nbsp;
<P>

<!-- ============ FIELD DETAIL =========== -->

<A NAME="field_detail"><!-- --></A>
<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=1><FONT SIZE="+2">
<B>Field Detail</B></FONT></TD>
</TR>
</TABLE>

<A NAME="session"><!-- --></A><H3>
session</H3>
<PRE>
protected <A HREF="../../javax/mail/Session.html">Session</A> <B>session</B></PRE>
<DL>
<DD>The session from which this service was created.</DL>
<HR>

<A NAME="url"><!-- --></A><H3>
url</H3>
<PRE>
protected <A HREF="../../javax/mail/URLName.html">URLName</A> <B>url</B></PRE>
<DL>
<DD>The <code>URLName</code> of this service.</DL>
<HR>

<A NAME="debug"><!-- --></A><H3>
debug</H3>
<PRE>
protected boolean <B>debug</B></PRE>
<DL>
<DD>Debug flag for this service.  Set from the session's debug
 flag when this service is created.</DL>

<!-- ========= CONSTRUCTOR DETAIL ======== -->

<A NAME="constructor_detail"><!-- --></A>
<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=1><FONT SIZE="+2">
<B>Constructor Detail</B></FONT></TD>
</TR>
</TABLE>

<A NAME="Service(javax.mail.Session, javax.mail.URLName)"><!-- --></A><H3>
Service</H3>
<PRE>
protected <B>Service</B>(<A HREF="../../javax/mail/Session.html">Session</A>&nbsp;session,
                  <A HREF="../../javax/mail/URLName.html">URLName</A>&nbsp;urlname)</PRE>
<DL>
<DD>Constructor.<DD><DL>
<DT><B>Parameters:</B><DD><CODE>session</CODE> - Session object for this service<DD><CODE>urlname</CODE> - URLName object to be used for this service</DL>
</DD>
</DL>

<!-- ============ METHOD DETAIL ========== -->

<A NAME="method_detail"><!-- --></A>
<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=1><FONT SIZE="+2">
<B>Method Detail</B></FONT></TD>
</TR>
</TABLE>

<A NAME="connect()"><!-- --></A><H3>
connect</H3>
<PRE>
public void <B>connect</B>()
             throws <A HREF="../../javax/mail/MessagingException.html">MessagingException</A></PRE>
<DL>
<DD>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. <p>

 If the connection is successful, an "open" <code>ConnectionEvent</code>
 is delivered to any <code>ConnectionListeners</code> on this service. <p>

 Most clients should just call this method to connect to the service.<p>

 It is an error to connect to an already connected service. <p>

 The implementation provided here simply calls the following
 <code>connect(String, String, String)</code> method with nulls.<DD><DL>
<DT><B>Throws:</B><DD><CODE><A HREF="../../javax/mail/AuthenticationFailedException.html">AuthenticationFailedException</A></CODE> - for authentication failures<DD><CODE><A HREF="../../javax/mail/MessagingException.html">MessagingException</A></CODE> - for other failures<DD><CODE>IllegalStateException</CODE> - if the service is already connected<DT><B>See Also: </B><DD><A HREF="../../javax/mail/event/ConnectionEvent.html"><CODE>ConnectionEvent</CODE></A></DL>
</DD>
</DL>
<HR>

<A NAME="connect(java.lang.String, java.lang.String, java.lang.String)"><!-- --></A><H3>
connect</H3>
<PRE>
public void <B>connect</B>(java.lang.String&nbsp;host,
                    java.lang.String&nbsp;user,
                    java.lang.String&nbsp;password)
             throws <A HREF="../../javax/mail/MessagingException.html">MessagingException</A></PRE>
<DL>
<DD>Connect to the specified address. This method provides a simple
 authentication scheme that requires a username and password. <p>

 If the connection is successful, an "open" <code>ConnectionEvent</code>
 is delivered to any <code>ConnectionListeners</code> on this service. <p>

 It is an error to connect to an already connected service. <p>

 The implementation in the Service class will collect defaults
 for the host, user, and password from the session, from the
 <code>URLName</code> for this service, and from the supplied
 parameters and then call the <code>protocolConnect</code> method.
 If the <code>protocolConnect</code> method returns <code>false</code>,
 the user will be prompted for any missing information and the
 <code>protocolConnect</code> method will be called again.  The
 subclass should override the <code>protocolConnect</code> method.
 The subclass should also implement the <code>getURLName</code>
 method, or use the implementation in this class. <p>

 On a successful connection, the <code>setURLName</code> method is
 called with a URLName that includes the information used to make
 the connection, including the password. <p>

 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 <code>setPasswordAuthenticaiton</code>.  If the
 password passed in is not null, it is not saved, on the assumption
 that the application is managing passwords explicitly.<DD><DL>
<DT><B>Parameters:</B><DD><CODE>host</CODE> - the host to connect to<DD><CODE>user</CODE> - the user name<DD><CODE>password</CODE> - this user's password<DT><B>Throws:</B><DD><CODE><A HREF="../../javax/mail/AuthenticationFailedException.html">AuthenticationFailedException</A></CODE> - for authentication failures<DD><CODE><A HREF="../../javax/mail/MessagingException.html">MessagingException</A></CODE> - for other failures<DD><CODE>IllegalStateException</CODE> - if the service is already connected<DT><B>See Also: </B><DD><A HREF="../../javax/mail/event/ConnectionEvent.html"><CODE>ConnectionEvent</CODE></A>, 
<A HREF="../../javax/mail/Session.html#setPasswordAuthentication(javax.mail.URLName, javax.mail.PasswordAuthentication)"><CODE>Session.setPasswordAuthentication(javax.mail.URLName, javax.mail.PasswordAuthentication)</CODE></A></DL>
</DD>
</DL>
<HR>

<A NAME="connect(java.lang.String, int, java.lang.String, java.lang.String)"><!-- --></A><H3>
connect</H3>
<PRE>
public void <B>connect</B>(java.lang.String&nbsp;host,
                    int&nbsp;port,
                    java.lang.String&nbsp;user,
                    java.lang.String&nbsp;password)
             throws <A HREF="../../javax/mail/MessagingException.html">MessagingException</A></PRE>
<DL>
<DD>Similar to connect(host, user, password) except a specific port
 can be specified.<DD><DL>
<DT><B>Parameters:</B><DD><CODE>host</CODE> - the host to connect to<DD><CODE>port</CODE> - the port to connect to (-1 means the default port)<DD><CODE>user</CODE> - the user name<DD><CODE>password</CODE> - this user's password<DT><B>Throws:</B><DD><CODE><A HREF="../../javax/mail/AuthenticationFailedException.html">AuthenticationFailedException</A></CODE> - for authentication failures<DD><CODE><A HREF="../../javax/mail/MessagingException.html">MessagingException</A></CODE> - for other failures<DD><CODE>IllegalStateException</CODE> - if the service is already connected<DT><B>See Also: </B><DD><A HREF="../../javax/mail/Service.html#connect(java.lang.String, java.lang.String, java.lang.String)"><CODE>connect(java.lang.String, java.lang.String, java.lang.String)</CODE></A>, 
<A HREF="../../javax/mail/event/ConnectionEvent.html"><CODE>ConnectionEvent</CODE></A></DL>
</DD>
</DL>
<HR>

<A NAME="protocolConnect(java.lang.String, int, java.lang.String, java.lang.String)"><!-- --></A><H3>
protocolConnect</H3>
<PRE>
protected boolean <B>protocolConnect</B>(java.lang.String&nbsp;host,
                                  int&nbsp;port,
                                  java.lang.String&nbsp;user,
                                  java.lang.String&nbsp;password)
                           throws <A HREF="../../javax/mail/MessagingException.html">MessagingException</A></PRE>
<DL>
<DD>The service implementation should override this method to
 perform the actual protocol-specific connection attempt.
 The default implementation of the <code>connect</code> method
 calls this method as needed. <p>

 The <code>protocolConnect</code> method should return
 <code>false</code> if a user name or password is required
 for authentication but the corresponding parameter is null;
 the <code>connect</code> method will prompt the user when
 needed to supply missing information.  This method may
 also return <code>false</code> if authentication fails for
 the supplied user name or password.  Alternatively, this method
 may throw an AuthenticationFailedException when authentication
 fails.  This exception may include a String message with more
 detail about the failure. <p>

 The <code>protocolConnect</code> method should throw an
 exception to report failures not related to authentication,
 such as an invalid host name or port number, loss of a
 connection during the authentication process, unavailability
 of the server, etc.<DD><DL>
<DT><B>Parameters:</B><DD><CODE>host</CODE> - the name of the host to connect to<DD><CODE>port</CODE> - the port to use (-1 means use default port)<DD><CODE>user</CODE> - the name of the user to login as<DD><CODE>password</CODE> - the user's password<DT><B>Returns:</B><DD>true if connection successful, false if authentication failed<DT><B>Throws:</B><DD><CODE><A HREF="../../javax/mail/AuthenticationFailedException.html">AuthenticationFailedException</A></CODE> - for authentication failures<DD><CODE><A HREF="../../javax/mail/MessagingException.html">MessagingException</A></CODE> - for non-authentication failures</DL>
</DD>
</DL>
<HR>

<A NAME="isConnected()"><!-- --></A><H3>
isConnected</H3>
<PRE>
public boolean <B>isConnected</B>()</PRE>
<DL>
<DD>Is this service currently connected? <p>

 This implementation uses a private boolean field to 
 store the connection state. This method returns the value
 of that field. <p>

 Subclasses may want to override this method to verify that any
 connection to the message store is still alive.<DD><DL>
<DT><B>Returns:</B><DD>true if the service is connected, false if it is not connected</DL>
</DD>
</DL>
<HR>

<A NAME="setConnected(boolean)"><!-- --></A><H3>
setConnected</H3>
<PRE>
protected void <B>setConnected</B>(boolean&nbsp;connected)</PRE>
<DL>
<DD>Set the connection state of this service.  The connection state
 will automatically be set by the service implementation during the
 <code>connect</code> and <code>close</code> methods.
 Subclasses will need to call this method to set the state
 if the service was automatically disconnected. <p>

 The implementation in this class merely sets the private field
 returned by the <code>isConnected</code> method.<DD><DL>
<DT><B>Parameters:</B><DD><CODE>connected</CODE> - true if the service is connected,
                  false if it is not connected</DL>
</DD>
</DL>
<HR>

<A NAME="close()"><!-- --></A><H3>
close</H3>
<PRE>
public void <B>close</B>()
           throws <A HREF="../../javax/mail/MessagingException.html">MessagingException</A></PRE>
<DL>
<DD>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. <p>

 This implementation uses <code>setConnected(false)</code> to set
 this service's connected state to <code>false</code>. It will then
 send a close ConnectionEvent to any registered ConnectionListeners.
 Subclasses overriding this method to do implementation specific
 cleanup should call this method as a last step to insure event
 notification, probably by including a call to <code>super.close()</code>
 in a <code>finally</code> clause.<DD><DL>
<DT><B>Throws:</B><DD><CODE><A HREF="../../javax/mail/MessagingException.html">MessagingException</A></CODE> - for errors while closing<DT><B>See Also: </B><DD><A HREF="../../javax/mail/event/ConnectionEvent.html"><CODE>ConnectionEvent</CODE></A></DL>
</DD>
</DL>
<HR>

<A NAME="getURLName()"><!-- --></A><H3>
getURLName</H3>
<PRE>
public <A HREF="../../javax/mail/URLName.html">URLName</A> <B>getURLName</B>()</PRE>
<DL>
<DD>Return a URLName representing this service.  The returned URLName
 does <em>not</em> include the password field.  <p>

 Subclasses should only override this method if their
 URLName does not follow the standard format. <p>

 The implementation in the Service class returns (usually a copy of)
 the <code>url</code> field with the password and file information
 stripped out.<DD><DL>
<DT><B>Returns:</B><DD>the URLName representing this service<DT><B>See Also: </B><DD><A HREF="../../javax/mail/URLName.html"><CODE>URLName</CODE></A></DL>
</DD>
</DL>
<HR>

<A NAME="setURLName(javax.mail.URLName)"><!-- --></A><H3>
setURLName</H3>
<PRE>
protected void <B>setURLName</B>(<A HREF="../../javax/mail/URLName.html">URLName</A>&nbsp;url)</PRE>
<DL>
<DD>Set the URLName representing this service.
 Normally used to update the <code>url</code> field
 after a service has successfully connected. <p>

 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
 <code>URLName</code>; a new <code>URLName</code> should
 be constructed with any unneeded fields removed. <p>

 The implementation in the Service class simply sets the
 <code>url</code> field.<DD><DL>
<DT><B>See Also: </B><DD><A HREF="../../javax/mail/URLName.html"><CODE>URLName</CODE></A></DL>
</DD>
</DL>
<HR>

<A NAME="addConnectionListener(javax.mail.event.ConnectionListener)"><!-- --></A><H3>
addConnectionListener</H3>
<PRE>
public void <B>addConnectionListener</B>(<A HREF="../../javax/mail/event/ConnectionListener.html">ConnectionListener</A>&nbsp;l)</PRE>
<DL>
<DD>Add a listener for Connection events on this service. <p>

 The default implementation provided here adds this listener
 to an internal list of ConnectionListeners.<DD><DL>
<DT><B>Parameters:</B><DD><CODE>l</CODE> - the Listener for Connection events<DT><B>See Also: </B><DD><A HREF="../../javax/mail/event/ConnectionEvent.html"><CODE>ConnectionEvent</CODE></A></DL>
</DD>
</DL>
<HR>

<A NAME="removeConnectionListener(javax.mail.event.ConnectionListener)"><!-- --></A><H3>
removeConnectionListener</H3>
<PRE>
public void <B>removeConnectionListener</B>(<A HREF="../../javax/mail/event/ConnectionListener.html">ConnectionListener</A>&nbsp;l)</PRE>
<DL>
<DD>Remove a Connection event listener. <p>

 The default implementation provided here removes this listener
 from the internal list of ConnectionListeners.<DD><DL>
<DT><B>Parameters:</B><DD><CODE>l</CODE> - the listener<DT><B>See Also: </B><DD><A HREF="../../javax/mail/Service.html#addConnectionListener(javax.mail.event.ConnectionListener)"><CODE>addConnectionListener(javax.mail.event.ConnectionListener)</CODE></A></DL>
</DD>
</DL>
<HR>

<A NAME="notifyConnectionListeners(int)"><!-- --></A><H3>
notifyConnectionListeners</H3>
<PRE>
protected void <B>notifyConnectionListeners</B>(int&nbsp;type)</PRE>
<DL>
<DD>Notify all ConnectionListeners. Service implementations are
 expected to use this method to broadcast connection events. <p>

 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.</DL>
<HR>

<A NAME="toString()"><!-- --></A><H3>
toString</H3>
<PRE>
public java.lang.String <B>toString</B>()</PRE>
<DL>
<DD>Return <code>getURLName.toString()</code> if this service has a URLName,
 otherwise it will return the default <code>toString</code>.<DD><DL>
<DT><B>Overrides:</B><DD><CODE>toString</CODE> in class <CODE>java.lang.Object</CODE></DL>
</DD>
</DL>
<HR>

<A NAME="queueEvent(javax.mail.event.MailEvent, java.util.Vector)"><!-- --></A><H3>
queueEvent</H3>
<PRE>
protected void <B>queueEvent</B>(<A HREF="../../javax/mail/event/MailEvent.html">MailEvent</A>&nbsp;event,
                          java.util.Vector&nbsp;vector)</PRE>
<DL>
<DD>Add the event and vector of listeners to the queue to be delivered.</DL>
<HR>

<A NAME="finalize()"><!-- --></A><H3>
finalize</H3>
<PRE>
protected void <B>finalize</B>()
                 throws java.lang.Throwable</PRE>
<DL>
<DD>Stop the event dispatcher thread so the queue can be garbage collected.<DD><DL>
<DT><B>Overrides:</B><DD><CODE>finalize</CODE> in class <CODE>java.lang.Object</CODE></DL>
</DD>
</DL>
<!-- ========= END OF CLASS DATA ========= -->
<HR>

<!-- ========== START OF NAVBAR ========== -->
<A NAME="navbar_bottom"><!-- --></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_bottom_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3">
  <TR ALIGN="center" VALIGN="top">
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="class-use/Service.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
  </TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>

<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;<A HREF="../../javax/mail/Provider.Type.html"><B>PREV CLASS</B></A>&nbsp;
&nbsp;<A HREF="../../javax/mail/Session.html"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
  <A HREF="../../index.html" TARGET="_top"><B>FRAMES</B></A>  &nbsp;
&nbsp;<A HREF="Service.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
  SUMMARY: &nbsp;INNER&nbsp;|&nbsp;<A HREF="#field_summary">FIELD</A>&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL: &nbsp;<A HREF="#field_detail">FIELD</A>&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<!-- =========== END OF NAVBAR =========== -->

<HR>

</BODY>
</HTML>
