atg.svc.repository.service
Class AsyncSolutionScoringService

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.svc.repository.service.BaseService
              extended by atg.svc.repository.service.SharedService
                  extended by atg.svc.repository.service.SolutionScoringService
                      extended by atg.svc.repository.service.AsyncSolutionScoringService
All Implemented Interfaces:
atg.naming.NameContextBindingListener, atg.naming.NameContextElement, atg.naming.NameResolver, atg.nucleus.AdminableService, atg.nucleus.logging.ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, atg.nucleus.logging.VariableArgumentApplicationLogging, atg.nucleus.naming.ComponentNameResolver, atg.nucleus.Service, atg.nucleus.ServiceListener, java.util.EventListener
Direct Known Subclasses:
SelfServiceSolutionScoringService

public class AsyncSolutionScoringService
extends SolutionScoringService

Queues solution scoring changes to a separate thread so solution scores and the view count, use count and hot use count are updated asynchronously. This prevents the user from blocking on the updates and helps prevent lock contention from multiple updates to the same solution blocking one another. Subclasses SolutionScoringService and overrides the methods that update the score.


Field Summary
static java.lang.String CLASS_VERSION
          Class version string
 
Fields inherited from class atg.svc.repository.service.SolutionScoringService
sLISTORDERING_ASC, sLISTORDERING_DESC, sLISTTYPE_HOT, sLISTTYPE_QOAA, sLISTTYPE_TOP, sSOLUTION_SCORING_FILTER_CONTEXT_PATH
 
Fields inherited from class atg.nucleus.GenericService
SERVICE_INFO_KEY
 
Fields inherited from interface atg.nucleus.logging.TraceApplicationLogging
DEFAULT_LOG_TRACE_STATUS
 
Fields inherited from interface atg.nucleus.logging.ApplicationLogging
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
 
Constructor Summary
AsyncSolutionScoringService()
           
 
Method Summary
 SolutionRelevance create(java.lang.String pSolutionId, java.lang.String pSolutionClassId)
          Creates a new solution relevance bean for the specified SolutionId and SolutionClassId Use save to persist the solution relevance object.
 int decrementHotUseCount(java.lang.String pSolutionId)
          Decrements the hot use count for the solution and saves it.
 int decrementUseCount(java.lang.String pSolutionId)
          Decrements the Use count for the solution and saves it.
 void doStartService()
          Start up the service...
 void doStopService()
           
 SolutionRelevance getSolutionRelevance(java.lang.String pSolutionId, java.lang.String pSolutionClassId)
          Gets a SolutionRelevance object for the given solution id.
 javax.transaction.TransactionManager getTransactionManager()
           
 int incrementHotUseCount(java.lang.String pSolutionId)
          Increments the hot use count for the solution and saves it.
 int incrementUseCount(java.lang.String pSolutionId)
          Overrides the synchronous implementation in SolutionScoringService.incrementUseCount(String).
 int incrementViewCount(java.lang.String pSolutionId)
          Increments the view count for the solution and saves it.
protected  void internalProcessUpdate(SolutionRelevanceCountUpdate pCountUpdate)
          Actually write the item changed event to the repository.
 boolean isEnableHotUseCountUpdate()
           
 boolean isEnableUseCountUpdate()
           
 boolean isEnableViewCountUpdate()
           
 boolean isQueueInSeparateThread()
          Whether to queue in a separate thread.
 SolutionRelevanceCountUpdate nextQueuedCountUpdate()
          Return the next queued item changed.
 void processUpdate(SolutionRelevanceCountUpdate pCountUpdate)
          Queue an item changed event.
 void setEnableHotUseCountUpdate(boolean pEnableHotUseCountUpdate)
           
 void setEnableUseCountUpdate(boolean pEnableUseCountUpdate)
           
 void setEnableViewCountUpdate(boolean pEnableViewCountUpdate)
           
 int setHotUseCount(java.lang.String pSolutionId, int pHotUseCount)
          Sets the hot use count for the solution and saves it.
 void setQueueInSeparateThread(boolean pQueueInSeparateThread)
          Whether to queue incrementing the view/use/hotuse count in a separate thread.
 void setTransactionManager(javax.transaction.TransactionManager pTransactionManager)
           
 int updateHotUseCount(java.lang.String pSolutionId, java.lang.String pSolutionClassId)
          Increments the hot use count for the solution and saves it.
 
