Package org.hibernate.search.util.configuration.impl

Examples of org.hibernate.search.util.configuration.impl.MaskedProperty


        shardIdentityProviderName,
        "ShardIdentifierProvider",
        serviceManager
    );

    shardIdentifierProvider.initialize( new MaskedProperty( indexProperty, SHARDING_STRATEGY ), buildContext );

    return shardIdentifierProvider;
  }
View Full Code Here


          "IndexShardingStrategy",
          serviceManager
      );
    }
    shardingStrategy.initialize(
        new MaskedProperty( indexProps[0], SHARDING_STRATEGY ), indexManagers
    );
    return shardingStrategy;
  }
View Full Code Here

    cfg.put( "hibernate.search.default.transaction.max_merge_docs", "6" );
    cfg.put( "hibernate.search.default.transaction.indexwriter.max_field_length", "7" );
    cfg.put( "hibernate.notsearch.tests.default", "7" );

    //this is more a "concept demo" than a test:
    Properties root = new MaskedProperty( cfg, "hibernate.search" );
    //only keys starting as "hibernate.search.default" are exposed:
    Properties common = new MaskedProperty( root, "default" );
    //now as "hibernate.search.Animals" or "hibernate.search.default" if first fails:
    Properties dirProvider = new MaskedProperty( root, "Animals", common );
    //this narrows visibility to "hibernate.search.<providername|default>.transaction":
    Properties transaction = new MaskedProperty( dirProvider, "transaction" );
    Properties shard2 = new MaskedProperty( dirProvider, "2", dirProvider );
    Properties transactionInShard2 = new MaskedProperty( shard2, "transaction", transaction );
    Properties newStyleTransaction = new MaskedProperty( transaction, "indexwriter", transaction );
    Properties newStyleTransactionInShard2 = new MaskedProperty(
        transactionInShard2, "indexwriter", transactionInShard2
    );

    assertEquals( "7", newStyleTransaction.getProperty( "max_field_length" ) );
    assertEquals( "7", newStyleTransactionInShard2.getProperty( "max_field_length" ) );
    assertEquals( "5", transaction.getProperty( "max_merge_docs" ) );
  }
View Full Code Here

  @Test
  public void testSerializability() throws IOException, ClassNotFoundException {
    Properties properties = new Properties();
    properties.setProperty( "base.key", "value" );
    MaskedProperty originalProps = new MaskedProperty( properties, "base" );
    MaskedProperty theCopy = SerializationTestHelper.duplicateBySerialization( originalProps );
    //this is also testing the logger (transient) has been restored:
    assertEquals( "value", theCopy.getProperty( "key" ) );
  }
View Full Code Here

    Properties rootProp = new Properties( defaultProp );
    rootProp.put( "some.long.dotted.prop1", "hello!" );
    rootProp.put( "hidden.long.dotted.prop2", "hello again" );
    Properties fallbackProp = new Properties();
    fallbackProp.put( "default.long.dotted.prop3", "hello!" );
    Properties masked = new MaskedProperty( rootProp, "some", fallbackProp );

    assertTrue( masked.keySet().contains( "long.dotted.prop1" ) );
    assertTrue( masked.keySet().contains( "default.long.dotted.prop3" ) );
    assertTrue( masked.keySet().contains( "inherited.prop" ) );
    assertFalse( masked.keySet().contains( "hidden.long.dotted.prop2" ) );
    assertFalse( masked.keySet().contains( "long.dotted.prop2" ) );

    Properties maskedAgain = new MaskedProperty(
        masked,
        "long.dotted",
        masked
    ); //falling back to same instance for **
    assertTrue( maskedAgain.keySet().contains( "prop1" ) );
    assertTrue( maskedAgain.keySet().contains( "long.dotted.prop1" ) ); //**: prop 1 should be visible in both ways
    assertTrue( maskedAgain.keySet().contains( "default.long.dotted.prop3" ) );

    Properties maskingAll = new MaskedProperty( masked, "secured" );
    assertTrue( maskingAll.keySet().isEmpty() );
    assertTrue( maskingAll.isEmpty() );
  }
