@Override protected void configure() { if (profile != null) { LOG.debug("Starting configuration with profile " + profile); } bind(String.class).annotatedWith(Names.named("sourcedir")).toInstance(rootdir); bind(Site.class).asEagerSingleton(); bind(ContentWriter.class).asEagerSingleton(); bind(ContentParser.class).to(YamlHeaderContentParser.class).asEagerSingleton(); if ("blog".equals(profile)) { blogProfile(); } else { wikiProfile(); } Matcher<TypeLiteral<?>> m = new AbstractMatcher<TypeLiteral<?>>() { @Override public boolean matches(TypeLiteral<?> typeLiteral) { return typeLiteral.getRawType().equals(String.class); } }; bindListener( Matchers.any(), new TypeListener() { @Override public <I> void hear(TypeLiteral<I> type, TypeEncounter<I> encounter) { encounter.register( new InjectionListener<I>() { @Override public void afterInjection(I injectee) { for (Field f : injectee.getClass().getDeclaredFields()) { if (f.isAnnotationPresent(Parameter.class)) { if (parameters.get(injectee.getClass()) != null) { String v = parameters.get(injectee.getClass()).get(f.getName()); if (v != null) { try { f.setAccessible(true); f.set(injectee, v); } catch (IllegalAccessException e) { throw new GeneratorException( "Can't inject parameter " + f.getName() + " to " + injectee, e); } } } } } } }); } }); // extend the config with scripts. ext.closeUsage(); readConfig(); ext.closeUsage(); bind(ExtensionManager.class).toInstance(ext); bind(GuiceConfig.class).toInstance(this); }