Added thread local variable

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-dashboard-harvester-se-plugin@169136 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2018-06-13 12:43:36 +00:00
parent f0f981d197
commit 3630de9582
1 changed files with 18 additions and 1 deletions

View File

@ -80,6 +80,23 @@ public class AccountingDataHarvesterPlugin extends Plugin<DataHarvestPluginDecla
return properties;
}
private static final InheritableThreadLocal<ContextAuthorization> contextAuthorization = new InheritableThreadLocal<ContextAuthorization>() {
@Override
protected ContextAuthorization initialValue() {
try {
return new ContextAuthorization();
} catch(Exception e) {
throw new RuntimeException("Unable to instantiate ContextAuthorization");
}
}
};
public static InheritableThreadLocal<ContextAuthorization> getContextAuthorization() {
return contextAuthorization;
}
/** {@inheritDoc} */
@Override
public void launch(Map<String,Object> inputs) throws Exception {
@ -138,7 +155,7 @@ public class AccountingDataHarvesterPlugin extends Plugin<DataHarvestPluginDecla
Properties properties = getConfigParameters();
getProperties().set(properties);
ContextAuthorization contextAuthorization = new ContextAuthorization();
ContextAuthorization contextAuthorization = AccountingDataHarvesterPlugin.contextAuthorization.get();
DatabaseManager dbaseManager = new DatabaseManager();