refactor(gateway-vertx) Anonymous class -> lambda in ConnectorFactory.
package io.apiman.gateway.platforms.vertx3.connector;
import io.apiman.common.config.options.TLSOptions;
-import io.apiman.gateway.engine.IApiConnection;
-import io.apiman.gateway.engine.IApiConnectionResponse;
import io.apiman.gateway.engine.IApiConnector;
import io.apiman.gateway.engine.IConnectorFactory;
-import io.apiman.gateway.engine.async.IAsyncResultHandler;
import io.apiman.gateway.engine.auth.RequiredAuthType;
import io.apiman.gateway.engine.beans.Api;
import io.apiman.gateway.engine.beans.ApiRequest;
-import io.apiman.gateway.engine.beans.exceptions.ConnectorException;
import io.apiman.gateway.platforms.vertx3.http.HttpClientOptionsFactory;
import io.vertx.core.Vertx;
import io.vertx.core.http.HttpClient;
@@ -87,13 +83,8 @@ public class ConnectorFactory implements IConnectorFactory {
// In the future we can switch to different back-end implementations here!
@Override
- public IApiConnector createConnector(ApiRequest request, Api api, RequiredAuthType authType, boolean hasDataPolicy) {
- return new IApiConnector() {
-
- @Override
- public IApiConnection connect(ApiRequest request,
- IAsyncResultHandler<IApiConnectionResponse> resultHandler)
- throws ConnectorException {
+ public IApiConnector createConnector(ApiRequest req, Api api, RequiredAuthType authType, boolean hasDataPolicy) {
+ return (request, resultHandler) -> {
HttpConnectorOptions httpOptions = new HttpConnectorOptions()
.setHasDataPolicy(hasDataPolicy)
.setRequiredAuthType(authType)
@@ -102,7 +93,6 @@ public class ConnectorFactory implements IConnectorFactory {
// Get from cache
HttpClient client = clientFromCache(httpOptions);
return new HttpConnector(vertx, client, request, api, httpOptions, resultHandler);
- }
};
}
@@ -114,7 +104,6 @@ public class ConnectorFactory implements IConnectorFactory {
}
}
-
private URI parseApiEndpoint(Api api) {
try {
return new URI(api.getEndpoint());
