Package com.vaadin.flow.spring.scopes
Class VaadinBrowserTabScope
java.lang.Object
com.vaadin.flow.spring.scopes.VaadinBrowserTabScope
- All Implemented Interfaces:
org.springframework.beans.factory.config.BeanFactoryPostProcessor,org.springframework.beans.factory.config.Scope
Implementation of Spring's
Scope that binds the beans
to the BrowserTab of the current UI. Registered by default as
the scope ""vaadin-browser-tab"".
The beans are shared by all the UIs that are loaded in the same browser tab,
so they survive a reload and navigation to another URL of the application in
the same tab. They are destroyed when the browser tab is destroyed, which
happens some time after the tab was closed or when the session is destroyed.
Destruction callbacks, such as @PreDestroy methods, therefore run
during the request of another UI, or with no request at all, and must not
rely on UI.getCurrent(). See BrowserTab for how browser tabs
are identified and when they are destroyed.
- Author:
- Vaadin Ltd
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected com.vaadin.flow.spring.scopes.BeanStoreGets bean store for this scope.protected com.vaadin.flow.server.VaadinSessionGets current Vaadin session.voidpostProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory) voidregisterDestructionCallback(String name, Runnable callback)
-
Field Details
-
VAADIN_BROWSER_TAB_SCOPE_NAME
Name the scope is registered under.- See Also:
-
-
Constructor Details
-
VaadinBrowserTabScope
public VaadinBrowserTabScope()Creates the scope. Spring instantiates it.
-
-
Method Details
-
postProcessBeanFactory
public void postProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory) -
getConversationId
-
getBeanStore
protected com.vaadin.flow.spring.scopes.BeanStore getBeanStore()Gets bean store for this scope.- Returns:
- bean store for the scope
-
resolveContextualObject
- Specified by:
resolveContextualObjectin interfaceorg.springframework.beans.factory.config.Scope
-
get
- Specified by:
getin interfaceorg.springframework.beans.factory.config.Scope
-
remove
- Specified by:
removein interfaceorg.springframework.beans.factory.config.Scope
-
registerDestructionCallback
- Specified by:
registerDestructionCallbackin interfaceorg.springframework.beans.factory.config.Scope
-
getVaadinSession
protected com.vaadin.flow.server.VaadinSession getVaadinSession()Gets current Vaadin session.Throws
IllegalStateExceptionif there is no current Vaadin session scope or it's not opened.- Returns:
- the current Vaadin session
-