Jira/Java - injecting cache manager not working (setter)

I'm building a plugin for Jira. I want to add a caching-layer so I wanted to use the

com.atlassian.cache.CacheManager

 I have to inject this via an argument / setter.

Since I'm extending an other class I wanted to inject this via a setter, but for some reason it returns null all the time. It does not go past the setter.

import com.atlassian.cache.Cache;
import com.atlassian.cache.CacheLoader;
import com.atlassian.cache.CacheManager;
import com.atlassian.cache.CacheSettingsBuilder;

public class Foo extends AbstractJiraContextProvider
{
    private CacheManager cacheManager;

    public void setCacheManager(CacheManager cacheManager) {
        //It does not get past this function..
        this.cacheManager = cacheManager;
    }

    @Override
    public Map getContextMap(ApplicationUser user, JiraHelper jiraHelper) {


        cache = this.cacheManager.getCache("bar");

    }
}

I also tried this by doing the following:

public Foo(CacheManager cacheManager) {
    this.cacheManager = cacheManager;
}

After that the plugin does nothing anymore. I do not get errors, but it just gives 0 output.

I used this for documentation: https://developer.atlassian.com/confdev/confluence-plugin-guide/writing-confluence-plugins/accessing-confluence-components-from-plugin-modules

And https://developer.atlassian.com/confdev/development-resources/confluence-developer-faq/how-do-i-cache-data-in-a-plugin#HowdoIcachedatainaplugin?-Instructions

2 answers

1 accepted

Accepted Answer
0 votes

Hi Wiard! This looks like a developer question, so my recommendation would be to ask our Developer Community for help. You can find them at community.developer.atlassian.com.

Cheers :)

Ana

Thank you Ana :) 

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Oct 16, 2018 in Jira

Looking for anyone who made the switch to Data Center

The Jira Marketing team is putting together an ebook on migrating to Data Center. We're looking for pro tips on how you staffed your project team and organized your Proof of Concept. Share yo...

72 views 0 3
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you