Hi all guys, I've had this mail draft for a long while and I think it's time to shout it out to get your feedbacks.
Due to my involvement in Apache Commons and being strongly influenced by the Google-Guice design, I think we could get benefit from a vision that mixes the power of: * modularity; * Embedded DSL. The current situation is that the sitemap takes tons of Kb of Spring dependencies (please assume I'm not a big fan of Spring so my POV is influenced :P) and the sitemap is described via XML. Since we can still take the XML configuration, I'm sure - but I haven't had the time to write even a kickoff spike, so I still don't have the proof on hands - we could simplify the foundation of sitemap design, getting benefits from the javac using directly the Java language to describe the sitemap. What I'd suggest is introducing Sitemap(s) to describe how the sitemap is organized, i.e. +-------------------------+ interface Sitemap { void configure( SitemapBinder binder ); } +-------------------------+ where the {{SitemapBinder}} contains a set of APIs to allow describing the path-matching; a possible case could be: +-------------------------+ public class MySitemap implements Sitemap { public void configure( SitemapBinder binder ) { binder.when( "linkmap.xml" ) .newCachingPipeline() .setStarter( new XMLGenerator(new URL( "feed.xml" ) ) .addComponent( new XSLTTransformer(this.getClass().getResource("/trax.xslt") ) .setFinisher( XMLSerializer.createXMLSerializer ); ... binder.when( "linkmap2.xml" ) .newCachingPipeline() .setStarter( new XMLGenerator(new URL( "feed2.xml" ) ) .addComponent( new XSLTTransformer(this.getClass().getResource("/trax2.xslt") ) .setFinisher( XMLSerializer.createXMLSerializer ); ... } } +-------------------------+ that would reflect what in XML would be expressed as: +-------------------------+ <map:match pattern="linkmap.xml"> <map:generate src="classpath:feed" /> <map:transform src="{lm:transform.linkmap.document}"/> <map:serialize type="xml" /> </map:match> ... <map:match pattern="linkmap2.xml"> <map:generate src="classpath:feed2" /> <map:transform src="{lm:transform.linkmap.document}"/> <map:serialize type="xml" /> </map:match> ... +-------------------------+ of course, XML looks compact, but please take in consideration that XML is not type checking, we can get errors at runtime only; that means that a transformer can be erroneously set as generator, while using Java APIs it would be notified at compile time. An AbstractSitemap would help to reduce the `binder` variable verbose and redundant call: +-------------------------+ public class MySitemap extends AbstractSitemap { @Override public void configure() { when( "linkmap.xml" ) .newCachingPipeline() .setStarter( new XMLGenerator(new URL( "feed.xml" ) ) .addComponent( new XSLTTransformer(this.getClass().getResource("/trax.xslt") ) .setFinisher( XMLSerializer.createXMLSerializer ); ... when( "linkmap2.xml" ) .newCachingPipeline() .setStarter( new XMLGenerator(new URL( "feed2.xml" ) ) .addComponent( new XSLTTransformer(this.getClass().getResource("/trax2.xslt") ) .setFinisher( XMLSerializer.createXMLSerializer ); ... } } +-------------------------+ we could also work by Sitemap composition: +-------------------------+ public class MySitemap implements Sitemap { public void configure( SitemapBinder binder ) { binder.when( "linkmap.xml" ) .newCachingPipeline() .setStarter( new XMLGenerator(new URL( "feed.xml" ) ) .addComponent( new XSLTTransformer(this.getClass().getResource("/trax.xslt") ) .setFinisher( XMLSerializer.createXMLSerializer ); ... binder.include( new MySitemap2() ); ... } } +-------------------------+ then a special loader is used to create the application: +-------------------------+ SitemapLoader.load( Sitemap...sitemaps ); +-------------------------+ WDYT? TIA, all the best, -Simo http://people.apache.org/~simonetripodi/ http://www.99soft.org/