Creating / attaching / using component objects

Sample files

Please open ComponentIntro.lava in LavaPE.

Please open AttachDemo.lava in LavaPE.

Please open AttachDemo.ldoc in Lava.

Please open StreamSample.lava in LavaPE and Lava.

Topics

Lava component support: Using external (transient or persistent, Lava or "foreign") data objects.

Overview

Creating/attaching component objects

From the Lava perspective, component objects are "external" objects that are identified by external "component object identifiers" (COID). The COID is specified as part of a "component object specification" (COS), which also comprises a list of all "component object interfaces" that are supported by the component object.

You can use the Lava new and attach expressions to create a new or access an existing component object. You have to specify 1. a COS in these expressions, 2. a component object interface that you want to open, and 3., if the respective object is persistent, you have to specify a url which identifies the location of the object within the respective component namespace. The latter depends on the component protocol (LAVA, .NET, CORBA, EJB, FILE, HTTP, FTP, MAIL, ...) of the object. The respective component implementation is found on the basis of the external COID in a way that depends on the respective component protocol.

If a component object supports more than one component object interface then you can navigate between these, using the query interface expression to get any further interface from a given one.

The first sample (ComponentIntro.lava) presents an outline of what is envisaged by this Lava component concept.

Persistent Lava objects

If you want to make a Lava object persistent you have to implement it within a Lava component (file name suffix .lcom instead of .lava):

Use "New component" from the file menu of LavaPE to create a new Lava component file. This file will typically include some other files which in turn contain Lava component object specifications.

Click the button "New component object implementation" to create a new component object implementation. The associated dialog box provides a list of all component object specifications that are visible at this place. Select one of these. A "component assembly interface" having this same name is created below the declarations node of the component object implementation.

This interface extends all interfaces that are supported by the underlying component object specification, and the actual component object implementation now is essentially a quite normal Lava implementation of this component assembly interface. This in turn amounts to implementing the individual component object interfaces that are supported by the underlying component object specification.

A Lava program can create or attach such an external Lava object as described above, and it can change its state (if it is a state object). The modified state is saved automatically when the object's reference count goes down to zero. (You may invoke Object::DontSave on the object if you don't want to save it.)

The state of a (new or modified) Lava component object is stored in a file having a file name suffix ".ldoc". This file contains a pointer to the underlying *.lcom component implementation file. Many such *.ldoc "Lava document files" may use the same *.lcom component implementation, just like many MS Word documents may use the same Word program. In order to avoid the dependency of the *.ldoc's from the absolute pathnames of the *.lcom files, you can "register" the latter in a fixed place: You can place a link to it (i.e., a quite normal Windows *.lnk file) in the "Components" subdirectory of the Lava installation directory.

Either the absolute pathname or the name of this link file may be specified as the COID (component object identifier) of the component object in its COS (component object specification).

A Lava component object may also be associated with a form representation. In this case, when you double-click an *.lcom file in the Windows Explorer, then the Lava object is activated and the corresponding form is displayed; you can fill it in, and if you close this application it may be stored as a *.ldoc file. If you double-click a *.ldoc file then it is opened and displayed again and you can modify the fields of the form and save it again.

Lava *.ldoc document objects may be processed both by the attach mechanism and via the forms-oriented user interface (if the latter exists), but presently not at the same time.

Close integration of component objects

Lava .lcom/.ldoc document objects that have a user interface may also be embedded into OLE container applications, e.g., into a MS Word or Excel document. See the LavaEmbeddedInWord.doc sample below. I.e., these objects always support OLE in-place activation/editing without any further provisions.

Where to look and what to do

Please open ComponentIntro.lava in LavaPE.

This minimalistic sample presents a raw impression of what the Lava component concept envisages.

Please open AttachDemo.lava in LavaPE.

The initiator of AttachDemo.lava uses attach to open the Lava document file AttachDemo.ldoc. The (state object) sAttach of type LavaCompoIF is then presented to the user by calling the Edit method of the GUI service that has been associated with class LavaCompoIF. You can then modify the content of this object and click the OK button to terminate the form editing process. Finally the object is saved automatically, when its reference count becomes zero on program termination.

Subsequently you may double-click the Lava document file AttachDemo.ldoc to which the Lava document object has been saved in the preceding step. You will see your modifications and may now apply further modifications, this time directly through the GUI service CompoForm contained in the component object implementation in file LCompoImpl.lcom. You can save these new modifications and use the Close command from the file menu to close the Lava document.