I spent the weekend exploring how to use convention-based
configuration with ibatis3 on a new project I'm working on.

Open source is great, so I lifted the Stripes ResolverUtil class to
assist me in finding classes that I then wired into my ibatis
configuration at startup.

For example:
 - I have all of my beans in one package, so I create type aliases for
all of them: "blah.blah.Order" becomes "Order"
 - I have all of my type handlers in one package, so I register (or
alias) them the same way (more on this in a bit)
 - I have all of my mapper interfaces in one package, so I register
all of them the same way

My current configuration eliminates the main XML configuration file,
and I also put the SQL map XML files in the same packages as the
mapper interfaces, so registering the interface loads the XML SQL
maps, too.

One thing I did have to add is a @MappedType(class[]) annotation for
my type handlers - this allows me to control if I want to have my type
handlers registered globally or just aliased - without the annotation,
they are just aliased (so "blah.blah.OrderHandler" becomes
"OrderHandler" - simpler to use in the XML files). With the the
annotation, I register it globally for the types listed.

If folks are interested in seeing more on this, I can put together a
simple example app that does it (or help someone out if they want it
sooner).

Anyone?

Larry


PS:

This may be more appropriate on the dev list, but since Stripes is
distributed under ASL2, I could even add this to the core - it's one
new class, and we could extend the configuration API to have these
kinds of methods:
 - typeHandlerRegistry.registerPackage(String packageName);
 - configuration.addMapperPackage(String packageName)
 - typeAliasRegistry.registerAliases(String packageName);

---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscr...@ibatis.apache.org
For additional commands, e-mail: user-java-h...@ibatis.apache.org

Reply via email to