本文整理汇总了Java中com.vaadin.server.WrappedSession.getAttribute方法的典型用法代码示例。如果您正苦于以下问题:Java WrappedSession.getAttribute方法的具体用法?Java WrappedSession.getAttribute怎么用?Java WrappedSession.getAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.vaadin.server.WrappedSession
的用法示例。
在下文中一共展示了WrappedSession.getAttribute方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processExternalLink
import com.vaadin.server.WrappedSession; //导入方法依赖的package包/类
public void processExternalLink(VaadinRequest request) {
WrappedSession wrappedSession = request.getWrappedSession();
String action = (String) wrappedSession.getAttribute(LAST_REQUEST_ACTION_ATTR);
if (webConfig.getLinkHandlerActions().contains(action)) {
//noinspection unchecked
Map<String, String> params =
(Map<String, String>) wrappedSession.getAttribute(LAST_REQUEST_PARAMS_ATTR);
params = params != null ? params : Collections.emptyMap();
try {
LinkHandler linkHandler = AppBeans.getPrototype(LinkHandler.NAME, app, action, params);
if (app.connection.isConnected() && linkHandler.canHandleLink()) {
linkHandler.handle();
} else {
app.linkHandler = linkHandler;
}
} catch (Exception e) {
error(new com.vaadin.server.ErrorEvent(e));
}
}
}
示例2: doDispatch
import com.vaadin.server.WrappedSession; //导入方法依赖的package包/类
private void doDispatch(final List<TenantAwareEvent> events, final WrappedSession wrappedSession) {
final SecurityContext userContext = (SecurityContext) wrappedSession
.getAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY);
final SecurityContext oldContext = SecurityContextHolder.getContext();
try {
SecurityContextHolder.setContext(userContext);
final List<EventContainer<TenantAwareEvent>> groupedEvents = groupEvents(events, userContext,
eventProvider);
vaadinUI.access(() -> {
if (vaadinSession.getState() != State.OPEN) {
return;
}
LOG.debug("UI EventBus aggregator of UI {} got lock on session.", vaadinUI.getUIId());
groupedEvents.forEach(holder -> eventBus.publish(vaadinUI, holder));
LOG.debug("UI EventBus aggregator of UI {} left lock on session.", vaadinUI.getUIId());
}).get();
} catch (InterruptedException | ExecutionException e) {
LOG.warn("Wait for Vaadin session for UI {} interrupted!", vaadinUI.getUIId(), e);
} finally {
SecurityContextHolder.setContext(oldContext);
}
}
示例3: getAuthentication
import com.vaadin.server.WrappedSession; //导入方法依赖的package包/类
@Override
public Authentication getAuthentication() {
final SecurityContext securityContext = SecurityContextHolder.getContext();
Authentication authentication = securityContext.getAuthentication();
if (authentication == null) {
// The SecurityContextHolder only holds the Authentication when it is
// processing the securityFilterChain. After it completes the chain
// it clears the context holder.
// Therefore, the Authentication object can be retrieved from the
// location where the securityFilterChain or VaadinSecurity has left it,
// within the HttpSession.
LOGGER.debug("No authentication object bound to thread, trying to access the session directly");
WrappedSession session = getSession();
if (session != null) {
SecurityContext context = (SecurityContext) session.getAttribute(springSecurityContextKey);
authentication = context.getAuthentication();
} else {
LOGGER.debug("No session bound to current thread, cannot retrieve the authentication object");
}
}
return authentication;
}
示例4: processExternalLink
import com.vaadin.server.WrappedSession; //导入方法依赖的package包/类
@Override
public void processExternalLink(VaadinRequest request) {
WrappedSession wrappedSession = request.getWrappedSession();
String action = (String) wrappedSession.getAttribute(LAST_REQUEST_ACTION_ATTR);
if (NexbitLinkHandler.RESET_ACTION.equals(action)) {
//noinspection unchecked
Map<String, String> params =
(Map<String, String>) wrappedSession.getAttribute(LAST_REQUEST_PARAMS_ATTR);
if (params == null) {
log.warn("Unable to process the external link: lastRequestParams not found in session");
return;
}
try {
LinkHandler linkHandler = AppBeans.getPrototype(LinkHandler.NAME, app, action, params);
if (((NexbitLinkHandler)linkHandler).canHandleLink(action, params)) {
linkHandler.handle();
wrappedSession.setAttribute(LAST_REQUEST_ACTION_ATTR, null);
return;
}
} catch (Exception e) {
error(new com.vaadin.server.ErrorEvent(e));
}
}
super.processExternalLink(request);
}