use of org.jdbi.v3.core.extension.ExtensionMethod in project jdbi by jdbi.
the class ConstantHandleSupplier method invokeInContext.
@Override
public <V> V invokeInContext(ExtensionMethod extensionMethod, ConfigRegistry config, Callable<V> task) throws Exception {
ExtensionMethod oldExtensionMethod = handle.getExtensionMethod();
try {
handle.setExtensionMethod(extensionMethod);
ConfigRegistry oldConfig = handle.getConfig();
try {
handle.setConfig(config);
return task.call();
} finally {
handle.setConfig(oldConfig);
}
} finally {
handle.setExtensionMethod(oldExtensionMethod);
}
}
use of org.jdbi.v3.core.extension.ExtensionMethod 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