title: Annotation version of ApplicationListener<ContextClosedEvent> and similar interfaces
body: <p>You can use code like the following to do some events based on when your web service is shut down (or refreshed/started).</p>
  
  <pre><code>public class APIService implements ApplicationListener&lt;ContextClosedEvent&gt;
  {
      @Override
      public void onApplicationEvent(ContextClosedEvent contextClosedEvent) {
          //Do shutdown work.
      }
  }
  </code></pre>
  
  <p>I was told that there is an annotation driven way to do this that does not require you to implement this interface.  Specifically, you should be able to define a function with any name you like and annotate it so that it executes on service start-up or shut-down.</p>
  
  <p>I'm having trouble finding references to this in my spring book or via google though.  Can someone provide an example of how to do the above code via annotations alone?</p>