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

            // First delete any record we might already have.
            run.update(conn, "DELETE FROM gw_apis WHERE org_id = ? AND id = ? AND version = ?",  //$NON-NLS-1$
                    api.getOrganizationId(), api.getApiId(), api.getVersion());

            // Now insert a row for the api.
            String bean = mapper.writeValueAsString(api);
            run.update(conn, "INSERT INTO gw_apis (org_id, id, version, bean) VALUES (?, ?, ?, ?)",  //$NON-NLS-1$
                    api.getOrganizationId(), api.getApiId(), api.getVersion(), bean);

            DbUtils.commitAndClose(conn);
            handler.handle(AsyncResultImpl.create((Void) null, Void.class));
        } catch (SQLException | JsonProcessingException e) {
            handler.handle(AsyncResultImpl.create(e));
        }
    }
@see io.apiman.gateway.engine.IRegistry#publishApi(io.apiman.gateway.engine.beans.Api, io.apiman.gateway.engine.async.IAsyncResultHandler)
gateway/engine/jdbc/src/main/java/io/apiman/gateway/engine/jdbc/JdbcRegistry.java