Search in sources :

Example 1 with Configurer

use of org.jdbi.v3.sqlobject.config.Configurer in project jdbi by jdbi.

the class RegisterColumnMappersImpl method configureForType.

@Override
public void configureForType(ConfigRegistry registry, Annotation annotation, Class<?> sqlObjectType) {
    Configurer delegate = new RegisterColumnMapperImpl();
    RegisterColumnMappers registerColumnMappers = (RegisterColumnMappers) annotation;
    Stream.of(registerColumnMappers.value()).forEach(anno -> delegate.configureForType(registry, anno, sqlObjectType));
}
Also used : RegisterColumnMappers(org.jdbi.v3.sqlobject.config.RegisterColumnMappers) Configurer(org.jdbi.v3.sqlobject.config.Configurer)

Example 2 with Configurer

use of org.jdbi.v3.sqlobject.config.Configurer in project jdbi by jdbi.

the class RegisterConstructorMappersImpl method configureForType.

@Override
public void configureForType(ConfigRegistry registry, Annotation annotation, Class<?> sqlObjectType) {
    Configurer delegate = new RegisterConstructorMapperImpl();
    RegisterConstructorMappers registerConstructorMappers = (RegisterConstructorMappers) annotation;
    Stream.of(registerConstructorMappers.value()).forEach(anno -> delegate.configureForType(registry, anno, sqlObjectType));
}
Also used : RegisterConstructorMappers(org.jdbi.v3.sqlobject.config.RegisterConstructorMappers) Configurer(org.jdbi.v3.sqlobject.config.Configurer)

Example 3 with Configurer

use of org.jdbi.v3.sqlobject.config.Configurer in project jdbi by jdbi.

the class RegisterRowMappersImpl method configureForType.

@Override
public void configureForType(ConfigRegistry registry, Annotation annotation, Class<?> sqlObjectType) {
    Configurer delegate = new RegisterRowMapperImpl();
    RegisterRowMappers registerRowMappers = (RegisterRowMappers) annotation;
    Stream.of(registerRowMappers.value()).forEach(anno -> delegate.configureForType(registry, anno, sqlObjectType));
}
Also used : RegisterRowMappers(org.jdbi.v3.sqlobject.config.RegisterRowMappers) Configurer(org.jdbi.v3.sqlobject.config.Configurer)

Example 4 with Configurer

use of org.jdbi.v3.sqlobject.config.Configurer in project jdbi by jdbi.

the class SqlObjectFactory method attach.

/**
 * Create a sql object of the specified type bound to this handle. Any state changes to the handle, or the sql
 * object, such as transaction status, closing it, etc, will apply to both the object and the handle.
 *
 * @param extensionType the type of sql object to create
 * @param handle the Handle instance to attach ths sql object to
 * @return the new sql object bound to this handle
 */
@Override
public <E> E attach(Class<E> extensionType, HandleSupplier handle) {
    Map<Method, Handler> handlers = methodHandlersFor(extensionType, handle.getConfig(Handlers.class), handle.getConfig(HandlerDecorators.class));
    ConfigRegistry instanceConfig = handle.getConfig().createCopy();
    for (Class<?> iface : extensionType.getInterfaces()) {
        forEachConfigurer(iface, (configurer, annotation) -> configurer.configureForType(instanceConfig, annotation, extensionType));
    }
    forEachConfigurer(extensionType, (configurer, annotation) -> configurer.configureForType(instanceConfig, annotation, extensionType));
    InvocationHandler invocationHandler = createInvocationHandler(extensionType, instanceConfig, handlers, handle);
    return extensionType.cast(Proxy.newProxyInstance(extensionType.getClassLoader(), new Class[] { extensionType }, invocationHandler));
}
Also used : ConfigRegistry(org.jdbi.v3.core.config.ConfigRegistry) InvocationHandler(java.lang.reflect.InvocationHandler) ExtensionMethod(org.jdbi.v3.core.extension.ExtensionMethod) Method(java.lang.reflect.Method) InvocationHandler(java.lang.reflect.InvocationHandler)

Example 5 with Configurer

use of org.jdbi.v3.sqlobject.config.Configurer in project jdbi by jdbi.

the class RegisterColumnMapperFactoriesImpl method configureForType.

@Override
public void configureForType(ConfigRegistry registry, Annotation annotation, Class<?> sqlObjectType) {
    Configurer delegate = new RegisterColumnMapperFactoryImpl();
    RegisterColumnMapperFactories registerColumnMapperFactories = (RegisterColumnMapperFactories) annotation;
    Stream.of(registerColumnMapperFactories.value()).forEach(anno -> delegate.configureForType(registry, anno, sqlObjectType));
}
Also used : RegisterColumnMapperFactories(org.jdbi.v3.sqlobject.config.RegisterColumnMapperFactories) Configurer(org.jdbi.v3.sqlobject.config.Configurer)

Aggregations

Configurer (org.jdbi.v3.sqlobject.config.Configurer)10 InvocationHandler (java.lang.reflect.InvocationHandler)2 Method (java.lang.reflect.Method)2 ConfigRegistry (org.jdbi.v3.core.config.ConfigRegistry)2 ExtensionMethod (org.jdbi.v3.core.extension.ExtensionMethod)2 Annotation (java.lang.annotation.Annotation)1 AnnotatedElement (java.lang.reflect.AnnotatedElement)1 Proxy (java.lang.reflect.Proxy)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 Collections.synchronizedMap (java.util.Collections.synchronizedMap)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 WeakHashMap (java.util.WeakHashMap)1 BiConsumer (java.util.function.BiConsumer)1 Stream (java.util.stream.Stream)1 ExtensionFactory (org.jdbi.v3.core.extension.ExtensionFactory)1 HandleSupplier (org.jdbi.v3.core.extension.HandleSupplier)1 ConfiguringAnnotation (org.jdbi.v3.sqlobject.config.ConfiguringAnnotation)1 RegisterArgumentFactories (org.jdbi.v3.sqlobject.config.RegisterArgumentFactories)1