当前位置: 首页>>代码示例>>Java>>正文


Java IAsyncResult.isError方法代码示例

本文整理汇总了Java中io.apiman.gateway.engine.async.IAsyncResult.isError方法的典型用法代码示例。如果您正苦于以下问题:Java IAsyncResult.isError方法的具体用法?Java IAsyncResult.isError怎么用?Java IAsyncResult.isError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.apiman.gateway.engine.async.IAsyncResult的用法示例。


在下文中一共展示了IAsyncResult.isError方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: wrapResultHandler

import io.apiman.gateway.engine.async.IAsyncResult; //导入方法依赖的package包/类
/**
 * Wraps the result handler so that metrics can be properly recorded.
 */
private IAsyncResultHandler<IEngineResult> wrapResultHandler(final IAsyncResultHandler<IEngineResult> handler) {
    return (IAsyncResult<IEngineResult> result) -> {
        boolean doRecord = true;
        if (result.isError()) {
            recordErrorMetrics(result.getError());
        } else {
            IEngineResult engineResult = result.getResult();
            if (engineResult.isFailure()) {
                recordFailureMetrics(engineResult.getPolicyFailure());
            } else {
                recordSuccessMetrics(engineResult.getApiResponse());
                doRecord = false; // don't record the metric now because we need to record # of bytes downloaded, which hasn't happened yet
            }
        }
        requestMetric.setRequestEnd(new Date());
        if (doRecord) {
            metrics.record(requestMetric);
        }
        handler.handle(result);
    };
}
 
开发者ID:apiman,项目名称:apiman,代码行数:25,代码来源:ApiRequestExecutorImpl.java

示例2: doCreate

import io.apiman.gateway.engine.async.IAsyncResult; //导入方法依赖的package包/类
/**
 * @param connection
 */
protected void doCreate(final IJdbcConnection connection) {
    String createSql = "CREATE TABLE users ("
                        + "userId VARCHAR(255) NOT NULL, "
                        + "name VARCHAR(255) NOT NULL, "
                        + "age INTEGER, "
                        + "isAdmin BIT, "
                        + "PRIMARY KEY (userId))";
    IAsyncResultHandler<Void> afterCreateTable = new IAsyncResultHandler<Void>() {
        @Override
        public void handle(IAsyncResult<Void> result) {
            if (result.isError()) {
                errors.add(result.getError());
            } else {
                System.out.println("Create worked, inserting.");
                doInserts(connection);
            }
        }
    };
    connection.execute(afterCreateTable, createSql);
}
 
开发者ID:apiman,项目名称:apiman,代码行数:24,代码来源:DefaultJdbcComponentTest.java

示例3: doInserts

import io.apiman.gateway.engine.async.IAsyncResult; //导入方法依赖的package包/类
/**
 * @param connection
 */
protected void doInserts(IJdbcConnection connection) {
    String insertSql = "INSERT INTO users (userId, name, age, isAdmin) VALUES (?, ?, ?, ?)";
    IAsyncResultHandler<Void> dfltHandler = new IAsyncResultHandler<Void>() {
        @Override
        public void handle(IAsyncResult<Void> result) {
            if (result.isError()) {
                errors.add(result.getError());
            } else {
                System.out.println("Insert successful.");
            }
        }
    };
    connection.execute(dfltHandler, insertSql, "ewittman", "Eric Wittmann", 17, Boolean.TRUE);
    connection.execute(dfltHandler, insertSql, "msavy", "Marc Savy", 50, Boolean.FALSE);
    connection.execute(dfltHandler, insertSql, "ryordan", "Rachel Yordan", 92, Boolean.FALSE);

    doQueries(connection);
}
 
开发者ID:apiman,项目名称:apiman,代码行数:22,代码来源:DefaultJdbcComponentTest.java

示例4: doQueries

import io.apiman.gateway.engine.async.IAsyncResult; //导入方法依赖的package包/类
/**
 * @param connection
 */
private void doQueries(IJdbcConnection connection) {
    IAsyncResultHandler<IJdbcResultSet> queryHandler = new IAsyncResultHandler<IJdbcResultSet>() {
        @Override
        public void handle(IAsyncResult<IJdbcResultSet> result) {
            if (result.isError()) {
                errors.add(result.getError());
            } else {
                try {
                    doQueryAssertions(result.getResult());
                } catch (Throwable t) {
                    errors.add(t);
                }
            }
        }
    };
    String querySql = "SELECT u.userId, u.name, u.age, u.isAdmin FROM users u WHERE userId = ?";
    connection.query(queryHandler, querySql , "ewittman");
}
 
