@Override public void configure(Map configurationValues) { configuration = new RemoteNeo4jConfiguration( new ConfigurationPropertyReader( configurationValues ), defaultPort ); sequenceCacheMaxSize = new ConfigurationPropertyReader( configurationValues ) .property( Neo4jProperties.SEQUENCE_QUERY_CACHE_MAX_SIZE, int.class ) .withDefault( DEFAULT_SEQUENCE_QUERY_CACHE_MAX_SIZE ) .getValue(); }
/** * Set the properties defined using the prefix {@link InfinispanRemoteProperties#HOT_ROD_CLIENT_PREFIX} * * @param configurationMap contains all the properties defined for OGM * @param propertyReader read the value of a property * @param hotRodConfiguration the Hot Rod configuration to update */ private void setAdditionalProperties(Map<?, ?> configurationMap, ConfigurationPropertyReader propertyReader, Properties hotRodConfiguration) { // Programmatic properties override the resource file for ( Entry<?, ?> property : configurationMap.entrySet() ) { String key = (String) property.getKey(); if ( key.startsWith( HOT_ROD_CLIENT_PREFIX ) ) { String hotRodProperty = key.substring( HOT_ROD_CLIENT_PREFIX.length() ); String value = propertyReader.property( key, String.class ).getValue(); if ( !ArrayHelper.contains( noPrefixProperties, hotRodProperty ) ) { hotRodProperty = HOT_ROD_ORIGINAL_PREFIX + hotRodProperty; } hotRodConfiguration.setProperty( hotRodProperty, value ); } } }
@Override public void configure(Map configurationValues) { configuration = new CouchDBConfiguration( new ConfigurationPropertyReader( configurationValues ) ); }
@Override public AssociationStorageType getDefaultValue(ConfigurationPropertyReader propertyReader) { return propertyReader.property( DocumentStoreProperties.ASSOCIATIONS_STORE, AssociationStorageType.class ) .withDefault( DEFAULT_ASSOCIATION_STORAGE ) .getValue(); } }
@Override public void configure(Map configurationValues) { ClassLoaderService classLoaderService = registry.getService( ClassLoaderService.class ); ConfigurationPropertyReader propertyReader = new ConfigurationPropertyReader( configurationValues, classLoaderService ); sessionFactoryOptions = new OptionsServiceContextImpl( OptionValueSources.getDefaultSources( propertyReader ) ); }
/** * Decides if we need to start OGM when {@link OgmProperties#ENABLED} is not set. * At the moment, if a dialect class is not declared, Hibernate ORM requires a datasource or a JDBC connector when a dialect is not declared. * If none of those properties are declared, we assume the user wants to start Hibernate OGM. * * @param settings * @return {@code true} if we have to start OGM, {@code false} otherwise */ private boolean isOgmImplicitEnabled(Map<?, ?> settings) { String jdbcUrl = new ConfigurationPropertyReader( settings ) .property( Environment.URL, String.class ) .getValue(); String jndiDatasource = new ConfigurationPropertyReader( settings ) .property( Environment.DATASOURCE, String.class ) .getValue(); String dialect = new ConfigurationPropertyReader( settings ) .property( Environment.DIALECT, String.class ) .getValue(); return jdbcUrl == null && jndiDatasource == null && dialect == null; } }
@Override public AssociationDocumentStorageType getDefaultValue(ConfigurationPropertyReader propertyReader) { return propertyReader.property( MongoDBProperties.ASSOCIATION_DOCUMENT_STORAGE, AssociationDocumentStorageType.class ) .withDefault( AssociationDocumentStorageType.GLOBAL_COLLECTION ) .getValue(); } }
@Override public void configure(Map configurationValues) { OptionsService optionsService = serviceRegistry.getService( OptionsService.class ); ClassLoaderService classLoaderService = serviceRegistry.getService( ClassLoaderService.class ); ConfigurationPropertyReader propertyReader = new ConfigurationPropertyReader( configurationValues, classLoaderService ); config = new CassandraConfiguration( propertyReader, optionsService.context().getGlobalOptions() ); }
@Override public void initialize(Map<?, ?> properties) { ConfigurationPropertyReader configurationPropertyReader = new ConfigurationPropertyReader( properties ); String path = configurationPropertyReader.property( Neo4jProperties.DATABASE_PATH, String.class ) .required() .getValue(); this.dbLocation = new File( path ); this.configurationLocation = configurationPropertyReader .property( Neo4jProperties.CONFIGURATION_RESOURCE_NAME, URL.class ) .getValue(); configuration = properties; }
@Override public MapStorageType getDefaultValue(ConfigurationPropertyReader propertyReader) { return propertyReader .property( DocumentStoreProperties.MAP_STORAGE, MapStorageType.class ) .withDefault( DEFAULT_MAP_STORAGE ) .getValue(); } }
@Override public void configure(Map configurationValues) { OptionsService optionsService = serviceRegistry.getService( OptionsService.class ); ClassLoaderService classLoaderService = serviceRegistry.getService( ClassLoaderService.class ); ConfigurationPropertyReader propertyReader = new ConfigurationPropertyReader( configurationValues, classLoaderService ); try { this.config = new MongoDBConfiguration( propertyReader, optionsService.context().getGlobalOptions() ); } catch (Exception e) { // Wrap Exception in a ServiceException to make the stack trace more friendly // Otherwise a generic unable to request service is thrown throw log.unableToConfigureDatastoreProvider( e ); } }
private boolean isOgmEnabled(Map<?, ?> settings) { Boolean ogmEnabled = new ConfigurationPropertyReader( settings ) .property( OgmProperties.ENABLED, Boolean.class ) .getValue(); if ( ogmEnabled == null ) { return isOgmImplicitEnabled( settings ); } return ogmEnabled; }
@Override public AssociationDocumentStorageType getDefaultValue(ConfigurationPropertyReader propertyReader) { return propertyReader.property( MongoDBProperties.ASSOCIATION_DOCUMENT_STORAGE, AssociationDocumentStorageType.class ) .withDefault( AssociationDocumentStorageType.GLOBAL_COLLECTION ) .getValue(); } }
@Override public void configure(Map configurationValues) { OptionsService optionsService = serviceRegistry.getService( OptionsService.class ); ClassLoaderService classLoaderService = serviceRegistry.getService( ClassLoaderService.class ); ConfigurationPropertyReader propertyReader = new ConfigurationPropertyReader( configurationValues, classLoaderService ); try { this.config = new MongoDBConfiguration( propertyReader, optionsService.context().getGlobalOptions() ); } catch (Exception e) { // Wrap Exception in a ServiceException to make the stack trace more friendly // Otherwise a generic unable to request service is thrown throw log.unableToConfigureDatastoreProvider( e ); } }
/** * Initialize the internal values from the given {@link Map}. * * @param configurationMap The values to use as configuration */ public void initialize(Map configurationMap) { this.url = new ConfigurationPropertyReader( configurationMap ) .property( EhcacheProperties.CONFIGURATION_RESOURCE_NAME, URL.class ) .withDefault( EhcacheConfiguration.class.getClassLoader().getResource( DEFAULT_CONFIG ) ) .getValue(); }
@Override public CacheMappingType getDefaultValue(ConfigurationPropertyReader propertyReader) { return propertyReader.property( KeyValueStoreProperties.CACHE_MAPPING, CacheMappingType.class ) .withDefault( DEFAULT_CACHE_STORAGE ) .getValue(); } }
private ErrorHandler getErrorHandler(Map<?, ?> configurationValues, ServiceRegistryImplementor registry) { ConfigurationPropertyReader propertyReader = new ConfigurationPropertyReader( configurationValues, registry.getService( ClassLoaderService.class ) ); return propertyReader.property( OgmProperties.ERROR_HANDLER, ErrorHandler.class ).instantiate().getValue(); } }
public RemoteNeo4jConfiguration(ConfigurationPropertyReader propertyReader, int defaultPort) { String host = propertyReader.property( OgmProperties.HOST, String.class ) .withDefault( DEFAULT_HOST ) .getValue(); Integer port = propertyReader.property( OgmProperties.PORT, Integer.class ) .withValidator( Validators.PORT ) .withDefault( null ) .getValue(); this.hosts = HostParser.parse( host, port, defaultPort ); this.databaseName = propertyReader.property( OgmProperties.DATABASE, String.class ) .withDefault( DEFAULT_DB ) .getValue(); this.username = propertyReader.property( OgmProperties.USERNAME, String.class ).getValue(); this.password = propertyReader.property( OgmProperties.PASSWORD, String.class ).getValue(); this.socketTimeout = propertyReader.property( Neo4jProperties.SOCKET_TIMEOUT, Long.class ).getValue(); this.establishConnectionTimeout = propertyReader.property( Neo4jProperties.ESTABLISH_CONNECTION_TIMEOUT, Long.class ).getValue(); this.connectionCheckoutTimeout = propertyReader.property( Neo4jProperties.CONNECTION_CHECKOUT_TIMEOUT, Long.class ).getValue(); this.connectionTTL = propertyReader.property( Neo4jProperties.CONNECTION_TTL, Long.class ).getValue(); this.createDatabase = propertyReader.property( OgmProperties.CREATE_DATABASE, boolean.class ) .withDefault( false ) .getValue(); this.authenticationRequired = this.username != null; this.clientPoolSize = propertyReader.property( Neo4jProperties.CONNECTION_POOL_SIZE, Integer.class ) .withDefault( DEFAULT_CONNECTION_POOL_SIZE ).getValue(); this.nativeClientResource = propertyReader.property( OgmProperties.NATIVE_CLIENT_RESOURCE, String.class ) .withDefault( null ) .getValue(); }
/** * Initialize the internal values form the given {@link Map}. * * @param configurationMap * The values to use as configuration */ public void initConfiguration(Map<?, ?> configurationMap) { ConfigurationPropertyReader propertyReader = new ConfigurationPropertyReader( configurationMap ); this.configUrl = propertyReader .property( InfinispanProperties.CONFIGURATION_RESOURCE_NAME, URL.class ) .withDefault( InfinispanConfiguration.class.getClassLoader().getResource( INFINISPAN_DEFAULT_CONFIG ) ) .getValue(); this.jndi = propertyReader .property( InfinispanProperties.CACHE_MANAGER_JNDI_NAME, String.class ) .getValue(); log.tracef( "Initializing Infinispan from configuration file at %1$s", configUrl ); } }
@Override public ReadConcern getDefaultValue(ConfigurationPropertyReader propertyReader) { ReadConcernType readConcernType = propertyReader.property( MongoDBProperties.READ_CONCERN, ReadConcernType.class ) .withDefault( ReadConcernType.DEFAULT ) .getValue(); return readConcernType.getReadConcern(); } }