title: Map of Enums and dependency injection in Spring 2.5
body: <p>Let's assume we've got the following Java code:</p>
  
  <pre><code>public class Maintainer {
     private Map&lt;Enum, List&lt;Listener&gt;&gt; map;
  
     public Maintainer() {
        this.map = new java.util.ConcurrentHashMap&lt;Enum, List&lt;Listener&gt;&gt;();
     }
  
     public void addListener( Listener listener, Enum eventType ) {
        List&lt;Listener&gt; listeners;
        if( ( listeners = map.get( eventType ) ) == null ) {
           listeners = new java.util.concurrent.CopyOnWriteArrayList&lt;Listener&gt;();
           map.put( eventType, listeners );
        }
        listeners.add( listener );
     }
  }
  </code></pre>
  
  <p>This code snippet is nothing but a bit improved listener pattern where each listener is telling what type of event it is interested in, and the provided method maintains a concurrent map of these relationships.</p>
  
  <p>Initially, I wanted this method to be called via my own annotation framework, but bumped into a brick wall of various annotation limitations (e.g. you can't have <em>java.lang.Enum</em> as annotation param, also there's a set of various classloader issues) therefore decided to use Spring.</p>
  
  <p>Could anyone tell me how do I Spring_ify_ this? What I want to achive is:<br>
  1. Define <em>Maintainer</em> class as a Spring bean.<br>
  2. Make it so that all sorts of listeners would be able to register themselves to <em>Maintainer</em> via XML by using <em>addListener</em> method. Spring doc nor Google are very generous in examples.</p>
  
  <p>Is there a way to achieve this easily?</p>