开发者ID:apiman,项目名称:apiman,代码行数:22,代码来源:DefaultJdbcComponentTest.java

示例5: handleError

import io.apiman.gateway.engine.async.IAsyncResult; //导入方法依赖的package包/类
protected <T> void handleError(IAsyncResult<IHttpClientResponse> result, IAsyncResultHandler<T> handler) {
    if (result.isError()) {
        handler.handle(AsyncResultImpl.<T> create(result.getError()));
    } else if (result.getResult().getResponseCode() != 200) {
        handler.handle(AsyncResultImpl.<T> create(new InfluxException("Influx: " //$NON-NLS-1$
                + result.getResult().getResponseCode() + " " + result.getResult().getResponseMessage()))); //$NON-NLS-1$
    }
}
 
开发者ID:apiman,项目名称:apiman,代码行数:9,代码来源:InfluxDb09Driver.java

示例6: handle

import io.apiman.gateway.engine.async.IAsyncResult; //导入方法依赖的package包/类
@Override
public void handle(IAsyncResult<Void> result) {
    if (result.isError()) {
        log.error("Error {0}", result.getError());
        throw new RuntimeException(result.getError());
    }
}
 
开发者ID:apiman,项目名称:apiman,代码行数:8,代码来源:EBInMemoryRegistry.java

示例7: validate

import io.apiman.gateway.engine.async.IAsyncResult; //导入方法依赖的package包/类
/**
 * @param connection
 * @param query
 * @param username
 * @param context
 * @param password
 * @param config
 * @param handler
 */
protected void validate(final IJdbcConnection connection, final String query, final String username,
        final String password, final IPolicyContext context, final JDBCIdentitySource config,
        final IAsyncResultHandler<Boolean> handler) {
    IAsyncResultHandler<IJdbcResultSet> queryHandler = new IAsyncResultHandler<IJdbcResultSet>() {
        @Override
        public void handle(IAsyncResult<IJdbcResultSet> result) {
            if (result.isError()) {
                closeQuietly(connection);
                handler.handle(AsyncResultImpl.create(result.getError(), Boolean.class));
            } else {
                boolean validated = false;
                IJdbcResultSet resultSet = result.getResult();
                if (resultSet.next()) {
                    validated = true;
                }
                resultSet.close();
                if (validated && config.isExtractRoles()) {
                    extractRoles(connection, username, context, config, handler);
                } else {
                    closeQuietly(connection);
                    handler.handle(AsyncResultImpl.create(validated));
                }
            }
        }
    };
    connection.query(queryHandler, query, username, password);
}
 
开发者ID:apiman,项目名称:apiman,代码行数:37,代码来源:JDBCIdentityValidator.java

示例8: extractRoles

import io.apiman.gateway.engine.async.IAsyncResult; //导入方法依赖的package包/类
/**
 * @param connection
 * @param username
 * @param context
 * @param config
 * @param handler
 */
protected void extractRoles(final IJdbcConnection connection, final String username,
        final IPolicyContext context, final JDBCIdentitySource config,
        final IAsyncResultHandler<Boolean> handler) {
    
    String roleQuery = config.getRoleQuery();
    IAsyncResultHandler<IJdbcResultSet> roleHandler = new IAsyncResultHandler<IJdbcResultSet>() {
        @Override
        public void handle(IAsyncResult<IJdbcResultSet> result) {
            if (result.isError()) {
                closeQuietly(connection);
                handler.handle(AsyncResultImpl.create(result.getError(), Boolean.class));
            } else {
                Set<String> extractedRoles = new HashSet<>();
                IJdbcResultSet resultSet = result.getResult();
                while (resultSet.next()) {
                    String roleName = resultSet.getString(1);
                    extractedRoles.add(roleName);
                }
                context.setAttribute(AuthorizationPolicy.AUTHENTICATED_USER_ROLES, extractedRoles);
                closeQuietly(connection);
                handler.handle(AsyncResultImpl.create(true));
            }
        }
    };
    connection.query(roleHandler, roleQuery, username);
}
 
开发者ID:apiman,项目名称:apiman,代码行数:34,代码来源:JDBCIdentityValidator.java


注:本文中的io.apiman.gateway.engine.async.IAsyncResult.isError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。