add observer pattern - java