atg.scenario.targeting
Class Slot

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.scenario.targeting.Slot
All Implemented Interfaces:
NameContextBindingListener, NameContextElement, NameResolver, AdminableService, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, atg.nucleus.logging.VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, Targeter, java.io.Serializable, java.util.EventListener
Direct Known Subclasses:
RepositoryItemSlot

public class Slot
extends GenericService
implements Targeter, java.io.Serializable

A Slot is a container for a set of displayable dynamic beans. A slot acts as a Targeter, i.e. a source of personalized displayable content. As such, it can be used by any of the Targeting family of droplets to render content within a page.

Slots serve as buffers between generators of displayable content and renderers of that content. A generator will access a slot and modify its contents, perhaps adding some content items from a repository. A renderer may later access the same slot via the Targeter interface, pulling content out of the slot and showing it. Many modes of use are possible: the generator and renderer may access the slot in quick succession during the same request thread, or the generator may run once to set up content at session start to be subsequently rendered over and over again.

Slots have both an active and a passive mode:

In the passive mode, which is the default, a slot simply waits for content generators to place items in it. No messages are posted.

In the active mode, an empty slot will post a synchronous local JMS message when its contents are requested; the purpose of the message is to notify any interested content generators that the slot would like some items. The message will convey significant data from the NameResolver context passed in by the renderer.

Slots can also be configured for the following retrieval modes:

Slots can be also configured to automatically order their contents in the following ways:

A slot guarantees that following any generator modification of its contents, ordering will be reapplied before a renderer can access those contents.

Slots do not permit duplicate items to be entered, even with different priorities. Adding an item that already exists does not duplicate it, but results in its priority being set to the maximum of all priorities that it has been added with.

Finally, slots can be configured with a maxRenderSize property; this determines the largest number of items that a call to any of the target() methods will ever return, effectively acting as a ceiling on the pMaxNumber parameter to those methods. A rotating slot whose maxRenderSize is 1 will always return items one-at-a-time, rotating through the set of items in the slot, even if a TargetingForEach droplet is used with no maximum item count parameter.

See Also:
Serialized Form

Nested Class Summary
protected static class Slot.SlotEntry
          SlotEntry class: holds priority alongside item.
 
Field Summary
static int ACTIVE_GENERATION
           
static java.lang.String CLASS_VERSION
           
protected static int DEFAULT_PRIORITY
           
static int DESTRUCTIVE_RETRIEVAL
           
static int PASSIVE_GENERATION
           
static int PRIORITY_RANDOM_ORDERING
           
static int PRIORITY_SEQUENTIAL_ORDERING
           
static int ROTATING_RETRIEVAL
           
static int STATIC_RETRIEVAL
           
 
Fields inherited from class atg.nucleus.GenericService
SERVICE_INFO_KEY
 
Fields inherited from interface atg.targeting.Targeter
NO_MAX_NUMBER, NO_START_INDEX
 
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
Slot()
           
 
Method Summary
 void add(java.lang.Object pItem)
          Add an item to this slot with a default priority.
 void add(java.lang.Object pItem, int pPriority)
          Add an item to this slot.
 void addAll(java.util.Collection pItems)
          Add multiple items to this slot with a default priority.
 void addAll(java.util.Collection pItems, int pPriority)
          Add an item to this slot.
 void clear()
          Clear all items from the slot.
 boolean getAllowDuplicates()
          Returns flag controlling whether duplicates are allowed or not
 java.util.Collection getCurrentItems()
           
 int getEntryCount()
          Returns the number of entries currently in this slot
 int getGeneration()
          Returns content generation mode
 int getMaxRenderSize()
          Returns maximum render size.
 java.lang.String getMessageSourcePath()
          Returns the path to the DSS Message Source
 int getOrdering()
          Returns content ordering mode
