FolderListener and IDLE

View: New views
2 Messages — Rating Filter:   Alert me  

FolderListener and IDLE

by Wolfgang Beikircher :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi there!

I have again a problem with the IDLE command. Maybe I'm too stupid for
that kind of stuff. ;)

I try to install a FolderListener on a folder object (not on a store
object). Then I try to create new folder (as a sub folder to the
monitored one) but I don't get any callback.

If I try for example a MessageCountListener, all is fine. I get the
callback and can process the message.

I used for my experiments the 'monitor.java' example. I changed only a
bit the authentication so that it fits my needs. But the main stuff
remained the same. Here is a cutting of the used code:

[...]
Folder folder = store.getFolder("inbox/automatedTests/test");
  if (folder == null || !folder.exists()) {
    System.out.println("Invalid folder");
    System.exit(1);
  }

folder.open(Folder.READ_WRITE);

folder.addFolderListener(new FolderAdapter() {
   public void folderCreated(FolderEvent arg0) {
      System.out.println("Catched a 'folder created' event.");
   }
   public void folderDeleted(FolderEvent arg0) {
      System.out.println("Catched a 'folder deleted' event.");
   }
   public void folderRenamed(FolderEvent arg0) {
      System.out.println("Catched a 'folder rename' event.");
   }

});

// Check mail once in "freq" MILLIseconds
int freq = Integer.parseInt("5000");
boolean supportsIdle = false;
try {
  if (folder instanceof IMAPFolder) {
    IMAPFolder f = (IMAPFolder)folder;
    f.idle();
    supportsIdle = true;
  }
} catch (FolderClosedException fex) {
  throw fex;

[...]

Sorry for bothering you with that stuff. But I didn't find any example
on how to using the FolderListener in the web.

I hope you could help me.

thanks.
Wolfgang

===========================================================================
To unsubscribe, send email to listserv@... and include in the body
of the message "signoff JAVAMAIL-INTEREST".  For general help, send email to
listserv@... and include in the body of the message "help".

Re: FolderListener and IDLE

by Bill Shannon :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Wolfgang Beikircher wrote:
> Hi there!
>
> I have again a problem with the IDLE command. Maybe I'm too stupid for
> that kind of stuff. ;)
>
> I try to install a FolderListener on a folder object (not on a store
> object). Then I try to create new folder (as a sub folder to the
> monitored one) but I don't get any callback.

The FolderEvent javadocs say:

  * This class models Folder <em>existence</em> events. FolderEvents are
  * delivered to FolderListeners registered on the affected Folder as
  * well as the containing Store.

If you register a folder listener on the Folder object for the folder
you're about to create, you should get a callback.  Probably not as useful
as registering the listener on the Store object.

And this only works within the same application.  The IMAP protocol
provides no notifications for folders created by other applications.

===========================================================================
To unsubscribe, send email to listserv@... and include in the body
of the message "signoff JAVAMAIL-INTEREST".  For general help, send email to
listserv@... and include in the body of the message "help".