类com.vaadin.server.WrappedSession源码实例Demo

下面列出了怎么用com.vaadin.server.WrappedSession的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: vertx-vaadin   文件: VertxVaadin.java
private void configureSessionStore() {
    final Registration sessionInitListenerReg = this.service.addSessionInitListener(event -> {
        MessageConsumer<String> consumer = sessionExpiredHandler(vertx, msg ->
            Optional.of(event.getSession().getSession())
                .filter(session -> msg.body().equals(session.getId()))
                .ifPresent(WrappedSession::invalidate));
        AtomicReference<Registration> sessionDestroyListenerUnregister = new AtomicReference<>();
        sessionDestroyListenerUnregister.set(
            event.getService().addSessionDestroyListener(ev2 -> {
                consumer.unregister();
                sessionDestroyListenerUnregister.get().remove();
            })
        );

    });
    this.service.addServiceDestroyListener(event -> sessionInitListenerReg.remove());
}
 
源代码2 项目: cuba   文件: AppUI.java
protected void processLinkHandlerRequest(VaadinRequest request) {
    WrappedSession wrappedSession = request.getWrappedSession();
    //noinspection unchecked
    Map<String, String> params =
            (Map<String, String>) wrappedSession.getAttribute(LAST_REQUEST_PARAMS_ATTR);
    params = params != null ? params : Collections.emptyMap();

    try {
        String action = (String) wrappedSession.getAttribute(LAST_REQUEST_ACTION_ATTR);
        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));
    }
}
 
源代码3 项目: cuba   文件: LinkHandler.java
/**
 * Called to handle the link.
 */
public void handle() {
    try {
        ExternalLinkContext linkContext = new ExternalLinkContext(requestParams, action, app);
        for (LinkHandlerProcessor processor : processors) {
            if (processor.canHandle(linkContext)) {
                processor.handle(linkContext);
                break;
            }
        }
    } finally {
        VaadinRequest request = VaadinService.getCurrentRequest();
        WrappedSession wrappedSession = request.getWrappedSession();
        wrappedSession.removeAttribute(AppUI.LAST_REQUEST_PARAMS_ATTR);
        wrappedSession.removeAttribute(AppUI.LAST_REQUEST_ACTION_ATTR);
    }
}
 
源代码4 项目: hawkbit   文件: DelayedEventBusPushStrategy.java
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);
        Thread.currentThread().interrupt();
    } finally {
        SecurityContextHolder.setContext(oldContext);
    }
}
 
源代码5 项目: cuba   文件: AppUI.java
protected boolean isLinkHandlerRequest(VaadinRequest request) {
    WrappedSession wrappedSession = request.getWrappedSession();
    if (wrappedSession == null) {
        return false;
    }

    String action = (String) wrappedSession.getAttribute(LAST_REQUEST_ACTION_ATTR);

    return webConfig.getLinkHandlerActions().contains(action);
}
 
源代码6 项目: hawkbit   文件: DelayedEventBusPushStrategy.java
@Override
public void run() {
    LOG.debug("UI EventBus aggregator started for UI {}", vaadinUI.getUIId());
    final long timestamp = System.currentTimeMillis();

    final int size = queue.size();
    if (size <= 0) {
        LOG.debug("UI EventBus aggregator for UI {} has nothing to do.", vaadinUI.getUIId());
        return;
    }

    final WrappedSession wrappedSession = vaadinSession.getSession();
    if (wrappedSession == null) {
        return;
    }

    final List<TenantAwareEvent> events = new ArrayList<>(size);
    final int eventsSize = queue.drainTo(events);

    if (events.isEmpty()) {
        LOG.debug("UI EventBus aggregator for UI {} has nothing to do.", vaadinUI.getUIId());
        return;
    }

    LOG.debug("UI EventBus aggregator dispatches {} events for session {} for UI {}", eventsSize, vaadinSession,
            vaadinUI.getUIId());

    doDispatch(events, wrappedSession);

    LOG.debug("UI EventBus aggregator done with sending {} events in {} ms for UI {}", eventsSize,
            System.currentTimeMillis() - timestamp, vaadinUI.getUIId());

}
 
源代码7 项目: vertx-vaadin   文件: VertxVaadinRequest.java
@Override
public WrappedSession getWrappedSession() {
    return getWrappedSession(true);
}
 
源代码8 项目: vertx-vaadin   文件: VertxVaadinRequest.java
@Override
public WrappedSession getWrappedSession(boolean allowSessionCreation) {
    return Optional.ofNullable(routingContext.session())
        .map(ExtendedSession::adapt)
        .map(VertxWrappedSession::new).orElse(null);
}
 
源代码9 项目: cuba   文件: TestVaadinRequest.java
@Override
public WrappedSession getWrappedSession() {
    return null;
}
 
源代码10 项目: cuba   文件: TestVaadinRequest.java
@Override
public WrappedSession getWrappedSession(boolean allowSessionCreation) {
    return null;
}