Archive for April 12th, 2008

Automatic Mapping Scanning with Compass

Saturday, April 12th, 2008

Compass now supports (trunk) automatic scanning of different mappings definitions (a much requested feature). Here is a code example of how it can be used:

1
2
3
Compass compass = new CompassConfiguration().setConnection("test-index")
                 .addScan("com.mycompany", "**/model/**")
                 .buildCompass();

The above code will scan the package com.mycompany and match any sub package that has model in it (ant style pattern matching, can be null). The scanning process will scan for all the typical xml mapping definitions (ends with .cpm.xml), and will try and find classes with @Searchable annotations using either ASM or Javassist (if found in the classpath).

The scanner is supported both in the dtd based configuration and the schema based configuration. Enjoy!.