📄 service.html
字号:
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><A HREF="../../javax/mail/MessagingException.html">MessagingException</A> - 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 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><A HREF="../../javax/mail/MessagingException.html">MessagingException</A> - 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> 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> 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> 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 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>toString in class java.lang.Object</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> event,
java.util.Vector 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>finalize in class java.lang.Object</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" ID="NavBarCell1">
<A NAME="navbar_bottom_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" ID="NavBarCell1"> <A HREF="../../overview-summary.html"><FONT ID="NavBarFont1"><B>Overview</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" ID="NavBarCell1"> <A HREF="package-summary.html"><FONT ID="NavBarFont1"><B>Package</B></FONT></A> </TD>
<TD BGCOLOR="#FFFFFF" ID="NavBarCell1Rev"> <FONT ID="NavBarFont1Rev"><B>Class</B></FONT> </TD>
<TD BGCOLOR="#EEEEFF" ID="NavBarCell1"> <A HREF="class-use/Service.html"><FONT ID="NavBarFont1"><B>Use</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" ID="NavBarCell1"> <A HREF="package-tree.html"><FONT ID="NavBarFont1"><B>Tree</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" ID="NavBarCell1"> <A HREF="../../deprecated-list.html"><FONT ID="NavBarFont1"><B>Deprecated</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" ID="NavBarCell1"> <A HREF="../../index-files/index-1.html"><FONT ID="NavBarFont1"><B>Index</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" ID="NavBarCell1"> <A HREF="../../help-doc.html"><FONT ID="NavBarFont1"><B>Help</B></FONT></A> </TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" ID="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../javax/mail/Provider.Type.html"><B>PREV CLASS</B></A>
<A HREF="../../javax/mail/Session.html"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" ID="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../index.html" TARGET="_top"><B>FRAMES</B></A>
<A HREF="Service.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD>
</TR>
<TR>
<TD VALIGN="top" ID="NavBarCell3"><FONT SIZE="-2">
SUMMARY: INNER | <A HREF="#field_summary">FIELD</A> | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" ID="NavBarCell3"><FONT SIZE="-2">
DETAIL: <A HREF="#field_detail">FIELD</A> | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<!-- =========== END OF NAVBAR =========== -->
<HR>
</BODY>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -