Topic
IC4NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
5 replies Latest Post - ‏2009-08-04T15:01:44Z by SystemAdmin
brittany_lazarski
brittany_lazarski
42 Posts
ACCEPTED ANSWER

Pinned topic Convert Domino Java agent to Java class

‏2007-09-25T19:41:12Z |
I am new to the Java world, so forgive me if this is an easy question. I am trying to create a new class in my Portlet Factory project. I want to basically copy my Domino Java agent into this new class, but am having a hard time with it. I tried to do an import of lotus.domino.*, but it doesn't like it, and therefore cannot resolve what "AgentBase" is. I have the ncso.jar file in my build path. Do I have anything blatently wrong here?

package com.bradycorp.DominoAgents;
import lotus.domino.*;

public class GetNamesAgent extends AgentBase {
public void NotesMain() {
try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
// (Rest of code will go here)

} catch(Exception e) {
e.printStackTrace();
}
}
}
Updated on 2009-08-04T15:01:44Z at 2009-08-04T15:01:44Z by SystemAdmin
  • mburati
    mburati
    17 Posts
    ACCEPTED ANSWER

    Re: Convert Domino Java agent to Java class

    ‏2007-09-25T19:45:21Z  in response to brittany_lazarski
    I'm not a Domino/NCSO expert, but I just opened NCSO.jar in WinZip and I don't see an AgentBase class in the jar. Are you sure that's a class that should be supported by the NCSO API?

    ..mb1
  • SystemAdmin
    SystemAdmin
    334 Posts
    ACCEPTED ANSWER

    Re: Convert Domino Java agent to Java class

    ‏2007-09-26T19:43:59Z  in response to brittany_lazarski
    Hi,
    I assume you want to use Portlet Factory and its Domino builders to access an existing Domino database. Tell me more about what you want your application to do. Are you trying to resuse an existing Domino java agent that you have written? The more detail the better.

    I believe AgentBase is only used (and accessible) when you are writing an agent in Domino Designer and the agent is run and called by the Domino web server. (Your sample below is the skeleton code provided when you create a new Domino agent in Domino Designer) Like mb1 says, it it not part of ncso.jar, so AgentBase is not meant to be used remotely.

    Since you are new to Portlet Factory and the Java world, you might want to start by looking at the Getting Started guide. Start menu > IBM WebSphere > Portlet Factory > Gettting Started Guide. Then, we also have a sample of using Portlet Factory to connect to Domino here: http://www.ibm.com/developerworks/websphere/zones/portal/portletfactory/samples/datasvc.html

    The Domino builders in Portlet Factory support create, retrieve, update, and delete operations, and a few other operations (see the Domino Help). If you are trying to use Portlet Factory and the Domino Java API to do some additional custom coding, we provide many "back doors" into the API. For instance, the Domino builders contain method that will return you the lotus.domino.Session object and the lotus.domino.Database objects. (See the Domino builder help). You could use these in a Method or Linked Java Object builder.

    Once you read the Getting Started and Domino samples, do tell me a little more about what you are trying to do, and I can probably tailor my response accordingly.

    Stick with it. There is a learning curve with Portlet Factory, but once you get it, you'll realize its power and flexibility!

    Sam

    > I am new to the Java world, so forgive me if this is
    > an easy question. I am trying to create a new class
    > in my Portlet Factory project. I want to basically
    > copy my Domino Java agent into this new class, but am
    > having a hard time with it. I tried to do an import
    > of lotus.domino.*, but it doesn't like it, and
    > therefore cannot resolve what "AgentBase" is. I have
    > the ncso.jar file in my build path. Do I have
    > anything blatently wrong here?
    >
    > package com.bradycorp.DominoAgents;
    > import lotus.domino.*;
    >
    > public class GetNamesAgent extends AgentBase {
    > public void NotesMain() {
    > try {
    > Session session = getSession();
    > AgentContext agentContext =
    > text = session.getAgentContext();
    > // (Rest of code will go here)
    >
    > } catch(Exception e) {
    > e.printStackTrace();
    > }
    > }
    > }
    • SystemAdmin
      SystemAdmin
      334 Posts
      ACCEPTED ANSWER

      Re: Convert Domino Java agent to Java class

      ‏2007-09-26T19:59:18Z  in response to SystemAdmin
      Hi,
      I just realized your previous posts, and that you've had success with PF and the Domino builders. So you do have familiarity with PF and the Domino builders.

      Based on your previous posts, it sounds like you are needing to write some custom Java using the Domino API to do something we don't already do in the builder. This is a common use case, and the builder provides "backdoors" into the Domino API to let you do this. Check out the getDominoSession() (returns a lotus.domino.Session) and getDominoDatabase() (returns a lotus.domino.Database) methods provided by the builder. Once you get the Session or the Database, you can likely do what you need to do.

      If your code is pretty small, consider using a Method builder. If your code is more complex, consider writing your own Java classes, and use a Linked Java Object builder in your model to access the class.

      With this approach, you don't need AgentBase.

      Hopefully this helps.

      Sam
      • ByjuJoy
        ByjuJoy
        1 Post
        ACCEPTED ANSWER

        Re: Convert Domino Java agent to Java class

        ‏2009-08-03T05:35:50Z  in response to SystemAdmin
        A dummy AgentBase class can be created to avoid compilation issue. Like the code given below.
        This is just for resolving compilation. Not for running. As mentioned in one of the previous posts Agent should run locally in Domino..

        import lotus.domino.Session;

        public class AgentBase {
        public Session getSession(){
        return null;
        }
        }
        • SystemAdmin
          SystemAdmin
          334 Posts
          ACCEPTED ANSWER

          Re: Convert Domino Java agent to Java class

          ‏2009-08-04T15:01:44Z  in response to ByjuJoy
          Hi,
          Not sure if you realized it, but the thread is two years old.

          Also, I don't really think making a dummy AgentBase class would help the user and I would not recommend this approach. When using Portlet Factory's Domino builders, you don't need AgentBase at all. If you're trying to run an existing agent from Portlet Factory, the Domino builders have the ability to run named agents. (In some cases the agent might need to be tweaked a bit) and they also expose the lotus.domino.Session and lotus.domino.Database objects, so if you need to write custom Domino Java api code in your app, you can do so.

          Sam