The Spring Framework

## org.springframework.context.event
Class AbstractApplicationEventMulticaster

    java.lang.Object
      org.springframework.context.event.AbstractApplicationEventMulticaster

All Implemented Interfaces:
  ApplicationEventMulticaster

Direct Known Subclasses:
  SimpleApplicationEventMulticaster

    public abstract class AbstractApplicationEventMulticaster

extends Object
implements ApplicationEventMulticaster

Abstract implementation of the `ApplicationEventMulticaster` interface, providing the basic listener registration facility.

Doesn't permit multiple instances of the same listener by default, as it keeps listeners in a linked Set. The collection class used to hold ApplicationListener objects can be overridden through the "collectionClass" bean property.

Implementing ApplicationEventMulticaster's actual `ApplicationEventMulticaster.multicastEvent(org.springframework.context.ApplicationEvent)` method is left to subclasses. `SimpleApplicationEventMulticaster` simply multicasts all events to all registered listeners, invoking them in the calling thread. Alternative implementations could be more sophisticated in those respects.

Since:
  1.2.3
Author:
  Juergen Hoeller
See Also:
  `setCollectionClass(java.lang.Class)`, `getApplicationListeners()`, `SimpleApplicationEventMulticaster`

Constructor Summary
`AbstractApplicationEventMulticaster()`

Method Summary
`void` `addApplicationListener(ApplicationListener listener)` Add a listener to be notified of all events.
`protected Collection` `getApplicationListeners()` Return the current Collection of ApplicationListeners.
`void` `removeAllListeners()` Remove all listeners registered with this multicaster.
`void` `removeApplicationListener(ApplicationListener listener)` Remove a listener from the notification list.
`void` `setCollectionClass(Class collectionClass)` Specify the collection class to use.
`void` `setConcurrentUpdates(boolean concurrent)` Set whether this multicaster should expect concurrent updates at runtime (i.e. after context startup finished).

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface org.springframework.context.event.ApplicationEventMulticaster
`multicastEvent`

Constructor Detail

### AbstractApplicationEventMulticaster

    public AbstractApplicationEventMulticaster()

Method Detail

### setConcurrentUpdates

    public void setConcurrentUpdates(boolean concurrent)

  Set whether this multicaster should expect concurrent updates at runtime (i.e. after context startup finished). In case of concurrent updates, a copy-on-write strategy is applied, keeping iteration (for multicasting) without synchronization while still making listener updates thread-safe.

### setCollectionClass

    public void setCollectionClass(Class collectionClass)

  Specify the collection class to use. Can be populated with a fully qualified class name when defined in a Spring application context.

  Default is a linked HashSet, keeping the registration order. Note that a Set class specified will not permit multiple instances of the same listener, while a List class will allow for registering the same listener multiple times.

### addApplicationListener

    public void addApplicationListener(ApplicationListener listener)

  Description copied from interface: `ApplicationEventMulticaster`
  Add a listener to be notified of all events.

  Specified by:
    `addApplicationListener` in interface `ApplicationEventMulticaster`
  Parameters:
    `listener` - the listener to add

### removeApplicationListener

    public void removeApplicationListener(ApplicationListener listener)

  Description copied from interface: `ApplicationEventMulticaster`
  Remove a listener from the notification list.

  Specified by:
    `removeApplicationListener` in interface `ApplicationEventMulticaster`
  Parameters:
    `listener` - the listener to remove

### removeAllListeners

    public void removeAllListeners()

  Description copied from interface: `ApplicationEventMulticaster`
  Remove all listeners registered with this multicaster. It will perform no action on event notification until more listeners are registered.

  Specified by:
    `removeAllListeners` in interface `ApplicationEventMulticaster`

### getApplicationListeners

    protected Collection getApplicationListeners()

  Return the current Collection of ApplicationListeners.

  Note that this is the raw Collection of ApplicationListeners, potentially modified when new listeners get registered or existing ones get removed. This Collection is not a snapshot copy.

  Returns:
    a Collection of ApplicationListeners
  See Also:
    `ApplicationListener`

The Spring Framework

Copyright © 2002-2008 The Spring Framework.