Choosing a Java Solution in Domino

We've just begun to scratch the surface of Java, and there is still a lot to learn ”streams, threads, packages, JAR files, serialization, abstract classes, nested classes, inner classes, anonymous classes, adapters, listeners, and resources, to say nothing of the hundreds of classes and interfaces in the Java 1.3 class library. But this is a book about Domino, and many great books on Java are available to help you learn more about it. That said, let's explore the many ways you can use Java to develop Domino applications.

You have about a dozen ways to deploy and run Java code in a Domino network, making it the most flexible and extensible programming option available. You can use Java to make agents , applets, servlets, and applications. Your code can run from Notes clients , Domino servers, Web browsers, and remote computers without Notes or Domino installed. Choosing among the many options might seem mystifying at first, but fear not: There's a lot of overlap in what you must learn.

Which option you choose depends primarily on three factors: where you want to put your code, how you want to start it, and where you want it to run, as shown in Table 18.2.

Table 18.2. Java Usage in Domino

Type Code Kept Starts From Runs On
Agent Notes database Notes, event, or URL Notes client, Domino server
Applet Notes DB or file system URL Notes client, browser
Servlet Domino or Web server URL Domino or Web server
Application File system Command line Any JRE

Agents

Java agents work just like their LotusScript counterparts and have many benefits. First, agents are stored in Notes databases, so they can be replicated like any other design element. Agents also have the most flexible start options of the four Java program types. An agent can be launched manually from either the Notes client or a Web browser; it can be run on a schedule or in response to an event such as email arriving or a document changing; it can be run from another agent; or it can be called by a URL if running on a Domino server. Agents started manually from a Notes client run within the client's JVM. Agents that start automatically can execute on any Domino server you choose, as long as the agent signer has the permission to run agents.

A primary benefit to using agents is security. Each agent is digitally signed by the author each time it's modified, which prevents unscrupulous tampering. The signature is also used to determine access rights. Agents executing within a Notes client use the access rights of the current Notes user .

When an agent runs on a server, you have three options to control the authority under which it runs. By default, the agent runs with the authority of the developer who signed it. However, you can also set a flag that makes agents launched over the Web run with the authority of the Web user who launched it. The final option, Run Agent on Behalf Of, is new in Domino 6; it allows you to specify a user whose authority should be used when running the agent. It is worth noting that the user named here must be in the database ACL.

There are two drawbacks to using Java agents. First, they can't interact with users. The Java binding lacks the front-end classes of the NOI, such as LotusScript's NotesUIDocument . This essentially cuts you off from being able to display information or gather new information from users while your agent is running. The second drawback is that agents must execute on machines with Notes or Domino installed. The other three program types can execute remotely using CORBA.

Applets

Applets are small Java programs that run within larger applications such as a Web browser or a Notes client. You've probably seen them while browsing the Web. The big thing about applets is that they're downloaded on the spot and run within the JVM contained within your application. This enables you to deploy your Java code in one common location, ensuring that all users run the most current version. Because of their "download on demand" nature, applets are the best way to access Domino servers remotely via CORBA.

Downloading someone else's code and running it on your machine can be a scary thing, which is why Java applets are usually forbidden from accessing your hard disk or printing a file. Applets that are subject to such restrictions are called untrusted applets. If your applet needs special access, it can be digitally signed to indicate its origin, although each user must still approve its use before it becomes a trusted applet.

The best time to use applets in a Notes/Domino environment is when you want to make a custom user interface and have it be equally accessible from both Notes clients and Web browsers. You can write an applet to present a consistent, customized interface to both sets of users. You also gain the benefit of Java's extensive windowing environment, as well as access to numerous third-party tools and components .

Applets let you present a secure, professional, and universally accessible Domino client that sidesteps the administrative hassles of installation, upgrading, and maintenance. So why use anything else? The main drawback is that large applets can take a long time to download to a browser, particularly over a slow modem connection. Newer browsers will cache your code after it's downloaded, which helps speed up things the second time, but for many, it's that first impression that sells the show. As such, applets are usually best kept small if users will be connecting at slow speeds.

Servlets

Servlets are the server-side equivalent of applets: small Java programs that run within a Domino server or a Web server. They're executed as a result of a Web browser request, such as when a user fills out a form and clicks Submit. The information in the form is passed to the servlet, which then generates a response page and returns it to the browser.

Servlets perform roughly the same function as traditional CGI programs, which are typically written in languages such as Perl or C. Although Domino allows you to use CGI programs, servlets offer much better performance. They're loaded once and start a new thread for each request, whereas CGI programs start and stop a new process each time. This can be costly, particularly if dozens of people hit the same page at the same time.

Domino agents can also be used to serve up dynamic pages. This is useful if you have limited access to the file system on your Domino server. Like CGI programs, agents start up and shut down with each request, so they're less efficient. Another drawback is that agents lack the capability to remember session state from page to page, wheras servlets use cookies to keep track of user sessions; your servlets can process multipage interactions, such as those found in shopping cart applications, much more easily.

You can also put servlets on a regular Web server and have them use CORBA to remotely access information on separate Domino servers. This can be useful when your corporate Web site is outside your firewall and you want to better control access to internal servers.

Applications

Java applications are full-fledged standalone programs that run in their own JVM. They're usually started from the command line, but they can easily be associated with a desktop icon or menu shortcut in your operating system.

The benefit to using Java applications is that you can create larger programs that make full use of Java without worrying about download time or UI restrictions. Because they can use CORBA to remotely access Domino servers, Java applications are great for enhancing your Domino network with full-featured standalone GUI clients or quick command-line tools.

The drawback to Java applications is deployment. Like most programs, they must be installed on individual machines. This makes administration more difficult. You must also find and use an existing JVM on each machine during installation or install a platform-specific one. Sun Microsystems allows free distribution of its Java Runtime Environment (JRE) for Windows and Solaris. Check out http://java.sun.com. Even better, use a product such as InstallAnywhere, which creates platform-specific installers for your program that first check for an existing JVM and install one if necessary.

Part I. Introduction to Release 6

Whats New in Release 6?

The Release 6 Object Store

The Integrated Development Environment

Part II. Foundations of Application Design

Forms Design

Advanced Form Design

Designing Views

Using Shared Resources in Domino Applications

Using the Page Designer

Creating Outlines

Adding Framesets to Domino Applications

Automating Your Application with Agents

Part III. Programming Domino Applications

Using the Formula Language

Real-World Examples Using the Formula Language

Writing LotusScript for Domino Applications

Real-World LotusScript Examples

Writing JavaScript for Domino Applications

Real-World JavaScript Examples

Writing Java for Domino Applications

Real-World Java Examples

Enhancing Domino Applications for the Web

Part IV. Advanced Design Topics

Accessing Data with XML

Accessing Data with DECS and DCRs

Security and Domino Applications

Creating Workflow Applications

Analyzing Domino Applications

Part V. Appendices

Appendix A. HTML Reference

Appendix B. Domino URL Reference



Lotus Notes and Domino 6 Development
Lotus Notes and Domino 6 Development (2nd Edition)
ISBN: 0672325020
EAN: 2147483647
Year: 2005
Pages: 288

Flylib.com © 2008-2020.
If you may any questions please contact us: flylib@qtcs.net