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


Java IAsyncResult.isSuccess方法代码示例

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


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

示例1: verifyResult

import io.apiman.gateway.engine.async.IAsyncResult; //导入方法依赖的package包/类
/**
 * Verify the session data.
 *
 * @param result    the result of retrieving session data
 * @param sessionId the ID of the session
 * @param request   the service request
 * @param context   the policy context
 * @param config    the policy configuration
 * @return the result of the validation
 */
private ValidationResult verifyResult(IAsyncResult<Session> result, String sessionId, ApiRequest request,
                                      IPolicyContext context, CookieValidateConfigBean config) {

    final ValidationResult validationResult;
    final Session sessionData = result.getResult();

    if (result.isSuccess() && null != sessionData && StringUtils.isNotBlank(sessionData.getSessionId())) {
        validationResult = verifySessionData(sessionData, sessionId, request, context, config);

    } else {
        //noinspection ThrowableResultOfMethodCallIgnored
        if (null != result.getError()) {
            LOGGER.error(MESSAGES.format("ErrorReadingSessionData", sessionId), result.getError());
        }

        // session not present
        validationResult = new ValidationResult(false,
                MESSAGES.format("MissingSessionData", sessionId));
    }

    return validationResult;
}
 
开发者ID:outofcoffee,项目名称:apiman-plugins-session,代码行数:33,代码来源:CookieValidatePolicy.java

示例2: handle

import io.apiman.gateway.engine.async.IAsyncResult; //导入方法依赖的package包/类
@Override
    public void handle(IAsyncResult<IHttpClientResponse> result) {
        if (result.isSuccess()) {
            IHttpClientResponse postResponse = result.getResult();
            if ((postResponse.getResponseCode() / 100) == 2) {
                resultHandler.handle(RESULT_OK);
            } else {
                try {
//                  ReportResponse reportResponse = parseReport(postResponse.getBody());
//                  RuntimeException re = new RuntimeException(String.format("Backend report failed. Code: %s, Message: %s",
//                          reportResponse.getErrorCode(), reportResponse.getErrorMessage()));
                    ReportResponse reportResponse = parseReport(postResponse.getBody());
                    resultHandler.handle(AsyncResultImpl.create(reportResponse));
                } catch (Exception e) {
                    RuntimeException re = new RuntimeException("Unable to parse report response", e); // TODO more specific //$NON-NLS-1$
                    resultHandler.handle(AsyncResultImpl.create(re));
                }
            }
        }
    }
 
开发者ID:apiman,项目名称:apiman-plugins,代码行数:21,代码来源:ReportResponseHandler.java

示例3: registerClient

import io.apiman.gateway.engine.async.IAsyncResult; //导入方法依赖的package包/类
/**
 * @see io.apiman.gateway.engine.CachingJdbcRegistry.CachingESRegistry#registerClient(io.apiman.gateway.engine.beans.Client, io.apiman.gateway.engine.async.IAsyncResultHandler)
 */
@Override
public void registerClient(Client client, final IAsyncResultHandler<Void> handler) {
    super.registerClient(client, new IAsyncResultHandler<Void>() {
        /**
         * @see io.apiman.gateway.engine.async.IAsyncHandler#handle(java.lang.Object)
         */
        @Override
        public void handle(IAsyncResult<Void> result) {
            if (result.isSuccess()) {
                updateDataVersion();
            }
            handler.handle(result);
        }
    });
}
 
开发者ID:apiman,项目名称:apiman,代码行数:19,代码来源:PollCachingJdbcRegistry.java

示例4: registerClient

import io.apiman.gateway.engine.async.IAsyncResult; //导入方法依赖的package包/类
/**
 * @see io.apiman.gateway.engine.es.CachingESRegistry#registerClient(io.apiman.gateway.engine.beans.Client, io.apiman.gateway.engine.async.IAsyncResultHandler)
 */
