Search in sources :

Example 11 with ConfigurationUnit

use of org.jnosql.artemis.ConfigurationUnit in project jnosql-artemis by eclipse.

the class DocumentCollectionFactoryProducer method getDocumentCollection.

private <T extends DocumentCollectionManager> DocumentCollectionManagerFactory<T> getDocumentCollection(InjectionPoint injectionPoint) {
    Annotated annotated = injectionPoint.getAnnotated();
    ConfigurationUnit annotation = getConfigurationUnit(injectionPoint, annotated).orElseThrow(() -> new IllegalStateException("The @ConfigurationUnit does not found"));
    ConfigurationSettingsUnit unit = configurationReader.get().read(annotation, DocumentConfiguration.class);
    Class<DocumentConfiguration> configurationClass = unit.<DocumentConfiguration>getProvider().orElseThrow(() -> new IllegalStateException("The DocumentConfiguration provider is required in the configuration"));
    DocumentConfiguration configuration = reflections.newInstance(configurationClass);
    return configuration.get(unit.getSettings());
}
Also used : Annotated(javax.enterprise.inject.spi.Annotated) ConfigurationSettingsUnit(org.jnosql.artemis.ConfigurationSettingsUnit) ConfigurationUnit(org.jnosql.artemis.ConfigurationUnit) DocumentConfiguration(org.jnosql.diana.api.document.DocumentConfiguration)

Example 12 with ConfigurationUnit

use of org.jnosql.artemis.ConfigurationUnit in project jnosql-artemis by eclipse.

the class BucketManagerFactoryProducer method getBuckerManagerFactocy.

private <T extends BucketManager> BucketManagerFactory<T> getBuckerManagerFactocy(InjectionPoint injectionPoint) {
    Annotated annotated = injectionPoint.getAnnotated();
    ConfigurationUnit annotation = getConfigurationUnit(injectionPoint, annotated).orElseThrow(() -> new IllegalStateException("The @ConfigurationUnit does not found"));
    ConfigurationSettingsUnit unit = configurationReader.get().read(annotation, KeyValueConfiguration.class);
    Class<KeyValueConfiguration> configurationClass = unit.<KeyValueConfiguration>getProvider().orElseThrow(() -> new IllegalStateException("The ColumnConfiguration provider is required in the configuration"));
    KeyValueConfiguration columnConfiguration = reflections.newInstance(configurationClass);
    return columnConfiguration.get(unit.getSettings());
}
Also used : Annotated(javax.enterprise.inject.spi.Annotated) KeyValueConfiguration(org.jnosql.diana.api.key.KeyValueConfiguration) ConfigurationSettingsUnit(org.jnosql.artemis.ConfigurationSettingsUnit) ConfigurationUnit(org.jnosql.artemis.ConfigurationUnit)

Example 13 with ConfigurationUnit

use of org.jnosql.artemis.ConfigurationUnit in project jnosql-artemis by eclipse.

the class DocumentCollectionFactoryProducer method getDocumentCollectionAsync.

private <T extends DocumentCollectionManagerAsync> DocumentCollectionManagerAsyncFactory<T> getDocumentCollectionAsync(InjectionPoint injectionPoint) {
    Annotated annotated = injectionPoint.getAnnotated();
    ConfigurationUnit annotation = getConfigurationUnit(injectionPoint, annotated).orElseThrow(() -> new IllegalStateException("The @ConfigurationUnit does not found"));
    ConfigurationSettingsUnit unit = configurationReader.get().read(annotation, DocumentConfigurationAsync.class);
    Class<DocumentConfigurationAsync> configurationClass = unit.<DocumentConfigurationAsync>getProvider().orElseThrow(() -> new IllegalStateException("The DocumentConfiguration provider is required in the configuration"));
    DocumentConfigurationAsync documentConfiguration = reflections.newInstance(configurationClass);
    return documentConfiguration.getAsync(unit.getSettings());
}
Also used : Annotated(javax.enterprise.inject.spi.Annotated) DocumentConfigurationAsync(org.jnosql.diana.api.document.DocumentConfigurationAsync) ConfigurationSettingsUnit(org.jnosql.artemis.ConfigurationSettingsUnit) ConfigurationUnit(org.jnosql.artemis.ConfigurationUnit)

Example 14 with ConfigurationUnit

use of org.jnosql.artemis.ConfigurationUnit in project jnosql-artemis by eclipse.

the class ColumnFamilyManagerFactoryProducer method gettColumnFamilyManagerAsyncFactory.

private <T extends ColumnFamilyManagerAsync> ColumnFamilyManagerAsyncFactory<T> gettColumnFamilyManagerAsyncFactory(InjectionPoint injectionPoint) {
    Annotated annotated = injectionPoint.getAnnotated();
    ConfigurationUnit annotation = getConfigurationUnit(injectionPoint, annotated).orElseThrow(() -> new IllegalStateException("The @ConfigurationUnit does not found"));
    ConfigurationSettingsUnit unit = configurationReader.get().read(annotation, ColumnConfigurationAsync.class);
    Class<ColumnConfigurationAsync> configurationClass = unit.<ColumnConfigurationAsync>getProvider().orElseThrow(() -> new IllegalStateException("The ColumnConfiguration provider is required in the configuration"));
    ColumnConfigurationAsync columnConfiguration = reflections.newInstance(configurationClass);
    return columnConfiguration.getAsync(unit.getSettings());
}
Also used : Annotated(javax.enterprise.inject.spi.Annotated) ConfigurationSettingsUnit(org.jnosql.artemis.ConfigurationSettingsUnit) ConfigurationUnit(org.jnosql.artemis.ConfigurationUnit) ColumnConfigurationAsync(org.jnosql.diana.api.column.ColumnConfigurationAsync)

Example 15 with ConfigurationUnit

use of org.jnosql.artemis.ConfigurationUnit in project jnosql-artemis by eclipse.

the class DefaultConfigurationReaderTest method shouldReturnNPEWhenConfigurationIsNull.

@Test
public void shouldReturnNPEWhenConfigurationIsNull() {
    Assertions.assertThrows(NullPointerException.class, () -> {
        ConfigurationUnit annotation = mock(ConfigurationUnit.class);
        configurationReader.read(annotation, null);
    });
}
Also used : ConfigurationUnit(org.jnosql.artemis.ConfigurationUnit) Test(org.junit.jupiter.api.Test)

Aggregations

ConfigurationUnit (org.jnosql.artemis.ConfigurationUnit)24 Test (org.junit.jupiter.api.Test)19 ConfigurationSettingsUnit (org.jnosql.artemis.ConfigurationSettingsUnit)12 HashMap (java.util.HashMap)7 Annotated (javax.enterprise.inject.spi.Annotated)5 ColumnConfiguration (org.jnosql.diana.api.column.ColumnConfiguration)1 ColumnConfigurationAsync (org.jnosql.diana.api.column.ColumnConfigurationAsync)1 DocumentConfiguration (org.jnosql.diana.api.document.DocumentConfiguration)1 DocumentConfigurationAsync (org.jnosql.diana.api.document.DocumentConfigurationAsync)1 KeyValueConfiguration (org.jnosql.diana.api.key.KeyValueConfiguration)1