Class POP3Store
- java.lang.Object
-
- javax.mail.Service
-
- javax.mail.Store
-
- com.sun.mail.pop3.POP3Store
-
- All Implemented Interfaces:
java.lang.AutoCloseable
- Direct Known Subclasses:
POP3SSLStore
public class POP3Store extends Store
A POP3 Message Store. Contains only one folder, "INBOX". See the com.sun.mail.pop3 package documentation for further information on the POP3 protocol provider.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) booleancacheWriteToprivate java.util.Map<java.lang.String,java.lang.String>capabilitiesprivate intdefaultPort(package private) booleandisableTop(package private) java.io.FilefileCacheDir(package private) booleanfinalizeCleanClose(package private) booleanforgetTopHeadersprivate java.lang.Stringhostprivate booleanisSSL(package private) booleankeepMessageContentprivate MailLoggerlogger(package private) java.lang.reflect.Constructor<?>messageConstructorprivate java.lang.Stringnameprivate java.lang.Stringpasswdprivate Protocolportprivate intportNumprivate POP3FolderportOwnerprivate booleanrequireStartTLS(package private) booleanrsetBeforeQuit(package private) booleansupportsUidl(package private) booleanuseFileCacheprivate java.lang.Stringuserprivate booleanuseStartTLSprivate booleanusingSSL
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Map<java.lang.String,java.lang.String>capabilities()Return a Map of the capabilities the server provided, as per RFC 2449.private voidcheckConnected()private static java.io.IOExceptioncleanupAndThrow(Protocol p, java.io.IOException ife)voidclose()Close this service and terminate its connection.(package private) voidclose(boolean force)(package private) voidclosePort(POP3Folder owner)protected voidfinalize()Stop the event dispatcher thread so the queue can be garbage collected.private booleangetBoolProp(java.lang.String prop)Get the value of a boolean property.FoldergetDefaultFolder()Returns a Folder object that represents the 'root' of the default namespace presented to the user by the Store.FoldergetFolder(java.lang.String name)Only the name "INBOX" is supported.FoldergetFolder(URLName url)Return a closed Folder object, corresponding to the given URLName.(package private) ProtocolgetPort(POP3Folder owner)(package private) SessiongetSession()Get a reference to the session.booleanisConnected()Check whether this store is connected.private static booleanisRecoverable(java.lang.Throwable t)booleanisSSL()Is this POP3Store using SSL to connect to the server?protected booleanprotocolConnect(java.lang.String host, int portNum, java.lang.String user, java.lang.String passwd)The service implementation should override this method to perform the actual protocol-specific connection attempt.-
Methods inherited from class javax.mail.Store
addFolderListener, addStoreListener, getPersonalNamespaces, getSharedNamespaces, getUserNamespaces, notifyFolderListeners, notifyFolderRenamedListeners, notifyStoreListeners, removeFolderListener, removeStoreListener
-
Methods inherited from class javax.mail.Service
addConnectionListener, connect, connect, connect, connect, getURLName, notifyConnectionListeners, queueEvent, removeConnectionListener, setConnected, setURLName, toString
-
-
-
-
Field Detail
-
name
private java.lang.String name
-
defaultPort
private int defaultPort
-
isSSL
private boolean isSSL
-
port
private Protocol port
-
portOwner
private POP3Folder portOwner
-
host
private java.lang.String host
-
portNum
private int portNum
-
user
private java.lang.String user
-
passwd
private java.lang.String passwd
-
useStartTLS
private boolean useStartTLS
-
requireStartTLS
private boolean requireStartTLS
-
usingSSL
private boolean usingSSL
-
capabilities
private java.util.Map<java.lang.String,java.lang.String> capabilities
-
logger
private MailLogger logger
-
messageConstructor
volatile java.lang.reflect.Constructor<?> messageConstructor
-
rsetBeforeQuit
volatile boolean rsetBeforeQuit
-
disableTop
volatile boolean disableTop
-
forgetTopHeaders
volatile boolean forgetTopHeaders
-
supportsUidl
volatile boolean supportsUidl
-
cacheWriteTo
volatile boolean cacheWriteTo
-
useFileCache
volatile boolean useFileCache
-
fileCacheDir
volatile java.io.File fileCacheDir
-
keepMessageContent
volatile boolean keepMessageContent
-
finalizeCleanClose
volatile boolean finalizeCleanClose
-
-
Method Detail
-
getBoolProp
private final boolean getBoolProp(java.lang.String prop)
Get the value of a boolean property. Print out the value if logging is enabled.
-
getSession
Session getSession()
Get a reference to the session.
-
protocolConnect
protected boolean protocolConnect(java.lang.String host, int portNum, java.lang.String user, java.lang.String passwd) throws MessagingExceptionDescription copied from class:ServiceThe service implementation should override this method to perform the actual protocol-specific connection attempt. The default implementation of theconnectmethod calls this method as needed.The
protocolConnectmethod should returnfalseif a user name or password is required for authentication but the corresponding parameter is null; theconnectmethod will prompt the user when needed to supply missing information. This method may also returnfalseif 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.The
protocolConnectmethod 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.- Overrides:
protocolConnectin classService- Parameters:
host- the name of the host to connect toportNum- the port to use (-1 means use default port)user- the name of the user to login aspasswd- the user's password- Returns:
- true if connection successful, false if authentication failed
- Throws:
AuthenticationFailedException- for authentication failuresMessagingException- for non-authentication failures
-
isConnected
public boolean isConnected()
Check whether this store is connected. Override superclass method, to actually ping our server connection.- Overrides:
isConnectedin classService- Returns:
- true if the service is connected, false if it is not connected
-
getPort
Protocol getPort(POP3Folder owner) throws java.io.IOException
- Throws:
java.io.IOException
-
cleanupAndThrow
private static java.io.IOException cleanupAndThrow(Protocol p, java.io.IOException ife)
-
isRecoverable
private static boolean isRecoverable(java.lang.Throwable t)
-
closePort
void closePort(POP3Folder owner)
-
close
public void close() throws MessagingExceptionDescription copied from class:ServiceClose 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.This implementation uses
setConnected(false)to set this service's connected state tofalse. 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 tosuper.close()in afinallyclause.- Specified by:
closein interfacejava.lang.AutoCloseable- Overrides:
closein classService- Throws:
MessagingException- for errors while closing- See Also:
ConnectionEvent
-
close
void close(boolean force) throws MessagingException- Throws:
MessagingException
-
getDefaultFolder
public Folder getDefaultFolder() throws MessagingException
Description copied from class:StoreReturns a Folder object that represents the 'root' of the default namespace presented to the user by the Store.- Specified by:
getDefaultFolderin classStore- Returns:
- the root Folder
- Throws:
MessagingException- for other failures
-
getFolder
public Folder getFolder(java.lang.String name) throws MessagingException
Only the name "INBOX" is supported.- Specified by:
getFolderin classStore- Parameters:
name- The name of the Folder. In some Stores, name can be an absolute path if it starts with the hierarchy delimiter. Else it is interpreted relative to the 'root' of this namespace.- Returns:
- Folder object
- Throws:
MessagingException- for other failures- See Also:
Folder.exists(),Folder.create(int)
-
getFolder
public Folder getFolder(URLName url) throws MessagingException
Description copied from class:StoreReturn a closed Folder object, corresponding to the given URLName. The store specified in the given URLName should refer to this Store object.Implementations of this method may obtain the name of the actual folder using the
getFile()method on URLName, and use that name to create the folder.- Specified by:
getFolderin classStore- Parameters:
url- URLName that denotes a folder- Returns:
- Folder object
- Throws:
MessagingException- for other failures- See Also:
URLName
-
capabilities
public java.util.Map<java.lang.String,java.lang.String> capabilities() throws MessagingExceptionReturn a Map of the capabilities the server provided, as per RFC 2449. If the server doesn't support RFC 2449, an emtpy Map is returned. The returned Map can not be modified. The key to the Map is the upper case capability name as a String. The value of the entry is the entire String capability line returned by the server.For example, to check if the server supports the STLS capability, use:
if (store.capabilities().containsKey("STLS")) ...- Returns:
- Map of capabilities
- Throws:
MessagingException- for failures- Since:
- JavaMail 1.4.3
-
isSSL
public boolean isSSL()
Is this POP3Store using SSL to connect to the server?- Returns:
- true if using SSL
- Since:
- JavaMail 1.4.6
-
finalize
protected void finalize() throws java.lang.ThrowableDescription copied from class:ServiceStop the event dispatcher thread so the queue can be garbage collected.
-
checkConnected
private void checkConnected() throws MessagingException- Throws:
MessagingException
-
-