Example usage for com.vaadin.server VaadinSession accessSynchronously

List of usage examples for com.vaadin.server VaadinSession accessSynchronously

Introduction

In this page you can find the example usage for com.vaadin.server VaadinSession accessSynchronously.

Prototype

public void accessSynchronously(Runnable runnable) 

Source Link

Document

Locks this session and runs the provided Runnable right away.

Usage

From source file:de.metas.ui.web.vaadin.session.UserSession.java

License:Open Source License

public static final UserSession getCurrent() {
    final VaadinSession vaadinSession = VaadinSession.getCurrent();
    if (vaadinSession == null) {
        return null;
    }//from  w  ww  . ja  v a 2  s . c o m

    if (vaadinSession.hasLock()) {
        return getCurrent(vaadinSession);
    } else {
        final Mutable<UserSession> userSessionRef = new Mutable<UserSession>();
        vaadinSession.accessSynchronously(new Runnable() {

            @Override
            public void run() {
                userSessionRef.setValue(getCurrent(vaadinSession));
            }
        });

        return userSessionRef.getValue();
    }
}