ibspan.ecap.merchant.shopdecisions.negotiationpreparation
Class NegotiationPreparingModule

java.lang.Object
  extended by ibspan.ecap.merchant.shopdecisions.negotiationpreparation.NegotiationPreparingModule

public class NegotiationPreparingModule
extends java.lang.Object

A subsystem responsible for preparing negotiation templates and strategies. Designed as a singleton.

Author:
Micha³ Drozdowicz

Method Summary
static NegotiationPreparingModule getInstance()
           
 NegotiationDescription prepareNegotiationDescription(java.lang.String productId)
          Synchronously prepares a new negotiation template for the given product.
 void productRegistered(java.lang.String productId)
          Registers the product for periodic template updates and requests an immediate asynchronous preparation of the first template.
 void productWithdrawn(java.lang.String productId)
          Withdraws the product from periodic template updates.
 void requestNegotiationDescription(java.lang.String productId)
          Requests the preparation of a negotiation template for the given product.
 void requestNextNegotiationDescription()
          Requests the preparation of a negotiation template for the next registered product.
 boolean roundFinished()
           
 NegotiationDescription takeResult()
          Performs a blocking receive of a completed task.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static NegotiationPreparingModule getInstance()
Returns:
the instance of NegotiationPreparingModule.

takeResult

public NegotiationDescription takeResult()
                                  throws java.lang.InterruptedException,
                                         java.util.concurrent.ExecutionException
Performs a blocking receive of a completed task. Returns only after a task has completed or when the thread has been interrupted.

Returns:
a complete NegotiationDescription result
Throws:
java.lang.InterruptedException - when the thread has been interrupted while it was waiting for a result
java.util.concurrent.ExecutionException - when an exception occurred during the preparation of the negotiation template

prepareNegotiationDescription

public NegotiationDescription prepareNegotiationDescription(java.lang.String productId)
Synchronously prepares a new negotiation template for the given product.

Parameters:
productId - the id of the product for which a negotiation template is to be prepared.
Returns:
a new negotiation template.

requestNegotiationDescription

public void requestNegotiationDescription(java.lang.String productId)
Requests the preparation of a negotiation template for the given product. This operation runs asynchronously and the result can be obtained using the takeResult() method. *

Parameters:
productId - the product whose template should be prepared

requestNextNegotiationDescription

public void requestNextNegotiationDescription()
Requests the preparation of a negotiation template for the next registered product. This operation runs asynchronously and the result can be obtained using the takeResult() method.


productRegistered

public void productRegistered(java.lang.String productId)
Registers the product for periodic template updates and requests an immediate asynchronous preparation of the first template.

Parameters:
productId - the id of the product to be handled

productWithdrawn

public void productWithdrawn(java.lang.String productId)
Withdraws the product from periodic template updates.

Parameters:
productId - the id of the product to be withdrawn

roundFinished

public boolean roundFinished()