/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- * * This file is part of the design patterns project at UBC * * The contents of this file are subject to the Mozilla Public License * Version 1.1 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The Original Code is ca.ubc.cs.spl.patterns. * * Contributor(s): */ import java.awt.Color; /** * Implements the driver for the observer design pattern example.
* * Intent: Define a one-to-many dependency between objects so that when one * object changes state, all its dependents are notified and updated * automatically
*
* Participatng objects are Point
p and Screen
* s1, s2, s3, s4, and s5.
* * Three different kinds of observing relationships are realized:
Screen
s1 and s2 observe color changes of Point
*
p.
* Screen
s3 and s4 observe coordinate changes of
* Point
p.
* Screen
s5 observes the display(String)
* methods of Screen
s2 and s4.
* Screen
* prints and appropriate message to stdout.
*
* This is the AspectJ version.
*
* @author Gregor Kiczales
* @author Jan Hannemann
* @version 1.0, 05/13/02
*
* @see Point
* @see Screen
*/
public class Main {
/**
* Implements the driver for the observer example. It creates five
* Screen
objects and one Point
object
* and sets the appropriate observing relationships (see above).
* After the setup, the color of the point is changed, then it's
* x-coordinate.
* The following results should be expected: