MCPcopy Create free account
hub / github.com/OpenFeign/feign-vertx / newInstance

Method newInstance

src/main/java/feign/VertxFeign.java:49–79  ·  view source on GitHub ↗
(final Target<T> target)

Source from the content-addressed store, hash-verified

47 }
48
49 @Override
50 @SuppressWarnings("unchecked")
51 public <T> T newInstance(final Target<T> target) {
52 checkNotNull(target, "Argument target must be not null");
53
54 final Map<String, MethodHandler> nameToHandler = targetToHandlersByName.apply(target);
55 final Map<Method, MethodHandler> methodToHandler = new HashMap<>();
56 final List<DefaultMethodHandler> defaultMethodHandlers = new ArrayList<>();
57
58 for (final Method method : target.type().getMethods()) {
59 if (isDefault(method)) {
60 final DefaultMethodHandler handler = new DefaultMethodHandler(method);
61 defaultMethodHandlers.add(handler);
62 methodToHandler.put(method, handler);
63 } else {
64 methodToHandler.put(method, nameToHandler.get(Feign.configKey(target.type(), method)));
65 }
66 }
67
68 final InvocationHandler handler = factory.create(target, methodToHandler);
69 final T proxy = (T) Proxy.newProxyInstance(
70 target.type().getClassLoader(),
71 new Class<?>[] { target.type() },
72 handler);
73
74 for (final DefaultMethodHandler defaultMethodHandler : defaultMethodHandlers) {
75 defaultMethodHandler.bindTo(proxy);
76 }
77
78 return proxy;
79 }
80
81 /**
82 * VertxFeign builder.

Callers 2

targetMethod · 0.80

Calls 2

applyMethod · 0.45
createMethod · 0.45

Tested by

no test coverage detected