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

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 Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,139 views 13 19
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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot