E4/RAP Integration/CleanupOnSessionTimeout

From Eclipsepedia

< E4‎ | RAP Integration
Revision as of 10:07, 14 August 2008 by Rsternberg.innoopract.com (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Cleanup on Session Timeout

To avoid MemoryLeaks we had to add some code due to some missing cleanup on workbench shutdown. For example the org.eclipse.ui.internal.activities.ExtensionActivityRegistry registers itself as listener at the extension registry, but get never unregistered in case of a workbench shutdown. To solve the problem locally we wait for a session timeout notification to unregister the listener:

 final IRegistryChangeListener listener = new IRegistryChangeListener() {
   public void registryChanged(IRegistryChangeEvent registryChangeEvent) {
     IExtensionDelta[] extensionDeltas = registryChangeEvent.getExtensionDeltas(Persistence.PACKAGE_PREFIX,
                                                                                Persistence.PACKAGE_BASE);
     if (extensionDeltas.length != 0) {
       try {
         load();
       } catch (IOException eIO) {
       }
     }
   }
 };
 this.extensionRegistry.addRegistryChangeListener(listener);
 RWT.getSessionStore().addSessionStoreListener( new SessionStoreListener() {
   public void beforeDestroy( final SessionStoreEvent event ) {
     ExtensionActivityRegistry.this.extensionRegistry.removeRegistryChangeListener( listener );
   }
 } );