Factory actions are configured in the wsag4j engine configuration file. Each wsag4j engine configuration file configures one agreement factory instance that is deployed in a wsag4j server. These configuration files are specified in the WSAG4JEngineInstances section of the global wsag4j server configuration that is located in the /WEB-INF/classes/wsag4j-engine.config file.
It is possible to configure multiple factory actions for one agreement factory instance. Each server action results in one agreement template that is deployed in the agreement factory. Each factory action has a template creation strategy, a negotiation strategy, and an agreement creation strategy as shown below. For a detailed description on factory actions, see the factory actions. The template name and template id uniquely identify the factory action within an agreement factory instance.
<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:FileTemplateConfiguration> <wsag4j-config:Filename>/samples/sample-template.xml</wsag4j-config:Filename> </wsag4j-config:FileTemplateConfiguration> </wsag4j-config:GetTemplateConfiguration> <wsag4j-config:NegotiationConfiguration> <wsag4j-config:ImplementationClass>org.ogf.graap.wsag.samples.actions.SampleNegotiateAction</wsag4j-config:ImplementationClass> </wsag4j-config:NegotiationConfiguration> <wsag4j-config:CreateAgreementConfiguration> <wsag4j-config:ImplementationClass>org.ogf.graap.wsag.samples.actions.SampleCreateAgreementAction</wsag4j-config:ImplementationClass> </wsag4j-config:CreateAgreementConfiguration> </wsag4j-config:Action>
Please have a look on the SampleGetTemplateAction, SampleNegotiateAction and SampleCreateAgreementAction classes defined in above factory action configuration for a sample implementation of IGetTemplateAction, INegotiationAction and ICreateAgreementAction interfaces.
The initialize() method is invoked by the WSAG4J engine when a factory action is instantiated. This method is also called for each strategy configured for a factory actions. Within this method, implementations can do additional initialization, e.g. based on the configuration data provided in the wsag4j-engine.config.
The GenericAgreementFactory provides the functionality to create new agreements, list all agreements, etc. The DatabaseWSAG4JPersistence is database-enabled persistence implementation which persists all agreements in the configured (relational) database. Each agreement is wrapped in some kind of container, which allows the engine to store and retrieve all required information.
For each incoming offer, the offer items are validated for each Offer Item Constraint specified in the template that was used to create the offer. Only if the offer validation succeeded the agreement creation process is started. During the validation process the offer validator dynamically creates a XML Schema based on the contents of an Item Constraint and validates of the correct definition of an Item Constraint. Therefore, all domain specific schemas should be available to the framework for validation. As shown below, JSDL and time constraints schemas are added because both are used in service description terms of the sample template.
<wsag4j-config:Validator> <wsag4j-config:SchemaImports> ........ <wsag4j-config:SchemaFilename>/validator/jsdl.xsd-18.xsd</wsag4j-config:SchemaFilename> <wsag4j-config:SchemaFilename>/validator/wsag4j-scheduling-types.xsd</wsag4j-config:SchemaFilename> </wsag4j-config:SchemaImports> </wsag4j-config:Validator>