org.ogf.graap.wsag.server.persistence.impl
Class DatabasePersistentAgreement

java.lang.Object
  extended by org.ogf.graap.wsag.server.persistence.impl.DatabasePersistentAgreement
All Implemented Interfaces:
Observer, Agreement, PersistentAgreement

public class DatabasePersistentAgreement
extends Object
implements PersistentAgreement, Agreement, Observer

Database-related implementation of the PersistentAgreement interface. This implementation uses PersistentAgreementContainer instances to rebuild the original agreement and provides a transparent access to the stored informations.

During object instantiation an existing PersistentAgreementContainer instance is used to rebuild the agreement or an agreement itself is passed to the constructor. In the second case a PersistentAgreementContainer instance is created and stored, to initially persist the agreement.

Author:
T.Weuffel

Field Summary
protected  MonitorableAgreement agreement
          The MonitorableAgreement wraps the domain specific agreement implementation that inherits from AbstractAgreementType.
static String AGREEMENT_CONTEXT_ENTRY
          Data associated with an agreement instance is stored in the database under a unique identifier.
static String AGREEMENT_PROPERTIES_ENTRY
          Data associated with an agreement instance is stored in the database under a unique identifier.
protected  String agreementFactoryId
          The factory resource id.
protected  PersistentAgreementContainer persistentAgreementContainer
          This container stores the agreement resource properties document and the agreement execution properties in the database.
 
Constructor Summary
DatabasePersistentAgreement(PersistentAgreementContainer persistentAgreementContainer, String agreementFactoryId)
          Uses an existing PersistentAgreementContainer instance to instantiate the persisted agreement.
 
Method Summary
 Agreement getAgreement()
          
 EndpointReferenceType getAgreementEPR()
          Deprecated.  
 String getAgreementId()
          Returns the agreement id.
 AbstractAgreementType getAgreementInstance()
          Returns a domain-specific agreement implementation.
 AgreementContextType getContext()
          
 GuaranteeTermStateType[] getGuaranteeTermStates()
          
 String getName()
          Returns the agreement name.
 PersistentAgreementContainer getPersistentAgreementContainer()
           
 ServiceTermStateType[] getServiceTermStates()
          
 AgreementStateType getState()
          
 TermTreeType getTerms()
          
static DatabasePersistentAgreement insertAgreement(Agreement agreement, String agreementFactoryId)
          Inserts an agreement in the database.
 void load()
           Load an agreement based on the persisted information, the PersistentAgreementContainer instance.
 void save()
           Handles the save-operation of an agreement.
 void terminate(TerminateInputType reason)
          Terminates an agreement.
 void update(Observable o, Object arg)
          Retrieves state change notifications of the concrete agreement implementation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

AGREEMENT_CONTEXT_ENTRY

public static final String AGREEMENT_CONTEXT_ENTRY
Data associated with an agreement instance is stored in the database under a unique identifier. This key identifies the context of a particular agreement in the database.

See Also:
Constant Field Values

AGREEMENT_PROPERTIES_ENTRY

public static final String AGREEMENT_PROPERTIES_ENTRY
Data associated with an agreement instance is stored in the database under a unique identifier. This key identifies the context properties of a particular agreement in the database.

See Also:
Constant Field Values

agreement

protected MonitorableAgreement agreement
The MonitorableAgreement wraps the domain specific agreement implementation that inherits from AbstractAgreementType. After reload all agreement instances are wrapped with a MonitorableAgreement. in case monitoring was active it will be restarted, otherwise the MonitorableAgreement acts as an isolation layer to the concrete implementation, i.e. all calls are simply delegated to the concrete implementation.


persistentAgreementContainer

protected PersistentAgreementContainer persistentAgreementContainer
This container stores the agreement resource properties document and the agreement execution properties in the database. AbstractAgreementType.getXMLObject() AbstractAgreementType.getExecutionContext()


agreementFactoryId

protected String agreementFactoryId
The factory resource id. This id identifies the factory uniquely in the system.

Constructor Detail

DatabasePersistentAgreement

public DatabasePersistentAgreement(PersistentAgreementContainer persistentAgreementContainer,
                                   String agreementFactoryId)
Uses an existing PersistentAgreementContainer instance to instantiate the persisted agreement. The initialization itself is delegated to the load() method. Use this constructor to load an existing agreement instance.

