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


Introduction to Netscape's Interface Definition Language

This chapter describes Netscape's Interface Definition Language, which is used to define the interface specifications and class descriptions of a Netscape extension.

The following topics are included in this chapter:


What is Netscape's Interface Definition Language?
Netscape's Interface Definition Language, called KIDL, is the language used to define the interface specifications and class descriptions of a Netscape extension. An interface specifies what a client can do with an object. A class description, or coclass, specifies the definition of a class by noting the interfaces the class will implement.

KIDL, similar to related industry IDL, does not specify the implementation details of a class (or, once instantiated, an object). For example, implementation details are the operating system on which an object is running or the language in which an object is written. Since interfaces and classes can be defined without regard to these types of details, the objects instantiated from KIDL defined interfaces and classes can inter-operate with each other regardless of implementation differences.

KIDL encompasses theories and practices of CORBA IDL and Microsoft COM IDL. If you are not familiar with IDL at all, you should read an introductory book on the subject that describes both CORBA and COM interface design languages.


About KIDL
KIDL allows you to develop interfaces and classes that can link disparate and proprietary code to application components. KIDL allows the inter-operation of application components and Netscape extension objects, regardless of how the extension objects are implemented. Without KIDL, much more work would be required to provide application components access to legacy and third-party technology.

In addition to providing a gateway for the integration of third-party and legacy functionality, KIDL is used to generate repetitive code. By supporting the use of implementation hints, called decorations, the KIDL Compiler can generate specific method stubs and value-added code, saving development time once spent writing similar code over and over again. KIDL's various uses are described further in the next section, How KIDL Corresponds to the Parts of a Netscape Extension.


How KIDL Corresponds to the Parts of a Netscape Extension
A Netscape extension is designed and built in parts, as depicted in the following illustration:



The top three levels are modules, or logical groupings, of an extension and the components within an extension. You design extensions within these modules, which are described in the following sections:

Each of the above modules corresponds to individual IDL files: one file for the extension, one file for each access module, and one file for each service module. KIDL is used in different ways depending on the module of the extension you are designing. The IDL files are then used as input to the KIDL Compiler, which creates the extension source code and method stubs. These concepts and procedures are described in later sections.

Extension Module
The extension module represents the extension as a whole. It is a grouping of the interfaces and services that compose the extension. The extension module contains the access module and the service module, and everything those modules contain.

The IDL file for the extension module is very simple. Below is an example of the IDL code as it appears in an actual extension module IDL file.

//

// This file is generated by KIDL - do not edit

//

global [package(testextension), extension_language(java_code), extension_name(TestExtension_EXT)]

package extension;

typedef long time_t;

typedef unsigned int size_t;

typedef HRESULT SCODE;

typedef _GUID GUID;

typedef GUID IID;

typedef GUID CLSID;

typedef IID REFIID;

typedef CLSID REFCLSID;

typedef GUID REFGUID;

#include "KIVA.idl"

#include "myiext.idl"

This file is named TestExtension_EXT.idl, as denoted by the extension_name decoration in the first lines of code.

Note the # include statements at the bottom of the IDL file. The first includes the Netscape Application Server access module IDL file, which contains the support interfaces necessary for inter-operating with the Netscape Application Server. The second # include statement refers to the extension access module IDL file, which describes the interfaces created for the extension.

The service modules are included in the extension by referring to the extension module using a # include, as described later.

The entire content of the extension IDL file is generated by the Netscape Extension Builder Designer, so you don't have to write any of it.

Access Module
The access module is a grouping of the interfaces used by application components to access Netscape extension objects. The interfaces within the access module have no implementation details and are simply the specifications of the operations a client, by invoking the methods exposed by the interfaces, can perform when interacting with an object.

For example, you might define an IQueryAccount interface with a GetBalance( ) method. This method probably contains several parameters. Within the access module, the IDL code would specify that an IQueryAccount interface was going to exist, as well as the GetBalance( ) method and the parameters of that method. Basically, the access module specifies the names of the interfaces, methods, and parameters available to the application components. Below is an example of the IDL code as it appears in an access module IDL file.

//

// This file is generated by KIDL - do not edit

//

[package(testextension)]

module myiext

