throws SQLException
{
final Slot<Permission> p = new Slot<Permission>();
DBConnection connection = getConnection();
try {
connection.query(PERMISSION_BY_UUID, new DBQueryHandler() {
public void prepare(PreparedStatement s)
throws SQLException
{
s.setString(1,id.toString());
}
public void onResults(ResultSet set)
throws SQLException
{
if (set.next()) {
p.set(new Permission(AuthDB.this,set.getInt(1),set.getString(2),id));
}
}
});
} finally {
release(connection);
}
return p.get();
}
protected Permission fetchById(final Integer id)
throws SQLException
{
final Slot<Permission> p = new Slot<Permission>();
DBConnection connection = getConnection();
try {
connection.query(PERMISSION_BY_ID, new DBQueryHandler() {
public void prepare(PreparedStatement s)
throws SQLException
{
s.setInt(1,id);
}
public void onResults(ResultSet set)
throws SQLException
{
if (set.next()) {
p.set(new Permission(AuthDB.this,set.getInt(1),set.getString(2),UUID.fromString(set.getString(3))));
}
}
});
} finally {
release(connection);
}
return p.get();
}
protected Permission fetchByName(final String name)
throws SQLException
{
final Slot<Permission> p = new Slot<Permission>();
DBConnection connection = getConnection();
try {
connection.query(PERMISSION_BY_NAME, new DBQueryHandler() {
public void prepare(PreparedStatement s)
throws SQLException
{
s.setString(1,name);
}
public void onResults(ResultSet set)
throws SQLException
{
if (set.next()) {
p.set(new Permission(AuthDB.this,set.getInt(1),set.getString(2),UUID.fromString(set.getString(3))));
}
}
});
} finally {
release(connection);
}
return p.get();
}
protected int getId(Permission p) {
return p.getId();
}
protected UUID getFacet(Permission p) {
return p.getUUID();
}
protected String getName(Permission r) {
return r.getName();
}
};
roleCache = new DBCache<UUID,Role>(-1,EXPIRATION,true) {
protected Role fetch(final UUID id)
throws SQLException
{
final Slot<Role> r = new Slot<Role>();
DBConnection connection = getConnection();
try {
connection.query(ROLE_BY_UUID, new DBQueryHandler() {
public void prepare(PreparedStatement s)
throws SQLException
{
s.setString(1,id.toString());
}
public void onResults(ResultSet set)
throws SQLException
{
if (set.next()) {
r.set(new Role(AuthDB.this,set.getInt(1),set.getString(2),id));
}
}
});
} finally {
release(connection);
}
return r.get();
}
protected Role fetchById(final Integer id)
throws SQLException
{
final Slot<Role> r = new Slot<Role>();
DBConnection connection = getConnection();
try {
connection.query(ROLE_BY_ID, new DBQueryHandler() {
public void prepare(PreparedStatement s)
throws SQLException
{
s.setInt(1,id);
}
public void onResults(ResultSet set)
throws SQLException
{
if (set.next()) {
r.set(new Role(AuthDB.this,set.getInt(1),set.getString(2),UUID.fromString(set.getString(3))));
}
}
});
} finally {
release(connection);
}
return r.get();
}
protected Role fetchByName(final String name)
throws SQLException
{
final Slot<Role> r = new Slot<Role>();
DBConnection connection = getConnection();
try {
connection.query(ROLE_BY_NAME, new DBQueryHandler() {
public void prepare(PreparedStatement s)
throws SQLException
{
s.setString(1,name);
}
public void onResults(ResultSet set)
throws SQLException
{
if (set.next()) {
r.set(new Role(AuthDB.this,set.getInt(1),set.getString(2),UUID.fromString(set.getString(3))));
}
}
});
} finally {
release(connection);
}
return r.get();
}
protected int getId(Role r) {
return r.getId();
}
protected UUID getFacet(Role r) {
return r.getUUID();
}
protected String getName(Role r) {
return r.getName();
}
};
realmCache = new DBCache<UUID,Realm>(-1,EXPIRATION,true) {
protected Realm fetch(final UUID id)
throws SQLException
{
final Slot<Realm> r = new Slot<Realm>();
DBConnection connection = getConnection();
try {
connection.query(REALM_BY_UUID, new DBQueryHandler() {
public void prepare(PreparedStatement s)
throws SQLException
{
s.setString(1,id.toString());
}
public void onResults(ResultSet set)
throws SQLException
{
if (set.next()) {
r.set(new Realm(AuthDB.this,set.getInt(1),set.getString(2),id));
}
}
});
} finally {
release(connection);
}
return r.get();
}
protected Realm fetchById(final Integer id)
throws SQLException
{
final Slot<Realm> r = new Slot<Realm>();
DBConnection connection = getConnection();
try {
connection.query(REALM_BY_ID, new DBQueryHandler() {
public void prepare(PreparedStatement s)
throws SQLException
{
s.setInt(1,id);
}
public void onResults(ResultSet set)
throws SQLException
{
if (set.next()) {
r.set(new Realm(AuthDB.this,set.getInt(1),set.getString(2),UUID.fromString(set.getString(3))));
}
}
});
} finally {
release(connection);
}
return r.get();
}
protected Realm fetchByName(final String name)
throws SQLException
{
final Slot<Realm> r = new Slot<Realm>();
DBConnection connection = getConnection();
try {
connection.query(REALM_BY_NAME, new DBQueryHandler() {
public void prepare(PreparedStatement s)
throws SQLException
{
s.setString(1,name);
}
public void onResults(ResultSet set)
throws SQLException
{
if (set.next()) {
r.set(new Realm(AuthDB.this,set.getInt(1),set.getString(2),UUID.fromString(set.getString(3))));
}
}
});
} finally {
release(connection);
}
return r.get();
}
protected int getId(Realm r) {
return r.getId();
}
protected UUID getFacet(Realm r) {
return r.getUUID();
}
protected String getName(Realm r) {
return r.getName();
}
};
userCache = new DBCache<UUID,User>(100,EXPIRATION,true) {
protected User fetch(final UUID id)
throws SQLException
{
final Slot<User> u = new Slot<User>();
DBConnection connection = getConnection();
try {
connection.query(USER_BY_UUID, new DBQueryHandler() {
public void prepare(PreparedStatement s)
throws SQLException
{
s.setString(1,id.toString());
}
public void onResults(ResultSet set)
throws SQLException
{
if (set.next()) {
int uid = set.getInt(1);
String alias = getUserAlias(uid);
u.set(new User(AuthDB.this,uid,id,alias,set.getString(2),set.getString(3)));
}
}
});
} finally {
release(connection);
}
return u.get();
}
protected User fetchById(final Integer id)
throws SQLException
{
final Slot<User> u = new Slot<User>();
DBConnection connection = getConnection();
try {
connection.query(USER_BY_ID, new DBQueryHandler() {
public void prepare(PreparedStatement s)
throws SQLException
{
s.setInt(1,id.intValue());
}
public void onResults(ResultSet set)
throws SQLException
{
if (set.next()) {
int uid = set.getInt(1);
String alias = getUserAlias(uid);
u.set(new User(AuthDB.this,uid,UUID.fromString(set.getString(4)),alias,set.getString(2),set.getString(3)));
}
}
});
} finally {
release(connection);
}
return u.get();
}
protected User fetchByName(final String name)
throws SQLException
{
final Slot<User> u = new Slot<User>();
DBConnection connection = getConnection();
try {
connection.query(USER_BY_ALIAS, new DBQueryHandler() {
public void prepare(PreparedStatement s)
throws SQLException
{
s.setString(1,name);
}