Java expands on Domino servers: Let Domino have facing features

xiaoxiao2021-03-06  39

Let Domino have face-oriented features

Summary: This article applies aspectj to the development of Notes database on the Domino server.

Thus, it is achieved that Domino has some purposes for aspective features.

Keywords: Lotus Domino / Notes, Lotus Domino Diiop for Java, Aspectj.

How to apply AspectJ to Domino to develop, so that Domino has some views of the characteristics and is the purpose of writing this article. The authors in the article are sorted by AspectJ in the Domino project, simplifying - provides a brief introduction to beginners. The source code of the instance is provided at the end of this article.

The following steps are explained:

Step 1: AspectJ development environment configuration

In actual project development, since the current Aspectj integrated development environment is small, the author chooses the simplest and currently effective development tools: editplus. Before using EditPlus, you will be as follows:

D: /J2SDK1.4.2_02/jRE/Lib/rt.jar; D: /J2SDK1.4.2_02/lib/tools.jar; d: /aspectj/lib/aspectjrt.jar; D: / aspectj / lib / aspectjtools. JAR; D: /LOTUS/domino/Notes.jar; D: /lotus/domino/data/domino/java/ncso.jar

The author's Domino server is installed in D: disk, Java SDK is also d: disk, the same aspectj v1.2 is also unzipped in D: disk.

Next, set EditPlus to facilitate development, enter the [Tools] menu, [Select User Tool]:

GROUP 1:

Javac

(

Command: d: /j2sdk1.4.2_02/bin/javac.exe

Parameters: -d "." $ (Filename)

)

Next, complete the "AspectJ" entry settings:

Aspectj

(

Command: d: /aspectj/bin/ajc.bat

Parameters: -d "." -ARGFILE FILES.LST

)

Step 2: Using Editplus to develop in Domino Agent

The Notes database Aspectjtest agent is as follows:

Import Lotus.domino. *;

Public Class JavaAgent Extends AgentBase

{

Public void notesmain ()

{

Try

{

SESSION session = getsession ();

AgentContext AgentContext = session.getagentContext ();

Your code Goes here

OUTPRINTER ();

}

Catch (Exception E)

{

E.PrintStackTrace ();

}

}

Public void outprinter ()

{

System.out.Println ("Outprinter () Work!"); / / Output to Domino Console

}

}

Aspects with the agent are as follows:

Aspect aspectjtest

{

/ / Define the Outprinter () method in the cut point mycut () capture agent () method

Pointcut mycut ():

Call (public void outprinter ());

// Notice before the cut point arrives

Before ():

Mycut ()

{

/ / Output to Domino Console

System.out.println ("... before ...");

}

}

Analysis of these two program code can be seen: If the AspectJtest agent is running normally, then "... Before ..." before outputting "Outprinter () Work!", This may be our purpose.

Step 3: Produce files.lst files and complete compilation

This file is a text file, and some of the Group AspectJ compilers complete the make-file feature. It should be noted here that the author lives in EditPlus, and JavaAgent.java, aspectjtest.java files are put together.

D: / askAPRO directory.

Next you can select the [AspectJ] entry to press the [Tools] menu to compile this proxy with aspective features. Generate javaagent.class and aspectjtest.class files. Of course, you can also compile them with the following command line: AJC -D "." -Argfile files.lst

This requires you to make a corresponding PATH setting: Ajc.bat is in the D: / aspectj / bin directory.

Step 4: Create Database Test.nsf and Test Forms and AspectJtest Agents

Create a TEST.NSF database on the server and create a TEST form in the Test.nsf database, put a button in the TEST form. With "aspectj test", the formula of the button is @Command ([Toolsrunmacro]; "aspectjtest")

Step 5: Establish an AspectJtest agent

Note When you create an AspectJtest agent, you must be as follows:

Agent name: aspectjtest

Running Selection: Agent List Selection.

TAGET :: None

Next, select [Imported Java] and [REIMPORT CLASS Files] to introduce class files: aspectjrt.jar, aspectjtest.class, javaagent.class.

Note that this D: /ASPECTJ/LIB/ASpectjrt.jar is copied to the D: / aspectJPro directory.

Browse the form TEST in the browser and press the button "Aspectj Test", you will see the output in the Domino Console:

"... before ..."

Outprinter () Work! "

We see "... Before ..." output "Outprinter () Work!" Is our purpose.

This document is working properly and very stable in Lotus Domino R6.5.

Conclusion: This article successfully introduced AspectJ-oriented language in Domino, although simply, Domino can have some face-oriented features.

Self introduction:

Sheng Zhongli, male, started software development in 1988, proficient in multi-door computer language, deep understanding of software systems. It is mainly concentrated in the enterprise-class distributed calculation of Domino and J2EE, which is mainly based primarily for AspectJ and an enterprise-level promotion application and project implementation. Interested friends can send an email to quzhongwei@126.com Tel: 13008687769, QQ: 308742908

转载请注明原文地址:https://www.9cbs.com/read-76571.html

New Post(0)