org.ogf.graap.wsag.server.engine
Class GenericAgreementFactory

java.lang.Object
  extended by org.ogf.graap.wsag.server.api.EngineComponent
      extended by org.ogf.graap.wsag.server.api.impl.AbstractAgreementFactory
          extended by org.ogf.graap.wsag.server.engine.GenericAgreementFactory
All Implemented Interfaces:
AgreementFactory, IAgreementFactory, IEngineComponent

public class GenericAgreementFactory
extends AbstractAgreementFactory

The GenericAgreementFactory is the default implementation of an agreement factory. It support configuration of AgreementFactoryAction's and automatic offer validation out of the box.

Author:
Oliver Waeldrich
See Also:
AgreementFactoryAction

Constructor Summary
GenericAgreementFactory()
           
 
Method Summary
 Agreement createAgreement(AgreementOffer offer, Map<String,Object> context)
          Creates a new agreement based on an offer.
 Agreement createPendingAgreement(AgreementOffer offer, PendingAgreementListener listener, Map<String,Object> context)
          Creates a new pending agreement based on an offer.
 void doInitialize()
          Initializes a GenericAgreementFactory instance based on a provided EngineConfiguration.
 TemplateRegistry getTemplateRegistry()
          The template registry stores the templates of this factory instance along with the associated AgreementFactoryAction.
 AgreementTemplateType[] getTemplates()
          
 Negotiation initiateNegotiation(NegotiationContextType context, org.apache.xmlbeans.XmlObject[] criticalExtensions, org.apache.xmlbeans.XmlObject[] nonCriticalExtensions, Map<String,Object> environment)
          Initializes a new negotiation instance.
protected  AgreementFactoryAction[] loadActions()
          Load the agreement factory actions based on the WSAG4J factory configuration.
 
Methods inherited from class org.ogf.graap.wsag.server.api.impl.AbstractAgreementFactory
getFactoryContext, setFactoryContext
 
Methods inherited from class org.ogf.graap.wsag.server.api.EngineComponent
getEngine, initialize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.ogf.graap.wsag.server.api.IEngineComponent
getEngine, initialize
 

Constructor Detail

GenericAgreementFactory

public GenericAgreementFactory()
Method Detail

loadActions

protected AgreementFactoryAction[] loadActions()
                                        throws Exception
Load the agreement factory actions based on the WSAG4J factory configuration. The factory configuration is stored in the factory context under the key WsagConstants.WSAG4J_FACTORY_CONFIGURATION.

Returns:
the actions that are configured with the factory
Throws:
Exception - indicates that an error occurred while loading the actions

doInitialize

public void doInitialize()
Initializes a GenericAgreementFactory instance based on a provided EngineConfiguration. The initialize method loads the engine configuration, initializes the configured actions, and populates the action registry.

Specified by:
doInitialize in class EngineComponent
Parameters:
engine - the WsagEngine for this factory

createAgreement

public Agreement createAgreement(AgreementOffer offer,
                                 Map<String,Object> context)
                          throws AgreementFactoryException
Creates a new agreement based on an offer.

Parameters:
offer - agreement offer
context - invocation context
Returns:
the created agreement instance
Throws:
AgreementFactoryException - Indicates that the agreement offer was rejected or another fault occurred.
See Also:
org.ogf.graap.wsag.api.AgreementFactory#createAgreement(org.ogf.graap.wsag.api.AgreementOffer)

initiateNegotiation

public Negotiation initiateNegotiation(NegotiationContextType context,
                                       org.apache.xmlbeans.XmlObject[] criticalExtensions,
                                       org.apache.xmlbeans.XmlObject[] nonCriticalExtensions,
                                       Map<String,Object> environment)
                                throws NegotiationFactoryException
Initializes a new negotiation instance. This method creates a new negotiation instance based on the provided negotiation context, taking into account the critical and non-critical extensions.

Parameters:
context - The negotiation context defines the roles and obligations of the negotiating parties. Furthermore, it defines the nature of the negotiation process (e.g. negotiation or re-negotiation).
criticalExtensions - Critical extensions must be supported during the negotiation process. If a critical extension is not understood or supported by the negotiation factory, it must throw an @see NegotiationFactoryException.
nonCriticalExtensions - Non-critical extensions should be supported during the negotiation process. If a non-critical extension is not understood or supported by the negotiation factory, it can be ignored. Alternatively, an @see NegotiationFactoryException could be thrown.
environment - Provides access to additional variables provided by the calling instance. These environment variables are domain specific.
Returns:
the new initiated negotiation instance
Throws:
NegotiationFactoryException - indicates that an error occurred while instantiating the negotiation process

getTemplates

public AgreementTemplateType[] getTemplates()

Returns:
the agreement templates exposed by this factory
See Also:
AgreementFactory.getTemplates()

getTemplateRegistry

public TemplateRegistry getTemplateRegistry()
The template registry stores the templates of this factory instance along with the associated AgreementFactoryAction.

Returns:
the template registry of this factory instance

createPendingAgreement

public Agreement createPendingAgreement(AgreementOffer offer,
                                        PendingAgreementListener listener,
                                        Map<String,Object> context)
                                 throws AgreementFactoryException
Description copied from interface: AgreementFactory
Creates a new pending agreement based on an offer.

Parameters:
offer - agreement offer
listener - the listener, when provided, receives the agreement acceptance events once the creation process is finished
context - invocation context
Returns:
the created agreement instance
Throws:
AgreementFactoryException - Indicates that the agreement offer was rejected or another fault occurred.


Copyright © 2008-2012. All Rights Reserved.