In the wsag4j framework agreements are created based on specific templates. A client can query the supported agreement templates from an agreement factory. It creates a new agreement offer based on a suitable template. The resulting agreement offer can then be modified by the client. Finally the offer is send to the agreement factory that creates a new agreement instance if the offer is accepted.
Each agreement must be created on a template exposed by an agreement factory where a template corresponds to the concept of a class in an object-oriented programming language, while a particular agreement instance corresponds to the concept, and agreements correspond to an instance of this class. Refer to the agreement template design for more details on how templates are created.
When wsag4j agreement factory receives a create agreement request, it first looks up the template that was used for creating the agreement offer. This template must be specified within the agreement offer's context element. If this is not the case, the offer is rejected. Each template is uniquely identified by its name and its template id. The template name specifies the SLA type (class) and the template id specifies the template version. Together, these two identifiers specify the factory action that is used to create an agreement.
A wsag4j factory action consist of the following 3 parts:
Each of the above mentioned strategies implement domain-specific functionality that can be configured and plugged into a wsag4j server.
The wsag4j framework supports multiple factory actions per agreement factory. Each factory action has a template creation strategy, a negotiation strategy, and an agreement creation strategy. The template creation strategy returns exactly one agreement template. The template name and template id uniquely identify the factory action with an agreement factory instance. This mapping is illustrated below.
As mentioned before, a particular negotiation strategy is invoked for negotiation offers that are based on the template generated by the corresponding template creation strategy of a factory action. Accordingly, the agreement creation strategy of server action is invoked for agreement offers that are based on the template generated by the associated agreement creation strategy. When a client creates an agreement offer (negotiation offer) based on an agreement template it must reference this template within the Context element of the offer. When the WSAG4J server receives such an offer it first looks up the referenced template and validates the offer against the creation constraints defined in the template. Then it looks up the corresponding factory action. Finally it invokes the according agreement creation strategy of the factory action. This process is shown in the picture below.
The template creation strategy, negotiation strategy and agreement creation strategy need to be implemented in a domain-specific way for each SLA. The following sections describe how this is done in the WSAG4J framework.
A template creation strategy returns exactly one agreement template that is uniquely identified by its name and id. For convenience the context element of the template should also specify the name and id of this template. A template creation strategy implements the IGetTemplateAction interface. For convenience the WSAG4J framework provides an abstract base implementation of this interface with the AbstractGetTemplateAction class.
Moreover, WSAG4J supports the dynamic creation agreement templates using the Velocity template language. It is possible to design templates as XML files that include specific macros in order to dynamically generate for example service description terms or creation constraints. This template creation strategy is implemented by the VelocityAgreementTemplateAction class. This is the WSAG4J default implementation of a template creation strategy. For more information on how to create dynamic agreement templates using this strategy refer to the guide to create templates.
For each factory action a corresponding agreement creation strategy must be configured. This strategy is invoked for valid agreement offers that are based on the agreement template generated by this factory action. Before the agreement creation strategy is invoked, the WSAG4J server validates the incoming offer against the creation constraints defined in the corresponding template. This prevents that a strategy is invoked for invalid offers. Valid offers must for example have a defined structure or values of specific elements must be in predefined value spaces.
An agreement creation strategy implements the ICreateAgreementAction interface. The WSAG4J framework provides an abstract base implementation this interface with the AbstractCreateAgreementAction class. Implementations should inherit from this class.
For description on how to configure factory actions in wsag4j engine configuration see factory actions configuration.