@Override
    public void registerClient(Client client, IAsyncResultHandler<Void> handler) {
        Connection conn = null;
        try {
            conn = ds.getConnection();
            conn.setAutoCommit(false);
            QueryRunner run = new QueryRunner();

            // Validate the client and populate the api map with apis found during validation.
            validateClient(client, conn);

            // Remove any old data first, then (re)insert
            run.update(conn, "DELETE FROM gw_clients WHERE org_id = ? AND id = ? AND version = ?",  //$NON-NLS-1$
                    client.getOrganizationId(), client.getClientId(), client.getVersion());

            String bean = mapper.writeValueAsString(client);
            run.update(conn, "INSERT INTO gw_clients (api_key, org_id, id, version, bean) VALUES (?, ?, ?, ?, ?)",  //$NON-NLS-1$
                    client.getApiKey(), client.getOrganizationId(), client.getClientId(), client.getVersion(), bean);

            DbUtils.commitAndClose(conn);
            handler.handle(AsyncResultImpl.create((Void) null));
        } catch (Exception re) {
            DbUtils.rollbackAndCloseQuietly(conn);
            handler.handle(AsyncResultImpl.create(re, Void.class));
        }
    }
@see io.apiman.gateway.engine.IRegistry#registerClient(io.apiman.gateway.engine.beans.Client, io.apiman.gateway.engine.async.IAsyncResultHandler)
gateway/engine/jdbc/src/main/java/io/apiman/gateway/engine/jdbc/JdbcRegistry.java