1 2 3 4 5 6 | @Provides @RequestScoped Member member(AuthManager authManager, MemberRepository memberRepository) { return memberRepository.findById(authManager.getCurrentUserId()); } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | // The reference to the request is hold when the // doWebSocketMethod is called HttpServletRequest request = [...] Map<Key<?>, Object> bindings = new HashMap<Key<?>, Object>(); // I have a service which needs a request to get the session, // so I provide the request, but you could provide any other // binding that may be needed bindings.put(Key.get(HttpServletRequest.class), request); ServletScopes.scopeRequest(new Callable<Object>() { @Override public Object call() throws Exception { // call your repository or any service using the scoped objects outbound.sendMessage([...]); return null; } }, bindings).call(); |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |