Search code examples
javaandroidandroid-annotations

Change @Rest rootUrl at runtime with AndroidAnnotations


I'm using a rest service with AndroidAnnotations, configured like so:

@Rest(rootUrl = "http://192.168.1.48:8080/stuff/services/rest/StuffService/",
        converters = {MappingJacksonHttpMessageConverter.class})
public interface IStuff
{
    @Post("fetchAllStuff")
    public Response fetchAllStuff(Request req);
}

So what happens when I need to change the URL at runtime? If the URL is hard-coded in the annotation, what would I do to change it? Is there some way I could have it in a properties or XML file as well?


Solution

  • As explained on the wiki, you can simply define a void setRootUrl(String rootUrl) method and it will be generated as a setter on the final class