protected  java.lang.Object[] getRange(int pStartIndex, int pMaxNumber)
          Return a list of objects to be rendered.
 int getRetrieval()
          Returns content retrieval mode
 java.lang.Class getValueType()
          Returns the type of values contained by the slot, null if the slot is allowed to contain values of any type.
 void remove(java.lang.Object pItem)
          Remove an item from this slot.
 void removeAll(java.util.Collection pItems)
          Remove a collection of items from this slot.
 void setAllowDuplicates(boolean pAllowDuplicates)
          Sets flag controlling whether duplicates are allowed or not
 void setGeneration(int pGeneration)
          Sets content generation mode
 void setMaxRenderSize(int pMaxRenderSize)
          Sets maximum render size: the maximum number of items that will be returned at one time in a single rendering call through the Targeter interface.
 void setMessageSourcePath(java.lang.String pMessageSourcePath)
          Sets the nucleus path to the DSS Message Source
 void setOrdering(int pOrdering)
          Sets content ordering mode
 void setRetrieval(int pRetrieval)
          Sets content retrieval mode
 void setValueType(java.lang.Class pValueType)
          Sets the type of values contained by the slot.
protected  void sortItems()
          Sort the collection of items according to our mode.
 java.lang.Object[] target(NameResolver pNameResolver)
          Performs a targeting operation, returning an array of "target" objects.
 java.lang.Object[] target(NameResolver pNameResolver, int pMaxNumber)
          Performs a targeting operation, returning an array of "target" objects containing at most pMaxNumber elements.
 java.lang.Object[] target(NameResolver pNameResolver, int pStartIndex, int pMaxNumber)
          Performs a targeting operation, returning an array of "target" objects, beginning at the starting index of the entire result set, and containing at most pMaxNumber elements.
 java.lang.String toString()
          Render slot as a string, marking current item.
protected  void trimConsumedItems()
          Trim off any inactive portion of the list.
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, doStartService, doStopService, 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, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION

ACTIVE_GENERATION

public static final int ACTIVE_GENERATION
See Also:
Constant Field Values

PASSIVE_GENERATION

public static final int PASSIVE_GENERATION
See Also:
Constant Field Values

STATIC_RETRIEVAL

public static final int STATIC_RETRIEVAL
See Also:
Constant Field Values

ROTATING_RETRIEVAL

public static final int ROTATING_RETRIEVAL
See Also:
Constant Field Values

DESTRUCTIVE_RETRIEVAL

public static final int DESTRUCTIVE_RETRIEVAL
See Also:
Constant Field Values

PRIORITY_SEQUENTIAL_ORDERING

public static final int PRIORITY_SEQUENTIAL_ORDERING
See Also:
Constant Field Values

PRIORITY_RANDOM_ORDERING

public static final int PRIORITY_RANDOM_ORDERING
See Also:
Constant Field Values

DEFAULT_PRIORITY

protected static final int DEFAULT_PRIORITY
See Also:
Constant Field Values
Constructor Detail

Slot

public Slot()
Method Detail

setGeneration

public void setGeneration(int pGeneration)
Sets content generation mode


getGeneration

public int getGeneration()
Returns content generation mode


setRetrieval

public void setRetrieval(int pRetrieval)
Sets content retrieval mode


getRetrieval

public int getRetrieval()
Returns content retrieval mode


setOrdering

public void setOrdering(int pOrdering)
Sets content ordering mode


getOrdering

public int getOrdering()
Returns content ordering mode


setAllowDuplicates

public void setAllowDuplicates(boolean pAllowDuplicates)
Sets flag controlling whether duplicates are allowed or not


getAllowDuplicates

public boolean getAllowDuplicates()
Returns flag controlling whether duplicates are allowed or not


setMaxRenderSize

public void setMaxRenderSize(int pMaxRenderSize)
Sets maximum render size: the maximum number of items that will be returned at one time in a single rendering call through the Targeter interface.


getMaxRenderSize

public int getMaxRenderSize()
Returns maximum render size.


getValueType

public java.lang.Class getValueType()
Returns the type of values contained by the slot, null if the slot is allowed to contain values of any type.


setValueType

public void setValueType(java.lang.Class pValueType)
Sets the type of values contained by the slot. The value type serves as a hint to the UI as to what type of objects are contained in the slot; it is not enforced in any way by the server.


getMessageSourcePath

public java.lang.String getMessageSourcePath()
Returns the path to the DSS Message Source


