📄 session.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><!--NewPage--><HTML><HEAD><!-- Generated by javadoc (build 1.4.2_02) on Thu Nov 13 17:20:41 PST 2003 --><TITLE>Session (Java 2 Platform Ent. Ed. v1.4)</TITLE><META NAME="keywords" CONTENT="javax.mail.Session class"><LINK REL ="stylesheet" TYPE="text/css" HREF="../../stylesheet.css" TITLE="Style"><SCRIPT type="text/javascript">function windowTitle(){ parent.document.title="Session (Java 2 Platform Ent. Ed. v1.4)";}</SCRIPT></HEAD><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=""><TR><TD COLSPAN=3 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="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-all.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> </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM><b>Java<sup><font size=-2>TM</font></sup> 2 Platform<br>Ent. Ed. v1.4</b></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../javax/mail/Service.html" title="class in javax.mail"><B>PREV CLASS</B></A> <A HREF="../../javax/mail/Store.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" target="_top"><B>FRAMES</B></A> <A HREF="Session.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>'); } //--></SCRIPT><NOSCRIPT> <A HREF="../../allclasses-noframe.html"><B>All Classes</B></A></NOSCRIPT></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: NESTED | FIELD | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: FIELD | CONSTR | <A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><A NAME="skip-navbar_top"></A><!-- ========= END OF TOP NAVBAR ========= --><HR><!-- ======== START OF CLASS DATA ======== --><H2><FONT SIZE="-1">javax.mail</FONT><BR>Class Session</H2><PRE><A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html" title="class or interface in java.lang">java.lang.Object</A> <IMG SRC="../../resources/inherit.gif" ALT="extended by"><B>javax.mail.Session</B></PRE><HR><DL><DT>public final class <B>Session</B><DT>extends <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html" title="class or interface in java.lang">Object</A></DL><P>The Session class represents a mail session and is not subclassed. It collects together properties and defaults used by the mail API's. A single default session can be shared by multiple applications on the desktop. Unshared sessions can also be created. <p> The Session class provides access to the protocol providers that implement the <code>Store</code>, <code>Transport</code>, and related classes. The protocol providers are configured using the following files: <ul> <li> <code>javamail.providers</code> and <code>javamail.default.providers</code> </li> <li> <code>javamail.address.map</code> and <code>javamail.default.address.map</code> </li> </ul> <p> Each <code>javamail.</code><i>X</i> resource file is searched for using three methods in the following order: <ol> <li> <code>java.home/lib/javamail.</code><i>X</i> </li> <li> <code>META-INF/javamail.</code><i>X</i> </li> <li> <code>META-INF/javamail.default.</code><i>X</i> </li> </ol> <p> The first method allows the user to include their own version of the resource file by placing it in the <code>lib</code> directory where the <code>java.home</code> property points. The second method allows an application that uses the JavaMail APIs to include their own resource files in their application's or jar file's <code>META-INF</code> directory. The <code>javamail.default.</code><i>X</i> default files are part of the JavaMail <code>mail.jar</code> file. <p> File location depends upon how the <code>ClassLoader</code> method <code>getResource</code> is implemented. Usually, the <code>getResource</code> method searches through CLASSPATH until it finds the requested file and then stops. JDK 1.1 has a limitation that the number of files of each name that will be found in the CLASSPATH is limited to one. However, this only affects method two, above; method one is loaded from a specific location (if allowed by the SecurityManager) and method three uses a different name to ensure that the default resource file is always loaded successfully. J2SE 1.2 and later are not limited to one file of a given name. <p> The ordering of entries in the resource files matters. If multiple entries exist, the first entries take precedence over the later entries. For example, the first IMAP provider found will be set as the default IMAP implementation until explicitly changed by the application. The user- or system-supplied resource files augment, they do not override, the default files included with the JavaMail APIs. This means that all entries in all files loaded will be available. <p> <b><code>javamail.providers</code></b> and <b><code>javamail.default.providers</code></b><p> These resource files specify the stores and transports that are available on the system, allowing an application to "discover" what store and transport implementations are available. The protocol implementations are listed one per line. The file format defines four attributes that describe a protocol implementation. Each attribute is an "="-separated name-value pair with the name in lowercase. Each name-value pair is semi-colon (";") separated. The following names are defined. <p> <table border=1> <caption> Attribute Names in Providers Files </caption> <tr> <th>Name</th><th>Description</th> </tr> <tr> <td>protocol</td> <td>Name assigned to protocol. For example, <code>smtp</code> for Transport.</td> </tr> <tr> <td>type</td> <td>Valid entries are <code>store</code> and <code>transport</code>.</td> </tr> <tr> <td>class</td> <td>Class name that implements this protocol.</td> </tr> <tr> <td>vendor</td> <td>Optional string identifying the vendor.</td> </tr> <tr> <td>version</td> <td>Optional string identifying the version.</td> </tr> </table><p> Here's an example of <code>META-INF/javamail.default.providers</code> file contents: <pre> protocol=imap; type=store; class=com.sun.mail.imap.IMAPStore; vendor=Sun Microsystems, Inc.; protocol=smtp; type=transport; class=com.sun.mail.smtp.SMTPTransport; vendor=Sun Microsystems, Inc.; </pre><p> <b><code>javamail.address.map</code></b> and <b><code>javamail.default.address.map</code></b><p> These resource files map transport address types to the transport protocol. The <code>getType</code> method of </code>javax.mail.Address</code> returns the address type. The <code>javamail.address.map</code> file maps the transport type to the protocol. The file format is a series of name-value pairs. Each key name should correspond to an address type that is currently installed on the system; there should also be an entry for each <code>javax.mail.Address</code> implementation that is present if it is to be used. For example, the <code>javax.mail.internet.InternetAddress</code> method <code>getType</code> returns "rfc822". Each referenced protocol should be installed on the system. For the case of <code>news</code>, below, the client should install a Transport provider supporting the nntp protocol. <p> Here are the typical contents of a <code>javamail.address.map</code> file: <pre> rfc822=smtp news=nntp </pre><P><P><DL><DT><B>Version:</B></DT> <DD>1.64, 03/05/26</DD><DT><B>Author:</B></DT> <DD>John Mani, Bill Shannon, Max Spivak</DD></DL><HR><P><!-- ======== NESTED CLASS SUMMARY ======== --><!-- =========== FIELD SUMMARY =========== --><!-- ======== CONSTRUCTOR SUMMARY ======== --><!-- ========== METHOD SUMMARY =========== --><A NAME="method_summary"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><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> boolean</CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/mail/Session.html#getDebug()">getDebug</A></B>()</CODE><BR> Get the debug setting for this Session.</TD></TR><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/docs/api/java/io/PrintStream.html" title="class or interface in java.io">PrintStream</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/mail/Session.html#getDebugOut()">getDebugOut</A></B>()</CODE><BR> Returns the stream to be used for debugging output. </TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static <A HREF="../../javax/mail/Session.html" title="class in javax.mail">Session</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/mail/Session.html#getDefaultInstance(java.util.Properties)">getDefaultInstance</A></B>(<A HREF="http://java.sun.com/j2se/1.4/docs/api/java/util/Properties.html" title="class or interface in java.util">Properties</A> props)</CODE><BR> Get the default Session object. </TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static <A HREF="../../javax/mail/Session.html" title="class in javax.mail">Session</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/mail/Session.html#getDefaultInstance(java.util.Properties, javax.mail.Authenticator)">getDefaultInstance</A></B>(<A HREF="http://java.sun.com/j2se/1.4/docs/api/java/util/Properties.html" title="class or interface in java.util">Properties</A> props, <A HREF="../../javax/mail/Authenticator.html" title="class in javax.mail">Authenticator</A> authenticator)</CODE><BR> Get the default Session object. </TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../../javax/mail/Folder.html" title="class in javax.mail">Folder</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/mail/Session.html#getFolder(javax.mail.URLName)">getFolder</A></B>(<A HREF="../../javax/mail/URLName.html" title="class in javax.mail">URLName</A> url)</CODE>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -