@Override public AssociationStorageType getDefaultValue(ConfigurationPropertyReader propertyReader) { return propertyReader.property( DocumentStoreProperties.ASSOCIATIONS_STORE, AssociationStorageType.class ) .withDefault( DEFAULT_ASSOCIATION_STORAGE ) .getValue(); } }
@Override public WriteConcern getDefaultValue(ConfigurationPropertyReader propertyReader) { WriteConcernType writeConcernType = propertyReader.property( MongoDBProperties.WRITE_CONCERN, WriteConcernType.class ) .withDefault( DEFAULT_WRITE_CONCERN ) .getValue(); // load/instantiate custom type if ( writeConcernType == WriteConcernType.CUSTOM ) { return propertyReader.property( MongoDBProperties.WRITE_CONCERN_TYPE, WriteConcern.class ) .instantiate() .required() .getValue(); } // take pre-defined value else { return writeConcernType.getWriteConcern(); } } }
public DocumentStoreConfiguration(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(); hosts = HostParser.parse( host, port, defaultPort ); this.nativeClientResource = propertyReader.property( OgmProperties.NATIVE_CLIENT_RESOURCE, String.class ) .withDefault( null ) .getValue(); PropertyReaderContext<String> databaseNamePropertyReader = propertyReader.property( OgmProperties.DATABASE, String.class ); if ( nativeClientResource == null ) { // Require databaseName property, if nativeClientResource is not defined databaseNamePropertyReader.required(); } this.databaseName = databaseNamePropertyReader.getValue(); this.username = propertyReader.property( OgmProperties.USERNAME, String.class ).getValue(); this.password = propertyReader.property( OgmProperties.PASSWORD, String.class ).getValue(); this.createDatabase = propertyReader.property( OgmProperties.CREATE_DATABASE, boolean.class ) .withDefault( false ) .getValue(); }
@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; }
.withDefaultStringValue( InfinispanRemoteProperties.DEFAULT_CONFIGURATION_RESOURCE_NAME ) .getValue(); .instantiate() .getValue(); .instantiate() .getValue(); .getValue(); .withDefault( InfinispanRemoteProperties.DEFAULT_SCHEMA_PACKAGE_NAME ) .getValue(); .withDefault( InfinispanRemoteProperties.DEFAULT_SCHEMA_FILE_NAME ) .withValidator( InfinispanRemoteValidators.SCHEMA_FILE_NAME ) .getValue(); .withDefault( false ) .getValue(); .withDefault( null ) .getValue(); .withDefault( InfinispanRemoteProperties.DEFAULT_TRANSACTION_MODE ) .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(); }
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(); } }
/** * 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 ); } } }
public GraphDatabaseServiceFactory load(Map<?, ?> properties, ClassLoaderService classLoaderService) { GraphDatabaseServiceFactory factory = new ConfigurationPropertyReader( properties, classLoaderService ) .property( EmbeddedNeo4jInternalProperties.NEO4J_GRAPHDB_FACTORYCLASS, GraphDatabaseServiceFactory.class ) .instantiate() .withDefaultImplementation( EmbeddedNeo4jGraphDatabaseFactory.class ) .getValue(); factory.initialize( properties ); return factory; } }
/** * 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 CacheMappingType getDefaultValue(ConfigurationPropertyReader propertyReader) { return propertyReader.property( KeyValueStoreProperties.CACHE_MAPPING, CacheMappingType.class ) .withDefault( DEFAULT_CACHE_STORAGE ) .getValue(); } }
@Override public WriteConcern getDefaultValue(ConfigurationPropertyReader propertyReader) { WriteConcernType writeConcernType = propertyReader.property( MongoDBProperties.WRITE_CONCERN, WriteConcernType.class ) .withDefault( DEFAULT_WRITE_CONCERN ) .getValue(); // load/instantiate custom type if ( writeConcernType == WriteConcernType.CUSTOM ) { return propertyReader.property( MongoDBProperties.WRITE_CONCERN_TYPE, WriteConcern.class ) .instantiate() .required() .getValue(); } // take pre-defined value else { return writeConcernType.getWriteConcern(); } } }
public static List<OptionValueSource> getDefaultSources(ConfigurationPropertyReader propertyReader) { AppendableConfigurationContext programmaticOptions = propertyReader.property( InternalProperties.OGM_OPTION_CONTEXT, AppendableConfigurationContext.class ) .instantiate() .getValue(); OptionConfigurator configurator = propertyReader.property( OgmProperties.OPTION_CONFIGURATOR, OptionConfigurator.class ) .instantiate() .getValue(); if ( configurator != null ) { if ( programmaticOptions != null ) { throw log.ambigiousOptionConfiguration( OgmProperties.OPTION_CONFIGURATOR ); } programmaticOptions = invokeOptionConfigurator( configurator ); } return programmaticOptions != null ? Arrays.<OptionValueSource>asList( new ProgrammaticOptionValueSource( programmaticOptions ), new AnnotationOptionValueSource(), new ConfigurationOptionValueSource( propertyReader ) ) : Arrays.<OptionValueSource>asList( new AnnotationOptionValueSource(), new ConfigurationOptionValueSource( propertyReader ) ); }
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(); } }
/** * Initialize the internal values from the given {@link Map}. * * @param configurationMap The values to use as configuration */ public void initialize(Map configurationMap, ClassLoaderService classLoaderService) { ConfigurationPropertyReader configurationPropertyReader = new ConfigurationPropertyReader( configurationMap, classLoaderService ); this.url = configurationPropertyReader .property( IgniteProperties.CONFIGURATION_RESOURCE_NAME, URL.class ) .withDefault( IgniteProviderConfiguration.class.getClassLoader().getResource( DEFAULT_CONFIG ) ) .getValue(); String configBuilderClassName = configurationPropertyReader .property( IgniteProperties.CONFIGURATION_CLASS_NAME, String.class ) .getValue(); if ( configBuilderClassName != null ) { this.configBuilder = configurationPropertyReader .property( IgniteProperties.CONFIGURATION_CLASS_NAME, IgniteConfigurationBuilder.class ) .instantiate() .getValue(); } this.instanceName = configurationPropertyReader .property( IgniteProperties.IGNITE_INSTANCE_NAME, String.class ) .getValue(); }
@Override public DatastoreProvider initiateService(Map configurationValues, ServiceRegistryImplementor registry) { ConfigurationPropertyReader propertyReader = new ConfigurationPropertyReader( configurationValues, registry.getService( ClassLoaderService.class ) ); DatastoreProvider datastoreProvider = propertyReader.property( OgmProperties.DATASTORE_PROVIDER, DatastoreProvider.class ) .instantiate() .withDefaultImplementation( DEFAULT_DATASTORE_PROVIDER ) .withShortNameResolver( DatastoreProviderShortNameResolver.INSTANCE ) .getValue(); log.useDatastoreProvider( datastoreProvider.getClass() ); return datastoreProvider; }
@Override public MapStorageType getDefaultValue(ConfigurationPropertyReader propertyReader) { return propertyReader .property( DocumentStoreProperties.MAP_STORAGE, MapStorageType.class ) .withDefault( DEFAULT_MAP_STORAGE ) .getValue(); } }
@Override public GridDialect initiateService(Map configurationValues, ServiceRegistryImplementor registry) { DatastoreProvider datastore = registry.getService( DatastoreProvider.class ); boolean errorHandlerConfigured = configurationValues.containsKey( OgmProperties.ERROR_HANDLER ); EventContextManager eventContext = registry.getService( EventContextManager.class ); ConfigurationPropertyReader propertyReader = new ConfigurationPropertyReader( configurationValues, registry.getService( ClassLoaderService.class ) ); return ( (DefaultClassPropertyReaderContext<GridDialect>) propertyReader.property( OgmProperties.GRID_DIALECT, GridDialect.class ) .instantiate() ) .withDefaultImplementation( registry.getService( DatastoreProvider.class ).getDefaultDialect() ) .withInstantiator( new GridDialectInstantiator( datastore, errorHandlerConfigured, eventContext ) ) .getValue(); }
@Override public AssociationDocumentStorageType getDefaultValue(ConfigurationPropertyReader propertyReader) { return propertyReader.property( MongoDBProperties.ASSOCIATION_DOCUMENT_STORAGE, AssociationDocumentStorageType.class ) .withDefault( AssociationDocumentStorageType.GLOBAL_COLLECTION ) .getValue(); } }