setMessageSourcePath

public void setMessageSourcePath(java.lang.String pMessageSourcePath)
Sets the nucleus path to the DSS Message Source


add

public void add(java.lang.Object pItem)
Add an item to this slot with a default priority.

Parameters:
pItem - the item to be added.

add

public void add(java.lang.Object pItem,
                int pPriority)
Add an item to this slot.

Parameters:
pItem - the item to be added.
pPriority - a relative priority used to order the items for rendering

addAll

public void addAll(java.util.Collection pItems)
Add multiple items to this slot with a default priority.

Parameters:
pItems - the collection of items to be added.

addAll

public void addAll(java.util.Collection pItems,
                   int pPriority)
Add an item to this slot.

Parameters:
pItems - the items to be added.
pPriority - a relative priority used to order the items for rendering

remove

public void remove(java.lang.Object pItem)
Remove an item from this slot.

Parameters:
pItem - the item to be removed.

removeAll

public void removeAll(java.util.Collection pItems)
Remove a collection of items from this slot.

Parameters:
pItems - the items to be removed.

getEntryCount

public int getEntryCount()
Returns the number of entries currently in this slot

Returns:
the number of entries currently in this slot

clear

public void clear()
Clear all items from the slot.


target

public java.lang.Object[] target(NameResolver pNameResolver)
                          throws atg.targeting.TargetingException
Performs a targeting operation, returning an array of "target" objects. The NameResolver argument carries information about the source objects associated with the targeting operation - the "context" of the targeting operation.

Returns null if no items are found matching the targeting criteria.

Specified by:
target in interface Targeter
Parameters:
pNameResolver - a NameResolver that can be used by the operation. At a minimum this must be able to resolve global Nucleus components.
Throws:
atg.targeting.TargetingException - if a problem was encountered during the targeting operation

target

public java.lang.Object[] target(NameResolver pNameResolver,
                                 int pMaxNumber)
                          throws atg.targeting.TargetingException
Performs a targeting operation, returning an array of "target" objects containing at most pMaxNumber elements. The NameResolver argument carries information about the source objects associated with the targeting operation - the "context" of the targeting operation.

Returns null if no items are found matching the targeting criteria.

Specified by:
target in interface Targeter
Parameters:
pNameResolver - a NameResolver that can be used by the operation. At a minimum this must be able to resolve global Nucleus components.
pMaxNumber - the maximum number of elements to return; if -1, the entire result set will be retrieved
Throws:
atg.targeting.TargetingException - if a problem was encountered during the targeting operation

target

public java.lang.Object[] target(NameResolver pNameResolver,
                                 int pStartIndex,
                                 int pMaxNumber)
                          throws atg.targeting.TargetingException
Performs a targeting operation, returning an array of "target" objects, beginning at the starting index of the entire result set, and containing at most pMaxNumber elements. The NameResolver argument carries information about the source objects associated with the targeting operation - the "context" of the targeting operation.

Returns null if no items are found matching the targeting criteria, or if the number of items found is smaller than the specified starting index.

Specified by:
target in interface Targeter
Parameters:
pNameResolver - a NameResolver that can be used by the operation. At a minimum this must be able to resolve global Nucleus components.
pStartIndex - the starting index; must be >= 0
pMaxNumber - the maximum number of elements to return; if -1, the entire result set starting at index pStartIndex will be retrieved
Throws:
atg.targeting.TargetingException - if a problem was encountered during the targeting operation

getRange

protected java.lang.Object[] getRange(int pStartIndex,
                                      int pMaxNumber)
Return a list of objects to be rendered.

Parameters:
pStartIndex - the starting index of the rendering
pMaxNumber - the maximum number of objects to render
Returns:
an array of items that should be rendered by the caller.

sortItems

protected void sortItems()
Sort the collection of items according to our mode.


trimConsumedItems

protected void trimConsumedItems()
Trim off any inactive portion of the list.


toString

public java.lang.String toString()
Render slot as a string, marking current item.

Overrides:
toString in class java.lang.Object

getCurrentItems

public java.util.Collection getCurrentItems()
Returns:
a collection of items currently in the slot.