Wouldn't Google Guice annotations[1] would solve this problem. Example Bind: bind(GadgetHtmlParser.class) .annotatedWith(Names.named("parser-accel")) .to(CajaHtmlParser.class);
Inject: @Inject public Accel(@Named("parser-acce") GadgetHtmlParser parser, ... http://code.google.com/p/google-guice/wiki/BindingAnnotations On Mon, Oct 4, 2010 at 6:27 PM, <gagan.g...@gmail.com> wrote: > On 2010/10/05 01:02:01, chirag wrote: > > http://codereview.appspot.com/2119043/diff/63001/java/common/conf/shindig.properties >> >> File java/common/conf/shindig.properties (right): > > > http://codereview.appspot.com/2119043/diff/63001/java/common/conf/shindig.properties#newcode155 >> >> java/common/conf/shindig.properties:155: shindig.html.parser=neko >> Doesn't guice offer the same solution? >> Currently, we can switch between parsers by updating > > ParseModule#configure with > >> bind(GadgetHtmlParser.class).to(NekoSimplifiedHtmlParser.class); > > When you bind GadgetHtmlParser to say NekoSimplifiedHtmlParser, you lose > the ability to use neko for say proxy servlet (because existing gadgets > are using it) and caja for say accel servlet. > Also, adding the router opens more possibilities like: > > 1) Parsing dom for encoding detection: You have around 1024 bytes of the > initial content of a page and you want to determine the encoding. > You can try to parse the html and look for <meta > http-equiv="Content-Type"> > To make this parsing more robust, you could cycle through all the > available parsers and choose the one which does not throw an exception. > > > http://codereview.appspot.com/2119043/ >