title: How do i register AbstractMongoEventListener programmatically?
body: <p>In my Spring Boot application, i have a configuration, which reads entries from a Mongo database.</p>
  
  <p>After this is done, my subclass of <code>AbstractMongoEventListener</code> is created, even though it operates on a different table and different scope (my own custom <code>@CustomerScope</code>).</p>
  
  <p>Here is the listener:</p>
  
  <pre><code>@CustomerScoped
  @Component
  public class ProjectsRepositoryListener extends AbstractMongoEventListener&lt;Project&gt; {
  
      @Override
      public void onAfterSave(Project source, DBObject dbo) {
          System.out.println("saved");
      }
  }
  </code></pre>
  
  <p>And here the configuration:</p>
  
  <pre><code>@Configuration
  public class MyConfig {
  
      @Autowired
      private CustomersRepository customers;
  
      @PostConstruct
      public void initializeCustomers() {
          for (Customer customer : customers.findAll()) {
              System.out.println(customer.getName());
          }
      }
  }
  </code></pre>
  
  <p>I find it surprising that the listener is instantiated at all. Especially since it is instantiated well after the call to the customers repository has finished.</p>
  
  <p>Is there a way to prevent this? I was thinking of programmatically registering it per table/scope, without annotation magic.</p>