Parameters:
persistentAgreementContainer - Instance storing all the agreement-related information.
agreementFactoryId - ID of the agreement factory, used to build and deploy this agreement.
Method Detail

insertAgreement

public static DatabasePersistentAgreement insertAgreement(Agreement agreement,
                                                          String agreementFactoryId)
                                                   throws AgreementFactoryException
Inserts an agreement in the database.

Parameters:
agreement - the agreement to persist
agreementFactoryId - the id of the factory that created the agreement
Returns:
an instance of the persisted agreement
Throws:
AgreementFactoryException - failed to insert agreement in the database

getGuaranteeTermStates

public GuaranteeTermStateType[] getGuaranteeTermStates()

Specified by:
getGuaranteeTermStates in interface Agreement
Returns:
the agreement guarantee term states
See Also:
MonitorableAgreement.getGuaranteeTermStates()

getAgreementId

public String getAgreementId()
Returns the agreement id.

Specified by:
getAgreementId in interface Agreement
Returns:
the agreement id
See Also:
MonitorableAgreement.getAgreementId()

getContext

public AgreementContextType getContext()

Specified by:
getContext in interface Agreement
Returns:
the agreement context
See Also:
MonitorableAgreement.getContext()

getName

public String getName()
Returns the agreement name.

Specified by:
getName in interface Agreement
Returns:
the agreement name
See Also:
MonitorableAgreement.getName()

getServiceTermStates

public ServiceTermStateType[] getServiceTermStates()

Specified by:
getServiceTermStates in interface Agreement
Returns:
the agreement service term states
See Also:
MonitorableAgreement.getServiceTermStates()

getState

public AgreementStateType getState()

Specified by:
getState in interface Agreement
Returns:
the agreement state
See Also:
MonitorableAgreement.getState()

getTerms

public TermTreeType getTerms()

Specified by:
getTerms in interface Agreement
Returns:
the agreement terms
See Also:
MonitorableAgreement.getTerms()

getAgreementInstance

public AbstractAgreementType getAgreementInstance()
Returns a domain-specific agreement implementation. The AbstractAgreementType implements the domain-specific termination method and stored the agreement properties. The AbstractAgreementType.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
See Also:
MonitorableAgreement.getAgreementInstance()

terminate

public void terminate(TerminateInputType reason)
Terminates an agreement.

Specified by:
terminate in interface Agreement
Parameters:
reason - termination reason
See Also:
MonitorableAgreement.terminate(org.ogf.schemas.graap.wsAgreement.TerminateInputType)

load

public void load()
          throws Exception

Load an agreement based on the persisted information, the PersistentAgreementContainer instance. All information packages in the PersistenceAgreementContextType instance is loaded and used to re-build the original XML documents.

The result of this load-operation is a MonitorableAgreement instance stored in the agreement variable.

Loads the agreement (based on the persisted /information/state, the configuration/etc.).

Specified by:
load in interface PersistentAgreement
Throws:
Exception - indicates an exception while loading the agreement from the database

save

public void save()
          throws Exception

Handles the save-operation of an agreement. All required information (the current version/state of the information) are capsuled in the agreement-related PersistentAgreementContainer instance, which then is stored in the database.

If the agreement was already persisted, the existing persisted agreement is replaced with the new version. If not, the agreement is initially persisted. The decision is based on the existence of a database-record with the same agreement id.

Saves/persistes an agreement.

Specified by:
save in interface PersistentAgreement
Throws:
Exception - indicates an exception while saving the agreement to the database

getAgreement

public Agreement getAgreement()

Specified by:
getAgreement in interface PersistentAgreement
Returns:
The agreement instance itself.

getAgreementEPR

@Deprecated
public EndpointReferenceType getAgreementEPR()
Deprecated. 

Specified by:
getAgreementEPR in interface PersistentAgreement
Returns:
The EPR of the agreement.

getPersistentAgreementContainer

public PersistentAgreementContainer getPersistentAgreementContainer()
Returns:
the persistent agreement container of this instance

update

public void update(Observable o,
                   Object arg)
Retrieves state change notifications of the concrete agreement implementation. If a state notification was received the agreement is saved.

Specified by:
update in interface Observer
See Also:
Observer.update(java.util.Observable, java.lang.Object)


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