The Server Side

The code fragment below show the declaration of the server part of the server class implementation for the Collection class.

Example 8-1. Server Side Units

with OOS.Abstract_Plugin;		use OOS.Abstract_Plugin;
with OOS.Server_Interface;		use OOS.Server_Interface;
use  OOS;

package OOS.Collection.Server is

   type Object( Size : Natural ) is new Abstract_Class.Object with private;(1)

   function Initialize(                                    (2)
       Interface : in Server_Interface.Handle ) return Abstract_Plugin.Handle;

   pragma Export_Function(Internal => Initialize,
   			   External => initialize,
   			   Parameter_Types => (Server_Interface.Handle),     (3)
   			   Result_Type => Abstract_Plugin.Handle );

   procedure Execute(
      This   : in out Object;
      Buffer : in Buffer_Access;
      Length : in out Natural;
      Method : in Unbounded_String );

   procedure Store(                                        (4)
      This   : in Object;
      Data   : in Buffer_Access;
      Length : out Natural ) ;

   procedure Load( 
      This   : in out Object;
      Data   : in Buffer_Access; 
      Length : in Natural ) ;

private

   type Bag_Type is array( Natural range <>) of Object_ID;

   -- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --
   -- This object contains the persistent data of the server class           --
   -- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --
   type Object ( Size : Natural ) is new Abstract_Class.Object with record
         Bag : Bag_Type( 1..size ) := (others => Null_Object_ID);
      end record;

end OOS.Collection.Server;

	   
(1)
This declares a server object which will be maintained on the server side.
(2)
The function Initialize is used during initialization of the plugin code. Typically this function registers a constructor and returns a handle Abstract_Plugin.Handle
(3)
This is the declaration for the function which will be invoked every time, the client requests the execution of some primitive. The method operates on the server object. Input for such operations are the Buffer which contains the arguments of the operation and the Method which is simply a string indicating the command to be executed.
(4)
The method store and load are used to store and retrieve the object data in the persistent storage of the database server.