protected void loadClientMetadata ( Map < String , Object > puProperties ) { clientMetadata = new ClientMetadata ( ) ; String luceneDirectoryPath = puProperties != null ? ( String ) puProperties . get ( PersistenceProperties . KUNDERA_INDEX_HOME_DIR ) : null ; String indexerClass = puProperties != null ? ( String ) puProperties . get ( PersistenceProperties . KUNDERA_INDEXER_CLASS ) : null ; String autoGenClass = puProperties != null ? ( String ) puProperties . get ( PersistenceProperties . KUNDERA_AUTO_GENERATOR_CLASS ) : null ; if ( indexerClass == null ) { indexerClass = kunderaMetadata . getApplicationMetadata ( ) . getPersistenceUnitMetadata ( persistenceUnit ) . getProperties ( ) . getProperty ( PersistenceProperties . KUNDERA_INDEXER_CLASS ) ; } if ( autoGenClass == null ) { autoGenClass = kunderaMetadata . getApplicationMetadata ( ) . getPersistenceUnitMetadata ( persistenceUnit ) . getProperties ( ) . getProperty ( PersistenceProperties . KUNDERA_AUTO_GENERATOR_CLASS ) ; } if ( luceneDirectoryPath == null ) { luceneDirectoryPath = kunderaMetadata . getApplicationMetadata ( ) . getPersistenceUnitMetadata ( persistenceUnit ) . getProperty ( PersistenceProperties . KUNDERA_INDEX_HOME_DIR ) ; } if ( autoGenClass != null ) { clientMetadata . setAutoGenImplementor ( autoGenClass ) ; } // in case set empty via external property, means want to avoid lucene // directory set up. if ( luceneDirectoryPath != null && ! StringUtils . isEmpty ( luceneDirectoryPath ) ) { // Add client metadata clientMetadata . setLuceneIndexDir ( luceneDirectoryPath ) ; // Set Index Manager try { Method method = Class . forName ( IndexingConstants . LUCENE_INDEXER ) . getDeclaredMethod ( "getInstance" , String . class ) ; Indexer indexer = ( Indexer ) method . invoke ( null , luceneDirectoryPath ) ; indexManager = new IndexManager ( indexer , kunderaMetadata ) ; } catch ( Exception e ) { logger . error ( "Missing lucene from classpath. Please make sure those are available to load lucene directory {}!" , luceneDirectoryPath ) ; throw new InvalidConfigurationException ( e ) ; } // indexManager = new IndexManager(LuceneIndexer.getInstance(new // StandardAnalyzer(Version.LUCENE_CURRENT), // luceneDirectoryPath)); } else if ( indexerClass != null ) { try { Class < ? > indexerClazz = Class . forName ( indexerClass ) ; Indexer indexer = ( Indexer ) indexerClazz . newInstance ( ) ; indexManager = new IndexManager ( indexer , kunderaMetadata ) ; clientMetadata . setIndexImplementor ( indexerClass ) ; } catch ( Exception cnfex ) { logger . error ( "Error while initialzing indexer:" + indexerClass , cnfex ) ; throw new KunderaException ( cnfex ) ; } } else { indexManager = new IndexManager ( null , kunderaMetadata ) ; } // if // (kunderaMetadata.getClientMetadata(persistenceUnit) // == // null) // { // kunderaMetadata.addClientMetadata(persistenceUnit, // clientMetadata); // } }
Load client metadata .