View Full Code Here

      return Executors.QUEUE_MAX_LENGTH;
    }
  }

  public static OptimizerStrategy getOptimizerStrategy(IndexManager callback, Properties indexProps) {
    MaskedProperty optimizerCfg = new MaskedProperty(indexProps, "optimizer" );
    String customImplementation = optimizerCfg.getProperty( "implementation" );
    if ( customImplementation != null && (! "default".equalsIgnoreCase( customImplementation ) ) ) {
      return ClassLoaderHelper.instanceFromName( OptimizerStrategy.class,
          customImplementation,
          callback.getClass().getClassLoader(),
          "Optimizer Strategy" );
    }
    else {
      boolean incremental = optimizerCfg.containsKey( "operation_limit.max" )
        || optimizerCfg.containsKey( "transaction_limit.max" );
      OptimizerStrategy optimizerStrategy;
      if ( incremental ) {
        optimizerStrategy = new IncrementalOptimizerStrategy();
        optimizerStrategy.initialize( callback, optimizerCfg );
      }
View Full Code Here

  public static LuceneIndexingParameters extractIndexingPerformanceOptions(Properties properties) {
    return new LuceneIndexingParameters( properties );
  }

  public static DirectoryBasedReaderProvider createDirectoryBasedReaderProvider(DirectoryBasedIndexManager indexManager, Properties cfg) {
    Properties props = new MaskedProperty( cfg, Environment.READER_PREFIX );
    String impl = props.getProperty( "strategy" );
    DirectoryBasedReaderProvider readerProvider;
    if ( StringHelper.isEmpty( impl ) ) {
      readerProvider = new SharingBufferReaderProvider();
    }
    else if ( "not-shared".equalsIgnoreCase( impl ) ) {
View Full Code Here

      throw log.assertionFailureCannotCastToWorkerBuilderContext( searchFactory.getClass() );
    }

    Properties properties = entityIndexBinding.getProperties();
    if ( shardName != null ) {
      properties = new MaskedProperty( properties, shardName, properties );
    }

    indexManager = createIndexManager(
        indexName,
        entityIndexBinding.getDocumentBuilder().getBeanClass(),
View Full Code Here

   * If the index is sharded, the Properties index matches the shard index
   *
   * @return an array of index properties
   */
  private static Properties[] getIndexProperties(SearchConfiguration cfg, String indexName) {
    Properties rootCfg = new MaskedProperty( cfg.getProperties(), "hibernate.search" );
    Properties globalProperties = new MaskedProperty( rootCfg, "default" );
    Properties directoryLocalProperties = new MaskedProperty( rootCfg, indexName, globalProperties );
    String shardsCountValue = directoryLocalProperties.getProperty( NBR_OF_SHARDS );

    if ( shardsCountValue == null ) {
      // no shard finished.
      return new Properties[] { directoryLocalProperties };
    }
    else {
      // count shards
      int shardsCount = ConfigurationParseHelper.parseInt(
          shardsCountValue, "'" + shardsCountValue + "' is not a valid value for " + NBR_OF_SHARDS
      );

      if ( shardsCount <= 0 ) {
        throw log.getInvalidShardCountException( shardsCount );
      }

      // create shard-specific Props
      Properties[] shardLocalProperties = new Properties[shardsCount];
      for ( int i = 0; i < shardsCount; i++ ) {
        shardLocalProperties[i] = new MaskedProperty(
            directoryLocalProperties, Integer.toString( i ), directoryLocalProperties
        );
      }
      return shardLocalProperties;
    }
View Full Code Here

        ShardIdentifierProvider.class,
        shardIdentityProviderName,
        DirectoryProviderFactory.class.getClassLoader(),
        "ShardIdentifierProvider"
    );
    shardIdentifierProvider.initialize( new MaskedProperty( indexProperty, SHARDING_STRATEGY ), context );

    return shardIdentifierProvider;
  }
View Full Code Here

TOP

Related Classes of org.hibernate.search.util.configuration.impl.MaskedProperty

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.