To facilitate greater code reuse, application integration, and package extensibility within the OpenACS.
To do this acs-service-contract defines an api for the creation of interfaces and discovery of interface implementations.
Most component systems are based on the use of interfaces. Interfaces allow components to create contracts which define their functional level of reuse and customization. It also provides the infrastructure for runtime discovery of which implemented interfaces are available.
The ACS4 is based on a thin object system, that is primarily relational but the acs_objects system allows a veneer of object orientedness by providing globally unique object ids, object metadata, and bundling of data and methods as an object. While this permits a level of reuse on an object or package basis, it requires hardcoding the unit of reuse.
ACS Service contract allows these objects and packages to also define and register their implementation of interfaces, so the level of reuse is defined at the contract level.
In addition ACS Service contract provides mean to dispatch method calls on an interface implementation. The dispatch means is only available through tcl.
Interface Discovery is available programmatically as well as via documentation through ad_proc.
The Service Contract interface specification was inspired by WDSL, the interface specfication for web services.
First Off design the interface for your contract, keeping in mind that all implementations need to implement it and that extension of the contract after deployment is often not practical. In other words take the time to do a little future proofing and thinking about possible uses that you weren't planning on.
Next define the logical operations that will make up your contract
with acs contracts.
Implement the Contract
This might seem a little strange since a binding is the official reference between an implementation and an interface. However it is quite possible that an implementation for interface might exist prior to the interface being defined, ie the interface defining package is not installed. By retaining this information the interface defining package can be installed and the implementations already installed on the system can be bound to it.
[for oracle please syntax replace __ with .]
defines a type based on spec. Spec should
be a string (possibly emtpy) that defines the
names and types that compose this type.
ObjectDisplay.Name.InputType as name
object_id:integer as spec.
acs_sc_contract__new (contract_name, contract_desc):
creates a new contract to serve as a logical container for operations. contract_desc is a text description of the contract.
acs_sc_operation__new (contract_name, operation_name, operation_desc, operation_iscachable_p, operation_inputtype, operation_outputtype ):
creates a new operation as part of a contract.
Included in the service contract package are examples for oracle and postgresql of a trivial contract.
Also the search contract functions as a non-trivial core contract used by openacs4.
Abstract Factory Pattern - GOF
Component Systems - Clemens Syzperski
Most content was provided by Neophytos Demetriou. Most of the errors were provided by Kapil Thangavelu.