Complete Contents
Introduction
Chapter 1 About Netscape Application Server Extensions
Chapter 2 About the Netscape Extension Builder
Chapter 3 Introduction to Netscape's Interface Definition Language
Chapter 4 Designing a Netscape Extension
Chapter 5 Generating Output Files
Chapter 6 Completing Method Stubs
Chapter 7 Using Template Streaming
Chapter 8 Managing State and Session Information
Chapter 9 Using Object Pools
Chapter 10 Compiling the Extension Source Code
Chapter 11 Deploying and Managing a Netscape Extension
Chapter 12 Example Extension: HelloWorld
Appendix A C++ Helper Functions
Appendix B Java Helper Static Methods
Appendix C Java Class Decorations
Appendix D Reserved Words
Appendix E The ConnManager.cpp File
Glossary
Previous Next Contents Index


About Netscape Application Server Extensions

This chapter describes Netscape Application Server extensions, which provide an important service in applications by allowing Java application components to access third-party solutions, legacy systems and shared services.

The following topics are included in this chapter:


What is a Netscape Application Server Extension?
A Netscape Application Server (NAS) extension provides an important service in Netscape Application Server applications by allowing Java application components to access third-party solutions, legacy systems and shared services. A Netscape Application Server extension allows these technologies, which do not typically conform to the Netscape Application Server architecture, to be integrated into Netscape Application Server applications without rebuilding the original functionality. In addition, Netscape Application Server extensions provide a bridge between different architectures, allowing older technology to take advantage of new technology, often adding performance and reliability to existing applications.

A Netscape Application Server extension is similar to the Netscape Application Server application services built into the server, such as the Data Access Service, the State and Session Management Service and the Transaction Management Service. Both Netscape Application Server extensions and Netscape Application Server services are accessed by Java application components through exposed interfaces. The main difference between a Netscape Application Server extension and the Netscape Application Server services is that you must define what the extension does whereas the services are defined for you.

Netscape Application Server extensions can be written in C++ or Java. Java extensions can be accessed from Java clients, which are application components written in Java. Similarly, C++ extensions can be accessed from C++ clients, which are AppLogic objects written in C++. Java clients can also access C++ extensions, provided you enable the Java Access Layer for the C++ extensions. More details about choosing the extension language and using the Java Access Layer are provided in later sections of this guide.


About the NAS Application Model
The NAS application model is the conceptual division of a software application into functional components. For Java applications, the model incorporates standard components based on Java technologies such as servlets, JavaServer Pages (JSP), Enterprise JavaBeans (EJB) and any other Java class.

If an application is written C++ or if it will run in the NAS 2.x environment, application components include AppLogics. An AppLogic is a set of programming instructions, written in C++ that perform a well-defined, modular task within an application.


How Extensions Relate to NAS Application Model
A Netscape Application Server extension is a middle-layer service that resides within Netscape Application Server. An extension fits between components of an application and the piece of software code you are integrating into the Netscape Application Server application. Application components call into the extension using the exposed interfaces and corresponding method calls. These method calls then map into the appropriate part of the extended technology. The following diagram illustrates the location of the Netscape Application Server extension relative to the application components (the circles in the center core of Netscape Application Server) and the existing technology, whether a third-party or legacy solution.



The illustration depicts the legacy or third-party technology as separate from Netscape Application Server. This is because such technology is outside of the Netscape Application Server context. The Netscape Application Server context is where services are loaded into Netscape Application Server so the server can interact with those services.

Access to the third-party or legacy technology is provided through the Netscape Application Server extension, which, like the pre-built Netscape Application Server services, is a part of Netscape Application Server context. A Netscape Application Server extension becomes part of the Netscape Application Server context through a manager class, which is explained later in this guide.


Why Build an Extension?
Building a Netscape Application Server extension is useful for quickly and efficiently integrating existing functionality and reusable services into Netscape Application Server so you can provide that functionality or service to users through a high performance Netscape Application Server application. A Netscape Application Server extension enables you to extend the functionality of Netscape Application Server to do the following:

Integrate Existing Functionality
Netscape Application Server extensions provide a means of integrating legacy code and existing client/server solutions into a new Netscape Application Server application. This can save you tremendous time and money because you do not have to re-create these solutions when building a new Netscape Application Server application.

For example, you might have a CICS/mainframe application providing services to your company's employees. This application is running on expensive hardware and required many engineering hours to build. The investment in this application is not trivial and warrants concern about migrating to a new application server technology. To preserve this investment, you can build a Netscape Application Server extension that provides the layer that allows application components to call into the legacy code.

Integrate Third-Party Solutions
Third party companies have developed many of the necessary technologies used in Web applications, such as credit card billing, membership and order-fulfillment services, and so on. Rather than re-create these technologies within Netscape Application Server application components, you can encapsulate access to this functionality within a Netscape Application Server extension and allow the application components to call into the third-party technology through the extension.

For example, a typical electronic-commerce application consists of many technologies such as credit card billing, customer fulfillment, order verification and tracking, and database access and record retrieval. For such an application, Netscape Application Server provides the best technology for user access, verification of whether a product is available (through database access), and customer order tracking. Netscape Application Server also provides many performance enhancing functionalities such as load balancing and ease of scalability.

