Question

I'm able to call a Java agent in SSJS with the following code:

var db:NotesDatabase = session.getCurrentDatabase();
var agent:NotesAgent = db.getAgent("AgentName");
agent.run();

But what I'm wanting to do is to call a Java agent from a Java class? Is this possible? Thanks for any tips.

Was it helpful?

Solution

The interesting challenge is to get hands on the session and/or database inside your Java class. The class could be in your NSF, in a plug-in, or a jar in jvm/lib/ext.

You don't want to depend on where it came from, so you use dependency injection to provide them (which is a fancy word for: provide as parameter) something like:

public class Leon implements Serializable {

      public void cleanerDoYourWork(Database db) {
            Agent theProfessional = db.getAgent("acidAndGuns");
            theProfessional.run();
            theProfessional.recycle();
      }
    }

In case you don't get the pun, search IMDB for Leon :-)

Remark: In SSJS you don't need session.getCurrentDatabase();, it is already there as "database"

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top