@Override
public void registerClient(Client client, final IAsyncResultHandler<Void> handler) {
    super.registerClient(client, new IAsyncResultHandler<Void>() {
        /**
         * @see io.apiman.gateway.engine.async.IAsyncHandler#handle(java.lang.Object)
         */
        @Override
        public void handle(IAsyncResult<Void> result) {
            if (result.isSuccess()) {
                updateDataVersion();
            }
            handler.handle(result);
        }
    });
}
 
开发者ID:apiman,项目名称:apiman,代码行数:19,代码来源:PollCachingESRegistry.java

示例5: downloadPlugin

import io.apiman.gateway.engine.async.IAsyncResult; //导入方法依赖的package包/类
/**
 * Downloads the plugin via its maven GAV information.  This will first look in the local
 * .m2 directory.  If the plugin is not found there, then it will try to download the
 * plugin from one of the configured remote maven repositories.
 */
protected void downloadPlugin(final PluginCoordinates coordinates, final IAsyncResultHandler<File> handler) {
    if (pluginRepositories.isEmpty()) {
        // Didn't find it - no repositories configured!
        handler.handle(AsyncResultImpl.create((File) null));
        return;
    }

    final Iterator<URI> iterator = pluginRepositories.iterator();
    URI repoUrl = iterator.next();
    final IAsyncResultHandler<File> handler2 = new IAsyncResultHandler<File>() {
        @Override
        public void handle(IAsyncResult<File> result) {
            if (result.isSuccess() && result.getResult() == null && iterator.hasNext()) {
                downloadFromMavenRepo(coordinates, iterator.next(), this);
            } else {
                handler.handle(result);
            }
        }
    };
    downloadFromMavenRepo(coordinates, repoUrl, handler2);
}
 
开发者ID:apiman,项目名称:apiman,代码行数:27,代码来源:DefaultPluginRegistry.java

示例6: flush

import io.apiman.gateway.engine.async.IAsyncResult; //导入方法依赖的package包/类
@Override
public void flush(IAsyncResult<ReportResponse> reportResponse) {
    if (reportResponse.isSuccess()) {
        flushHandler.handle(AsyncResultImpl.create(reports));
    } else { // Flushing failed! Likely same result -- want to flush from cache somewhere.
        flushHandler.handle(new IAsyncResult<List<BatchedReportData>>() {

            @Override
            public boolean isSuccess() {
                return false;
            }

            @Override
            public boolean isError() {
                return true;
            }

            @Override
            public List<BatchedReportData> getResult() {
                return reports;
            }

            @Override
            public Throwable getError() {
                return new RuntimeException("Reporting failed; see #getResult for failed entries."); //$NON-NLS-1$
            }
        });
    }
}
 
开发者ID:apiman,项目名称:apiman-plugins,代码行数:30,代码来源:ReporterImpl.java

示例7: explodeOnFailure

import io.apiman.gateway.engine.async.IAsyncResult; //导入方法依赖的package包/类
/**
 * Handler that fails tests if result is unsuccessful, with the exception included in the error.
 *
 * @param context the test context
 * @param async the async object
 * @param successHandler the success handler, called only if the result was successful
 * @return the result handler
 */
static <T> IAsyncResultHandler<T> explodeOnFailure(TestContext context, Async async, Handler<T> successHandler) {
    return new IAsyncResultHandler<T>() {

        @Override
        public void handle(IAsyncResult<T> result) {
            if (result.isSuccess()) {
                successHandler.handle(result.getResult());
            } else {
                System.err.println("Operation failed"); //$NON-NLS-1$
                context.fail(result.getError());
            }
        }
    };
}
 
开发者ID:apiman,项目名称:apiman,代码行数:23,代码来源:SpecHelpers.java

示例8: publishApi

import io.apiman.gateway.engine.async.IAsyncResult; //导入方法依赖的package包/类
/**
 * @see io.apiman.gateway.engine.CachingJdbcRegistry.CachingESRegistry#publishApi(io.apiman.gateway.engine.beans.Api, io.apiman.gateway.engine.async.IAsyncResultHandler)
 */
