Почему мой код в аннотациях Android не работает в журналах?

Я новичок в аннотациях Android, так что, может быть, я что-то упустил, но я в основном пытаюсь скопировать оставшийся клиент, увиденный https://github.com/excilys/androidannotations/wiki/Rest%20API здесь

Где у меня есть перехватчик, определенный следующим образом

@EBean(scope = Scope.Singleton)
public class RestInterceptor implements ClientHttpRequestInterceptor{

final String TAG = "rest";

@Bean
AuthStore authStore;

@Override
public ClientHttpResponse intercept(HttpRequest request, byte[] data, ClientHttpRequestExecution execution)
        throws IOException{

    //Need to set the api key here but nothing happens code quits
//        Log.d("Rest",authStore.getSessionKey());

     HttpHeaders headers = request.getHeaders();

     headers.set("api_key",authStore.getApiKey());

     ClientHttpResponse resp = execution.execute(request, data);

     HttpStatus code = resp.getStatusCode();

     Log.d(TAG,resp.getBody().toString());

     if(code.value() == 200){
        Log.d(TAG,"success code 200"); 

     }
     else{
         Log.d(TAG,"fail code" + code.toString());
     }
     return resp;
}

}

Но код просто выходит, когда я пытаюсь добавить дополнительный заголовок. Класс auth store выглядит следующим образом

@EBean(scope = Scope.Singleton)
 public class AuthStore {

public String apiKey,sessionKey;

public String getApiKey() {
    return apiKey;
}

public void setApiKey(String apiKey) {
    this.apiKey = apiKey;
}

public String getSessionKey() {
    return sessionKey;
}

public void setSessionKey(String sessionKey) {
    this.sessionKey = sessionKey;
}

}

Интерфейс отдыха

@Rest(rootUrl = "https://pathtoapi/rest/public/", converters = {     GsonHttpMessageConverter.class }, interceptors = {RestInterceptor.class })
public interface ApiClient {

@Get("force_login")
ApiSession forceLogin();

// if you need to add some configuration to the Spring RestTemplate.
RestTemplate getRestTemplate();

void setRestTemplate(RestTemplate restTemplate);

}

0 ответов

Другие вопросы по тегам