@@ -0,0 +1,1479 @@
+/**%0A * @file Template.java%0A * @author Valery Samovich%0A * @version 1%0A * @date 2015/01/09%0A * %0A * The observer pattern is a software design pattern in which an object, %0A * called the subject, maintains a list of its dependents, called observers, %0A * and notifies them automatically of any state changes, usually by calling %0A * one of their methods.%0A */%0A%0Apackage com.samovich.specialized.patterns.observer;%0A%0Aimport java.util.Observable;%0Aimport java.util.Observer;%0A%0Apublic class ObservableDemo extends Object %7B%0A%0A    MyView view;%0A    MyModel model;%0A    %0A    // Constructor.%0A    public ObservableDemo() %7B%0A        view = new MyView();%0A        model = new MyModel();%0A        model.addObserver(view);%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        %0A        ObservableDemo myObservable = new ObservableDemo();%0A        myObservable.demo();%0A    %7D%0A%0A    private void demo() %7B%0A        model.changeSomething();%0A    %7D%0A    %0A    // The Observer normally maintains a view on the data.%0A    class MyView implements Observer %7B%0A        // For now, we just print the fact that we got notified.%0A        public void update(Observable obs, Object x) %7B%0A            System.out.println(%22Update(%22 + obs + %22, %22 + x + %22);%22);%0A        %7D%0A    %7D%0A    %0A    // The Observable normally maintains the data%0A    class MyModel extends Observable %7B%0A        public void changeSomething() %7B%0A            // Notify observers of change%0A            setChanged();%0A            notifyObservers();%0A        %7D%0A        %0A    %7D%0A%7D%0A

Add Observable example