Use Eclipse IDE to develop Java proxies for Lotus Notes/Domino. Download and install eclipse, and then learn how easy it is to use eclipse to create a project, debug Java, refactor the proxy, and import the proxy to Domino designer.
Java and Lotus Notes/Domino are ideal development combinations. By combining them, the Notes/Domino developers can make full use of all currently available Java in Domino designer.CodeAnd package.
Eclipse is probably one of the best integrated development environments. It provides rich features, including context-related operations, views, and rich debugging.Program(Rich debugger) and refactoring. Refactoring can rename, move, add, and extract Java code to a new method to reduce the workload of clearing the initial encoding attempt and make it easy to read, and make it the code you want to display to other developers. For many development jobs, refactoring is the best feature of Eclipse.
With the ability to debug Java agents in Lotus Notes/Domino 7, you can now coordinate Lotus Notes/Domino and eclipse, create a well-designed Java proxy project for the notes/Domino application.
For any Lotus Workplace Development, you must understand how eclipse works. Lotus Notes/Domino 7 provides an excellent reason to start learning eclipse now. You can use it for notes/Domino operations to increase your skills that can be applied to Lotus workplace projects in the future.
This article describes how to install eclipse, how to create a project for Lotus Notes/Domino, how to import the project to the domino Java proxy, and then debug the proxy. This article also provides some tips and possible traps for debugging these proxies.
The installation of eclipse WebSphere Studio Application Developer is based on Eclipse, So If eclipse is installed, you can follow this article to learn how to use WebSphere Studio application developer. If eclipse or WebSphere Studio Application Developer is not installed, You need to obtain the two applications first. Eclipse can be downloaded from the eclipse basic website for free. The trial version of WebSphere Studio Application Developer can also be found.
Download eclipse or WebSphere Studio application developer. Eclipse is easy to install. Installation instructions are provided 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 complex. See the relevant documentation for installation instructions.
Note: The following steps describe eclipse 3.0. If you have installed other versions of Eclipse, you may find that the user interface and steps are different from those described in this article.
Eclipse and rational clearcaseSource codeTo 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 Java project in eclipse and installing eclipse and all plug-ins, you can now create a project and use it as the start of the work of Notes/Domino. All Java code must be stored in one project. You can have multiple projects in the workspace. You can also have multiple work zones on your computer. You can use the-data switch of eclipse.exe to point to different work zones.
To create a new Java project, open eclipse and select File-New-project. Select a Java project in the new project dialog box, and click Next.
Figure 1. New Project dialog box
Enter the project name and click Finish. After creating a project, you need to change the path in the project properties to point it to the notes. jar file. Right-click the project in the package explorer tab and select Properties. In the Properties dialog box, select Java build path and then select the "Libraries" tab. Click Add external jars and navigate to the notes. jar file to add it to the class path.
Figure 2. Properties dialog box
After the JAR file is added, you can use the classes and interfaces defined by the notes Java API in the project. Domino designer on-line help contains documents on notes Java APIs.
Next, you need to download sun 1.3.1 JRE. Alternatively, if the Domino server is installed on the computer, you can use the JVM of the server. The Notes client and Domino server should match each other to ensure that the JVM used for building the project is the same as that used for calling the slave server task or proxy server task.
The current version of Lotus Notes/Domino uses Java 1.3.1. Therefore, you must install the software to build the project using the correct version. (JDK 1.4 is used for Lotus Notes/Domino 7 .) Although many Java proxies and programs can be compiled, there is no problem, but it may fall into another problem. For example, if you build a program using one JDK version, it runs on another version.
If eclipse 3.0 is installed, because it is based on Java 1.4.2, You need to delete the JDK system library and create a new library to point to JDK 1.3.1 for installation. To perform this operation, select the JRE system library in the Properties dialog box of the libraries tab and click Remove.
To add a new library, click Add library. In the Add library dialog box, select JRE system library and click Next. Select the alternative JRE option (if not selected ). Click the installed jres button. Click Add and complete the Add JRE dialog box to add JDK 1.3.1.
Figure 3. Add JRE dialog box
Save the changes to the project.
The first Java proxy Domino designer is automatically filled with the first Java proxy at the beginning. However, eclipse does not. Therefore, it needs to create a new class to implement the correct agentbase interface and obtain the domino session and agentcontext object. You can use the code in Domino designer as a guide.
Figure 4. Domino designer Java proxy
Copy the backbone Java code from the domino designer to a new class in the Eclipse project. We recommend that you create a new package and store the proxy in it. This will help organize projects, and this complies with General Java design principles. To create a new package, select File-New-package.
Figure 5. New Java package dialog box
We created a package named com. IBM. notesjava. Agents because it works in IBM and is our notes Java project. We will store the proxy in this package. Other common packages are com. Sun. *, org. Apache. *, and Java. Lang. * of core Java language functions .*. As for how to organize a package, there is a set of principles, but this is not covered in this article. It is important not to place the proxy and code in the default package because the package is messy and unprofessional.
Now you have a new package, so you can create a new Java class. To create a new Java class in eclipse, select File-New-class. Eclipse is very efficient, so if you have selected a package, eclipse will fill in the package name.
You can add names and superclasses here. For the notes agent, the superclass must always be Lotus. Domino. agentbase. In Domino designer, this operation is performed automatically, but in eclipse, you must manually complete this operation.
Figure 6. New Java class dialog box
After creating a class, you can enter the remaining proxy code to make it look the same as the proxy in the domino designer example.
Figure 7. Java agent in eclipse
When a proxy is built, the javaagent. Class file is created in the package directory. Now that you have a class file, you can import it to the proxy in Domino designer and manage the code in eclipse.
In Domino designer on-line help, see the "Import Java" topic for more information. After the file is imported into the proxy, when the proxy is called, you can run the written Java code. Now you can use the eclipse debugging program to debug the code.
Debugging Java code eclipse encapsulates Java debugging programs, allowing you to traverse and change variables, monitor items, and add breakpoints in Java code. The first step is to load the JVM in Lotus Domino in debug mode. In this way, you can force the JVM to stop and wait until the debugging program is attached to it to continue its operation.
Lotus Notes/Domino 6 or later versions include this feature. To enable this feature, you can add the notes. ini variable javaenabledebug = 1 and restart the server.
The next stage is to run the proxy on the server and wait for the server to freeze the proxy. After the agent is frozen, JVM will wait for the debugging program to be appended to the TCP/IP Port 9788.
Open eclipse and projects. Select Run-Debug to open the debug dialog box, select remote Java application, and click New to create a new debugging session. Finally, in the connect tab, specify the name of the server host. If the server is on the computer to be debugged, specify the name of the local host.
Figure 8. debug dialog box
For advanced users, you can change the port number and debugging settings as follows:
JavaDebugOptions=transport=dt_socket,
server=y,
suspend=n,
address=8000
Suspend=n
|
The server is not frozen to wait for the debugging connection, so you can miss the startup of the agent. This debugging setting allows you to transmit additional parameters to the JVM debugging program on the server. If you have your favorite settings, you can also use them here.
It is best to set a breakpoint in the proxy code. When you use eclipse to append the code to the server in debug mode, it should be automatically disconnected and allow you to check the variables, set other breakpoints, and execute all other debugging tasks that need to be used.
Other eclipse pointers
Eclipse now has a project, which provides many enhanced development and organization tasks not available for large Java projects in Domino designer. Domino designer is applicable to small Java tasks, such as obtaining or setting multiple values or simple reports. However, once the code is divided into different packages, the interface is defined, and the work is delegated to others, project management becomes more complex.
Eclipse contains built-in tools for collaborative work, including CVS source code control integration. The rational clearcase source code control plug-in allows you to attach to an Eclipse project stored in clearcase. It provides automatic or real-time code check-in and check-out, simple modifiers, so that you can easily identify the objects in the source code control and their States.
Another very useful feature in eclipse is the ability to refactor projects. For example, you can select a part of the code and move it to its own method. If you have a very long method and want to divide it into smaller steps, you can automate this operation. eclipse can help you achieve this automation. The following code snippet is an example of refactoring:
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 assume 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 select the code part of the function to be moved to, and then select refactor-extract method. This will determine the parameters to be transmitted and the data to be returned. All you need to do is select the method name. You can preview the changes and view the operations you want to perform. This will help you better organize the code and make it easier for others who try to understand the code to maintain the code. As all developers know, code base contains short functions, concise, and well-organized code base) it is much easier to use than a very long 1000-row function that does not seem to end.
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 assume 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;
}
|
Refactoring is the basic part of all development work. We are always reluctant to share the first cut of the Code immediately. This is especially true when using new APIs or working methods. First, it takes a lot of time to write a small part of the code to test how it works. Then, when the code can be run, it stops to properly organize the code so that the people who view the code can understand it.
Conclusion
Eclipse is a very useful platform for Notes developers to use in their current and future projects. It helps developers better organize projects, share code with others in the group, and better utilize Java design technologies such as interfaces and code separation.
As the integration of Lotus workplace and Lotus Notes/Domino increases, Java and eclipse will play an important role. Notes developers can now build on their own merging and grouping skills, while preparing to cope with future challenges.
New products or work methods must have some important functions and advantages to ensure that people are willing to adopt such products or methods. For Notes developers who must submit well-written applications that provide high-quality Java code, eclipse provides debugging, refactoring, and source code control.
All of these are important functions in any important development work, and they will ensure that you spend time learning how to use eclipse for notes development is worthwhile compared to the results.