Configuration Interfaces. Correct way to do setters? Value not updating

Hi guys,

Just wondering what the correct method is to set the configuration interface values programmatically?

I am trying to store a token but having a hell of a time with it. The values do not seem to be updating correctly.

Here is the code I am currently trying. After running this with the new token and looking at the property in the admin - app properties area the value doesn’t change. But it does change after a while. Or maybe after a restart…

    protected XeroConfig xeroConfig;

    protected ConfigStorageAPI configStorageAPI;



        configStorageAPI.setDbProperty("xero.accessToken", tokenResponse.getAccessToken());
        configStorageAPI.setDbProperty("xero.refreshToken", tokenResponse.getRefreshToken());



@Source(type = SourceType.DATABASE)
public interface XeroConfig extends Config {

    String getAccessToken();
    void setAccessToken(String xeroAccessToken);


generally, you can use a setter method in the config interface in order to save values to the DB. I’m not sure about the cache invalidation though. Perhaps you have to clear that manually.

Perhaps you have already seen it: I created a Xero integration component which seems to do similar things. Perhaps you want to take a look and see if you can leverage some of the work: Xero – CUBA Platform.


Configuration properties are aggressively cached, to make access to them as quick as possible.
For your case - it seems that you are trying to use configuration properties for a wrong purpose.

You can create a simple entity with 1-2 fields and load / save it to the database when necessary.

Thanks Mario and Alex,

Mario, I did have a look at that.
Unfortunately Xero is forcing the stricter Oauth2 with callback in March so that will become unusable.

I’m going to have a go at storing the variables with the setters but also locally within the service. So that the service uses the local variables first but on restart will reload them from the configuration interface if they are null. Presumably that will solve this… Just have to keep waiting for the token to expire to test!

I could make my component public if anyone is interested in contributing. Xero is a very popular accounting platform and it would be great to have an up-to-date addon for Cuba.