org.processmining.framework.models.recommendation.net.client
Class RecommendationProviderProxy

java.lang.Object
  extended by org.processmining.framework.models.recommendation.net.client.RecommendationProviderProxy
All Implemented Interfaces:
RecommendationProvider

public class RecommendationProviderProxy
extends java.lang.Object
implements RecommendationProvider

Author:
christian

Field Summary
protected  java.lang.String host
           
protected  int port
           
protected  RecommendationQueryMarshal queryMarshal
           
protected  RecommendationResultMarshal resultMarshal
           
protected  java.net.Socket socket
           
 
Constructor Summary
RecommendationProviderProxy(java.lang.String aHost, int aPort)
           
 
Method Summary
 RecommendationResult getRecommendation(RecommendationQuery query)
          This is the main query method, which can be used to retrieve recommendations for specific queries.
 void signalPickedResult(RecommendationResult result, int index)
          This method may be used to let the recommendation provider know, which of the provided results has been picked by the requesting party finally.
 void signalPickedResult(RecommendationResult result, Recommendation picked)
          This method may be used to let the recommendation provider know, which of the provided results has been picked by the requesting party finally.
protected  void writeLine(java.io.PrintWriter out, java.lang.String line)
          safe and convenient writing to socket character streams; internal helper method
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

socket

protected java.net.Socket socket

host

protected java.lang.String host

port

protected int port

queryMarshal

protected RecommendationQueryMarshal queryMarshal

resultMarshal

protected RecommendationResultMarshal resultMarshal
Constructor Detail

RecommendationProviderProxy

public RecommendationProviderProxy(java.lang.String aHost,
                                   int aPort)
Method Detail

getRecommendation

public RecommendationResult getRecommendation(RecommendationQuery query)
                                       throws java.lang.Exception,
                                              java.io.IOException
Description copied from interface: RecommendationProvider

This is the main query method, which can be used to retrieve recommendations for specific queries. All communication and encoding of parameters can be assumed to be performed in subclasses implementing this interface.

Note: This method may block for an unspecified time, including network transport and resolving the query on the provider side. Use this method in a separate thread if you wish your application to remain responsive.
Also note that the query can fail, both due to transmission errors (which will yield an IOException, and due to the provider's inability to resolve the query (i.e., an error occurred while handling the issued request, signaled by an ordinary Exception being thrown; or, the query did not yield any usable result, which results in a null response value.

Specified by:
getRecommendation in interface RecommendationProvider
Parameters:
query - The query for recommendations.
Returns:
The resulting set of recommendations (correlated with the issued query), or null, of no result could be obtained (may also be empty result list).
Throws:
java.lang.Exception - Signals an error in the recommendation provider implementation.
java.io.IOException - Signals an error due to network transport problems.

signalPickedResult

public void signalPickedResult(RecommendationResult result,
                               int index)
Description copied from interface: RecommendationProvider

This method may be used to let the recommendation provider know, which of the provided results has been picked by the requesting party finally. The provider will use this information for logging purposes, or to improve future results.

Specified by:
signalPickedResult in interface RecommendationProvider
Parameters:
result - The result set which has been delivered earlier on.
index - Index of the result which has been picked for usage in the result set. If the given index is negative, the semantics are that the requesting party has picked neither of the provided recommendations, i.e. ignored them or found them not useful.

writeLine

protected void writeLine(java.io.PrintWriter out,
                         java.lang.String line)
safe and convenient writing to socket character streams; internal helper method

Parameters:
out -
line -

signalPickedResult

public void signalPickedResult(RecommendationResult result,
                               Recommendation picked)
Description copied from interface: RecommendationProvider

This method may be used to let the recommendation provider know, which of the provided results has been picked by the requesting party finally. The provider will use this information for logging purposes, or to improve future results.

Specified by:
signalPickedResult in interface RecommendationProvider
Parameters:
result - The result set which has been delivered earlier on.