org.ogf.graap.wsag.api.types
Class AbstractAgreementType

java.lang.Object
  extended by java.util.Observable
      extended by org.ogf.graap.wsag.api.types.WSAGXmlType
          extended by org.ogf.graap.wsag.api.types.AbstractAgreementType
All Implemented Interfaces:
Agreement
Direct Known Subclasses:
ExampleAgreement, PendingAgreement, PendingAgreementImpl, SampleAgreement, SampleAgreement, SampleMonitoredAgreement, SimpleMonitoredAgreement

public abstract class AbstractAgreementType
extends WSAGXmlType
implements Agreement

Abstract implementation of an agreement. This class implements the required methods to access and store the properties of an agreement. Additionally, when an agreement is created based on an offer, the corresponding states are created for each service term and each guarantee term specified in the offer.

Author:
Oliver Waeldrich
To Do:
a future implementation of agreement type will use a handler mechanism to implement the agreement termination strategy. For that reason, this class will not be abstract anymore and subclassing of AbstractAgreementType will not be required anymore. This will make the framework more robust for user implementations., Implement Observer pattern to allow registered objects to get notified if the abstract agreement is updated.

Field Summary
protected  AgreementPropertiesType agreementProperties
          The internal XML representation of the agreement instance.
protected static String DEFAULT_GUARANTEE_TERM_XPATH
          Default XPath expression for selecting all guarantee terms in an agreement.
protected static String DEFAULT_SDT_XPATH
          Default XPath expression for selecting all service description terms in an agreement.
 
Constructor Summary
AbstractAgreementType()
          Default constructor.
AbstractAgreementType(AgreementOffer offer)
          Creates an agreement based on an offer.
AbstractAgreementType(AgreementPropertiesType agreementPropertiesType)
          Creates a new agreement instance.
 
Method Summary
 String getAgreementId()
          Returns the agreement id.
 AbstractAgreementType getAgreementInstance()
          Returns a domain-specific agreement implementation.
 AgreementContextType getContext()
          
 Map<String,org.apache.xmlbeans.XmlObject> getExecutionContext()
          Returns the persisted execution context for this agreement.
 GuaranteeTermStateType[] getGuaranteeTermStates()
          
 String getName()
          Returns the agreement name.
 ServiceTermStateType[] getServiceTermStates()
          
 AgreementStateType getState()
          
 TermTreeType getTerms()
          
 Map<String,Object> getTransientExecutionContext()
          Returns the transient execution context for this agreement.
 org.apache.xmlbeans.XmlObject getXMLObject()
          Returns the agreement properties as XmlObject.
protected  void initialize(AgreementOffer offer)
          Initializes an agreement type with the standard selection strategy for service description term states and guarantee term states.
protected  void initialize(AgreementOffer offer, String sdtXPath, String guaranteeTermXPath)
          Initializes an agreement type with the custom selection strategy for service description term states and guarantee term states.
protected  void notifyReinitialized(Map<String,org.apache.xmlbeans.XmlObject> persistedExecutionCtx)
          Reload hook.
 void notifyReload(Map<String,org.apache.xmlbeans.XmlObject> executionCtx)
          This method allows an agreement instance to get notified after reload.
 void setAgreementId(String agreementId)
          Sets the ID of the agreement.
 void setContext(AgreementContextType context)
          Sets the context of the agreement.
 void setGuaranteeTermStates(GuaranteeTermStateType[] guaranteeTermStateList)
          Sets the guarantee term states of the agreement.
 void setName(String name)
          Sets the name of the agreement.
 void setServiceTermStates(ServiceTermStateType[] serviceTermStateList)
          Sets the service term states of the agreement.
 void setState(AgreementStateType agreementState)
          Sets the state of the agreement.
 void setTerms(TermTreeType terms)
          Sets the terms of the agreement.
 void setXmlObject(AgreementPropertiesType properties)
          Sets the properties for this agreement explicitly.
 boolean validate()
          Validates the resource properties document of this instance.
 
Methods inherited from class org.ogf.graap.wsag.api.types.WSAGXmlType
processTemplate, validate
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
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.api.Agreement
terminate
 

Field Detail

agreementProperties

protected AgreementPropertiesType agreementProperties
The internal XML representation of the agreement instance.


DEFAULT_SDT_XPATH

protected static final String DEFAULT_SDT_XPATH
Default XPath expression for selecting all service description terms in an agreement.

See Also:
Constant Field Values

DEFAULT_GUARANTEE_TERM_XPATH

protected static final String DEFAULT_GUARANTEE_TERM_XPATH
Default XPath expression for selecting all guarantee terms in an agreement.

See Also:
Constant Field Values
Constructor Detail

AbstractAgreementType

public AbstractAgreementType(AgreementOffer offer)
Creates an agreement based on an offer. The service term states and guarantee term states are automatically created. For each service description term and each guarantee term in the offer an appropriate state is created. for the term selection the according DEFAULT_SDT_XPATH and DEFAULT_GUARANTEE_TERM_XPATHXPath expression are used.

Parameters:
offer - the offer to create the agreement for

AbstractAgreementType

