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 vote

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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Thursday in Jira

Mission-critical battery manufacturer fulfills FAA software requirements with Commit Policy Plugin

EaglePicher Technologies is a leading manufacturer of battery systems for diverse industries like defense, aviation, space or medical. As they operate in highly regulated industries, keeping a clear ...

169 views 0 2
Read article

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