Skip to content

Instantly share code, notes, and snippets.

@spullara
Created July 30, 2010 17:14
Show Gist options
  • Select an option

  • Save spullara/500924 to your computer and use it in GitHub Desktop.

Select an option

Save spullara/500924 to your computer and use it in GitHub Desktop.
public static class ClassToTypeLiteralMatcherAdapter extends AbstractMatcher<TypeLiteral> {
private final Matcher<Class> classMatcher;
public ClassToTypeLiteralMatcherAdapter(Matcher<Class> classMatcher) {
this.classMatcher = classMatcher;
}
public boolean matches(TypeLiteral typeLiteral) {
return classMatcher.matches(typeLiteral.getRawType());
}
}
// Initialize CodeBehindHandlers
bindListener(new ClassToTypeLiteralMatcherAdapter(Matchers.subclassesOf(CodebehindHandler.class)),
new TypeListener() {
@Override
public <I> void hear(TypeLiteral<I> iTypeLiteral, TypeEncounter<I> iTypeEncounter) {
iTypeEncounter.register(new InjectionListener<I>() {
@Override
public void afterInjection(Object o) {
CodebehindHandler ch = (CodebehindHandler) o;
ch.getCode();
}
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment