Newsletter sign-up
View all newsletters

Enterprise Java Newsletter
Stay up to date on the latest tutorials and Java community news posted on JavaWorld

Sponsored Links

Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs

An inside view of Observer

The Observer pattern facilitates communication between decoupled objects

  • Print
  • Feedback

Page 6 of 6

  • Maintain a collection of listeners
  • Implement addPropertyChangeListener()
  • Notify listeners when a bound property changes

Once you implement the above steps, you can add property change listeners to your event source and react to events.

Listen and observe

The Observer design pattern is one of the most fundamental design patterns because it allows loosely coupled objects to communicate. That ability lets you create pluggable components, which lie at the heart of object-oriented extensibility and reuse.

About the author

David Geary is the author of Core JSTL Mastering the JSP Standard Tag Library (Prentice Hall, 2002; ISBN: 0131001531), Advanced JavaServer Pages (Prentice Hall, 2001; ISBN: 0130307041), and the Graphic Java series (Prentice Hall). David has been developing object-oriented software with numerous object-oriented languages for 18 years. Since the GOF Design Patterns book was published in 1994, David has been an active proponent of design patterns, and has used and implemented design patterns in Smalltalk, C++, and Java. In 1997, David began working full-time as an author and occasional speaker and consultant. David is a member of the expert groups defining the JSP Standard Tag Library and JavaServer Faces, and is a contributor to the Apache Struts JSP framework.

Read more about Core Java in JavaWorld's Core Java section.

  • Print
  • Feedback

Resources