Methods inherited from class atg.svc.repository.service.SolutionScoringService
computeHotScore, computeHotUseCount, computeQOAAScore, computeScore, computeTopScore, create, create, findByPrimaryKey, findBySolutionId, getAllSolutionRelevance, getBatchSolutionRelevance, getBestBetsCustomConstraints, getDefaultMax, getDefaultOrdering, getFilterLocale, getHotSolutionClasses, getHotSolutionClassesPropertyName, getHotSolutions, getHotSolutions, getHotSolutionsAsSolutions, getHotSolutionsAsSolutions, getHotSolutionsCustomConstraints, getHotSolutionTopics, getHotSolutionTopicsPropertyName, getHotUseCountDuration, getHotUseCountDurationPropertyName, getHotUseCountWeight, getHotUseCountWeightPropertyName, getHotViewCountWeight, getHotViewCountWeightPropertyName, getListFormulas, getListMax, getListOrderHotSolutions, getListOrdering, getListOrderQOAASolutions, getListOrderTopSolutions, getLists, getMaxBestBets, getMaxBestBets, getMaxBestBetsPropertyName, getMaxHotSolutions, getMaxHotSolutions, getMaxHotSolutionsPropertyName, getMaxTopQuestions, getMaxTopQuestions, getMaxTopQuestionsPropertyName, getQOAAList, getQOAAService, getRecommendedAnswerService, getSearchLanguageService, getSearchService, getSiteService, getSolutionRelevance, getSolutionRelevanceHotUseCountPropertyName, getSolutionRelevanceUseCountPropertyName, getSolutionRelevanceViewCountPropertyName, getSolutionSecurityUtils, getSolutionService, getTopSolutions, getTopSolutions, getTopSolutions, getTopSolutionsAsSolutions, getTopSolutionsAsSolutions, getTopSolutionsCustomConstraints, getUserOptionsService, isAgentModule, isFlexibleHotUseCount, isUseBestBetOnly, save, setAgentModule, setBestBetsCustomConstraints, setDefaultMax, setDefaultOrdering, setFlexibleHotUseCount, setHotSolutionClassesPropertyName, setHotSolutionsCustomConstraints, setHotSolutionTopicsPropertyName, setHotUseCountDurationPropertyName, setHotUseCountWeightPropertyName, setHotViewCountWeightPropertyName, setListFormulas, setListMax, setListOrdering, setLists, setMaxBestBetsPropertyName, setMaxHotSolutionsPropertyName, setMaxTopQuestionsPropertyName, setQOAAService, setRecommendedAnswerService, setSearchLanguageService, setSearchService, setSiteService, setSolutionRelevanceHotUseCountPropertyName, setSolutionRelevanceUseCountPropertyName, setSolutionRelevanceViewCountPropertyName, setSolutionSecurityUtils, setSolutionService, setTopSolutionsCustomConstraints, setUseBestBetOnly, setUserOptionsService, updateHotUseCount, updateHotUseCount
 
Methods inherited from class atg.svc.repository.service.SharedService
getServiceSharedBeanHomes, getServiceSharedBeanHomesName, getServiceSharedRepositoryHomes, getServiceSharedRepositoryHomesName, setServiceSharedBeanHomesName, setServiceSharedRepositoryHomesName
 
Methods inherited from class atg.svc.repository.service.BaseService
getRepositoryService, getToday, setRepositoryService
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, getAbsoluteName, getAdminServlet, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static final java.lang.String CLASS_VERSION
Class version string

See Also:
Constant Field Values
Constructor Detail

AsyncSolutionScoringService

public AsyncSolutionScoringService()
Method Detail

getTransactionManager

public javax.transaction.TransactionManager getTransactionManager()

setTransactionManager

public void setTransactionManager(javax.transaction.TransactionManager pTransactionManager)

isEnableUseCountUpdate

public boolean isEnableUseCountUpdate()

setEnableUseCountUpdate

public void setEnableUseCountUpdate(boolean pEnableUseCountUpdate)

isEnableHotUseCountUpdate

public boolean isEnableHotUseCountUpdate()

setEnableHotUseCountUpdate

public void setEnableHotUseCountUpdate(boolean pEnableHotUseCountUpdate)

isEnableViewCountUpdate

public boolean isEnableViewCountUpdate()

setEnableViewCountUpdate

public void setEnableViewCountUpdate(boolean pEnableViewCountUpdate)

setQueueInSeparateThread

public void setQueueInSeparateThread(boolean pQueueInSeparateThread)
Whether to queue incrementing the view/use/hotuse count in a separate thread.


isQueueInSeparateThread

public boolean isQueueInSeparateThread()
Whether to queue in a separate thread.


doStartService

public void doStartService()
                    throws atg.nucleus.ServiceException
Start up the service...

Overrides:
doStartService in class atg.nucleus.GenericService
Throws:
atg.nucleus.ServiceException

doStopService

public void doStopService()
                   throws atg.nucleus.ServiceException
Overrides:
doStopService in class atg.nucleus.GenericService
Throws:
atg.nucleus.ServiceException

processUpdate

public void processUpdate(SolutionRelevanceCountUpdate pCountUpdate)
Queue an item changed event.


internalProcessUpdate

protected void internalProcessUpdate(SolutionRelevanceCountUpdate pCountUpdate)
Actually write the item changed event to the repository.


nextQueuedCountUpdate

public SolutionRelevanceCountUpdate nextQueuedCountUpdate()
Return the next queued item changed.


create

public SolutionRelevance create(java.lang.String pSolutionId,
                                java.lang.String pSolutionClassId)
                         throws javax.ejb.CreateException
Creates a new solution relevance bean for the specified SolutionId and SolutionClassId Use save to persist the solution relevance object.