For the credit card billing and customer fulfillment services, this functionality already exists. Therefore, it makes more sense to extend that functionality to the Netscape Application Server application, rather than build it again.

Implement Shared Services
Building a Netscape Application Server extension is also useful for implementing core functionality as a service that is accessible to multiple applications and across multiple servers.

The following list highlights key features that make extensions more appropriate than application components for implementing services:

Extensions should be used as base services that are independent of any presentation logic, such as input validation or calls to the Netscape Application Server Template Engine. Use application components as the presentation layer between the client and the service or services you are implementing in an extension.


About Building a Netscape Application Server Extension
This section provides an overview of the process of building a Netscape Application Server extension. The details of these procedures follow in the subsequent sections of this guide.

Define the API
The first step in creating a Netscape Application Server extension is to define the API that will be available to the Netscape Application Server application components and, possibly, other extensions. The interfaces of this extension API are the access points between the application components and the technology being integrated.

For example, the interfaces in legacy and third-party technologies that are exposed to clients should be redefined in the Netscape Application Server extension. By doing so, you make that technology accessible to application components, and/or other extensions, as depicted in the following illustration:



Also depicted in the illustration are the extension classes, called coclasses at design time, that compose the remainder of the extension. Coclasses implement the interfaces you define.

Design the Interfaces and Coclasses
The next step in creating a Netscape Application Server extension is to design the interfaces that compose the extension's API as well as design the coclasses that become the extension classes.

Interface and coclass design can be encapsulated by the following procedural overview:

  1. Start by defining the name of the interfaces and the names of the methods and parameters exposed by each interface.
  2. Define the names of the coclasses that will become the extension classes.
  3. Specify the interface or interfaces that each coclass implements.
The interfaces and coclasses are defined in code written with the Netscape Application Server Interface Definition Language. For more information about this language and how it is used to define the components of a Netscape Application Server extension, see Introduction to Netscape's Interface Definition Language.

Netscape Extension Builder contains a GUI tool, Netscape Extension Builder Designer, to generate this interface code for you based on selections you make in the designer. You do not need to know how to write code with Netscape Application Server IDL. Designing the interfaces and coclasses with Netscape Extension Builder Designer is described in Designing a Netscape Extension.

Generate IDL Files
After you design the extension, you are ready to generate the IDL files that will later become the source code for the extension. Netscape Extension Builder Designer contains an IDL file generator that automatically writes the IDL for the extension and produces the necessary files for completing the extension. The following illustration shows how Netscape Extension Builder Designer generates interface and coclass IDL files:



Generate Extension Source Code
Next, you generate source code from the IDL files. Netscape Extension Builder Designer's file generator creates a make harness that you use to run the KIDL Compiler, included in Netscape Extension Builder. Running the KIDL Compiler takes the IDL files generated by Netscape Extension Builder Designer and translates them into source code and method stub files and places those files in their appropriate directories. The method stub files are where you will write the code that defines what the method does.

Also generated from the interface and coclass IDL files are value-added classes provided by Netscape Extension Builder, called runtime features, which you might have enabled for your extension. More information about the runtime features is provided in a later section. The source code files and directories and runtime feature classes are discussed in more detail in Generating Output Files.

Write the Implementation Code
After you generate the source code, you write the implementation code in the method stub files. The implementation code provides the functionality to link calls made by Netscape Application Server application components, or other extensions, to the technology you are extending. Typically, this is the only code you have to write when building a Netscape Application Server extension. Information about completing method stubs is covered in more detail in Completing Method Stubs.

Compile the Extension Source Code
After you write the implementation code, use the make harness to compile the completed method stubs and other source-code files. Compiling the extension source code is done using the makefiles created by Netscape Extension Builder Designer as well as a standard C++ or Java compiler.

The makefiles keep track of the source code files that compose your extension, and this information is fed into the compiler at the appropriate time to complete the extension. You do not have to keep track of each and every file and manually compile them. More information about compiling the extension source code is provided in Compiling the Extension Source Code.

Deploy the Extension
Once you have completed and compiled the method stubs and source-code files, you are ready to deploy the extension. Deploying the extension loads the extension run-time files onto Netscape Application Server or servers, registers the extension on those servers, and enables the extended technology to be used in Netscape Application Server applications.

Extensions can be built on Windows NT or on Unix. Java extensions built on one operating system can be deployed to a Netscape Application Server on another operating system. C++ extensions can be designed on Windows NT, but the project file must be moved to Unix for subsequent code generation, compilation, and deployment.

Procedural information about deploying extensions is provided in Deploying and Managing a Netscape Extension.

Write the Application Component
To access the extended technology, Netscape Application Server application components must be written to call into the extension, using the exposed extension interfaces you designed. As appropriate, the application components call into the extension through the methods contained in those interfaces. At this level, therefore, developing the application components that call into the extension is no different than developing application components that use, for example, the data access engine.

 

Copyright © 2000 Sun Microsystems, Inc. Some preexisting portions Copyright © 2000 Netscape Communications Corp. All rights reserved.