Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor constructor of ReflectiveFeign #1857

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions core/src/main/java/feign/AsyncFeign.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
package feign;

import feign.InvocationHandlerFactory.MethodHandler;
import feign.ReflectiveFeign.ParseHandlersByName;
import feign.Logger.Level;
import feign.Request.Options;
import feign.Target.HardCodedTarget;
Expand Down Expand Up @@ -208,11 +207,9 @@ public AsyncFeign<C> build() {
propagationPolicy, methodInfoResolver,
new RequestTemplateFactoryResolver(encoder, queryMapEncoder),
options, decoder, errorDecoder);
final ParseHandlersByName<C> handlersByName =
new ParseHandlersByName<>(contract,
methodHandlerFactory);
final ReflectiveFeign<C> feign =
new ReflectiveFeign<>(handlersByName, invocationHandlerFactory, defaultContextSupplier);
new ReflectiveFeign<>(contract, methodHandlerFactory, invocationHandlerFactory,
defaultContextSupplier);
return new AsyncFeign<>(feign);
}
}
Expand Down
9 changes: 3 additions & 6 deletions core/src/main/java/feign/Feign.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
*/
package feign;

import feign.ReflectiveFeign.ParseHandlersByName;
import feign.Request.Options;
import feign.Target.HardCodedTarget;
import feign.codec.Decoder;
Expand Down Expand Up @@ -203,15 +202,13 @@ public Feign build() {
final ResponseHandler responseHandler =
new ResponseHandler(logLevel, logger, decoder, errorDecoder,
dismiss404, closeAfterDecode, responseInterceptor);
MethodHandler.Factory<Object> synchronousMethodHandlerFactory =
MethodHandler.Factory<Object> methodHandlerFactory =
new SynchronousMethodHandler.Factory(client, retryer, requestInterceptors,
responseHandler, logger, logLevel, propagationPolicy,
new RequestTemplateFactoryResolver(encoder, queryMapEncoder),
options);
ParseHandlersByName<Object> handlersByName =
new ParseHandlersByName<>(contract,
synchronousMethodHandlerFactory);
return new ReflectiveFeign<>(handlersByName, invocationHandlerFactory, () -> null);
return new ReflectiveFeign<>(contract, methodHandlerFactory, invocationHandlerFactory,
() -> null);
}
}

Expand Down
11 changes: 7 additions & 4 deletions core/src/main/java/feign/ReflectiveFeign.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,13 @@ public class ReflectiveFeign<C> extends Feign {
private final InvocationHandlerFactory factory;
private final AsyncContextSupplier<C> defaultContextSupplier;

ReflectiveFeign(ParseHandlersByName<C> targetToHandlersByName, InvocationHandlerFactory factory,
ReflectiveFeign(
Contract contract,
MethodHandler.Factory<C> methodHandlerFactory,
InvocationHandlerFactory invocationHandlerFactory,
AsyncContextSupplier<C> defaultContextSupplier) {
this.targetToHandlersByName = targetToHandlersByName;
this.factory = factory;
this.targetToHandlersByName = new ParseHandlersByName<C>(contract, methodHandlerFactory);
this.factory = invocationHandlerFactory;
this.defaultContextSupplier = defaultContextSupplier;
}

Expand Down Expand Up @@ -113,7 +116,7 @@ public String toString() {
}
}

static final class ParseHandlersByName<C> {
private static final class ParseHandlersByName<C> {

private final Contract contract;
private final MethodHandler.Factory<C> factory;
Expand Down