org.ogf.graap.wsag.server.actions.impl
Class AgreementFactoryAction

java.lang.Object
  extended by org.ogf.graap.wsag.server.actions.impl.AgreementFactoryAction
All Implemented Interfaces:
IAction

public class AgreementFactoryAction
extends Object
implements IAction

This class implements a WSAG4J agreement factory action. A factory action contains a set of strategies to generate an agreement template, to negotiate offers based on this template and to create agreements based on the template. The strategies are configured in the WSAG4J engine configuration file.

Author:
Oliver Waeldrich
See Also:
IGetTemplateAction, INegotiationAction, ICreateAgreementAction

Constructor Summary
AgreementFactoryAction(IGetTemplateAction templateAction, ICreateAgreementAction createAgreementAction, INegotiationAction negotiationAction)
          Creates a new AgreementFactoryAction.
 
Method Summary
 Agreement createAgreement(AgreementOffer offer, Map<String,Object> context)
          Invokes the create agreement strategy implemented by the ICreateAgreementAction which is set for this action
 ImplementationConfigurationType getActionConfiguration()
          Returns the configuration of this particular AgreementFactoryAction instance.
 WsagEngine getEngine()
          Returns the WSAG4J engine instance for this handler.
 AgreementFactoryContext getFactoryContext()
          Allows implementations to access the context of the agreement factory in which this action was deployed.
 String getName()
           
 INegotiationAction getNegotiationAction()
           
 AgreementTemplateType getTemplate()
          Returns the agreement template associated with this factory action.
 void initialize()
          Initializes the action.
 boolean isNegotiationSupported()
          Indicates whether this action supports agreement negotiation or not.
 boolean isUsingSession()
           
 NegotiationOfferType[] negotiate(NegotiationOfferType quote, Map<String,Object> context)
          Implements the negotiation strategy for offers that are based on the template associated with this action.
 void setActionConfiguration(ImplementationConfigurationType configuration)
          Sets the configuration for this object.
 void setCreateAgreementAction(ICreateAgreementAction createAgreement)
          Sets the SLA creation strategy for this factory action.
 void setEngine(WsagEngine engine)
          Sets the WSAG4J engine instance for this handler.
 void setFactoryContext(AgreementFactoryContext factoryContext)
           
 void setGetTemplateAction(IGetTemplateAction templateAction)
          Sets the template creation strategy for this factory action.
 void setName(String name)
           
 void setNegotiationAction(INegotiationAction negotiationAction)
          Sets the negotiation strategy for this factory action.
 void setUseSession(boolean useSession)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AgreementFactoryAction

public AgreementFactoryAction(IGetTemplateAction templateAction,
                              ICreateAgreementAction createAgreementAction,
                              INegotiationAction negotiationAction)
Creates a new AgreementFactoryAction.

Parameters:
templateAction - The IGetTemplateAction that is called to generate the agreement template for this AgreementFactoryAction.
createAgreementAction - The ICreateAgreementAction that is called when an agreement is created based on the template generated by this AgreementFactoryAction.
negotiationAction - The negotiation action that is called when a negotiation offer based on the agreement template provided by this action was received.
Method Detail

isNegotiationSupported

public boolean isNegotiationSupported()
Indicates whether this action supports agreement negotiation or not. Negotiation is supported if the associated negotiation action is not null and not an instance of NegotiationUnsupportedAction

Returns:
true, if negotiation is supported, otherwise false
See Also:
setNegotiationAction(INegotiationAction)

setGetTemplateAction

public void setGetTemplateAction(IGetTemplateAction templateAction)
Sets the template creation strategy for this factory action.

Parameters:
templateAction - the template creation strategy to set

setCreateAgreementAction

public void setCreateAgreementAction(ICreateAgreementAction createAgreement)
Sets the SLA creation strategy for this factory action.

Parameters:
createAgreement - the agreement creation strategy to set

setNegotiationAction

public void setNegotiationAction(INegotiationAction negotiationAction)
Sets the negotiation strategy for this factory action.

Parameters:
negotiationAction - the negotiation action to set

initialize

public void initialize()
                throws ActionInitializationException
Initializes the action.

Specified by:
initialize in interface IAction
Throws:
ActionInitializationException
See Also:
IAction.initialize()

getTemplate

public AgreementTemplateType getTemplate()
Returns the agreement template associated with this factory action.

Returns:
the associated agreement template
See Also:
AgreementTemplateType

createAgreement

public Agreement createAgreement(AgreementOffer offer,
                                 Map<String,Object> context)
                          throws AgreementFactoryException
Invokes the create agreement strategy implemented by the ICreateAgreementAction which is set for this action

Parameters:
offer - the offer for which an agreement should be created
context - factory invocation context
Returns:
the agreement instance created by the ICreateAgreementAction
Throws:
AgreementFactoryException - the exception thrown by the ICreateAgreementAction
See Also:
setCreateAgreementAction(ICreateAgreementAction)

negotiate

public NegotiationOfferType[] negotiate(NegotiationOfferType quote,
                                        Map<String,Object> context)
                                 throws NegotiationException
Implements the negotiation strategy for offers that are based on the template associated with this action.

Parameters:
quote - the quote to negotiate
context - implementation specific context
Returns:
the counter offers produced by the negotiation strategy
Throws:
NegotiationException - An exception thrown by the negotiation strategy. See setNegotiationAction(INegotiationAction).
See Also:
INegotiationAction

isUsingSession

public boolean isUsingSession()
Returns:
true - if this AgreementFactoryAction is session aware. false - otherwise

setUseSession

public void setUseSession(boolean useSession)
Parameters:
useSession - Specifies whether an AgreementFactoryAction is session aware or not.

getName

public String getName()
Returns:
The name configured for this action.

setName

public void setName(String name)
Parameters:
name - Sets the name for this AgreementFactoryAction.

getActionConfiguration

public ImplementationConfigurationType getActionConfiguration()
Returns the configuration of this particular AgreementFactoryAction instance.

Specified by:
getActionConfiguration in interface IAction
Returns:
The configuration of this AgreementFactoryAction instance.

setActionConfiguration

public void setActionConfiguration(ImplementationConfigurationType configuration)
Sets the configuration for this object.

Specified by:
setActionConfiguration in interface IAction
Parameters:
configuration - The AgreementFactoryAction configuration to set.

getFactoryContext

public AgreementFactoryContext getFactoryContext()
Allows implementations to access the context of the agreement factory in which this action was deployed.

Specified by:
getFactoryContext in interface IAction
Returns:
The context of the factory in which this action is deployed.

setFactoryContext

public void setFactoryContext(AgreementFactoryContext factoryContext)

Specified by:
setFactoryContext in interface IAction
Parameters:
factoryContext - the factoryContext to set

getNegotiationAction

public INegotiationAction getNegotiationAction()
Returns:
the negotiation strategy for a particular template

getEngine

public WsagEngine getEngine()
Description copied from interface: IAction
Returns the WSAG4J engine instance for this handler.

Specified by:
getEngine in interface IAction
Returns:
the engine instance

setEngine

public void setEngine(WsagEngine engine)
Description copied from interface: IAction
Sets the WSAG4J engine instance for this handler.

Specified by:
setEngine in interface IAction
Parameters:
engine - the engine instance


Copyright © 2008-2012. All Rights Reserved.