org.apache.james.mailrepository.javamail
Interface FolderGateKeeper

All Known Implementing Classes:
FolderGateKeeperImpl

public interface FolderGateKeeper

offers access to an underlaying Folder and manages open/close operations.
The FolderGateKeeper can be handed over to different threads.
Clients have to call use() one time before and free() one time after they are operating on the folder. When use() has been called free() has to be called afterwards in any circumstance usally in a finally block.

 try {
     use();
     getFolder().doSomething();
     getFolder().doSomething();
 } finally {
     free();
 }
 
It is not allowed to open/close Folder from outside.


Method Summary
 void create(int holds_folders)
           
 boolean exists()
           
 void free()
          decrements count of users and closes folder if 0 and folder is open.
 FolderInterface getFolder()
          Gets the Folder and don't care whether it is open or closed.
 java.lang.String getFullName()
           
 FolderInterface getOpenFolder()
          Gets the Folder and opens it, if necessary
 int getUseCount()
          used to test whether everyone has freed it
 void renameTo(javax.mail.Folder folder)
           
 void renameTo(java.lang.String newName)
           
 void use()
          increments count of users
 

Method Detail

use

void use()
increments count of users


free

void free()
          throws javax.mail.MessagingException
decrements count of users and closes folder if 0 and folder is open.

Throws:
javax.mail.MessagingException - if something went wrong closing the Folder
java.lang.IllegalStateException - if there are already 0 users
java.lang.IllegalStateException - if the state of the folder differs from the last known

getOpenFolder

FolderInterface getOpenFolder()
                              throws javax.mail.MessagingException
Gets the Folder and opens it, if necessary

Returns:
an open Folder
Throws:
javax.mail.MessagingException - if something went wron opening the Folder
java.lang.IllegalStateException - if the state of the folder differs from the last known
java.lang.IllegalStateException - if there are only 0 users

getUseCount

int getUseCount()
used to test whether everyone has freed it

Returns:
number of users

getFolder

FolderInterface getFolder()
Gets the Folder and don't care whether it is open or closed.

Returns:
a open or closed Folder
Throws:
java.lang.IllegalStateException - if the state of the folder differs from the last known
java.lang.IllegalStateException - if there are only 0 users

getFullName

java.lang.String getFullName()
                             throws javax.mail.MessagingException
Throws:
javax.mail.MessagingException
See Also:
Folder.getFullName()

create

void create(int holds_folders)
            throws javax.mail.MessagingException
Throws:
javax.mail.MessagingException
See Also:
Folder

exists

boolean exists()
               throws javax.mail.MessagingException
Throws:
javax.mail.MessagingException
See Also:
Folder.exists()

renameTo

void renameTo(javax.mail.Folder folder)
              throws javax.mail.MessagingException
Throws:
javax.mail.MessagingException
See Also:
Folder.renameTo(Folder)

renameTo

void renameTo(java.lang.String newName)
              throws javax.mail.MessagingException
Throws:
javax.mail.MessagingException
See Also:
Folder.renameTo(Folder)


Copyright ? 2002-2009 The Apache Software Foundation. All Rights Reserved.