There is not always a one-to-one relationship between an activation in AEM and the content that needs flushing from the Dispatcher cache. For example, if a page is activated in a section all the other pages in the section may need to be flushed from the cache as well. There are stat files that can be used. Also, custom scripts can be triggered by Dispatcher when a call to flush is received. Another way is to use a workflow in AEM that is triggered by a change in content. A workflow step, written in Java, could determine what content needs to be flushed.
Jason Hamren at Axis41 wrote up how they used workflows to accomplish complex flushing: Solving the Dissonance Between AEM Dispatcher and Publish.