2016-07-19 5 views

Antwort

0

ich einen Weg gefunden, die einen Proxy wickeln den Dienst erstellen mit Retrofit verwenden:

Retrofit retrofit = new Retrofit.Builder() 
.baseUrl("https://example.com/") 
.build(); 

ApiService rawService = retrofit.create(ApiService.class); 

ApiService service = (ApiService) Proxy.newProxyInstance(rawService.getClass().getClassLoader(), 
       rawService.getClass().getInterfaces(), 
       new InvocationHandler() { 
        @Override 
        public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { 
         if (method.getAnnotation(CustomAnnotation.class) != null){ 
          //handler the Annotations 
         } 
         return method.invoke(rawService,args); 
        } 
       });