Agreement templates are a key component in the WSAG4J framework. Each template is uniquely identified in an Agreement Factory instance by the template name and template id. An agreement template represents a class of SLAs that is supported by the agreement factory. Each agreement is created based on a specific agreement template. Agreement templates can therefore be compared to the concept of a class in an object-oriented programming language, while concrete agreements correspond to the concept of an instance of a particular class. Agreement templates are developed using the eXtensible Markup Language (XML). The language and syntax elements are defined by the WS-Agreement XML schema.
The WSAG4J framework supports two types of different functionality that can be implemented as part of an agreement template:
Creation Constraints restrict the structure and values of acceptable agreement offers. By implementing appropriate creation constraints in an agreement template a developer can exactly specify how valid agreement offers look like, e.g. which terms must exist in an offer. Creation constraints are automatically evaluated by the WSAG4J framework before an agreement is created. For more information on creation constraints refer to the guide to creation constraints.
Agreement Guarantees are also implemented in an agreement template. Each guarantee defines a Service Level Objective e.g. a desired value for a specific service property that must be achieved in the service provisioning process in order to fulfill the guarantee. The Service Level Objective defines an expression over a desired service property and the actual delivered service property (e.g. service response time <= 1s). See the guide to guarantee evaluation for more information on this topic.
A sample agreement template with two service description terms can be found here: sample template
The domain specific description of a service can be injected between the ServiceDescriptionTerm tags (SDT). Any kind of specific schema can be inserted there. In the given example we see a domain specific JSDL template:
<wsag:ServiceDescriptionTerm wsag:Name="RESOURCE_STD" wsag:ServiceName="SAMPLE-SERVICE"> <jsdl:JobDefinition> ..... </jsdl:JobDefinition> </wsag:ServiceDescriptionTerm>
Multiple of such SDT sections are allowed.
In a simple case of static template usage WSAG4J by default uses the velocity framework. The user has to provide a static template and register it inside the wsag4j-engine configuration. The action definition of such static usage will probably look like this:
<wsag4j-config:Action wsag4j-config:name="WSAG4J-SAMPLE-4"> ... <wsag4j-config:GetTemplateConfiguration> <wsag4j-config:ImplementationClass>org.ogf.graap.wsag.server.actions.impl.VelocityAgreementTemplateAction</wsag4j-config:ImplementationClass> <wsag4j-config:FileTemplateConfiguration> <wsag4j-config:Filename>/samples/sample-template.xml</wsag4j-config:Filename> </wsag4j-config:FileTemplateConfiguration> </wsag4j-config:GetTemplateConfiguration ... </wsag4j-config:Action>
Location of the static template can be defined by filling the FileTemplateConfiguration section. The implementation class needs to be in the classpath.
Beyond static usage of templates, WSAG4J allows dynamic creation of templates. To do so, the creator of a template has to specify placeholders where dynamic generation will take place. To proceed with dynamic template generation three things have to be altered. The creator needs to edit the wsag4j-engine configuration, add placeholders to the template file and insert the actual mapping into the processig class. Inside the processing class (here SampleGetTemplateAction) the code for placeholder mapping could look like this:
ImplementationConfigurationType handlerConfiguration = getHandlerContext().getHandlerConfiguration(); XmlObject[] children = handlerConfiguration.selectChildren( FileTemplateConfigurationDocument.type.getDocumentElementName() );
FileTemplateConfigurationType config = (FileTemplateConfigurationType) children[0]; setTemplateFilename( config.getFilename() ); fileTemplate = new FileTemplate( getTemplateFilename() );
double totalResources = 10; fileTemplate.addParameter( "TOTALRESOURCES", totalResources );
To process such placeholders in a dynamic template, the action definition has to be altered. The default VelocityAgreementTemplateAction class is replaced by a custom one (SampleGetTemplateAction) inside the wsag4j-engine configuration file:
<wsag4j-config:Action wsag4j-config:name="WSAG4J-SAMPLE"> ... <wsag4j-config:GetTemplateConfiguration> <wsag4j-config:ImplementationClass>org.ogf.graap.wsag.samples.actions.SampleGetTemplateAction</wsag4j-config:ImplementationClass> ... </wsag4j-config:Action>
Example of such placeholder inside a template, namely $TOTALRESOURCES can be seen here:
... <wsag:ItemConstraint><xs:minInclusive value="1"/><xs:maxInclusive value="$TOTALRESOURCES"/></wsag:ItemConstraint> ...