On 6/5/06, Chris Hostetter <[EMAIL PROTECTED]> wrote:
I just wish it wasn't neccessary to have all these Factories ... has anyone done any serious bnchmarking of the cost of reflection in a case like this? ... if getting a Class by name is the expensive part, we can do that once when the config is loaded -- it's just a question of how "clazz.newInstance() performs relative to "new Foo()"
A factory is certainly necessary sometimes. You don't want to incur setup time for creating a SynonymMap or a StopSet for every instance you create. For simpler tokenizers or token filters, it would be nice to be able to use them directly. Perhaps we could look at the class type, and if it's a lucene Tokenizer or TokenFilter, try instantiating it directly with newInstance(). At schema creation time, we should probably check if the specified Tokenizer or TokenFilter has a default constructor. If it doesn't we should throw an error right then, not waiting for a confusing runtime exception. -Yonik