Skip to main content

Adding Projections to a Class

This topic discusses how to add projection definitions in a class definition.

A projection definition instructs the InterSystems IRIS® class compiler to perform specified operations when a class definition is compiled or removed. A projection defines the name of a projection class (derived from the %Projection.AbstractProjectionOpens in a new tab class) that implements methods that are called when either of the following is true:

  • The compilation of a class is complete.

  • A class definition is removed either because it is being deleted or because the class is about to be recompiled.

A class can contain any number of projection definitions. The actions for all of them are invoked when the class is compiled (the order in which they are invoked is not defined).

InterSystems IRIS includes predefined projection classes that generate client code that allows access to a class from Java, MV, and so on.

Projection Classes
Class Description
%Projection.JavaOpens in a new tab Generates a Java client class to enable access to the class from Java.
%Projection.Monitor Registers this class as a routine that works with Log Monitor. Metadata is written to Monitor.Application, Monitor.Alert, Monitor.Item and Monitor.ItemGroup. A new persistent class is created called Monitor.Sample.
%Projection.MVOpens in a new tab Generates an MV class that enables access to the class from MV.
%Projection.StudioDocumentOpens in a new tab Registers this class as a routine that works with Studio.
%Studio.Extension.ProjectionOpens in a new tab Projects the XData 'menu' block to the menu table.

You can also create your own projection classes and use them from Studio as you would any built-in projection class.

You can add a new projection to a class definition in two ways:

  • Editing the class definition using the Class Editor.

  • Using the New Projection wizard

To add a projection using the Class Editor, position the cursor at a blank line and enter a projection declaration.

Alternatively, you can copy and paste an existing projection declaration and then edit it.

For details, see Projection Definitions in the Class Definition Reference.

New Projection Wizard

You can invoke the New Projection wizard by selecting Class > Add > Projection. Alternatively right-click in the Class Inspector and select Add > New Projection.

The New Projection wizard displays pages prompting you for information about the new projection. You can click Finish before completing all of the wizard pages; in this case, default values are provided for any information you have not specified.

Name and Description Page

The New Projection wizard prompts you for the following information (you can later modify any of these values):

Projection Name

(required) Name of the new projection. This name must be a valid projection name and must not conflict with the name of a previously defined projection.

See Rules and Guidelines for Identifiers.

Description

(optional) Description of the new projection.

Projection Type Page

The projection type determines what actions happen when your class definition is compiled or removed. You can select what kind of projection you would like to define.

Projection Type

Name of a projection class whose methods are executed when a class definition is compiled or removed.

Projection Parameters

A set of name-value pairs that control the behavior of the projection class. The list of available parameter names is determined by the selected projection class.

Results of Running the New Projection Wizard

When you finish running the New Projection wizard, the Class Editor window is updated to include the new projection definition. For example:

/// This is a Person class
class MyApp.Person extends %Persistent 
{

Property Name As %String;

Projection JavaClient As %Projection.Java;
}

To edit this projection definition, use either the Class Editor or the Class Inspector.

FeedbackOpens in a new tab