{

[local, object, uuid(90BB7EB0-518F-11D1-A1AA-006008293C54)]

interface IExtMain : IGXObject

{

HRESULT GetMyName(

[out] LPSTR pName,

[in] unsigned long nameSize);

HRESULT CreateFirst(

[out] IExtFirstInterface** ppFirst);

HRESULT CreateSecond(

[out] IExtSecondInterface** ppSecond);

};

[local, object, uuid(B0399FF0-518F-11D1-A1AA-006008293C54)]

interface IExtFirstInterface : IGXObject

{

HRESULT DeliverTo(

[in] LPSTR deliverWhat,

[in] LPSTR toWhom);

HRESULT TurnUp(

[in] DWORD increment,

[out] IExtSecondInterface** ppNewGuage);

HRESULT SetFilmSize(

[in] DWORD filmSize);

HRESULT GetFilmSize(

[out] DWORD* pFilmSize);

};

[local, object, uuid(D94AC9F0-518F-11D1-A1AA-006008293C54)]

interface IExtSecondInterface : IGXObject

{

HRESULT GetDescription(

[out] LPSTR pDesc,

[in] unsigned long descSize);

HRESULT SetHighWaterMark(

[in] DWORD newMark);

};

}

In this example, the file is named myIExt.idl. There are three interfaces defined in this access module: the IExtMain, the IExtFirstInterface and the IExtSecondInterface. These are specified on the lines that begin with the keyword interface. Each interface is a client of (denoted by the colon) the IGXObject interface, from which all interfaces are derived.

Within each interface are the specifications for the methods that clients can use to invoke operations from the object or objects that will implement these interfaces. Methods are typically denoted with the HRESULT keyword. In the parentheses after each method are the parameters of the method along with a scope notation (denoted in the square brackets) of whether it is an in or out parameter.

Service Module
The service module is a grouping of coclasses. A coclass is a design specification of a class and becomes a class after the service module IDL file is compiled.

In the service module, coclasses typically implement one or more of the interfaces defined in the access module. When implementing those interfaces, you can add decorations to the interfaces, methods and parameters. Decorations describe a portion of the implementation details for how a coclass becomes a class. For example, a decoration can provide information to the KIDL Compiler that a certain interface is going to have a Java access layer that supports calls from Java application components.

Implementation details are not specified in the access module to simplify extension building and to support multiple interface implementation.

Multiple interface implementation allows for different implementations of the same interface. It is easier to assign decorations on a coclass basis, rather than define two interfaces, which would appear identical to the application component layer.

For example, you could define two coclasses that implement the same interface, but implement that interface in different ways. Within the service module you might have a Java version coclass called myExtJavaService as well as a C++ version coclass called myExtC++Service. Each coclass would implement the same interface. However, the implementation of the interface in the Java service would use a Java Access Layer decoration, whereas the C++ coclass implementation would not use the Java Access Layer decoration. This example is depicted in the following illustration:



Below is an example of the IDL code as it appears in a service module IDL file, named myext.idl. Note how the first line of code includes the extension module.

//

// This file is generated by KIDL - do not edit

//

#include "TestExtension_EXT.idl"

[package(testextension.myext)]

module myext

{

[uuid(72c1c580-9f31-11d1-a1bb-006008293c54), wrapper_uuid(72c1c581- 9f31-11d1-a1bb-006008293c54)]

coclass CExtModule

{

interface IGXModule

{

Init( pObj);

Uninit( pObj);

}

interface IExtModule

{

GetMyName([size_is(nameSize)] pName, [default_value(512)] nameSize);

CreateFirst([java_class(testextension.myext.CExtFirstClass),

cpp_class(CExtFirstClass)] ppFirst);

CreateSecond([java_class(testextension.myext.CExtSecondClass),

cpp_class(CExtSecondClass)] ppSecond);

}

};

[uuid(72c1c582-9f31-11d1-a1bb-006008293c54), wrapper_uuid(72c1c583- 9f31-11d1-a1bb-006008293c54)]

coclass CExtFirstClass

{

interface IExtFirstInterface

{

DeliverTo( deliverWhat, toWhom);

TurnUp( increment, [java_class(testextension.myext.CExtSecondClass),

cpp_class(CExtSecondClass)] ppNewGuage);

IgnoreThis( pIgnore);

SetFilmSize( filmSize);

GetFilmSize( pFilmSize);

}

};

[uuid(72c1c584-9f31-11d1-a1bb-006008293c54), wrapper_uuid(72c1c585- 9f31-11d1-a1bb-006008293c54)]

coclass CExtSecondClass

{

interface IExtSecondInterface

{

GetDescription([size_is(descSize)] pDesc, [default_value(512)] descSize);

SetHighWaterMark( newMark);

}

};

}

The definitions of the coclasses, denoted by the coclass keyword, include the interfaces, methods and parameters each coclass implements. Around all of these definitions are decorations, which are contained in square brackets [ ]. Notice how the decorations provide implementation details. Decorating the components of a coclass is covered later in Chapter 4, Designing a Netscape Extension.

 

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