public void execute() {
        state = State.Running;
        for (Subscription sub : subscriptions) {
           sub.publish(this, message);
        }
        state = State.Finished;
        // This part is necessary to support the feature of publishing a DeadMessage or FilteredMessage
        // in case that the original message has not made it to any listener.
        // This happens if subscriptions are empty (due to GC of weak listeners or explicit desubscription)
        // or if configured filters do not let a message pass. The flag is set by the dispatchers.
        // META: This seems to be a suboptimal design
        if (!dispatched) {
            if (!isFilteredMessage() && !isDeadMessage()) {
                runtime.getProvider().publish(new FilteredMessage(message));
            } else if (!isDeadMessage()) {
                runtime.getProvider().publish(new DeadMessage(message));
            }

        }
    }
public void execute ( ) { state = State . Running ; for ( Subscription sub : subscriptions ) { sub . publish ( this , message ) ; } state = State . Finished ; if ( ! dispatched ) { if ( ! isFilteredMessage ( ) && ! isDeadMessage ( ) ) { runtime . getProvider ( ) . publish ( new FilteredMessage ( message ) ) ; } else if ( ! isDeadMessage ( ) ) { runtime . getProvider ( ) . publish ( new DeadMessage ( message ) ) ; } } }
/*
TODO: document state transitions