Developing Apama Applications > Building Dashboards > Defining Dashboard Commands > Creating custom commands > Developing a custom-command library
Developing a custom-command library
A sample implementation of ICommandLibrary is included below in Sample ICommandLibrary implementation.
You can find a sample implementation of ICommandLibrary in the following file:
samples\tutorial\src\com\apama\dashboard\sample\SampleCommandLibrary.java
Your implementation of ICommandLibrary must implement the following methods:
*getCommandDescriptors: Creates a command descriptor for each function that the library supports; returns a list of com.apama.dashboard.command.ICommandDescriptors. This method is called once at Data Server or Display Server startup.
*invokeCommand: Performs the command with the specified name, using the specified arguments.
When you compile your implementation, ensure that dashboard_client5.1.jar is on your class path. This jar file is in the lib directory of your Apama installation.
Your implementation of invokeCommand can set or retrieve substitution values, if necessary, by using the following methods of com.apama.dashboard.DashboardManager and com.apama.dashboard.IDashboardContext:
*DashoardManager.getCommandDashboardContext: This static method returns an instance of IDashboardContext.
*IDashboardContext.getSubstitution: Gets the value of a substitution with a given name.
*IDashboardContext.setSubstitution: Sets the value of a substitution with a given name.
*IDashboardContext.setSubstitutions: Sets the values of substitutions, where the substitutions and values are specified with String vectors.
Each set method has a boolean argument, triggerUpdate, which controls whether objects attached to the substitution are updated. If it is false, they are not. If the substitutions are only used as command parameters or in drilldowns, you can improve performance by specifying false.
Following is an example:
import com.apama.dashboard.DashboardManager;
import com.apama.dashboard.IDashboardContext;
...
IDashboardContext ctxt =
   DashboardManager.getCommandDashboardContext();
String val1 = ctxt.getSubstitutionValue("$subst1");
...
ctxt.setSubstitution("$subst2", "val2", false);
Copyright © 2013 Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or Terracotta Inc., San Francisco, CA, USA, and/or Software AG (Canada) Inc., Cambridge, Ontario, Canada, and/or, Software AG (UK) Ltd., Derby, United Kingdom, and/or Software A.G. (Israel) Ltd., Or-Yehuda, Israel and/or their licensors.