com.instaclustr.cassandra.service.DefaultCqlSessionService Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of commons Show documentation
Show all versions of commons Show documentation
Common classes and utilities integrated with various projects
package com.instaclustr.cassandra.service;
import com.datastax.oss.driver.api.core.CqlSession;
import com.instaclustr.operations.FunctionWithEx;
public class DefaultCqlSessionService implements CqlSessionService {
@Override
public CqlSession getCqlSession() {
return createCqlSession();
}
@Override
public T doWithCqlSession(final FunctionWithEx func) throws Exception {
try (final CqlSession session = createCqlSession()) {
return func.apply(session);
}
}
protected CqlSession createCqlSession() {
return CqlSession.builder().build();
}
}