EclipseZone: IBM Sametime Instant Messaging To Be Eclipse Based

The word is spreading:

“Although to some us (thanks to little drop-ins by Chris Aniszczyk) this may come as no surprise, it has become official that the Sametime instant-messaging client is now built throug the Eclipse Rich Client platform components.”

The post also mentions the new Sametime 7.5 Microsoft Office features mentioned by Ed Brill yesterday:

“Sametime 7.5, which will be available in about two months, will allow people to use instant-messaging features without having to leave Office applications. For example, a person could open up an e-mail inside Outlook and find out whether the sender is available on Sametime and where he or she is located.”

Full post @ EclipseZone: IBM Sametime Instant Messaging To Be Eclipse Based

Java in Notes/Domino Explained: Test agents in Eclipse by extending AgentBase (part 5)


By now (I assume you read part 1, part 2, part 3 and part 4) we have a working AgentBase extension called EclipseAgentBase. In this part I’ll show how to use the new and improved AgentBase class to easily write, test and debug Notes/Domino Java agents in Eclipse.

Please bear in mind that setting up the runtime environment for each agent below can seem like a chore and unnecessarily complex and cumbersome. It does however have the advantage that you can test the agent code and not worry about whether the database is a known state etc. It is my experience that most times when agents fail in test it is because some required document or profile document is missing. You can stub out these requirements with the new EclipseAgentBase class so you can focus on the agent code.

Enough explaining – let’s look at some code.

Simple agents, no objects from AgentContext

In the most simple agents, which is normally never the case,me where you do not use any objects from the AgentContext you only need to override the NotesMain method and implement the main()-method boilerplate code. As you can see from the example you can use the isNotes() method if you need to know whether the code is running in Notes/Domino or in Eclipse. Notice how the code runs perfectly no matter if you run the code in Notes/Domino or in Eclipse.

import lotus.domino.NotesThread;
import lotus.domino.Session;

public class ExampleAgent1 extends EclipseAgentBase {

   public static void main(String[] args) {
      try {
         NotesThread.sinitThread();
         new ExampleAgent1().NotesMain();

      } catch (Exception e) {
         e.printStackTrace();
      } finally {
         NotesThread.stermThread();
      }
   }

   public void NotesMain() {
      try {
         Session session = this.getSession();
         if (this.isNotes()) {
            System.out.println("We're in Notes...");
         } else {
            System.out.println("We're outside Notes...");
         }
         System.out.println("Username: " + session.getUserName());
      } catch (Exception e) {
         e.printStackTrace();
      }
   }
}

“Normal” agents, using AgentContext.getCurrentDatabase()

In what I call “normal” agents you will probably at least use some information about the current database. To do this we have to override the callbackGetCurrentDatabase() method of the agent (in bold below). This overridden method will only be used when running outside Notes/Domino. If your agent does a lot of calls to the method you might want to store the database instance and return the same instance if called multiple times.

import lotus.domino.Database;
import lotus.domino.NotesException;
import lotus.domino.NotesThread;
import lotus.domino.Session;

public class ExampleAgent2 extends EclipseAgentBase {

   public static void main(String[] args) {
      try {
         NotesThread.sinitThread();
         new ExampleAgent2().NotesMain();

      } catch (Exception e) {
         e.printStackTrace();
      } finally {
         NotesThread.stermThread();
      }
   }

   protected Database callbackGetCurrentDatabase() throws NotesException {
      return this.getSession().getDatabase(null,"names.nsf");
   }

   public void NotesMain() {
      try {
         Session session = this.getSession();
         System.out.println("Database title: " +
               session.getAgentContext().getCurrentDatabase().getTitle());
      } catch (Exception e) {
         e.printStackTrace();
      }
   }
}

Document agents, using AgentContext.getUnprocessedDocuments()

Many agents is built to process the unprocessed documents of the database. This poses some problems when configuring the runtime environment for testing. This is purpose I have written a couple of utility classes to help set this up.

Stay tuned.

Free Access to Safari Books Online

I don’t know if you’re aware of O’Reilly Safari which is an online bookself. It’s a great resource – especially if you are a travelling consultant or simply need/wants online access to your books. I have been a subscriber for a while and can recommend the service. Now, in corporation with Sun Microsystems O’Reilly is offering a 30 day access, free of charge, to the system (normal trial period is 14 days). Apart from the book titles you’ll also be entitled to access to a couple of free web courses incl. “Introduction of Java Programming Language” which might be of interest to some.

“Sun now has a partnership with Safari Books Online and you can get free 30 day access to over 1700 IT online books, which includes the great Sun Press books as well as four Sun web courses.”

Free Access to Safari Books Online (via dZone):

Reading up on Eclipse

“This list is compiled from a variety of sources and is intended for anyone who wishes to find centralized reading material about Eclipse. One of the biggest challenges new Eclipse users face is where to find the right information for a task. This article provides a small step in solving that problem.”

Recommended Eclipse reading list via “Eclipse in the news”…

You might also want to check out Intelligentedu.com’s list of the Best 27 Eclipse Tutorials by IBM

Re: Do you have SWING Integrator experience?

I finally got a reply from a support representative from SWING Software and it appears that SWING Integrator doesn’t support writing formulas to Microsoft Excel. I think this is a real shame shame since it restricts its use dramatically or at least makes some functionality very difficult to implement. Of cause there might be a valid reason for this restriction.

Anyways I reimplemented the needed functionality by doing all the formatting in LotusScript. Apart from the solution being a lot longer (more lines of code) and taking more time to implement I solved the problem which is what really counts.

I have a bone to pick with the developer who decided on the Sametime error messages…

Who decided that the error message shown when trying to connect to a “limited use” Sametime server using the Sametime Connect client should be “Wrong password”? I would really like to meet that developer in a dark alley! We have spent the better part of a day trying to figure out why some clients could connect and some couldn’t. Arrgghhhh… (Of cause it would have helped if the customer had told us which Sametime server was installed but still.)

While we’re rounding up Sametime developers – maybe we should try to find the person who decided that Sametime should use hex error codes you can only find in the API documentation!

Sorry for the rant.

Do you have SWING Integrator experience?

If you have experience with SWING Integrator and Microsoft Excel, more specifically experience in writing formulas from Notes to MS Excel I would be VERY happy to hear from you. We have a major issue with an application due for launch. It seems like the SWING Integrator code removes the equal-signs in from of the formulas thus rendering them unusable in Excel.

The formula is a concatenation of two dates from the Date functions (the funny å-character is the Danish stand-in for year (år)):

=concatenate(text(date(2006;11;8); "dd-mm-åååå"); " - "; text(date(2006;11;19); "dd-mm-åååå"))

(If I remove the equal-sign in front of the formula the text is written correctly to Excel so I think the issue stems from how SWING Integrator handles formulas.)

Heeeeeelp!

Force application of mail settings

As previously reported I think I’ve found a bug in how Domino applied mail settings to users mail databases – at least when the setting requires an agent to be enabled as well (the “Allow Notes to update To Do status and dates for incomplete entries” setting on the calendar profile). For those who want to read the previous posts the first one is here (“Loving policies – especially mail settings”) and the second one is here (Re: Loving policies – especially mail settings).

I finally got around to bringing the issue up before Lotus Support and as part of the support process I learned a new AdminP command:

Tell AdminP Process Mail Policy

The command will force AdminP to apply mail settings immediately. Nice. Some might know the command already but I sure didn’t.

Show ‘n Tell Thursday: Automatically insert signature in the Notes/Domino 6/7 forum (22 June 2006)


The script is really simple. If I’m on a form in edit mode (https://www-10.lotus.com/ldd/nd6forum.nsf/*?OpenForm*) it composes the signature, inserts it in the body field and sets focus to the subject field if it’s empty (a new post) or the body field if it’s a reply. Sweet and simple.

// ==UserScript==
// @name          Notes/Domino 6/7 Forum Signature
// @namespace     http://lekkimworld.com/greasemonkey/ldd6_signature
// @description	  Inserts my LDD6/7 Forum signature
// @include       http*://www-10.lotus.com/ldd/nd6forum.nsf/*?OpenForm*
// ==/UserScript==

var e_subject = document.getElementById("Subject");
var e_body = document.getElementById("Body");

// compose signature
var signature = "nn/Mikkel HeisterbergnVisit my Notes/Domino blog " +
    "@ http://lekkimworld.comnfor posts on Notes/Domino " +
    "and how to use Java in Notes/Domino...";

// set signature
e_body.value = signature;

// set focus
if (e_subject.value == "") {
   e_subject.focus();
} else {
   e_body.focus();
   e_body.setSelectionRange(0, 0);
}

To install in Firefox you need Greasemonkey installed. Copy’n’paste the code above to a text file ending in .user.js and then drag the file onto Firefox to install. The tags at the top of the code determines the URL where the script should run, the name of the script etc.

The caveat is the call to the setSelectionRange() method to move the caret to the start of the Body textarea after setting the focus. Without this method the cursor would be at the end of the body field after the signature.

Feel free to change the script if need be…

Updated on 23 June 2006: Small change to make sure the script kicks in when connecting using HTTPS and HTTP.

Java in Notes/Domino Explained: Can I cast a null pointer?


In short – yes you can. There is nothing that prevents you from compiling the following:

String s1 = (String)null;

I even think you’ll have to do it to make your code compile for one for the methods of lotus.domino-package. I can’t of the top of my head remember which method it is, but there is one method where the compiler will force you to cast a null to a String. You’ll also sometimes end up casting a null pointer when doing dynamic classloading.

I told you it would be a short post.