Java's expansion on Domino servers: giving Domino the aspect-oriented features

Source: Internet
Author: User
Tags command line create database
Dom| Server Summary: This article applies aspectj to the development of the Notes database on the Domino server,

This enables Domino to have some aspect-oriented features.



Keywords: Lotus domino/notes, Lotus Domino diiop for Java, AspectJ.





The purpose of this paper is how to apply ASPECTJ to Domino's development so that Domino has some features to face. Based on the actual application of ASPECTJ in Domino project, the author makes a brief introduction for beginners. The source code for the instance is provided at the end of this article.

Here's a step-by-step explanation:



The first step: ASPECTJ Development environment Configuration

In the actual project development because of the present ASPECTJ integration development environment is very few, therefore the author chooses the simplest is also the present more effective development tool: EditPlus. Before using EditPlus, set the Classpath 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 on D: Disk, the Java SDK is also in D: disk, likewise AspectJ v1.2 is also unzipped installed in D: disk.

Next, set up editplus for easy development, go to the Tools menu, and the Select Configuration User tool appears:



Group 1:

Javac

(

Command: D:\j2sdk1.4.2_02\bin\javac.exe

Parameters:-D "." $ (FileName)

)



Next complete the "AspectJ" entry setting:

Aspectj

(

Command: D:\aspectj\bin\ajc.bat

Parameters:-D "." –argfile Files.lst

)



Step two: Using EditPlus in Domino agent development

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 the Domino console

}

}

And the agent supporting the following aspects:

Aspect Aspectjtest

{

Define the Outprinter () method in the Pointcut mycut () Capture agent

Pointcut Mycut ():

Call (public void outprinter ());

Notify before the tangency Point arrives

Before ():

Mycut ()

{

Output to the Domino console

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

}

}

Analysis of these two pieces of code is known: if the aspectjtest agent is running properly, then in the Domino console output

"Outprinter () work!" Before the output "... before", and this may be our purpose.



Step three: Make Files.lst file and finish compiling

The file is a text file, and some of its groups aspectj the compiler to complete the Make-file function. Here to note that: the author in the EditPlus to generate Files.lst files, and Javaagent.java, Aspectjtest.java file together are placed in

D:\aspectjpro directory.

Next you can select the "AspectJ" item on the "Tools" menu to compile the agent with aspect-oriented features. Generate Javaagent.class and Aspectjtest.class files. Of course, you can also manually compile them with the following command line: ajc-d "."-argfile Files.lst

This requires you to make the appropriate path settings: Ajc.bat in the D:\aspectj\bin directory.



Step Fourth: 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, and put a button in the Test form. Takes "AspectJ Test" as the name, and the button's formula is @command ([Toolsrunmacro]; "Aspectjtest")


Fifth step: Establish Aspectjtest Agent

Note that when establishing a aspectjtest agent, you must make the following selections in the proxy properties:



Agent Name: Aspectjtest

Runtime selection: Agent List selection.

Taget::none



Next, select "Imported Java" and "Reimport class files" to introduce the class file: Aspectjrt.jar, Aspectjtest.class, Javaagent.class.



Note that the D:\aspectj\lib\aspectjrt.jar is copied to the D:\aspectjpro directory here.



Browse the form test in the browser and press the button "AspectJ test" and you will see the output in the Domino console:

"... before ..."

"Outprinter () work!"



We see the "... before" output substituting "outprinter () work!" Ago, this is also our purpose.



This program example works well under Lotus Domino R6.5 and is very stable.



Conclusion: This article has successfully introduced the ASPECTJ-oriented language in Domino, although it is simple but demonstrates that domino can have some aspect-oriented features.





Related Article

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.