Overrides:
create in class SolutionScoringService
Parameters:
pSolutionId - Solution Repository Id
pSolutionClassId - SolutionClass Repository Id
Returns:
the new Solution Relevance repository item
Throws:
javax.ejb.CreateException - If the create fails.

getSolutionRelevance

public SolutionRelevance getSolutionRelevance(java.lang.String pSolutionId,
                                              java.lang.String pSolutionClassId)
                                       throws ObjectNotFoundException,
                                              javax.ejb.CreateException,
                                              PersistenceException
Gets a SolutionRelevance object for the given solution id. In case it does not exist a new SolutionRelevance object would be created. Please note that this method need a SolutionClassId as it may be possible that this service may not find the Solution as it may not have been checked in.

Parameters:
pSolutionId - Solution Repository Id
pSolutionClassId - SolutionClass Repository Id
Returns:
the new SolutionRelevance RepositoryItem
Throws:
ObjectNotFoundException - when the solution is not found
javax.ejb.CreateException - If the create for solution relevance object fails.
PersistenceException - If unable to save the newly created solution relevance object

incrementUseCount

public int incrementUseCount(java.lang.String pSolutionId)
                      throws javax.ejb.CreateException,
                             ObjectNotFoundException,
                             PersistenceException
Overrides the synchronous implementation in SolutionScoringService.incrementUseCount(String).

Overrides:
incrementUseCount in class SolutionScoringService
Parameters:
pSolutionId - The RepId of the solution
Returns:
the old use count
Throws:
javax.ejb.CreateException - If the create for solution relevance object fails.
ObjectNotFoundException - when a solution is not found
PersistenceException - problems saving the solution relevance object

decrementUseCount

public int decrementUseCount(java.lang.String pSolutionId)
                      throws javax.ejb.CreateException,
                             ObjectNotFoundException,
                             PersistenceException
Decrements the Use count for the solution and saves it.

Overrides:
decrementUseCount in class SolutionScoringService
Parameters:
pSolutionId - The RepId of the solution
Returns:
the old use count
Throws:
javax.ejb.CreateException - If the create for solution relevance object fails.
ObjectNotFoundException - when a solution is not found
PersistenceException - problems saving the solution relevance object

incrementViewCount

public int incrementViewCount(java.lang.String pSolutionId)
                       throws javax.ejb.CreateException,
                              ObjectNotFoundException,
                              PersistenceException
Increments the view count for the solution and saves it.

Overrides:
incrementViewCount in class SolutionScoringService
Parameters:
pSolutionId - The RepId of the solution
Returns:
the old view count
Throws:
javax.ejb.CreateException - If the create for solution relevance object fails.
ObjectNotFoundException - when a solution is not found
PersistenceException - problems saving the solution relevance object

updateHotUseCount

public int updateHotUseCount(java.lang.String pSolutionId,
                             java.lang.String pSolutionClassId)
                      throws javax.ejb.CreateException,
                             ObjectNotFoundException,
                             PersistenceException
Increments the hot use count for the solution and saves it.

Parameters:
pSolutionId - The RepId of the solution
pSolutionClassId - The repId of the SolutionClass
Returns:
the old hot use count
Throws:
javax.ejb.CreateException - If the create for solution relevance object fails.
ObjectNotFoundException - when a solution is not found
PersistenceException - problems saving the solution relevance object

incrementHotUseCount

public int incrementHotUseCount(java.lang.String pSolutionId)
                         throws javax.ejb.CreateException,
                                ObjectNotFoundException,
                                PersistenceException
Increments the hot use count for the solution and saves it.

Overrides:
incrementHotUseCount in class SolutionScoringService
Parameters:
pSolutionId - The RepId of the solution
Returns:
the old hot use count
Throws:
javax.ejb.CreateException - If the create for solution relevance object fails.
ObjectNotFoundException - when a solution is not found
PersistenceException - problems saving the solution relevance object

decrementHotUseCount

public int decrementHotUseCount(java.lang.String pSolutionId)
                         throws javax.ejb.CreateException,
                                ObjectNotFoundException,
                                PersistenceException
Decrements the hot use count for the solution and saves it.

Overrides:
decrementHotUseCount in class SolutionScoringService
Parameters:
pSolutionId - The RepId of the solution
Returns:
the old hot use count
Throws:
javax.ejb.CreateException - If the create for solution relevance object fails.
ObjectNotFoundException - when a solution is not found
PersistenceException - problems saving the solution relevance object

setHotUseCount

public int setHotUseCount(java.lang.String pSolutionId,
                          int pHotUseCount)
                   throws javax.ejb.CreateException,
                          ObjectNotFoundException,
                          PersistenceException
Sets the hot use count for the solution and saves it.

Overrides:
setHotUseCount in class SolutionScoringService
Parameters:
pSolutionId - The RepId of the solution
pHotUseCount -
Returns:
the old hot use count
Throws:
javax.ejb.CreateException - If the create for solution relevance object fails.
ObjectNotFoundException - when a solution is not found
PersistenceException - problems saving the solution relevance object