Is there a better way of accessing VaadinSession beans from Spring MVC @Con

I have a use case where I need to access VaadinSession beans from Spring MVC Controller. The way I am currently doing it is too hacky and I don’t even know if it is going to work with the future releases.

Is there a better way of doing it? Is there anything in Vaadin that supports the integration?

Thanks.

package app.service;

@Controller
@RequestMapping("/{uiId}")
public class DataController {

    @RequestMapping(value = "/{dataId}", method = RequestMethod.GET)
    public ModelAndView getData(@PathVariable Integer uiId, @PathVariable Integer dataId, HttpSession session) {
        Collection<VaadinSession> vaadinSessions = VaadinSession.getAllSessions(session);
        if(!vaadinSessions.isEmpty()) {
            VaadinSession vaadinSession = vaadinSessions.iterator().next();
            BeanStore beanStore = VaadinSessionAccessor.getBeanStore(vaadinSession, uiId);
            BeanClass bean = (BeanClass) beanStore.get("*BeanName*", null);
            // doing something with bean
        }
        ModelAndView mv = new ModelAndView();
        // updating session
        return mv;
    }
}

////////////////

package com.vaadin.spring.internal;

import com.vaadin.server.VaadinSession;

public class VaadinSessionAccessor {

    public static BeanStore getBeanStore(VaadinSession vaadinSession, int uiId) {
        return ((UIScopeImpl.UIStore)vaadinSession.getAttribute("com.vaadin.spring.internal.UIScopeImpl$UIStore")).getBeanStore(new UIID(uiId));
    }
}