package com.google.sitebricks.persist;

import com.google.inject.AbstractModule;
import com.google.inject.Key;
import com.google.inject.matcher.Matcher;

import java.lang.reflect.AnnotatedElement;

import static com.google.inject.matcher.Matchers.annotatedWith;
import static com.google.inject.matcher.Matchers.any;

/**
 * @author dhanji@gmail.com (Dhanji R. Prasanna)
 */
public final class PersistAopModule extends AbstractModule {
  private final AbstractPersistenceModule module;

  public PersistAopModule(AbstractPersistenceModule module) {
    this.module = module;
  }

  @Override
  protected void configure() {
    Key<Persister> persisterKey = module.selectorKey(Persister.class);
    WorkInterceptor workInterceptor = new WorkInterceptor(persisterKey);
    TransactionInterceptor transactionInterceptor = new TransactionInterceptor(persisterKey);
    requestInjection(workInterceptor);
    requestInjection(transactionInterceptor);

    Matcher<AnnotatedElement> workMatcher = annotatedWith(Work.class);
    Matcher<AnnotatedElement> txnMatcher = annotatedWith(Transactional.class);

    // Visible persistence APIs.
    if (module.selector != null) {
      workMatcher.and(annotatedWith(module.selector));
      txnMatcher.and(annotatedWith(module.selector));
    }

    bindInterceptor(any(), workMatcher, workInterceptor);
    bindInterceptor(any(), txnMatcher, transactionInterceptor);
  }
}

@@ -1163,16 +1163,30 @@
  %7B%0A     
+ workMatcher =
  workMat
@@ -1232,16 +1232,29 @@
 );%0A     
+ txnMatcher =
  txnMatc

Fix a bad, silly bug where selectors were not being added to matchers in the Persist AOP module