I am trying to create an agent and run it!! I have created two classes, one extends AgentBase . and the other one is a normal main class. I have written the code for agent in the 1st class and trying to run it from the second class. But i am not able to access it. I am a complete novice here, any guidance would be appreciated.
Agent Class
import lotus.domino.*;
import java.util.Vector;
import sun.management.Agent;
public class anagent extends AgentBase {
public void NotesMain() {
try {
Session session = getSession();
AgentContext agentContext =
session.getAgentContext();
// (Your code goes here)
System.out.println
("I am an agent");
} catch(Exception e) {
e.printStackTrace();
}
}
Main Class
public static void main(String [] args) throws NotesException {
Session session = null;
Database db = null;
try {
session = NotesFactory.createSession(hostname,UserName, password);
} catch (NotesException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
boolean x = session.isValid();
System.out.println("success- "+x);
try {
db = session.getDatabase(null,"LotusDB2.nsf");
} catch (NotesException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if(db.isOpen())
System.out.println("database open");
//Agent agnt = (Agent) a.firstElement();
//agnt.toString();}
//AgentContext agentContext = session.getAgentContext();
// db = agentContext.getCurrentDatabase();
Vector agents = db.getAgents();
//lotus.domino.Agent agent = new lotus.domino.Agent();
System.out.println("Agents in database:");
if(agents.size()>0) System.out.println("some agents found");
for (int i=0; i<agents.size(); i++)
{
lotus.domino.Agent agent = (lotus.domino.Agent)agents.elementAt(i);