When we need global declaration of variables or constants in more than one agent we usually create script library with those global declarations and link with the agent in order to use them.What about if same you wish to accomplish in Java ? Here are the simple steps,

# Create new Java library and add new class ,

public class GlobalDeclarations{
public static String viewName="ViewName1";
public static String viewName1="ViewName2";

# Save and close your Java library and include this library to the agent where these variables you intended to use.Including Java library in Java agent is explained here.

# In your Java agent use global variables like,

Session session = getSession();
AgentContext agentContext = session.getAgentContext();
Database db = agentContext.getCurrentDatabase();
View vwConfig=db.getView(GlobalDeclarations.viewName);
}catch(Exception e){

In above example ,I've accessed global variable using classname.variablename . Using this technique all the global variables can be declared in separate Java library to avoid hard coding in complex agents.

Leave a Reply

preload preload preload