Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Controller
- public MyController {
- @Autowired
- private MyService myService;
- someEndpoint() {
- ....
- myService.putData(key, value);
- .....
- }
- }
- public class MyFilter extends GenericFilterBean {
- @Autowired
- private MyService myService;
- public void doFilter(...) {
- //this is where I have a problem.
- // the reference myService.myMap seems to be pointing to a different instance
- // than the service.myMap in the controller which doesn't make any sense to me
- // the filter obviously intercepts all requests so I would expect that after that particular
- // endpoint is accessed the data will be there for subsequent requests
- myService.getData(..);
- }
- .....
- }
- @Service
- public class MyService {
- private Map <String,String> myMap = new HashMap <String,String> ();
- public String getData(String key) {
- return myMap.get(key);
- }
- public void putData(String key, String value){
- myMap.put(key,value);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement