Level: primary
Ian Connor
Software engineer, IBM Corporation, October 2004
Develop Java Agents for Lotus Notes / Domino with Eclipse IDE. Download and install Eclipse, then learn how easy you can use Eclipse to create projects, debug Java, Reconstruction Agents, and import agent into Domino Designer.
Java and Lotus Notes / Domino are ideal development combinations. Together, the Notes / Domino developers can make full use of all Java codes and packages currently available in Domino Designer in Domino Designer.
Eclipse is probably one of the best integrated development environments, which provides a very rich feature, including context-related operations, views, Rich Debugger and reconstruction. Reconstruction can rename, move, add, and extract Java code into a new method to mitigate the workload of the clearance of the initial encoding, make it simple and easy to read, and make the code you want to display to other developers. Reconstructing the best features of Eclipse for many development efforts.
With the ability to debug the Java agent in Lotus Notes / Domino 7, you can coordinate Lotus Notes / Domino and Eclipse, create an excellent Design to the Notes / Domino application to create an excellent Deskbi Java Agent project.
During any Lotus Workplace development, it is necessary to understand how Eclipse works. Lotus Notes / Domino 7 provides an excellent reason to start learning Eclipse now, which will use some of the operations of Notes / Domino, and increase the skills of the Lotus Workplace project in the future.
This article tells how to install Eclipse, how to create projects for Lotus Notes / Domino, and how to import this project into the Domino Java agent and debug the agent. This article also provides some techniques and traps that may encounter.
Installing EclipseWebsphere Studio Application Developer is based on Eclipse, so if Eclipse is installed, you can learn how to use WebSphere Studio Application Developer. If you do not install Eclipse or WebSphere Studio Application Developer, then you need to get these two applications. Eclipse can download free from the Eclipse foundation website. The trial version of WebSphere Studio Application Developer can also be found.
Download Eclipse or WebSphere Studio Application Developer. Eclipse is easy to install; there is an installation instructions on the Eclipse Web site. After downloading the ZIP file for Windows, you need to run the Eclipse.exe file. WebSphere Studio Application Developer is more complicated. Please refer to the appropriate document to get the installation instructions.
Note: The following steps describe Eclipse 3.0. If you have other versions of Eclipse installed, you may find that the user interface and the steps are different from those described herein.
Eclipse and Rational ClearCase Source Codes Control If you want to integrate Eclipse and Rational ClearCase source code control systems, you can download and install IBM Rational ClearCase SCM Adapters for Eclipse 2.11. Otherwise, the default source code control system is CVS. After creating a new Java project in Eclipse After installing Eclipse and all plug-ins, you can now create a project and start with this as a NOTES / DOMINO job. All Java code must be stored in one project. There can be multiple items in the workspace. There are also multiple workspaces in your computer, which can use the -Data switch of Eclipse.exe to point to different workspaces.
To create a new Java project, you need to open Eclipse, select File - New - Project. Then select Java Project in the New Project dialog, and finally click Next.
Figure 1. New Project dialog
Enter the project name and click Finish. After creating a project, you want to change the path in the project properties to point to the Notes.jar file. Right click on the project in the Package Explorer tab and select Properties. In the Properties dialog, select Java Build Path, then select the libraries. Click the Add External Jars button to navigate to the Notes.jar file to add it to the classpath.
Figure 2. Properties dialog
Once you have added JAR files, you can use the classes and interfaces defined in the project in the project. Domino Designer On-Line Help has a documentation about Notes Java API.
Then you need to download Sun 1.3.1 JRE. Or, if the Domino server is installed on your computer, you can use the JVM of the server. The Notes client and the Domino server should be matched to ensure that the JVM used by the project is the same as the proxy and programs that will run when the agent and programs are invoked from server tasks or proxy server tasks.
The current version of Lotus Notes / Domino is used by Java 1.3.1, so the software must be installed to build a project using the correct version. (Lotus Notes / Domino 7 uses JDK 1.4.) Although many Java proxy and programs can be compiled, there is no problem, but may fall into other issues, such as using a JDK version build program, running on another version. If Eclipse 3.0 is installed because it is based on Java 1.4.2, you need to delete JDK System Library and create a new library to point to JDK 1.3.1 installation. To do this, you need to select the JRE SYSTEM LIBRARY in the Properties dialog box of Libraries, and click Remove.
To add a new library, click the Add Library button. In the Add Library dialog, select JRE SYSTEM LIBRARY, and then click Next. Select the Alternative JRE option (if it has not been selected). Then click the Installed JRES button. Click Add and complete the ADD JRE dialog to add JDK 1.3.1.
Figure 3. Add JRE dialog
Save changes to the project.
Creating the first Java agent Domino Designer automatically populates the first Java agent for you at the beginning. However, Eclipse will not be like this, so it needs to create a new class to achieve the correct AgentBase interface, get Domino sessions and AgentContext objects. You can use the code in Domino Designer as a guide. Figure 4. Domino Designer Java Agent
Copy the backbone Java code directly from Domino Designer to the new class in the Eclipse project. We recommend that you create a new package and store the agent. This will help organize the project, and this is in line with the general Java design principles. To create a new package, you can choose File - New - Package.
Figure 5. New Java Package dialog
We create packages called com.ibm.notesjava.agents because it works in IBM and this is our Notes Java project. We will store agents in this package. Other common packs that can be seen are com.sun. *, Org.apache. * And core Java language function java.lang. *. As for how to organize package has a set of principles, this is not within the scope of this article, it is important to put proxy and code in the default package, because this package is messy and not professional.
There is already a new package now, so you can create a new Java class. To create a new Java class in Eclipse, you can choose File - New - Class. Eclipse is very efficient, so if you have already selected it, the Eclipse will populate the package name. You can add names and supercles here. For Notes agents, the superclass must always be Lotus.domino.agentBase. In Domino Designer, this operation is automatically made, but in Eclipse, this action must be done manually.
Figure 6. New Java Class dialog
After creating the class, you can enter the remaining proxy code to make it look like a proxy in the Domino Designer example.
Figure 7. JavaAgent in Eclipse
When building agency, create a javaagent.class file in the package directory. Now there is already a class file, we can import it into the agent in the Domino Designer and manage the code in Eclipse. In Domino Designer On-Line Help, see "Import Java" topic for more information. After importing the file into the agent, when the agent is called, you can run the Java code that has been written. You can now use the Eclipse debugger to debug the code.
Debug Java code Eclipse encapsulates the Java debugger so that you can traverse and change variables, monitor items and add breakpoints in the Java code. The first step is to load the JVM in Lotus Domino in debug mode. This can force the JVM to stop, etc., then continue its operation after an additional debugger. This feature contains this feature in Lotus Notes / Domino 6 or later. To enable this feature, you can add notes.ini variable javaenabledebug = 1, then restart the server.
The next stage is running the agent on the server and waits for the execution of the server freezing agent. After the execution of the freezing agent, the JVM will wait for the debugger to attach to the TCP / IP port 9788.
Open Eclipse and project. Select Run - Debug to open the debug dialog box and select Remote Java Application, click New to create a new debug session. Finally, in the Connect tab, the host name of the server is specified. If the server is on the debugged computer, the name of the local host is specified. Figure 8. Debug dialog
For advanced users, you can change the port number and debug settings as shown below:
Javadebugoptions = transport = dt_socket, server = y, susnd = n, address = 8000
Suspend = n No freezing server is waiting to debug connection, so you can miss the startup of the agent. This debug setting allows you to deliver additional parameters to the JVM debugger in the server. If you have your favorite settings, you can use it here.
It is best to have a breakpoint already set in the agent code. When using Eclipse to attach the code to the server in debug mode, it should be automatically disconnected and allow you to check the variables, set other breakpoints, and perform all other debug tasks you need to use.
Other Eclipse pointers now have an item in Eclipse, which provides many enhanced development and organizational tasks without large Java projects in Domino Designer. Domino Designer is suitable for smaller Java tasks, such as getting or setting multiple values or simple reports. However, once the code is started to different packages, the interface is defined and the work is commissioned to others, and the project management will become more complicated.
Eclipse contains built-in tools for collaborative work, including CVS source code control integration. The Rational ClearCase source control plugin allows you to attach to the Eclipse project stored in ClearCase. It provides automatic or instant code checking and detection, a concise modifier, so that the objects and status of the source code control can be easily identified.
Another very useful feature in Eclipse is to reconstruct the project. For example, you can select a part of the code and move it to its own method. If you have a very long way, you want to share it in a smaller step, you can automate this operation, and Eclipse can help you implement it. The following code snippet is an example of reconstruction:
Initial Function
Public void notesmain () {
Try {
SESSION session = getsession ();
AgentContext AgentContext = session.getagentContext ();
Database db;
// I am Running this, use the server - or it can assocament it is local
IF (session.getusername (). Equals ("cn = = IAN connor / ou = westford / o = IBM") == true)
DB = session.getDatabase ("support / iris", "support / retain.nsf");
Else
DB = session.getdatabase ("", "support / retain.nsf");
System.out.print (db.getfilename ());
} catch (exception e) {
E.PrintStackTrace ();
}
}
You can choose the code part you want to move to your own function, then select Refactor - Extract Method. This will determine the parameters that need to be transmitted and the data that should be returned. What you need to do is to choose a method name. You can then preview changes to see the operations you want to do. This will help you better organize the code so that others trying to understand the code easier to maintain the code. Just as all developers know, including shorter functions, concise, organized code bases, which seems to be much easier than the end, and seems to be much easier to use. Public void notesmain () {
Try {
SESSION session = getsession ();
AgentContext AgentContext = session.getagentContext ();
Database db;
DB = getretaindatabase (session);
System.out.print (db.getfilename ());
} catch (exception e) {
E.PrintStackTrace ();
}
}
Private Database Getretaindatabase (session session) throws notesException {
Database db;
// I am Running this, use the server - or it can assocament it is local
IF (session.getusername (). Equals ("cn = = IAN connor / ou = westford / o = IBM") == true)
DB = session.getDatabase ("support / iris", "support / retain.nsf");
Else
DB = session.getdatabase ("", "support / retain.nsf");
Return DB;
}
Reconstruction is the basics of all development work. We always don't want to share the first CUT of the code immediately. This is the case when using a new API or a new way. First spend a lot of time to write a small part of the code to test how it work, and then stop properly organize the code, so that the person who views the code can understand.
Conclusion Eclipse is a very useful platform that Notes developers can use in their current and future projects. It helps developers to better organize projects, share code with others in the group, and better utilize Java design techniques, such as interfaces and code separation. With the integration of Lotus Workplace and Lotus Notes / Domino, Java and Eclipse will play an important role. Notes developers can now build with their own mergers and group skills, but also prepare for future challenges.
New products or work methods must have some important functions and advantages to ensure that people are willing to adopt the product or method. For Notes developers who must submit a good written application, the NOTES developers who provide quality Java code, Eclipse provides debugging, reconstruction, and source code control. All of this is important in any important development, which will ensure that you spend time learning how to use Eclipse for Notes development compared to get the results.
Reference
You can see this article in our website on our world. Download Eclipse from the Eclipse Web site. Download the trial version of WebSphere Studio Application Developer. Download IBM Rational Clearcase SCM Adapters for Eclipse 2.11. Regarding the author Ian Connor is an IBM's maintenance software engineer, he cooperates with external support group to solve the problems encountered in support work. IAN also handles Lotus Team Workplace (QuickPlace) issues, for a while, he worked directly to the Lotus Team Workplace team, processing upload control, programmetry, web services, and notes integration. Ian likes to raise chickens, skiing, travel, and accompanying wife. At present, in order to repair his 1874 houses in the Compensation of Maizhou, he has already learned the personal goal of empty philosophy.