@Override
public void publishApi(Api api, final IAsyncResultHandler<Void> handler) {
    super.publishApi(api, new IAsyncResultHandler<Void>() {
        @Override
        public void handle(IAsyncResult<Void> result) {
            if (result.isSuccess()) {
                updateDataVersion();
            }
            handler.handle(result);
        }
    });
}
 
开发者ID:apiman,项目名称:apiman,代码行数:16,代码来源:PollCachingJdbcRegistry.java

示例9: retireApi

import io.apiman.gateway.engine.async.IAsyncResult; //导入方法依赖的package包/类
/**
 * @see io.apiman.gateway.engine.CachingJdbcRegistry.CachingESRegistry#retireApi(io.apiman.gateway.engine.beans.Api, io.apiman.gateway.engine.async.IAsyncResultHandler)
 */
@Override
public void retireApi(Api api, final IAsyncResultHandler<Void> handler) {
    super.retireApi(api, new IAsyncResultHandler<Void>() {
        @Override
        public void handle(IAsyncResult<Void> result) {
            if (result.isSuccess()) {
                updateDataVersion();
            }
            handler.handle(result);
        }
    });
}
 
开发者ID:apiman,项目名称:apiman,代码行数:16,代码来源:PollCachingJdbcRegistry.java

示例10: unregisterClient

import io.apiman.gateway.engine.async.IAsyncResult; //导入方法依赖的package包/类
/**
 * @see io.apiman.gateway.engine.CachingJdbcRegistry.CachingESRegistry#unregisterClient(io.apiman.gateway.engine.beans.Client, io.apiman.gateway.engine.async.IAsyncResultHandler)
 */
@Override
public void unregisterClient(Client client, final IAsyncResultHandler<Void> handler) {
    super.unregisterClient(client, new IAsyncResultHandler<Void>() {
        @Override
        public void handle(IAsyncResult<Void> result) {
            if (result.isSuccess()) {
                updateDataVersion();
            }
            handler.handle(result);
        }
    });
}
 
开发者ID:apiman,项目名称:apiman,代码行数:16,代码来源:PollCachingJdbcRegistry.java

示例11: publishApi

import io.apiman.gateway.engine.async.IAsyncResult; //导入方法依赖的package包/类
/**
 * @see io.apiman.gateway.engine.es.CachingESRegistry#publishApi(io.apiman.gateway.engine.beans.Api, io.apiman.gateway.engine.async.IAsyncResultHandler)
 */
@Override
public void publishApi(Api api, final IAsyncResultHandler<Void> handler) {
    super.publishApi(api, new IAsyncResultHandler<Void>() {
        @Override
        public void handle(IAsyncResult<Void> result) {
            if (result.isSuccess()) {
                updateDataVersion();
            }
            handler.handle(result);
        }
    });
}
 
开发者ID:apiman,项目名称:apiman,代码行数:16,代码来源:PollCachingESRegistry.java

示例12: retireApi

import io.apiman.gateway.engine.async.IAsyncResult; //导入方法依赖的package包/类
/**
 * @see io.apiman.gateway.engine.es.CachingESRegistry#retireApi(io.apiman.gateway.engine.beans.Api, io.apiman.gateway.engine.async.IAsyncResultHandler)
 */
@Override
public void retireApi(Api api, final IAsyncResultHandler<Void> handler) {
    super.retireApi(api, new IAsyncResultHandler<Void>() {
        @Override
        public void handle(IAsyncResult<Void> result) {
            if (result.isSuccess()) {
                updateDataVersion();
            }
            handler.handle(result);
        }
    });
}
 
开发者ID:apiman,项目名称:apiman,代码行数:16,代码来源:PollCachingESRegistry.java

示例13: unregisterClient

import io.apiman.gateway.engine.async.IAsyncResult; //导入方法依赖的package包/类
/**
 * @see io.apiman.gateway.engine.es.CachingESRegistry#unregisterClient(io.apiman.gateway.engine.beans.Client, io.apiman.gateway.engine.async.IAsyncResultHandler)
 */
