Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. @Controller
  2. public MyController {
  3.  
  4.  
  5.  
  6. @Autowired
  7. private MyService myService;
  8.  
  9.  
  10. someEndpoint() {
  11. ....
  12. myService.putData(key, value);
  13. .....
  14. }
  15.  
  16.  
  17. }
  18.  
  19.  
  20. public class MyFilter extends GenericFilterBean {
  21.  
  22.  
  23. @Autowired
  24. private MyService myService;
  25.  
  26.  
  27. public void doFilter(...) {
  28.  
  29. //this is where I have a problem.
  30. // the reference myService.myMap seems to be pointing to a different instance
  31. // than the service.myMap in the controller which doesn't make any sense to me
  32. // the filter obviously intercepts all requests so I would expect that after that particular
  33. // endpoint is accessed the data will be there for subsequent requests
  34. myService.getData(..);
  35.  
  36. }
  37.  
  38. .....
  39. }
  40.  
  41.  
  42. @Service
  43. public class MyService {
  44.  
  45.  
  46. private Map <String,String> myMap = new HashMap <String,String> ();
  47.  
  48.  
  49. public String getData(String key) {
  50. return myMap.get(key);
  51. }
  52.  
  53. public void putData(String key, String value){
  54. myMap.put(key,value);
  55. }
  56.  
  57.  
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement