How to read the pluginsettings in scheduler task?

Siva Balan December 29, 2019

I am able to store the configuration data in pluginsettings factory.

But I am unable to read it in my scheduler task code, Could you please guide me to fix this?

My code is here

@Scanned
public class ScheduledTask implements PluginJob {

private static final String PLUGIN_STORAGE_KEY = "com.jiradev.jira.plugins.dsconfigadmin";

//private static PluginSettingsFactory pluginSettingsFactory = null;
@ComponentImport
private final PluginSettingsFactory pluginSettingsFactory;

@Inject
public ScheduledTask(PluginSettingsFactory pluginSettingsFactory)
{
this.pluginSettingsFactory = pluginSettingsFactory;
}

public void execute(Map jobDataMap) {

PluginSettings pluginSettings = pluginSettingsFactory.createGlobalSettings();

System.out.println("Scheduler API Key: " + pluginSettings.get(PLUGIN_STORAGE_KEY + ".api_key") );

...

...

...

1 answer

1 accepted

0 votes
Answer accepted
Siva Balan December 30, 2019

I am able to get the pluginsettings using the below code.

PluginSettingsFactory pluginSettingsFactory = ComponentAccessor.getOSGiComponentInstanceOfType(PluginSettingsFactory.class);

Suggest an answer

Log in or Sign up to answer