The Lucene4 codec loads the corresponding class by reflection.
The information associated with reflection is placed in the Meta-inf\services directory of the Lucene jar file.
Related code in Namedspiloader.java
Some special projects need to remove the codec reflection mechanism, modify this function can be (4.5.0 version). After modification, no meta-inf\services is required.
Public synchronized void Reload (ClassLoader ClassLoader) {final linkedhashmap<string,s> services = new Linked
Hashmap<string,s> (this.services);
Final spiclassiterator<s> loader = Spiclassiterator.get (Clazz, ClassLoader);
if (Clazz.getsimplename (). Equals ("Postingsformat")) {services.put ("Lucene40", (S) New Lucene40postingsformat ());
Services.put ("Lucene41", (S) New Lucene41postingsformat ()); else if (Clazz.getsimplename (). Equals ("Docvaluesformat")) {services.put ("Lucene42", (S) New LUCENE42DOCVALUESFO
Rmat ());
Services.put ("Lucene45", (S) New Lucene45docvaluesformat ());
else if (Clazz.getsimplename (). Equals ("Codec")) {services.put ("Lucene40", (S) New Lucene40codec ());
Services.put ("Lucene41", (S) New Lucene41codec ());
Services.put ("Lucene42", (S) New Lucene42codec ());
Services.put ("Lucene45", (S) New Lucene45codec ());
Services.put ("lucene3x", (S) New Lucene3xcodec ());
} This.services = Collections.unmodifiablemap (services); }