Deregister UI remote event push strategy from application context (#1022)
* deregister UI remote event push strategy from application context * remove application context from holder after detaching the UI Signed-off-by: Bogdan Bondar <Bogdan.Bondar@bosch.io>
This commit is contained in:
@@ -23,6 +23,8 @@ import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.context.support.AbstractApplicationContext;
|
||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
|
||||
import com.vaadin.annotations.Theme;
|
||||
@@ -100,6 +102,21 @@ public abstract class AbstractHawkbitUI extends UI implements DetachListener {
|
||||
|
||||
if (pushStrategy != null) {
|
||||
pushStrategy.clean();
|
||||
clearContextListener();
|
||||
}
|
||||
|
||||
SpringContextHelper.clearContext();
|
||||
}
|
||||
|
||||
private void clearContextListener() {
|
||||
if (pushStrategy instanceof ApplicationListener && context instanceof AbstractApplicationContext) {
|
||||
final ApplicationListener<?> listener = (ApplicationListener<?>) pushStrategy;
|
||||
((AbstractApplicationContext) context).getApplicationListeners().remove(listener);
|
||||
|
||||
// we do not need to explicitly remove the listener from
|
||||
// ApplicationEventMulticaster because it is done by
|
||||
// UIBeanStore#destroy delegating to
|
||||
// ApplicationListenerDetector#postProcessBeforeDestruction
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -131,6 +131,9 @@ public class DelayedEventBusPushStrategy
|
||||
LOG.debug("Cleanup delayed event push strategy for UI {}", vaadinUI.getUIId());
|
||||
jobHandle.cancel(true);
|
||||
queue.clear();
|
||||
|
||||
jobHandle = null;
|
||||
vaadinUI = null;
|
||||
}
|
||||
|
||||
private final class DispatchRunnable implements Runnable {
|
||||
|
||||
@@ -12,9 +12,6 @@ import org.springframework.context.ApplicationContext;
|
||||
|
||||
/**
|
||||
* Singleton for the spring application context.
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public final class SpringContextHelper {
|
||||
|
||||
@@ -27,6 +24,12 @@ public final class SpringContextHelper {
|
||||
// Utility class
|
||||
}
|
||||
|
||||
/**
|
||||
* method to set application context.
|
||||
*
|
||||
* @param context
|
||||
* ApplicationContext
|
||||
*/
|
||||
public static void setContext(final ApplicationContext context) {
|
||||
SpringContextHelper.context = context;
|
||||
}
|
||||
@@ -70,4 +73,11 @@ public final class SpringContextHelper {
|
||||
return context.getBean(beanName, beanClazz);
|
||||
}
|
||||
|
||||
/**
|
||||
* method to clear application context.
|
||||
*
|
||||
*/
|
||||
public static void clearContext() {
|
||||
context = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ vaadin.servlet.productionMode=true
|
||||
vaadin.servlet.urlMapping=/UI/*
|
||||
vaadin.servlet.heartbeatInterval=60
|
||||
vaadin.servlet.closeIdleSessions=false
|
||||
server.servlet.session.timeout=300
|
||||
|
||||
hawkbit.server.ui.links.documentation.root=https://www.eclipse.org/hawkbit/
|
||||
hawkbit.server.ui.links.documentation.security=https://www.eclipse.org/hawkbit/concepts/authorization/
|
||||
|
||||
Reference in New Issue
Block a user