Skip to content

Commit

Permalink
Refactor constructor of ReflectiveFeign
Browse files Browse the repository at this point in the history
  • Loading branch information
wplong11 committed Nov 22, 2022
1 parent 273e5dc commit c1da67b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
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

0 comments on commit c1da67b

Please sign in to comment.