<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--NewPage-->
<!-- Generated by javadoc (build 1.6.0_10) on Tue Nov 17 12:13:38 PST 2009 -->
<
META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
Service (JavaMail API documentation)
<
META NAME="date" CONTENT="2009-11-17">
<
LINK REL ="stylesheet" TYPE="text/css" HREF="../../stylesheet.css" TITLE="Style">
<
SCRIPT type="text/javascript">
function windowTitle()
{
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="Service (JavaMail API documentation)";
}
}
<
BODY BGCOLOR="white" onload="windowTitle();">
<!-- ========= START OF TOP NAVBAR ======= -->
<
A NAME="navbar_top"><!-- --><
/A>
<
A HREF="#skip-navbar_top" title="Skip navigation links"><
/A>
<
TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<
TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<
A NAME="navbar_top_firstrow"><!-- --><
/A>
<
TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
<
TR ALIGN="center" VALIGN="top">
<
TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <
A HREF="../../overview-summary.html"><
FONT CLASS="NavBarFont1"><
B>Overview<
/B><
/FONT><
/A> <
/TD>
<
TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <
A HREF="package-summary.html"><
FONT CLASS="NavBarFont1"><
B>Package<
/B><
/FONT><
/A> <
/TD>
<
TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <
FONT CLASS="NavBarFont1Rev"><
B>Class<
/B><
/FONT> <
/TD>
<
TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <
A HREF="class-use/Service.html"><
FONT CLASS="NavBarFont1"><
B>Use<
/B><
/FONT><
/A> <
/TD>
<
TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <
A HREF="package-tree.html"><
FONT CLASS="NavBarFont1"><
B>Tree<
/B><
/FONT><
/A> <
/TD>
<
TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <
A HREF="../../deprecated-list.html"><
FONT CLASS="NavBarFont1"><
B>Deprecated<
/B><
/FONT><
/A> <
/TD>
<
TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <
A HREF="../../index-files/index-1.html"><
FONT CLASS="NavBarFont1"><
B>Index<
/B><
/FONT><
/A> <
/TD>
<
TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <
A HREF="../../help-doc.html"><
FONT CLASS="NavBarFont1"><
B>Help<
/B><
/FONT><
/A> <
/TD>
<
TD ALIGN="right" VALIGN="top" ROWSPAN=3><
EM>
<
TD BGCOLOR="white" CLASS="NavBarCell2"><
FONT SIZE="-2">
<
A HREF="../../javax/mail/SendFailedException.html" title="class in javax.mail"><
B>PREV CLASS<
/B><
/A>
<
A HREF="../../javax/mail/Session.html" title="class in javax.mail"><
B>NEXT CLASS<
/B><
/A><
/FONT><
/TD>
<
TD BGCOLOR="white" CLASS="NavBarCell2"><
FONT SIZE="-2">
<
A HREF="../../index.html?javax/mail/Service.html" target="_top"><
B>FRAMES<
/B><
/A>
<
A HREF="Service.html" target="_top"><
B>NO FRAMES<
/B><
/A>
<
SCRIPT type="text/javascript">
<!--
if(window==top) {
document.writeln('<A HREF="../../allclasses-noframe.html"><B>All Classes</B></A>');
}
//-->
<
A HREF="../../allclasses-noframe.html"><
B>All Classes<
/B><
/A>
<
TD VALIGN="top" CLASS="NavBarCell3"><
FONT SIZE="-2">
SUMMARY: NESTED | <
A HREF="#field_summary">FIELD<
/A> | <
A HREF="#constructor_summary">CONSTR<
/A> | <
A HREF="#method_summary">METHOD<
/A><
/FONT><
/TD>
<
TD VALIGN="top" CLASS="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>
<
A NAME="skip-navbar_top"><
/A>
<!-- ========= END OF TOP NAVBAR ========= -->
<!-- ======== START OF CLASS DATA ======== -->
<
A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">java.
lang.Object<
/A>
<
IMG SRC="../../resources/inherit.gif" ALT="extended by "><
B>javax.mail.Service<
/B>
<
DT><
B>Direct Known Subclasses:<
/B> <
DD><
A HREF="../../javax/mail/Store.html" title="class in javax.mail">Store<
/A>, <
A HREF="../../javax/mail/Transport.html" title="class in javax.mail">Transport<
/A><
/DD>
<
DT><
PRE>public abstract
class <
B>Service<
/B><
DT>extends <
A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object<
/A><
/DL>
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.
<!-- =========== FIELD SUMMARY =========== -->
<
A NAME="field_summary"><!-- --><
/A>
<
TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<
TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<
TH ALIGN="left" COLSPAN="2"><
FONT SIZE="+2">
<
TR BGCOLOR="white" CLASS="TableRowColor">
<
TD ALIGN="right" VALIGN="top" WIDTH="1%"><
FONT SIZE="-1">
<
TD><
CODE><
B><
A HREF="../../javax/mail/Service.html#debug">debug<
/A><
/B><
/CODE>
Debug flag
for this service.<
/TD>
<
TR BGCOLOR="white" CLASS="TableRowColor">
<
TD ALIGN="right" VALIGN="top" WIDTH="1%"><
FONT SIZE="-1">
<
CODE>protected <
A HREF="../../javax/mail/Session.html" title="class in javax.mail">Session<
/A><
/CODE><
/FONT><
/TD>
<
TD><
CODE><
B><
A HREF="../../javax/mail/Service.html#session">session<
/A><
/B><
/CODE>
The session from which this service was created.<
/TD>
<
TR BGCOLOR="white" CLASS="TableRowColor">
<
TD ALIGN="right" VALIGN="top" WIDTH="1%"><
FONT SIZE="-1">
<
CODE>protected <
A HREF="../../javax/mail/URLName.html" title="class in javax.mail">URLName<
/A><
/CODE><
/FONT><
/TD>
<
TD><
CODE><
B><
A HREF="../../javax/mail/Service.html#url">url<
/A><
/B><
/CODE>
The <
code>URLName<
/code> of this service.<
/TD>
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<
A NAME="constructor_summary"><!-- --><
/A>
<
TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<
TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<
TH ALIGN="left" COLSPAN="2"><
FONT SIZE="+2">
<
TR BGCOLOR="white" CLASS="TableRowColor">
<
TD ALIGN="right" VALIGN="top" WIDTH="1%"><
FONT SIZE="-1">
<
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" title="class in javax.mail">Session<
/A> session,
<
A HREF="../../javax/mail/URLName.html" title="class in javax.mail">URLName<
/A> urlname
)<
/CODE>
Constructor.<
/TD>
<!-- ========== METHOD SUMMARY =========== -->
<
A NAME="method_summary"><!-- --><
/A>
<
TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<
TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<
TH ALIGN="left" COLSPAN="2"><
FONT SIZE="+2">
<
TR BGCOLOR="white" CLASS="TableRowColor">
<
TD ALIGN="right" VALIGN="top" WIDTH="1%"><
FONT SIZE="-1">
<
TD><
CODE><
B><
A HREF="../../javax/mail/Service.html#addConnectionListener(javax.mail.event.ConnectionListener)">addConnectionListener<
/A><
/B>
(<
A HREF="../../javax/mail/event/ConnectionListener.html" title="interface in javax.mail.event">ConnectionListener<
/A> l
)<
/CODE>
Add a listener
for Connection events on this service.<
/TD>
<
TR BGCOLOR="white" CLASS="TableRowColor">
<
TD ALIGN="right" VALIGN="top" WIDTH="1%"><
FONT SIZE="-1">
<
TD><
CODE><
B><
A HREF="../../javax/mail/Service.html#close()">close<
/A><
/B>
()<
/CODE>
Close this service and terminate its connection.<
/TD>
<
TR BGCOLOR="white" CLASS="TableRowColor">
<
TD ALIGN="right" VALIGN="top" WIDTH="1%"><
FONT SIZE="-1">
<
TD><
CODE><
B><
A HREF="../../javax/mail/Service.html#connect()">connect<
/A><
/B>
()<
/CODE>
A generic connect
method that takes no parameters.<
/TD>
<
TR BGCOLOR="white" CLASS="TableRowColor">
<
TD ALIGN="right" VALIGN="top" WIDTH="1%"><
FONT SIZE="-1">
<
TD><
CODE><
B><
A HREF="../../javax/mail/Service.html#connect(java.lang.String, int, java.lang.String, java.lang.String)">connect<
/A><
/B>
(<
A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String<
/A> host,
int port,
<
A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String<
/A> user,
<
A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String<
/A> password
)<
/CODE>
Similar to connect(host, user, password) except a specific port
<
TR BGCOLOR="white" CLASS="TableRowColor">
<
TD ALIGN="right" VALIGN="top" WIDTH="1%"><
FONT SIZE="-1">
<
TD><
CODE><
B><
A HREF="../../javax/mail/Service.html#connect(java.lang.String, java.lang.String)">connect<
/A><
/B>
(<
A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String<
/A> user,
<
A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String<
/A> password
)<
/CODE>
Connect to the current host using the specified username
<
TR BGCOLOR="white" CLASS="TableRowColor">
<
TD ALIGN="right" VALIGN="top" WIDTH="1%"><
FONT SIZE="-1">
<
TD><
CODE><
B><
A HREF="../../javax/mail/Service.html#connect(java.lang.String, java.lang.String, java.lang.String)">connect<
/A><
/B>
(<
A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String<
/A> host,
<
A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String<
/A> user,
<
A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String<
/A> password
)<
/CODE>
Connect to the specified address.<
/TD>
<
TR BGCOLOR="white" CLASS="TableRowColor">
<
TD ALIGN="right" VALIGN="top" WIDTH="1%"><
FONT SIZE="-1">
<
TD><
CODE><
B><
A HREF="../../javax/mail/Service.html#finalize()">finalize<
/A><
/B>
()<
/CODE>
Stop the event dispatcher thread so the queue can be garbage collected.<
/TD>
<
TR BGCOLOR="white" CLASS="TableRowColor">
<
TD ALIGN="right" VALIGN="top" WIDTH="1%"><
FONT SIZE="-1">
<
CODE> <
A HREF="../../javax/mail/URLName.html" title="class in javax.mail">URLName<
/A><
/CODE><
/FONT><
/TD>
<
TD><
CODE><
B><
A HREF="../../javax/mail/Service.html#getURLName()">getURLName<
/A><
/B>
()<
/CODE>
Return a URLName representing this service.<
/TD>
<
TR BGCOLOR="white" CLASS="TableRowColor">
<
TD ALIGN="right" VALIGN="top" WIDTH="1%"><
FONT SIZE="-1">
<
TD><
CODE><
B><
A HREF="../../javax/mail/Service.html#isConnected()">isConnected<
/A><
/B>
()<
/CODE>
Is this service currently connected?<
/TD>
<
TR BGCOLOR="white" CLASS="TableRowColor">
<
TD ALIGN="right" VALIGN="top" WIDTH="1%"><
FONT SIZE="-1">
<
TD><
CODE><
B><
A HREF="../../javax/mail/Service.html#notifyConnectionListeners(int)">notifyConnectionListeners<
/A><
/B>
(int
type)<
/CODE>
Notify all ConnectionListeners.<
/TD>
<
TR BGCOLOR="white" CLASS="TableRowColor">
<
TD ALIGN="right" VALIGN="top" WIDTH="1%"><
FONT SIZE="-1">
<
TD><
CODE><
B><
A HREF="../../javax/mail/Service.html#protocolConnect(java.lang.String, int, java.lang.String, java.lang.String)">protocolConnect<
/A><
/B>
(<
A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String<
/A> host,
int port,
<
A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String<
/A> user,
<
A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String<
/A> password
)<
/CODE>
The service implementation should override this method to
perform the actual protocol-specific connection attempt.<
/TD>
<
TR BGCOLOR="white" CLASS="TableRowColor">
<
TD ALIGN="right" VALIGN="top" WIDTH="1%"><
FONT SIZE="-1">
<
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" title="class in javax.mail.event">MailEvent<
/A> event,
<
A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/util/Vector.html?is-external=true" title="class or interface in java.util">Vector<
/A> vector
)<
/CODE>
Add the event and vector of listeners to the queue to be delivered.<
/TD>
<
TR BGCOLOR="white" CLASS="TableRowColor">
<
TD ALIGN="right" VALIGN="top" WIDTH="1%"><
FONT SIZE="-1">
<
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> l
)<
/CODE>
Remove a Connection event listener.<
/TD>
<
TR BGCOLOR="white" CLASS="TableRowColor">
<
TD ALIGN="right" VALIGN="top" WIDTH="1%"><
FONT SIZE="-1">
<
TD><
CODE><
B><
A HREF="../../javax/mail/Service.html#setConnected(boolean)">setConnected<
/A><
/B>
(boolean connected
)<
/CODE>
Set the connection state of this service.<
/TD>
<
TR BGCOLOR="white" CLASS="TableRowColor">
<
TD ALIGN="right" VALIGN="top" WIDTH="1%"><
FONT SIZE="-1">
<
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> url
)<
/CODE>
Set the URLName representing this service.<
/TD>
<
TR BGCOLOR="white" CLASS="TableRowColor">
<
TD ALIGN="right" VALIGN="top" WIDTH="1%"><
FONT SIZE="-1">
<
CODE> <
A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html?is-external=true" 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>
Return <
code>getURLName.toString
()<
/code> if this service has a URLName,
otherwise it will return the default <
code>toString<
/code>.<
/TD>
<
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.4.2/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object<
/A><
/B><
/TH>
<
TR BGCOLOR="white" CLASS="TableRowColor">
<
TD><
CODE><
A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Object.html?is-external=true#clone()" title="class or interface in java.lang">clone<
/A>, <
A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Object.html?is-external=true#equals(java.lang.Object)" title="class or interface in java.lang">equals<
/A>, <
A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Object.html?is-external=true#getClass()" title="class or interface in java.lang">getClass<
/A>, <
A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Object.html?is-external=true#hashCode()" title="class or interface in java.lang">hashCode<
/A>, <
A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Object.html?is-external=true#notify()" title="class or interface in java.lang">notify<
/A>, <
A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Object.html?is-external=true#notifyAll()" title="class or interface in java.lang">notifyAll<
/A>, <
A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Object.html?is-external=true#wait()" title="class or interface in java.lang">wait<
/A>, <
A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Object.html?is-external=true#wait(long)" title="class or interface in java.lang">wait<
/A>, <
A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Object.html?is-external=true#wait(long, int)" title="class or interface in java.lang">wait<
/A><
/CODE><
/TD>
<!-- ============ 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">
<
A NAME="session"><!-- --><
/A><
H3>
protected <
A HREF="../../javax/mail/Session.html" title="class in javax.mail">Session<
/A> <
B>session<
/B><
/PRE>
<
DD>The session from which this service was created.
<
A NAME="url"><!-- --><
/A><
H3>
protected <
A HREF="../../javax/mail/URLName.html" title="class in javax.mail">URLName<
/A> <
B>url<
/B><
/PRE>
<
A NAME="debug"><!-- --><
/A><
H3>
protected boolean <
B>debug<
/B><
/PRE>
<
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> session,
<A HREF="../../javax/mail/URLName.html" title="class in javax.mail">URLName</A> 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.4.2/docs/api/java/lang/IllegalStateException.html?is-external=true" 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.4.2/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</A> host,
<A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</A> user,
<A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</A> 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
<
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.4.2/docs/api/java/lang/IllegalStateException.html?is-external=true" 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>
<
A NAME="connect(java.lang.String, java.lang.String)"><!-- --><
/A><
H3>
public void <
B>connect<
/B>
(<
A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String<
/A> user,
<
A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String<
/A> password
)
throws <
A HREF="../../javax/mail/MessagingException.html" title="class in javax.mail">MessagingException<
/A><
/PRE>
<
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.
<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.4.2/docs/api/java/lang/IllegalStateException.html?is-external=true" 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.4.2/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</A> host,
int port,
<A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</A> user,
<A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</A> 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
<
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.4.2/docs/api/java/lang/IllegalStateException.html?is-external=true" 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>
<
A NAME="protocolConnect(java.lang.String, int, java.lang.String, java.lang.String)"><!-- --><
/A><
H3>
protected boolean <
B>protocolConnect<
/B>
(<
A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String<
/A> host,
int port,
<
A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String<
/A> user,
<
A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String<
/A> password
)
throws <
A HREF="../../javax/mail/MessagingException.html" title="class in javax.mail">MessagingException<
/A><
/PRE>
<
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.
<
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" 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 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.
<P>
<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.
<P>
<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" title="class in javax.mail">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>
<
DD><
CODE><
A HREF="../../javax/mail/MessagingException.html" title="class in javax.mail">MessagingException<
/A><
/CODE> -
for errors while closing<
DT><
B>See Also:<
/B><
DD><
A HREF="../../javax/mail/event/ConnectionEvent.html" title="class in javax.mail.event"><
CODE>ConnectionEvent<
/CODE><
/A><
/DL>
<
A NAME="getURLName()"><!-- --><
/A><
H3>
public <
A HREF="../../javax/mail/URLName.html" title="class in javax.mail">URLName<
/A> <
B>getURLName<
/B>
()<
/PRE>
<
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.
<
DT><
B>Returns:<
/B><
DD>the URLName representing this service<
DT><
B>See Also:<
/B><
DD><
A HREF="../../javax/mail/URLName.html" title="class in javax.mail"><
CODE>URLName<
/CODE><
/A><
/DL>
<
A NAME="setURLName(javax.mail.URLName)"><!-- --><
/A><
H3>
protected void <
B>setURLName<
/B>
(<
A HREF="../../javax/mail/URLName.html" title="class in javax.mail">URLName<
/A> url
)<
/PRE>
<
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
be constructed with any unneeded fields removed. <
p>
The implementation in the Service class simply sets the
<
DT><
B>See Also:<
/B><
DD><
A HREF="../../javax/mail/URLName.html" title="class in javax.mail"><
CODE>URLName<
/CODE><
/A><
/DL>
<
A NAME="addConnectionListener(javax.mail.event.ConnectionListener)"><!-- --><
/A><
H3>
addConnectionListener<
/H3>
public void <
B>addConnectionListener<
/B>
(<
A HREF="../../javax/mail/event/ConnectionListener.html" title="interface in javax.mail.event">ConnectionListener<
/A> l
)<
/PRE>
<
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.
<
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" title="class in javax.mail.event"><
CODE>ConnectionEvent<
/CODE><
/A><
/DL>
<
A NAME="removeConnectionListener(javax.mail.event.ConnectionListener)"><!-- --><
/A><
H3>
removeConnectionListener<
/H3>
public void <
B>removeConnectionListener<
/B>
(<
A HREF="../../javax/mail/event/ConnectionListener.html" title="interface in javax.mail.event">ConnectionListener<
/A> l
)<
/PRE>
<
DD>Remove a Connection event listener. <
p>
The default implementation provided here removes this listener
from the internal list of ConnectionListeners.
<
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>
<
A NAME="notifyConnectionListeners(int)"><!-- --><
/A><
H3>
notifyConnectionListeners<
/H3>
protected void <
B>notifyConnectionListeners<
/B>
(int
type)<
/PRE>
<
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.
<
A NAME="toString()"><!-- --><
/A><
H3>
public <
A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String<
/A> <
B>toString<
/B>
()<
/PRE>
<
DD>Return <
code>getURLName.toString
()<
/code> if this service has a URLName,
otherwise it will return the default <
code>toString<
/code>.
<
DT><
B>Overrides:<
/B><
DD><
CODE><
A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Object.html?is-external=true#toString()" title="class or interface in java.lang">toString<
/A><
/CODE> in
class <
CODE><
A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object<
/A><
/CODE><
/DL>
<
A NAME="queueEvent(javax.mail.event.MailEvent, java.util.Vector)"><!-- --><
/A><
H3>
protected void <
B>queueEvent<
/B>
(<
A HREF="../../javax/mail/event/MailEvent.html" title="class in javax.mail.event">MailEvent<
/A> event,
<
A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/util/Vector.html?is-external=true" title="class or interface in java.util">Vector<
/A> vector
)<
/PRE>
<
DD>Add the event and vector of listeners to the queue to be delivered.
<
A NAME="finalize()"><!-- --><
/A><
H3>
protected void <
B>finalize<
/B>
()
throws <
A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Throwable.html?is-external=true" title="class or interface in java.lang">Throwable<
/A><
/PRE>
<
DD>Stop the event dispatcher thread so the queue can be garbage collected.
<
DT><
B>Overrides:<
/B><
DD><
CODE><
A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Object.html?is-external=true#finalize()" title="class or interface in java.lang">finalize<
/A><
/CODE> in
class <
CODE><
A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object<
/A><
/CODE><
/DL>
<
DD><
CODE><
A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Throwable.html?is-external=true" title="class or interface in java.lang">Throwable<
/A><
/CODE><
/DL>
<!-- ========= END OF CLASS DATA ========= -->
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<
A NAME="navbar_bottom"><!-- --><
/A>
<
A HREF="#skip-navbar_bottom" title="Skip navigation links"><
/A>
<
TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<
TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<
A NAME="navbar_bottom_firstrow"><!-- --><
/A>
<
TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
<
TR ALIGN="center" VALIGN="top">
<
TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <
A HREF="../../overview-summary.html"><
FONT CLASS="NavBarFont1"><
B>Overview<
/B><
/FONT><
/A> <
/TD>
<
TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <
A HREF="package-summary.html"><
FONT CLASS="NavBarFont1"><
B>Package<
/B><
/FONT><
/A> <
/TD>
<
TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <
FONT CLASS="NavBarFont1Rev"><
B>Class<
/B><
/FONT> <
/TD>
<
TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <
A HREF="class-use/Service.html"><
FONT CLASS="NavBarFont1"><
B>Use<
/B><
/FONT><
/A> <
/TD>
<
TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <
A HREF="package-tree.html"><
FONT CLASS="NavBarFont1"><
B>Tree<
/B><
/FONT><
/A> <
/TD>
<
TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <
A HREF="../../deprecated-list.html"><
FONT CLASS="NavBarFont1"><
B>Deprecated<
/B><
/FONT><
/A> <
/TD>
<
TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <
A HREF="../../index-files/index-1.html"><
FONT CLASS="NavBarFont1"><
B>Index<
/B><
/FONT><
/A> <
/TD>
<
TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <
A HREF="../../help-doc.html"><
FONT CLASS="NavBarFont1"><
B>Help<
/B><
/FONT><
/A> <
/TD>
<
TD ALIGN="right" VALIGN="top" ROWSPAN=3><
EM>
<
TD BGCOLOR="white" CLASS="NavBarCell2"><
FONT SIZE="-2">
<
A HREF="../../javax/mail/SendFailedException.html" title="class in javax.mail"><
B>PREV CLASS<
/B><
/A>
<
A HREF="../../javax/mail/Session.html" title="class in javax.mail"><
B>NEXT CLASS<
/B><
/A><
/FONT><
/TD>
<
TD BGCOLOR="white" CLASS="NavBarCell2"><
FONT SIZE="-2">
<
A HREF="../../index.html?javax/mail/Service.html" target="_top"><
B>FRAMES<
/B><
/A>
<
A HREF="Service.html" target="_top"><
B>NO FRAMES<
/B><
/A>
<
SCRIPT type="text/javascript">
<!--
if(window==top) {
document.writeln('<A HREF="../../allclasses-noframe.html"><B>All Classes</B></A>');
}
//-->
<
A HREF="../../allclasses-noframe.html"><
B>All Classes<
/B><
/A>
<
TD VALIGN="top" CLASS="NavBarCell3"><
FONT SIZE="-2">
SUMMARY: NESTED | <
A HREF="#field_summary">FIELD<
/A> | <
A HREF="#constructor_summary">CONSTR<
/A> | <
A HREF="#method_summary">METHOD<
/A><
/FONT><
/TD>
<
TD VALIGN="top" CLASS="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>
<
A NAME="skip-navbar_bottom"><
/A>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
Copyright &#
169;
2009 <
a href="http://www.sun.com">Sun Microsystems, Inc.<
/a>. All Rights Reserved.