Class PluginGadgetFinder

  extended by com.atlassian.gadgets.publisher.internal.PluginGadgetFinder
All Implemented Interfaces:

public class PluginGadgetFinder
extends Object
implements org.springframework.beans.factory.DisposableBean

Notifies a series of PluginGadgetSpecEventListener implementations when gadget specs are enabled and disabled by plugins. When the constructor completes, all of the specified event listeners will have been notified of the currently-enabled plugin gadget specs, by calling each listener's PluginGadgetSpecEventListener.pluginGadgetSpecEnabled(PluginGadgetSpec) method for each enabled PluginGadgetSpec retrieved from pluginAccessor. Subsequently, for the entire lifespan of this object, each listener will be notified as plugin gadget specs are enabled by calling its pluginGadgetSpecEnabled(PluginGadgetSpec) method for each enabled gadget spec, and as plugin gadget specs are disabled by calling its PluginGadgetSpecEventListener.pluginGadgetSpecDisabled(PluginGadgetSpec) method for each disabled gadget spec. These calls may happen on multiple threads, so all PluginGadgetSpecEventListener implementations must be thread-safe.

This class does not attempt to guarantee that listener methods will only be called once per event, so listener implementations should be prepared to handle multiple pluginGadgetSpecEnabled calls for the same gadget spec without an intervening pluginGadgetSpecDisabled call, as well as pluginGadgetSpecDisabled called with a gadget spec that was not previously passed to a pluginGadgetSpecEnabled call.

This class will never pass a null argument to listener methods.

The eventListeners iterable is not copied, and is considered "live" in the sense that listeners can be added or removed from the underlying collection in order to register and unregister listeners to be notified. The iterable must be thread-safe and support concurrent iteration and modification without ever throwing ConcurrentModificationException, and without requiring explicit synchronization or locking by the caller. Any Iterator returned must support the contract of Iterator. Specifically, if Iterator.hasNext() is called at any time and returns true, the next call to, whenever it occurs, must return a non-null PluginGadgetSpecEventListener, and must not throw NoSuchElementException or any other exception. The returned PluginGadgetSpecEventListener may, however, refuse to handle further events by throwing a RuntimeException implementation of its choosing. This will not affect the notification of other listeners.

The intent is that eventListeners will be an OSGi service collection injected by Spring Dynamic Modules, which guarantees the behavior documented above.

See Also:
Spring Dynamic Modules Reference Guide: Referencing A Collection Of Services

Constructor Summary
PluginGadgetFinder(com.atlassian.plugin.PluginAccessor pluginAccessor, com.atlassian.plugin.event.PluginEventManager pluginEventManager, Iterable<PluginGadgetSpecEventListener> eventListeners)
          Creates a new PublishedGadgetFinder.
Method Summary
 void destroy()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public PluginGadgetFinder(com.atlassian.plugin.PluginAccessor pluginAccessor,
                          com.atlassian.plugin.event.PluginEventManager pluginEventManager,
                          Iterable<PluginGadgetSpecEventListener> eventListeners)
Creates a new PublishedGadgetFinder.

pluginAccessor - the PluginAccessor for the host application, used to get the list of currently enabled plugin modules. Must not be null, or a NullPointerException will be thrown.
pluginEventManager - the PluginEventManager of the host application, used to register this PublishedGadgetFinder to receive events when plugin modules are enabled and disabled. Must not be null, or a NullPointerException will be thrown.
eventListeners - the event listeners that will be notified when gadget specs are enabled or disabled. Must not be null, or a NullPointerException will be thrown. Must be safe for concurrent iteration and modification, and all elements returned by iterating over it must be thread-safe.
NullPointerException - if any argument is null
Method Detail


public void destroy()
             throws Exception
Specified by:
destroy in interface org.springframework.beans.factory.DisposableBean

Copyright © 2010 Atlassian. All Rights Reserved.