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

java.lang.Object
  extended by org.ogf.graap.wsag.server.persistence.impl.AbstractPersistentAgreementFactory
All Implemented Interfaces:
AgreementFactory, IAgreementHome, PersistentAgreementFactory
Direct Known Subclasses:
DatabasePersistentAgreementFactory, SimplePersistentAgreementFactory

public abstract class AbstractPersistentAgreementFactory
extends Object
implements PersistentAgreementFactory

A persistent factory can list all agreements that it has created, even after system restart. Agreement creation itself is handles by a delegate, i.e. the factory class that is configured in the wsag4j config file.

Author:
owaeld

Field Summary
protected  AgreementFactory factory
          The factory implementation that handles agreement creation.
protected  String resourceId
          The resource id of the factory.
 
Constructor Summary
AbstractPersistentAgreementFactory(AgreementFactory factory)
           
 
Method Summary
 void addAgreement(Agreement agreement, EndpointReferenceType agreementEpr)
          Persists a new created agreement instance
 Agreement createAgreement(AgreementOffer offer)
          Creates a new agreement instance.
protected abstract  PersistentAgreement[] doLoad()
          Loads all agreements that were created by this factory.
protected abstract  void doRemove(PersistentAgreement toRemove)
          Removes an agreement from the persistence layer
 PersistentAgreement find(String agreementId)
          Finds an agreement with a given ID.
 AgreementFactory getAgreementFactory()
          
 String getResourceId()
           
 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.
 PersistentAgreement[] list()
          Lists all agreements.
 PersistentAgreement[] list(String agreementFactoryId)
          Lists all agreements for one specific agreement factory.
 void load()
          loads the factory instance
protected abstract  PersistentAgreement persistAgreement(Agreement agreement)
          Persists the given agreement instance.
 void remove(String agreementId)
          Removes the agreement with the given id.
 void save()
          saves the factory instance
 void setResourceId(String resourceId)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

factory

protected AgreementFactory factory
The factory implementation that handles agreement creation.


resourceId

protected String resourceId
The resource id of the factory. This id uniquely identifies the factory.

Constructor Detail

AbstractPersistentAgreementFactory

public AbstractPersistentAgreementFactory(AgreementFactory factory)
Parameters:
factory - the delegation target for the AgreementFactory calls. This is typically an instance of GenericAgreementFactory.
Method Detail

getAgreementFactory

public AgreementFactory getAgreementFactory()

Specified by:
getAgreementFactory in interface PersistentAgreementFactory
Returns:
the concrete implementation of the persisted factory

persistAgreement

protected abstract PersistentAgreement persistAgreement(Agreement agreement)
                                                 throws PersistedResourceException
Persists the given agreement instance.

Parameters:
agreement - the agreement to persist
Returns:
the persisted agreement
Throws:
PersistedResourceException - indicates that an error occurred while persisting the agreement

doLoad

protected abstract PersistentAgreement[] doLoad()
                                         throws PersistedResourceException
Loads all agreements that were created by this factory.

Returns:
the loaded agreements
Throws:
PersistedResourceException - indicates an error while loading the agreements from the persistence layer

doRemove

protected abstract void doRemove(PersistentAgreement toRemove)
                          throws PersistedResourceException
Removes an agreement from the persistence layer

Parameters:
toRemove - the agreement to remove
Throws:
PersistedResourceException - indicates that the agreement could not be removed from the persistence layer

createAgreement

public Agreement createAgreement(AgreementOffer offer)
                          throws AgreementFactoryException
Creates a new agreement instance.

Specified by:
createAgreement in interface AgreementFactory
Parameters:
offer - the agreement offer
Returns:
the new agreement
Throws:
AgreementFactoryException - indicates that the agreement offer was rejected or any other error while creating the agreement.
See Also:
AgreementFactory.createAgreement(org.ogf.graap.wsag.api.AgreementOffer)

addAgreement

public void addAgreement(Agreement agreement,
                         EndpointReferenceType agreementEpr)
Persists a new created agreement instance

Specified by:
addAgreement in interface PersistentAgreementFactory
Parameters:
agreement - the agreement instance to add
agreementEpr - the external reference for this agreement
See Also:
addAgreement(org.ogf.graap.wsag.api.Agreement, org.w3.x2005.x08.addressing.EndpointReferenceType)

load

public void load()
          throws Exception
loads the factory instance

Specified by:
load in interface PersistentAgreementFactory
Throws:
Exception - indicates an exception while loading the agreement factory from the database
See Also:
PersistentAgreementFactory.load()

save

public void save()
          throws Exception
saves the factory instance

Specified by:
save in interface PersistentAgreementFactory
Throws:
Exception - indicates an exception while saving the agreement to the database
See Also:
PersistentAgreementFactory.save()

list

public PersistentAgreement[] list()
Lists all agreements.

Specified by:
list in interface IAgreementHome
Returns:
List of all agreements.
See Also:
IAgreementHome.list()

list

public PersistentAgreement[] list(String agreementFactoryId)
                           throws Exception
Lists all agreements for one specific agreement factory.

Specified by:
list in interface IAgreementHome
Parameters:
agreementFactoryId - the id of the factory for which the agreements should be listed
Returns:
a list of all agreements for a specified agreement factory
Throws:
Exception - indicates an exception while loading the agreements from the database
See Also:
IAgreementHome.list(java.lang.String)

find

public PersistentAgreement find(String agreementId)
                         throws PersistedResourceException
Finds an agreement with a given ID.

Specified by:
find in interface IAgreementHome
Parameters:
agreementId - the ID of the agreement
Returns:
the agreement
Throws:
PersistedResourceException - indicates an exception while loading the agreement from the database
See Also:
IAgreementHome.find(java.lang.String)

remove

public void remove(String agreementId)
            throws PersistedResourceException
Removes the agreement with the given id.

Specified by:
remove in interface IAgreementHome
Parameters:
agreementId - the ID of the agreement, which should be removed
Throws:
PersistedResourceException - indicates an exception while removing the agreement from the database
See Also:
IAgreementHome.remove(java.lang.String)

getResourceId

public String getResourceId()
Specified by:
getResourceId in interface PersistentAgreementFactory
Returns:
the resourceId

setResourceId

public void setResourceId(String resourceId)
Parameters:
resourceId - the resourceId to set

getTemplates

public AgreementTemplateType[] getTemplates()
Specified by:
getTemplates in interface AgreementFactory
Returns:
the supported templates
See Also:
AgreementFactory.getTemplates()

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.

Specified by:
initiateNegotiation in interface AgreementFactory
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


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