@Override
public void unregisterClient(Client client, final IAsyncResultHandler<Void> handler) {
    super.unregisterClient(client, new IAsyncResultHandler<Void>() {
        @Override
        public void handle(IAsyncResult<Void> result) {
            if (result.isSuccess()) {
                updateDataVersion();
            }
            handler.handle(result);
        }
    });
}
 
开发者ID:apiman,项目名称:apiman,代码行数:16,代码来源:PollCachingESRegistry.java

示例14: handle

import io.apiman.gateway.engine.async.IAsyncResult; //导入方法依赖的package包/类
@Override
public void handle(IAsyncResult<IHttpClientResponse> result) {
    if (result.isSuccess()) {
        response = result.getResult();
        status = parseStatus(response.getBody());
        PolicyFailure policyFailure = null;

        switch (response.getResponseCode()) {
            case 200:
            case 202:
                break;
            case 403:
                // May be able to treat all error cases without distinction by using parsed response, maybe?
                policyFailure = policyFailure(PolicyFailureType.Authentication,
                        PolicyFailureCodes.BASIC_AUTH_FAILED,
                        403,
                        status.getReason());
                break;
            case 409: // Over limit.
                policyFailure = policyFailure(PolicyFailureType.Other,
                        PolicyFailureCodes.RATE_LIMIT_EXCEEDED,
                        409,
                        status.getReason());
                break;
            default:
                RuntimeException re = new RuntimeException("Unexpected or undocumented response code: " + response.getResponseCode()); //$NON-NLS-1$
                exceptionHandler.handle(re); // TODO catch-all. policy failure or exception?
                break;
        }

        if (policyFailure != null) {
            policyFailureHandler.handle(policyFailure);
        }

        statusHandler.handle(status);

        response.close();
    } else {
        exceptionHandler.handle(result.getError());
    }
}
 
开发者ID:apiman,项目名称:apiman-plugins,代码行数:42,代码来源:AuthResponseHandler.java

示例15: createApiConnectionResponseHandler

import io.apiman.gateway.engine.async.IAsyncResult; //导入方法依赖的package包/类
/**
 * Creates a response handler that is called by the api connector once a connection
 * to the back end api has been made and a response received.
 */
private IAsyncResultHandler<IApiConnectionResponse> createApiConnectionResponseHandler() {
    return (IAsyncResult<IApiConnectionResponse> result) -> {
        if (result.isSuccess()) {
            requestMetric.setApiEnd(new Date());
            // The result came back. NB: still need to put it through the response chain.
            apiConnectionResponse = result.getResult();
            ApiResponse apiResponse = apiConnectionResponse.getHead();
            context.setAttribute("apiman.engine.apiResponse", apiResponse); //$NON-NLS-1$

            // Execute the response chain to evaluate the response.
            responseChain = createResponseChain((ApiResponse response) -> {
                // Send the api response to the caller.
                final EngineResultImpl engineResult = new EngineResultImpl(response);
                engineResult.setConnectorResponseStream(apiConnectionResponse);

                resultHandler.handle(AsyncResultImpl.create(engineResult));

                // We've come all the way through the response chain successfully
                responseChain.bodyHandler(buffer -> {
                    requestMetric.setBytesDownloaded(requestMetric.getBytesDownloaded() + buffer.length());
                    engineResult.write(buffer);
                });

                responseChain.endHandler(isEnd -> {
                    engineResult.end();
                    finished = true;
                    metrics.record(requestMetric);
                });

                // Signal to the connector that it's safe to start transmitting data.
                apiConnectionResponse.transmit();
            });

            // Write data from the back-end response into the response chain.
            apiConnectionResponse.bodyHandler(buffer -> responseChain.write(buffer));

            // Indicate back-end response is finished to the response chain.
            apiConnectionResponse.endHandler(isEnd -> responseChain.end());

            responseChain.doApply(apiResponse);
        } else {
            resultHandler.handle(AsyncResultImpl.create(result.getError()));
        }
    };
}
 
开发者ID:apiman,项目名称:apiman,代码行数:50,代码来源:ApiRequestExecutorImpl.java


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