====== SolrMarc: Custom Java Best Practices ====== :!: This page only applies to SolrMarc 3.0 and later, which was bundled with VuFind® 3.1 and later. When using custom Java indexing code, the following best practices will make your life easier: * Create small classes containing related functionality for ease of maintenance. SolrMarc will find and compile all of the classes that you place under the import/index_java directory under your $VUFIND_HOME and $VUFIND_LOCAL_DIR. * Use distinctive method names; if you have the same method name in multiple classes, you will have to disambiguate the class name in your marc.properties file. Using distinctive names makes the shorthand syntax more reliable. * If your custom code needs to access public methods from the core SolrIndexer class, use SolrIndexer.instance() to reach them. * If your custom code needs to cache or persist values, create a thread-safe singleton to encapsulate those values. You can see an example of this pattern in the [[https://github.com/vufind-org/vufind/blob/dev/import/index_java/src/org/vufind/index/ConfigManager.java|ConfigManager]] used by, among other things, the [[https://github.com/vufind-org/vufind/blob/dev/import/index_java/src/org/vufind/index/FullTextTools.java|FullTextTools]].