Example usage for com.vaadin.server VaadinSession getCurrent

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

Introduction

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

Prototype

public static VaadinSession getCurrent() 

Source Link

Document

Gets the currently used session.

Usage

From source file:org.vaadin.spring.security.internal.VaadinSharedSecurity.java

License:Apache License

private WrappedSession getSession() {
    VaadinSession vaadinSession = VaadinSession.getCurrent();
    if (vaadinSession != null) {
        return vaadinSession.getSession();
    } else {// ww w.  ja va2  s  . co m
        return null;
    }
}

From source file:org.vaadin.spring.security.managed.DefaultVaadinManagedSecurity.java

License:Apache License

@Override
public void logout(String logoutUrl) {
    VaadinSession.getCurrent().close();
    Page.getCurrent().setLocation(logoutUrl);
}

From source file:org.vaadin.spring.security.shared.DefaultVaadinSharedSecurity.java

License:Apache License

private static WrappedSession getSession() {
    VaadinSession vaadinSession = VaadinSession.getCurrent();
    if (vaadinSession != null) {
        return vaadinSession.getSession();
    } else {// w  w  w .j a  v a 2 s  .c o  m
        return null;
    }
}

From source file:org.vaadin.tori.ToriApiLoader.java

License:Apache License

public static ToriApiLoader getCurrent() {
    final ToriApiLoader apiLoader = VaadinSession.getCurrent().getAttribute(ToriApiLoader.class);
    if (apiLoader != null) {
        return apiLoader;
    } else {/* w ww.j  a v a 2s . com*/
        throw new IllegalStateException(
                ToriApiLoader.class.getName() + " was not found in the state. This is bad...");
    }
}

From source file:org.vaadin.tori.ToriApiLoader.java

License:Apache License

public static void init(final VaadinRequest request) {
    ToriApiLoader toriApiLoader = VaadinSession.getCurrent().getAttribute(ToriApiLoader.class);
    if (toriApiLoader == null) {
        toriApiLoader = new ToriApiLoader();
        toriApiLoader.toriMailService = toriApiLoader.createToriMailService(request);
        if (toriApiLoader.getToriActivityMessaging() != null) {
            toriApiLoader.getToriActivityMessaging().register();
        }//w ww.  j ava 2s . co m
        request.getService().addSessionDestroyListener(toriApiLoader);
        VaadinSession.getCurrent().setAttribute(ToriApiLoader.class, toriApiLoader);
    }
    toriApiLoader.sessionId = VaadinSession.getCurrent().getSession().getId();
    toriApiLoader.setRequest(request);
}

From source file:org.vaadin.tori.util.ToriScheduler.java

License:Apache License

public static ToriScheduler get() {
    final String id = TORI_SCHEDULER + UI.getCurrent().getUIId();
    ToriScheduler scheduler = (ToriScheduler) VaadinSession.getCurrent().getAttribute(id);
    if (scheduler == null) {
        scheduler = new ToriScheduler();
        VaadinSession.getCurrent().setAttribute(id, scheduler);
    }/*from ww  w  . java2 s.  c o  m*/
    return scheduler;
}

From source file:pl.adrian.pieper.biuwaw.services.UsersManager.java

public User getUser() {
    return VaadinSession.getCurrent().getAttribute(User.class);
}

From source file:pl.adrian.pieper.biuwaw.services.UsersManager.java

public User login(String email) throws LoginException {
    if (users.containsKey(email)) {
        User user = users.get(email);// w  w w.  ja  va  2 s . c  o m
        VaadinSession.getCurrent().setAttribute(User.class, user);
        return user;
    }
    throw new LoginException("Uytkownik nie istnieje");
}

From source file:pl.exsio.frameset.vaadin.bootstrap.spring.scope.UIScope.java

License:Open Source License

@Override
public String getConversationId() {
    Integer uiId = null;/*from w  w  w . ja va 2  s . com*/

    UI ui = UI.getCurrent();
    if (ui == null) {
        UIid id = CurrentInstance.get(UIid.class);
        if (id != null) {
            uiId = id.getUiId();
        }
    } else if (ui != null) {
        if (!sessions.containsKey(ui)) {
            ui.addDetachListener(this);
            sessions.put(ui, VaadinSession.getCurrent().getSession().getId());
        }

        uiId = ui.getUIId();
    }

    return uiId != null ? getConversationId(uiId) : null;
}

From source file:pl.exsio.plupload.PluploadReceiver.java

License:Open Source License

public static PluploadReceiver getInstance() {
    VaadinSession session = VaadinSession.getCurrent();
    for (RequestHandler handler : session.getRequestHandlers()) {
        if (handler instanceof PluploadReceiver) {
            return (PluploadReceiver) handler;
        }/*from w ww.j  a v a 2  s .c o m*/
    }

    PluploadReceiver receiver = new PluploadReceiver();
    session.addRequestHandler(receiver);
    return receiver;
}