net.ttddyy.dsproxy.proxy.DefaultConnectionIdManager Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of datasource-proxy Show documentation
Show all versions of datasource-proxy Show documentation
Provide a datasource proxy that can inject your own logic into all queries.
package net.ttddyy.dsproxy.proxy;
import net.ttddyy.dsproxy.ConnectionIdManager;
import java.sql.Connection;
import java.util.concurrent.atomic.AtomicLong;
/**
* Default implementation of {@link ConnectionIdManager}.
*
* This implementation returns sequentially increasing unique number as connection id.
*
* @author Tadaya Tsuyukubo
* @since 1.4.2
*/
public class DefaultConnectionIdManager implements ConnectionIdManager {
private AtomicLong idCounter = new AtomicLong(0);
@Override
public long getId(Connection connection) {
return this.idCounter.incrementAndGet();
}
}