public AbstractAgreementType(AgreementPropertiesType agreementPropertiesType)
Creates a new agreement instance. The provided agreement properties document is used for this instance.

Parameters:
agreementPropertiesType - the agreement properties document

AbstractAgreementType

public AbstractAgreementType()
Default constructor. Initializes a minimal resource properties document for this instance with minimal default values.

Method Detail

validate

public boolean validate()
Validates the resource properties document of this instance.

Specified by:
validate in class WSAGXmlType
Returns:
true if the resource properties document is valid, otherwise false.

initialize

protected void initialize(AgreementOffer offer)
Initializes an agreement type with the standard selection strategy for service description term states and guarantee term states.

Parameters:
offer - The agreement offer that is used for the agreement initialization process.

initialize

protected void initialize(AgreementOffer offer,
                          String sdtXPath,
                          String guaranteeTermXPath)
Initializes an agreement type with the custom selection strategy for service description term states and guarantee term states.

Parameters:
offer - The agreement offer that is used for the agreement initialization process.
sdtXPath - Custom expression for selecting service terms from the agreement offer.
guaranteeTermXPath - Custom expression for selecting guarantee terms from the agreement offer.

notifyReload

public final void notifyReload(Map<String,org.apache.xmlbeans.XmlObject> executionCtx)
This method allows an agreement instance to get notified after reload. An invocation of the notifyReload(Map) method sets the execution context (see getExecutionContext()) of the agreement and invokes the notifyReinitialized(Map) method of this agreement instance.

Parameters:
executionCtx - the current execution context

notifyReinitialized

protected void notifyReinitialized(Map<String,org.apache.xmlbeans.XmlObject> persistedExecutionCtx)
Reload hook. Implementations can overwrite this method in order to implement custom functionality on agreement reload.

Parameters:
persistedExecutionCtx - persisted execution properties of the agreement instance

Since 1.0.0-m4


getAgreementId

public String getAgreementId()
Returns the agreement id.

Specified by:
getAgreementId in interface Agreement
Returns:
the agreement id

getContext

public AgreementContextType getContext()

Specified by:
getContext in interface Agreement
Returns:
the agreement context

getName

public String getName()
Returns the agreement name.

Specified by:
getName in interface Agreement
Returns:
the agreement name

getTerms

public TermTreeType getTerms()

Specified by:
getTerms in interface Agreement
Returns:
the agreement terms

setAgreementId

public void setAgreementId(String agreementId)
Sets the ID of the agreement.

Parameters:
agreementId - the agreement id to set

setContext

public void setContext(AgreementContextType context)
Sets the context of the agreement.

Parameters:
context - the agreement context to set

setName

public void setName(String name)
Sets the name of the agreement.

Parameters:
name - the agreement name to set

setTerms

public void setTerms(TermTreeType terms)
Sets the terms of the agreement.

Parameters:
terms - the agreement terms to set

getState

public AgreementStateType getState()

Specified by:
getState in interface Agreement
Returns:
the agreement state

getGuaranteeTermStates

public GuaranteeTermStateType[] getGuaranteeTermStates()

Specified by:
getGuaranteeTermStates in interface Agreement
Returns:
the agreement guarantee term states

getServiceTermStates

public ServiceTermStateType[] getServiceTermStates()

Specified by:
getServiceTermStates in interface Agreement
Returns:
the agreement service term states

setState

public void setState(AgreementStateType agreementState)
Sets the state of the agreement.

Parameters:
agreementState - the agreement state to set

setGuaranteeTermStates

public void setGuaranteeTermStates(GuaranteeTermStateType[] guaranteeTermStateList)
Sets the guarantee term states of the agreement.

Parameters:
guaranteeTermStateList - the guarantee term states to set

setServiceTermStates

public void setServiceTermStates(ServiceTermStateType[] serviceTermStateList)
Sets the service term states of the agreement.

Parameters:
serviceTermStateList - the service term states to set

getXMLObject

public org.apache.xmlbeans.XmlObject getXMLObject()
Returns the agreement properties as XmlObject.

Returns:
an XML representation of the agreement properties document

setXmlObject

public void setXmlObject(AgreementPropertiesType properties)
Sets the properties for this agreement explicitly.

Parameters:
properties - the agreement properties to set

getAgreementInstance

public AbstractAgreementType getAgreementInstance()
Returns a domain-specific agreement implementation. The AbstractAgreementType implements the domain-specific termination method and stored the agreement properties. The getXMLObject() returns the actual properties of an agreement implementation. These properties must be valid at all time, i.e. if an agreement implementation overrides the Agreement.getState() method the implementation must make sure that the agreement properties are updated with the returned state.

Specified by:
getAgreementInstance in interface Agreement
Returns:
the agreement implementation

getExecutionContext

public Map<String,org.apache.xmlbeans.XmlObject> getExecutionContext()
Returns the persisted execution context for this agreement.

Returns:
the agreement persisted execution context

getTransientExecutionContext

public Map<String,Object> getTransientExecutionContext()
Returns the transient execution context for this agreement.

Returns:
the agreement transient execution context


Copyright © 2008-2012 Fraunhofer Institute SCAI. All Rights Reserved.