Search in sources :

Example 1 with Reflections

use of org.eclipse.jnosql.mapping.reflection.Reflections in project jnosql-diana by eclipse.

the class DocumentCollectionManagerFactoryConverter method success.

@Override
public DocumentCollectionManagerFactory success(String value) {
    final SettingsConverter settingsConverter = BeanManagers.getInstance(SettingsConverter.class);
    Config config = BeanManagers.getInstance(Config.class);
    final Settings settings = settingsConverter.convert(value);
    String provider = value + ".provider";
    final Class<?> configurationClass = config.getValue(provider, Class.class);
    if (DocumentConfiguration.class.isAssignableFrom(configurationClass)) {
        final Reflections reflections = BeanManagers.getInstance(Reflections.class);
        final DocumentConfiguration configuration = (DocumentConfiguration) reflections.newInstance(configurationClass);
        return configuration.get(settings);
    }
    throw new ConfigurationException("The class " + configurationClass + " is not valid to " + DocumentConfiguration.class);
}
Also used : SettingsConverter(org.eclipse.jnosql.mapping.configuration.SettingsConverter) ConfigurationException(org.eclipse.jnosql.mapping.configuration.ConfigurationException) Config(org.eclipse.microprofile.config.Config) DocumentConfiguration(jakarta.nosql.document.DocumentConfiguration) Settings(jakarta.nosql.Settings) Reflections(org.eclipse.jnosql.mapping.reflection.Reflections)

Example 2 with Reflections

use of org.eclipse.jnosql.mapping.reflection.Reflections in project jnosql-diana by eclipse.

the class GraphConverter method success.

@Override
protected Graph success(String value) {
    final SettingsConverter settingsConverter = BeanManagers.getInstance(SettingsConverter.class);
    Config config = BeanManagers.getInstance(Config.class);
    final Settings settings = settingsConverter.convert(value);
    final String provider = value + ".provider";
    final Class<?> configurationClass = config.getValue(provider, Class.class);
    if (GraphConfiguration.class.isAssignableFrom(configurationClass)) {
        final Reflections reflections = BeanManagers.getInstance(Reflections.class);
        final GraphConfiguration configuration = (GraphConfiguration) reflections.newInstance(configurationClass);
        return configuration.apply(settings);
    }
    throw new ConfigurationException("The class " + configurationClass + " is not valid to " + GraphConfiguration.class);
}
Also used : GraphConfiguration(org.eclipse.jnosql.mapping.graph.GraphConfiguration) SettingsConverter(org.eclipse.jnosql.mapping.configuration.SettingsConverter) ConfigurationException(org.eclipse.jnosql.mapping.configuration.ConfigurationException) Config(org.eclipse.microprofile.config.Config) Settings(jakarta.nosql.Settings) Reflections(org.eclipse.jnosql.mapping.reflection.Reflections)

Example 3 with Reflections

use of org.eclipse.jnosql.mapping.reflection.Reflections in project jnosql-diana by eclipse.

the class BucketManagerFactoryConverter method success.

@Override
public BucketManagerFactory success(String value) {
    final SettingsConverter settingsConverter = BeanManagers.getInstance(SettingsConverter.class);
    Config config = BeanManagers.getInstance(Config.class);
    final Settings settings = settingsConverter.convert(value);
    String provider = value + ".provider";
    final Class<?> configurationClass = config.getValue(provider, Class.class);
    if (KeyValueConfiguration.class.isAssignableFrom(configurationClass)) {
        final Reflections reflections = BeanManagers.getInstance(Reflections.class);
        final KeyValueConfiguration configuration = (KeyValueConfiguration) reflections.newInstance(configurationClass);
        return configuration.get(settings);
    }
    throw new ConfigurationException("The class " + configurationClass + " is not valid to " + KeyValueConfiguration.class);
}
Also used : KeyValueConfiguration(jakarta.nosql.keyvalue.KeyValueConfiguration) SettingsConverter(org.eclipse.jnosql.mapping.configuration.SettingsConverter) ConfigurationException(org.eclipse.jnosql.mapping.configuration.ConfigurationException) Config(org.eclipse.microprofile.config.Config) Settings(jakarta.nosql.Settings) Reflections(org.eclipse.jnosql.mapping.reflection.Reflections)

Example 4 with Reflections

use of org.eclipse.jnosql.mapping.reflection.Reflections in project jnosql-diana by eclipse.

the class ColumnFamilyManagerFactoryConverter method success.

@Override
public ColumnFamilyManagerFactory success(String value) {
    final SettingsConverter settingsConverter = BeanManagers.getInstance(SettingsConverter.class);
    Config config = BeanManagers.getInstance(Config.class);
    final Settings settings = settingsConverter.convert(value);
    String provider = value + ".provider";
    final Class<?> configurationClass = config.getValue(provider, Class.class);
    if (ColumnConfiguration.class.isAssignableFrom(configurationClass)) {
        final Reflections reflections = BeanManagers.getInstance(Reflections.class);
        final ColumnConfiguration configuration = (ColumnConfiguration) reflections.newInstance(configurationClass);
        return configuration.get(settings);
    }
    throw new ConfigurationException("The class " + configurationClass + " is not valid to " + ColumnConfiguration.class);
}
Also used : SettingsConverter(org.eclipse.jnosql.mapping.configuration.SettingsConverter) ConfigurationException(org.eclipse.jnosql.mapping.configuration.ConfigurationException) Config(org.eclipse.microprofile.config.Config) ColumnConfiguration(jakarta.nosql.column.ColumnConfiguration) Settings(jakarta.nosql.Settings) Reflections(org.eclipse.jnosql.mapping.reflection.Reflections)

Aggregations

Settings (jakarta.nosql.Settings)4 ConfigurationException (org.eclipse.jnosql.mapping.configuration.ConfigurationException)4 SettingsConverter (org.eclipse.jnosql.mapping.configuration.SettingsConverter)4 Reflections (org.eclipse.jnosql.mapping.reflection.Reflections)4 Config (org.eclipse.microprofile.config.Config)4 ColumnConfiguration (jakarta.nosql.column.ColumnConfiguration)1 DocumentConfiguration (jakarta.nosql.document.DocumentConfiguration)1 KeyValueConfiguration (jakarta.nosql.keyvalue.KeyValueConfiguration)1 GraphConfiguration (org.eclipse.jnosql.mapping.graph.GraphConfiguration)1