use of org.jdbi.v3.core.config.ConfigRegistry in project jdbi by jdbi.
the class RegisterArgumentFactoryImpl method configureForType.
@Override
public void configureForType(ConfigRegistry registry, Annotation annotation, Class<?> sqlObjectType) {
RegisterArgumentFactory raf = (RegisterArgumentFactory) annotation;
Arguments arguments = registry.get(Arguments.class);
try {
arguments.register(raf.value().newInstance());
} catch (Exception e) {
throw new IllegalStateException("unable to instantiate specified argument factory", e);
}
}
use of org.jdbi.v3.core.config.ConfigRegistry in project jdbi by jdbi.
the class RegisterBeanMapperImpl method configureForType.
@Override
public void configureForType(ConfigRegistry registry, Annotation annotation, Class<?> sqlObjectType) {
RegisterBeanMapper registerBeanMapper = (RegisterBeanMapper) annotation;
Class<?> beanClass = registerBeanMapper.value();
String prefix = registerBeanMapper.prefix();
RowMappers mappers = registry.get(RowMappers.class);
if (prefix.isEmpty()) {
mappers.register(BeanMapper.factory(beanClass));
} else {
mappers.register(BeanMapper.factory(beanClass, prefix));
}
}
use of org.jdbi.v3.core.config.ConfigRegistry in project jdbi by jdbi.
the class RegisterBeanMappersImpl method configureForType.
@Override
public void configureForType(ConfigRegistry registry, Annotation annotation, Class<?> sqlObjectType) {
Configurer delegate = new RegisterBeanMapperImpl();
RegisterBeanMappers registerBeanMappers = (RegisterBeanMappers) annotation;
Stream.of(registerBeanMappers.value()).forEach(anno -> delegate.configureForType(registry, anno, sqlObjectType));
}
use of org.jdbi.v3.core.config.ConfigRegistry in project jdbi by jdbi.
the class TestSqlObjectMethodBehavior method setUp.
@Before
public void setUp() throws Exception {
HandleSupplier handleSupplier = new HandleSupplier() {
@Override
public ConfigRegistry getConfig() {
return new ConfigRegistry();
}
@Override
public Handle getHandle() {
throw new UnsupportedOperationException();
}
@Override
public <V> V invokeInContext(ExtensionMethod extensionMethod, ConfigRegistry config, Callable<V> task) throws Exception {
return task.call();
}
};
SqlObjectFactory factory = new SqlObjectFactory();
dao = factory.attach(UselessDao.class, handleSupplier);
anotherDao = factory.attach(UselessDao.class, handleSupplier);
}
Aggregations