public final class Invocation
extends java.lang.Object
Retrofit automatically adds an invocation to each OkHttp request as a tag. You can retrieve the invocation in an OkHttp interceptor for metrics and monitoring.
class InvocationLogger implements Interceptor {
@Override public Response intercept(Chain chain) throws IOException {
Request request = chain.request();
Invocation invocation = request.tag(Invocation.class);
if (invocation != null) {
System.out.printf("%s.%s %s%n",
invocation.method().getDeclaringClass().getSimpleName(),
invocation.method().getName(), invocation.arguments());
}
return chain.proceed(request);
}
}
Note: use caution when examining an invocation's arguments. Although the
arguments list is unmodifiable, the arguments themselves may be mutable. They may also be unsafe
for concurrent access. For best results declare Retrofit service interfaces using only immutable
types for parameters!public static Invocation of(java.lang.reflect.Method method, java.util.List<?> arguments)
public java.lang.reflect.Method method()
public java.util.List<?> arguments()
public java.lang.String toString()
toString 在类中 java.lang.Object