07-28-2008 03:44 AM
I developing an application with Folderlistner api.. i can get all mails from my store i got 2 problems in my application
I cant quit folderlistner. am using
removelistner method while calling exit (system.exit) after tat my application processing all emails for example my application deleting all emails from my store. how to remove folderlistner from store
when restart my application it processing emails once again i mean 2 listners working in same time not only 2
For every restart another one listner shoud added
how can i solve this problems?
to adding listner
mystore= session.getStore(); mystore.addFolderListener(this);
to removeing llistner while calling system.exit(0)
mystore.removeFolderListener(this); mystore=null;
Solved! Go to Solution.
07-28-2008 03:50 AM
take a look at this article which exactly does what you are looking for:
regards,
yosoh
07-28-2008 05:19 AM
07-28-2008 05:30 AM
private FolderListenerGUI folderListenerGUI = null;
//Long value: com.samples.folderListener
public static final long RTSID_MY_APP = 0x7451402f595f81a5L;
public FolderListenerApp()
{
try
{
//Get the store from the default instance.
Store store = Session.getDefaultInstance().getStore();
//Add the folder listener to the store.
store.addFolderListener(this);
}
catch (Exception e)
{
System.out.println(e.toString());
}
}
//Returns an instance of the running FolderListenerApp.
public static FolderListenerApp waitForSingleton()
{
//Ensure this is a singleton instance.
//Open the RuntimeStore.
RuntimeStore store = RuntimeStore.getRuntimeStore();
//Obtain the reference of FolderListenerApp.
Object obj = store.get(RTSID_MY_APP);
//If obj is null, there is no current reference
//to FolderListenerApp. Start a new instance
// of FolderListenerApp if one is not running.
if (obj == null)
{
//Store a reference to this instance in the RuntimeStore.
store.put(RTSID_MY_APP, new FolderListenerApp());
return (FolderListenerApp)store.get(RTSID_MY_APP);
} else
{
return (FolderListenerApp)obj;
}
}
regards,
yosoh
07-28-2008 07:56 AM