Experience in adding a custom tool for adding data to a custom master in example-simulated


I have been trying to build a CustomTool extending AbstractTool to populate data to my custom master.

I made a CustomToolContext class extending the ToolContext for that…

public class CustomToolContext extends ToolContext {

  • The Custom master.
    private CustomMaster _customMaster;

and I have added a custom toolcontext part in the toolcontext-xxx.ini file in the config.

My aim was to access the custom master in the Custom tool created myself by the following code.


Everyting seemed to be ok from the coding perspective but sucked with a class cast error.

tracking this class cast error I reached the code in ToolContextUtils.java

after a close watch I smelled something in the line 90’s in the function

public static ToolContext getToolContext(String configResourceLocation, Class<? extends ToolContext> toolContextClazz, List classifierChain)

ComponentManager manager = new ComponentManager(“toolcontext”);
ComponentRepository repo = manager.getRepository();
return repo.getInstance(ToolContext.class, “tool”);

I made a build to the OG-Component after changing the return statement to

 return repo.getInstance(toolContextClazz, "tool");

working fine for me in the particular case when we create custom tool context I believe.

so far I could not find any side effect for the change, though I am not sure this is the solution.


Fixed by http://jira.opengamma.com/browse/PLAT-5917


Thanks Stephen.