public class ExperimentContextImpl extends AbstractContextImpl implements ExperimentContext
ExperimentContext
interface to provide the
implementation details of the context object that is used in Experimentation. This
context contains user and store dependent experiment result information, which is a
randomly generated number used to determine the experimental element that will be
converted to the control activity.Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CONTEXT_NAME
This is the name of the context.
|
static java.lang.String |
COPYRIGHT
IBM copyright notice field.
|
SER_VALUE_SEP
Constructor and Description |
---|
ExperimentContextImpl()
The default constructor for this class, a new
java.util.HashMap
object is created to store user-specific experiment results. |
Modifier and Type | Method and Description |
---|---|
void |
clearContext()
This method clears the experiment context, it is called when the ContextSPI
object is returned to their respective object pool.
|
void |
copyContext(Context ctx)
This method copies the content of the specified context to this context.
|
java.lang.Object[] |
getContextAttributes()
This method returns an array of context attributes to be serialized and
persisted.
|
java.lang.String |
getContextName()
This method returns the name of this context.
|
java.lang.Short |
getExperimentResult(java.lang.Integer experimentId)
This method returns the result of the given experiment for the user who
owns this context.
|
java.lang.String |
getSessionId()
This method returns the current session ID for the user who is accessing
this context.
|
void |
initializeContext(com.ibm.commerce.component.contextservice.ActivityData initData)
This initializes the context when the session is created.
|
void |
preInvokeContext(com.ibm.commerce.component.contextservice.ActivityData sessionData)
Any pre-processing that is done before the request processed.
|
void |
setContextAttributes(java.lang.String[] ctxAttrs)
This method initializes the context from the specified list of attributes.
|
void |
setExperimentResult(java.lang.Integer experimentId,
java.lang.Short newExperimentResult)
This method sets the result of the given experiment for the user who owns
this context.
|
void |
setSessionId(java.lang.String newSessionId)
This method sets the current session ID for the user who is accessing
this context.
|
java.lang.String |
toString()
This method returns the string representation of the object.
|
boolean |
validate()
This method returns whether the context is valid.
|
clear, getActivityToken, getContextSerializedString, initialize, initialize, initializeContext, isDirty, postInvoke, postInvokeContext, preInvoke, recalibrate, recalibrateContext, reset, resetContext, setContextSerializedString, setDirty
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
getActivityToken
public static final java.lang.String COPYRIGHT
public static final java.lang.String CONTEXT_NAME
public ExperimentContextImpl()
java.util.HashMap
object is created to store user-specific experiment results.public void clearContext()
clearContext
in class AbstractContextImpl
AbstractContextImpl.clear()
public void copyContext(Context ctx)
copyContext
in interface Context
ctx
- The context to be copied from.public java.lang.Object[] getContextAttributes() throws BusinessContextException
getContextAttributes
in class AbstractContextImpl
BusinessContextException
AbstractContextImpl.getContextSerializedString()
public java.lang.String getContextName()
getContextName
in interface Context
public java.lang.Short getExperimentResult(java.lang.Integer experimentId)
getExperimentResult
in interface ExperimentContext
experimentId
- The ID of the experiment.public java.lang.String getSessionId()
getSessionId
in interface ExperimentContext
public void initializeContext(com.ibm.commerce.component.contextservice.ActivityData initData) throws BusinessContextException
initializeContext
in class AbstractContextImpl
initData
- The initialization data.BusinessContextException
com.ibm.commerce.context.baseimpl.AbstractContextImpl#initialize(com.ibm.commerce.component.contextservice.ActivityData)
public void preInvokeContext(com.ibm.commerce.component.contextservice.ActivityData sessionData) throws BusinessContextException
preInvokeContext
in class AbstractContextImpl
sessionData
- The data associated with the request processed.BusinessContextException
AbstractContextImpl.preInvoke(com.ibm.commerce.component.contextservice.ActivityData)
public void setContextAttributes(java.lang.String[] ctxAttrs) throws BusinessContextException
setContextAttributes
in class AbstractContextImpl
ctxAttrs
- An array of attributes of the context.BusinessContextException
public void setExperimentResult(java.lang.Integer experimentId, java.lang.Short newExperimentResult)
setExperimentResult
in interface ExperimentContext
experimentId
- The ID of the experiment.newExperimentResult
- The result of the given experiment.public void setSessionId(java.lang.String newSessionId)
setSessionId
in interface ExperimentContext
newSessionId
- The current session ID used specifically in marketing
experimentation.public java.lang.String toString()
toString
in class AbstractContextImpl
public boolean validate() throws BusinessContextException
validate
in interface Context
BusinessContextException
- if any one of the attributes is not validContext.validate()