Changeset 7275


Ignore:
Timestamp:
Jan 24, 2017, 2:26:32 PM (5 years ago)
Author:
Nicklas Nordborg
Message:

References #2053: Send out notifications when a service is stopped and started

Re-factored the implementation so that events are sent via the ActionIterator instead of internally in the ExtensionsInvoker.

Location:
trunk/src/core/net/sf/basedb/util/extensions
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/net/sf/basedb/util/extensions/ActionIterator.java

    r6875 r7275  
    2424import java.util.Iterator;
    2525import java.util.NoSuchElementException;
     26
     27import net.sf.basedb.util.extensions.events.EventType;
    2628
    2729
     
    170172
    171173  /**
     174    Send the event to event handlers registered in the registry.
     175    @see Registry#handleEvent(EventType, ExtensionPoint, Extension)}
     176    @since 3.10
     177  */
     178  public void handleEvent(EventType event)
     179  {
     180    currentContext.getRegistry().handleEvent(event, currentContext.getExtensionPoint(), currentContext.getExtension());
     181  }
     182 
     183  /**
    172184    Clear any error that has been registered for the current
    173185    action.
  • trunk/src/core/net/sf/basedb/util/extensions/ExtensionsInvoker.java

    r7272 r7275  
    2525import java.util.Iterator;
    2626
    27 import net.sf.basedb.core.Application;
    2827import net.sf.basedb.util.extensions.events.EventType;
    2928
     
    6059
    6160  private final Collection<ExtensionContext<A>> contexts;
    62   private final Registry registry;
    6361  private boolean clearErrors;
    6462 
     
    6664    Creates a new invoker object.
    6765  */
    68   ExtensionsInvoker(Collection<ExtensionContext<A>> contexts, Registry registry)
     66  ExtensionsInvoker(Collection<ExtensionContext<A>> contexts)
    6967  {
    7068    this.contexts = contexts;
    71     this.registry = registry;
    7269  }
    7370 
     
    189186        action = it.next();
    190187        renderer.render(action);
    191         if (event != null)
    192         {
    193           registry.handleEvent(event, it.getExtensionPoint(), it.getExtension());
    194         }
     188        if (event != null) it.handleEvent(event);
    195189      }
    196190      catch (Throwable t)
  • trunk/src/core/net/sf/basedb/util/extensions/Registry.java

    r7273 r7275  
    745745    // Sort the extensions
    746746    filter.sort(contexts);
    747     return new ExtensionsInvoker<Action>(contexts, this);
     747    return new ExtensionsInvoker<Action>(contexts);
    748748  }
    749749 
Note: See TracChangeset for help on using the changeset viewer.