private static void addSolr5Index ( ) { try { Field field = StandardIndexProvider . class . getDeclaredField ( "ALL_MANAGER_CLASSES" ) ; field . setAccessible ( true ) ; Field modifiersField = Field . class . getDeclaredField ( "modifiers" ) ; modifiersField . setAccessible ( true ) ; modifiersField . setInt ( field , field . getModifiers ( ) & ~ Modifier . FINAL ) ; Map < String , String > customMap = new HashMap <> ( StandardIndexProvider . getAllProviderClasses ( ) ) ; customMap . put ( "solr" , Solr5Index . class . getName ( ) ) ; // for // consistency // with Titan // 1.0.0 customMap . put ( "solr5" , Solr5Index . class . getName ( ) ) ; // for backward // compatibility ImmutableMap < String , String > immap = ImmutableMap . copyOf ( customMap ) ; field . set ( null , immap ) ; LOG . debug ( "Injected solr5 index - {}" , Solr5Index . class . getName ( ) ) ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } }
Titan loads index backend name to implementation using StandardIndexProvider . ALL_MANAGER_CLASSES But StandardIndexProvider . ALL_MANAGER_CLASSES is a private static final ImmutableMap Only way to inject Solr5Index is to modify this field . So using hacky reflection to add Sol5Index