Yes, it’s plain injection. ProjectMappingManagerImpl constructor has CacheManager cacheFactory (com.atlassian.cache.CacheManager) as IN parameter (see below).
import com.atlassian.cache.CacheManager;
import com.atlassian.cache.CacheSettingsBuilder;
import com.atlassian.jira.project.ProjectManager;
public class ProjectMappingManagerImpl implements ProjectMappingManager {
private final ProjectMappingDao dao;
private final ProjectManager projectManager;
private final Cache<Set<Long>, Optional<Set<Integer>>> cache;
public ProjectMappingManagerImpl(ProjectManager projectManager,
CacheManager cacheFactory,
ProjectMappingDao dao) {
this.projectManager = projectManager;
this.dao = dao;
this.cache = cacheFactory.getCache(ProjectMappingManagerImpl.class.getName() + ".cache",
new MappingCacheLoader(),
new CacheSettingsBuilder()
.expireAfterAccess(7, TimeUnit.DAYS)
.flushable()
.build());
}
“Also since you mentioned the issue of interacting with other add-ons - are you using osgi declarations? Is MemoryCacheManager optional there?”
What is osgi declaration?
We declare ProjectMappingManagerImpl in atlassian-plugin.xml
<component key="projectMappingManager" name="projectMappingManager" class="com.myplagin.ProjectMappingManagerImpl" public="false">
<interface>com.myplagin.ProjectMappingManager</interface>
</component>
but atlassian-plugin.xml doesn’t contain lines like
<component-import key="cacheManager" interface="com.atlassian.cache.CacheManager" />
<component-import key="projectManager" interface="com.atlassian.jira.project.ProjectManager" />
Shall we?
Also since you mentioned the issue of interacting with other add-ons
Sorry for confusing description. It is all about the single and the same add-on. I’ve just described the scenario of updating it from one version to another (so plugin’s event occur, like disable plugin, enable plugin and so on).