Examples of DBQueryHandler


Examples of org.milowski.db.DBQueryHandler

      throws SQLException
   {
      final Slot<User.Authenticated> retval = new Slot<User.Authenticated>();
      DBConnection connection = getConnection();
      try {
         connection.query(USER_SESSION, new DBQueryHandler() {
            public void prepare(PreparedStatement s)
               throws SQLException
            {
               s.setString(1,session.toString());
            }
View Full Code Here

Examples of org.milowski.db.DBQueryHandler

      throws SQLException
   {
      final Slot<String> alias = new Slot<String>();
      DBConnection connection = getConnection();
      try {
         connection.query(USER_ALIAS, new DBQueryHandler() {
            public void prepare(PreparedStatement s)
               throws SQLException
            {
               s.setInt(1,id);
            }
View Full Code Here

Examples of org.milowski.db.DBQueryHandler

         final User user = userCache.get(id);
         if (user!=null) {
            final Slot<RealmUser> u = new Slot<RealmUser>();
            final DBConnection connection = getConnection();
            try {
               connection.query(REALM_USER_BY_USER, new DBQueryHandler() {
                  public void prepare(PreparedStatement s)
                     throws SQLException
                  {
                     s.setInt(1,realm.getId());
                     s.setInt(2,user.getId());
                  }
                  public void onResults(ResultSet set)
                     throws SQLException
                  {
                     if (set.next()) {
                        final int rid = set.getInt(1);
                        final Slot<String> alias = new Slot<String>();
                        connection.query(REALM_USER_ALIAS, new DBQueryHandler() {
                           public void prepare(PreparedStatement s)
                              throws SQLException
                           {
                              s.setInt(1,rid);
                           }
View Full Code Here

Examples of org.milowski.db.DBQueryHandler

         throws SQLException
      {
         final Slot<RealmUser> u = new Slot<RealmUser>();
         final DBConnection connection = getConnection();
         try {
            connection.query(REALM_USER, new DBQueryHandler() {
               public void prepare(PreparedStatement s)
                  throws SQLException
               {
                  s.setInt(1,id.intValue());
               }
               public void onResults(ResultSet set)
                  throws SQLException
               {
                  if (set.next()) {
                     final Slot<String> alias = new Slot<String>();
                     connection.query(REALM_USER_ALIAS, new DBQueryHandler() {
                        public void prepare(PreparedStatement s)
                           throws SQLException
                        {
                           s.setInt(1,id);
                        }
View Full Code Here

Examples of org.milowski.db.DBQueryHandler

      {
         final Slot<RealmUser> u = new Slot<RealmUser>();

         final DBConnection connection = getConnection();
         try {
            connection.query(REALM_USER_BY_ALIAS, new DBQueryHandler() {
               public void prepare(PreparedStatement s)
                  throws SQLException
               {
                  s.setInt(1,realm.getId());
                  s.setString(2,name);
               }
               public void onResults(ResultSet set)
                  throws SQLException
               {
                  if (set.next()) {
                     User user = userCache.get(set.getInt(2));
                     u.set(new RealmUser(AuthDB.this,set.getInt(1),realm,user,name,set.getString(3),set.getString(4)));
                  }
               }
            });
         } finally {
            release(connection);
         }
        
         if (u.get()==null) {
            final User user = userCache.getNamed(name);
            if (user!=null) {
               final DBConnection connection2 = getConnection();
               try {
                  connection2.query(REALM_USER_BY_INHERITED_ALIAS, new DBQueryHandler() {
                     public void prepare(PreparedStatement s)
                        throws SQLException
                     {
                        s.setInt(1,realm.getId());
                        s.setInt(2,user.getId());
View Full Code Here

Examples of org.milowski.db.DBQueryHandler

         throws SQLException
      {
         final Slot<Group> g = new Slot<Group>();
         DBConnection connection = getConnection();
         try {
            connection.query(GROUP_BY_UUID, new DBQueryHandler() {
               public void prepare(PreparedStatement s)
                  throws SQLException
               {
                  s.setInt(1,realm.getId());
                  s.setString(2,id.toString());
View Full Code Here

Examples of org.milowski.db.DBQueryHandler

         throws SQLException
      {
         final Slot<Group> g = new Slot<Group>();
         DBConnection connection = getConnection();
         try {
            connection.query(GROUP_BY_ID, new DBQueryHandler() {
               public void prepare(PreparedStatement s)
                  throws SQLException
               {
                  s.setInt(1,realm.getId());
                  s.setInt(2,id);
View Full Code Here

Examples of org.milowski.db.DBQueryHandler

         throws SQLException
      {
         final Slot<Group> g = new Slot<Group>();
         DBConnection connection = getConnection();
         try {
            connection.query(GROUP_BY_ALIAS, new DBQueryHandler() {
               public void prepare(PreparedStatement s)
                  throws SQLException
               {
                  s.setInt(1,realm.getId());
                  s.setString(2,name);
View Full Code Here

Examples of org.milowski.db.DBQueryHandler

            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);
                  }
View Full Code Here

Examples of org.milowski.db.DBQueryHandler

      throws SQLException
   {
      final Slot<Iterator<Permission>> result = new Slot<Iterator<Permission>>();
      final DBConnection connection = getConnection();
      try {
         connection.query(PERMISSIONS, new DBQueryHandler() {
            public boolean shouldClose() { return false; }
            public void onResults(ResultSet set)
               throws SQLException
            {
               result.set(new DBIterator<Permission>(set,new DBResultConstructor<Permission>() {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.