service.html

来自「j2ee帮助文档软件设计/软件工程 文件格式」· HTML 代码 · 共 872 行 · 第 1/3 页

HTML
872
字号
<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" title="interface in javax.mail.event">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" title="class in javax.mail">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;<A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A></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" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"><TH ALIGN="left"><B>Methods inherited from class java.lang.<A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/Object.html" title="class or interface in java.lang">Object</A></B></TH></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/Object.html#clone()" title="class or interface in java.lang">clone</A>, <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/Object.html#equals(java.lang.Object)" title="class or interface in java.lang">equals</A>, <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/Object.html#getClass()" title="class or interface in java.lang">getClass</A>, <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/Object.html#hashCode()" title="class or interface in java.lang">hashCode</A>, <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/Object.html#notify()" title="class or interface in java.lang">notify</A>, <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/Object.html#notifyAll()" title="class or interface in java.lang">notifyAll</A>, <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/Object.html#wait()" title="class or interface in java.lang">wait</A>, <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/Object.html#wait(long)" title="class or interface in java.lang">wait</A>, <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/Object.html#wait(long, int)" title="class or interface in java.lang">wait</A></CODE></TD></TR></TABLE>&nbsp;<P><!-- ============ FIELD DETAIL =========== --><A NAME="field_detail"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2"><B>Field Detail</B></FONT></TH></TR></TABLE><A NAME="session"><!-- --></A><H3>session</H3><PRE>protected <A HREF="../../javax/mail/Session.html" title="class in javax.mail">Session</A> <B>session</B></PRE><DL><DD>The session from which this service was created.<P><DL></DL></DL><HR><A NAME="url"><!-- --></A><H3>url</H3><PRE>protected <A HREF="../../javax/mail/URLName.html" title="class in javax.mail">URLName</A> <B>url</B></PRE><DL><DD>The <code>URLName</code> of this service.<P><DL></DL></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.<P><DL></DL></DL><!-- ========= CONSTRUCTOR DETAIL ======== --><A NAME="constructor_detail"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2"><B>Constructor Detail</B></FONT></TH></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" title="class in javax.mail">Session</A>&nbsp;session,                  <A HREF="../../javax/mail/URLName.html" title="class in javax.mail">URLName</A>&nbsp;urlname)</PRE><DL><DD>Constructor.<P><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></DL><!-- ============ METHOD DETAIL ========== --><A NAME="method_detail"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2"><B>Method Detail</B></FONT></TH></TR></TABLE><A NAME="connect()"><!-- --></A><H3>connect</H3><PRE>public void <B>connect</B>()             throws <A HREF="../../javax/mail/MessagingException.html" title="class in javax.mail">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.<P><DD><DL><DT><B>Throws:</B><DD><CODE><A HREF="../../javax/mail/AuthenticationFailedException.html" title="class in javax.mail">AuthenticationFailedException</A></CODE> - for authentication failures<DD><CODE><A HREF="../../javax/mail/MessagingException.html" title="class in javax.mail">MessagingException</A></CODE> - for other failures<DD><CODE><A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/IllegalStateException.html" title="class or interface in java.lang">IllegalStateException</A></CODE> - if the service is already connected<DT><B>See Also:</B><DD><A HREF="../../javax/mail/event/ConnectionEvent.html" title="class in javax.mail.event"><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>(<A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A>&nbsp;host,                    <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A>&nbsp;user,                    <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A>&nbsp;password)             throws <A HREF="../../javax/mail/MessagingException.html" title="class in javax.mail">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 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 <code>setPasswordAuthentication</code>.  If the password passed in is not null, it is not saved, on the assumption that the application is managing passwords explicitly.<P><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" title="class in javax.mail">AuthenticationFailedException</A></CODE> - for authentication failures<DD><CODE><A HREF="../../javax/mail/MessagingException.html" title="class in javax.mail">MessagingException</A></CODE> - for other failures<DD><CODE><A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/IllegalStateException.html" title="class or interface in java.lang">IllegalStateException</A></CODE> - if the service is already connected<DT><B>See Also:</B><DD><A HREF="../../javax/mail/event/ConnectionEvent.html" title="class in javax.mail.event"><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, java.lang.String)"><!-- --></A><H3>connect</H3><PRE>public void <B>connect</B>(<A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A>&nbsp;user,                    <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A>&nbsp;password)             throws <A HREF="../../javax/mail/MessagingException.html" title="class in javax.mail">MessagingException</A></PRE><DL><DD>Connect to the current host using the specified username and password.  This method is equivalent to calling the <code>connect(host, user, password)</code> method with null for the host name.<P><DD><DL><DT><B>Parameters:</B><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" title="class in javax.mail">AuthenticationFailedException</A></CODE> - for authentication failures<DD><CODE><A HREF="../../javax/mail/MessagingException.html" title="class in javax.mail">MessagingException</A></CODE> - for other failures<DD><CODE><A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/IllegalStateException.html" title="class or interface in java.lang">IllegalStateException</A></CODE> - if the service is already connected<DT><B>Since:</B></DT>  <DD>JavaMail 1.4</DD><DT><B>See Also:</B><DD><A HREF="../../javax/mail/event/ConnectionEvent.html" title="class in javax.mail.event"><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>, <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></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>(<A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A>&nbsp;host,                    int&nbsp;port,                    <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A>&nbsp;user,                    <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A>&nbsp;password)             throws <A HREF="../../javax/mail/MessagingException.html" title="class in javax.mail">MessagingException</A></PRE><DL><DD>Similar to connect(host, user, password) except a specific port can be specified.<P><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" title="class in javax.mail">AuthenticationFailedException</A></CODE> - for authentication failures<DD><CODE><A HREF="../../javax/mail/MessagingException.html" title="class in javax.mail">MessagingException</A></CODE> - for other failures<DD><CODE><A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/IllegalStateException.html" title="class or interface in java.lang">IllegalStateException</A></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" title="class in javax.mail.event"><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>(<A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A>&nbsp;host,                                  int&nbsp;port,                                  <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A>&nbsp;user,                                  <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A>&nbsp;password)                           throws <A HREF="../../javax/mail/MessagingException.html" title="class in javax.mail">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.<P><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

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?