Create a Java proxy in Lotus designer 8.5

Source: Internet
Author: User

In developmentLotusDominoDatabaseDevelopers can createJavaAgent)ProgramTo integrate Lotus Notes Java APIs and any third-party Java class libraries into the domino database, making the Notes database highly scalable. In Domino designer 8.5.1, the eclipse development environment is integrated for Java proxy development. This article describes how to use Domino designer 8.5.1 to develop a Java agent dependent on a third-party Java class library through a specific application case, this article describes how to deploy event-based and scheduled proxies.

Application Environment Analysis

We need to transform an existing Notes database, which has a series of views. Some views contain documents that contain Excel attachments in a unified format. We need to extract Excel attachments from these notes documents in batches and save the data in the Excel filesDB2Database.

Customers have two different requirements. One is to manually select the Notes document to be processed, and the other is to execute the batch processing program at a fixed point in time each month, batch process the notes documents meeting specific conditions. For both of these requirements, we can achieve this by establishing a Java proxy program.

Use Domino designer 8.5.1 to create a Java proxy

Open the Notes database file testnsf in Domino designer 8.5.1. nsf: Expand the code node, right-click the agents node, select "new agent" from the menu, select "Java" in the displayed dialog box, and name it "dataextractionagent ". 1:

Figure 1. Create a Java Agent

The system automatically creates the javaagent. Java file in the default package, which extends the Lotus. Domino. agentbase class and reloads the notesmain () method.

Listing 1. Java proxyCodeExample

Public void notesmain () {try {session = getsession (); agentcontext = session. getagentcontext (); // (your code goes here)} catch (exception e) {e. printstacktrace ();}}

The Session object can be used to obtain the Notes database or other database objects of the current agent, and call the notes Java API to perform operations such as adding, deleting, modifying, and querying database documents and reading metadata.

AgentcontextThe object is the runtime environment object of the Java proxy. It can be used to obtain the list of documents of the user-selected Notes database and other objects. When the Java proxy is triggered, the notesmain () method of the agentbase class is called.

Next, we can create other Java packages and classes in the Java proxy. If we need to call a third-party Java API in the Java proxy program, we can copy the dependent Java class library to the LIB/ext directory of the notes or Domino built-in JVM.

Switch to the Java view in Domino designer and find that dataextractionagent exists as an independent Java project. The newly added Java class library, agent, can be seen under Domino Java library. jar contains the business logic for reading data from the Excel file and saving it in the DB2 database. The two jar packages starting with DB2 provide APIs for operating the DB2 database.

Figure 2. display of Java proxies in the Java package View

In the Java view, you can easily complete Java proxy program development, and then return to the domino designer view to execute the Java proxyTest.

Select the agents item under the Code node, get a list of all agent programs in the form on the right, right-click dataextractionagent, and select "run" to trigger the running of the agent program.

Figure 3. Test the Java Agent

The running result is a log dialog box prompting the execution of the agent.

Figure 4. Java proxy program running status

There are two ways to trigger a proxy: menu call and scheduling. The menu-called Java proxy can be deployed on the Notes client or Domino server, while the scheduled Java proxy can only run on the Domino server.

Debug Java proxies

You can use Domino designer to debug the newly created Java agent.

Select Java agent in the domino designer view, select the Security page in the Properties tab below, and select "compile Java code with debugging information ".

Figure 5. Set the debugging information of the agent program

Open the Tools menu, select Java debugging preferences, check "client agents/applets", and set the port number.

Figure 6. Set Java proxy debugging Parameters

Create a remote Java application debugging configuration, as shown in figure 7. Set host to localhost and port to 8701.

Figure 7. configure remote Java application debugging

Add a breakpoint in the notesmain () method of Java agent, and start debugging through the toolbar.

Figure 8. Start Java proxy debugging

Switch to the debug view and find that the remote debug connection has been established. Go to the Notes client, trigger the running of the Java proxy, and open the breakpoint, so you can debug it.

There are two types of triggering mechanisms for Java Proxy: one is event triggering and the other is timed triggering.

Call Java agent in the Notes View

On the basic attributes page of the Java agent, select "on Event" as the trigger mode at run time, and select "Agent list selection" from the drop-down list below ".

Figure 9. Set Java proxy program triggering

Create an action in the action list in the Notes view and name it "extract data". Edit the attribute of the action to display it in the tool menu. Double-click the action, set the business logic of the Click Event and run it on the client. The called program is "Notes formula:

Figure 10. Compile a formula for calling a Java proxy Program
 

Deploy a Java proxy program that is regularly called on the Domino server

Use Domino designer to complete Java proxy development and deploy it to the Notes database on the server. Set the call mechanism to regular call. When saving, the following dialog box is displayed, indicating that the current developer does not have sufficient permissions to deploy the Java agent on the server.

When we set the Java proxy to scheduled execution, we also needServerTo open the domino administrator, select the rightmost Configuration tab, and select the Security page in the lower-right workspace. SetManagementMember's Notes ID is added to the domain "sign or run restricted Lotus script/Java agents. If the Java agent needs to write files in the file system on the server side, add the Administrator's Notes ID in the full access administrators field. Save the modification.

Figure 11. Configure the permissions for the Java agent to run on the Domino server

Summary

This article describes how to develop Java proxies in Lotus Domino designer 8.5.1 and call third-party class libraries in Java proxies, in addition, the methods for debugging the Java proxy and the key points for deploying the Java proxy to the Domino server are introduced, which has some reference value.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.