E4/RAP Integration/CleanupOnSessionTimeout

From Eclipsepedia

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,
     if (extensionDeltas.length != 0) {
       try {
       } catch (IOException eIO) {
 RWT.getSessionStore().addSessionStoreListener( new SessionStoreListener() {
   public void beforeDestroy( final SessionStoreEvent event ) {
     ExtensionActivityRegistry.this.extensionRegistry.removeRegistryChangeListener( listener );
 } );