com.google.code.rees.scope.conversation
Class ConversationUtil

java.lang.Object
  extended by com.google.code.rees.scope.conversation.ConversationUtil

public class ConversationUtil
extends Object

Provides static methods intended primarily for use internally and in unit testing. Use outside of these contexts should come only as a last resort.

Author:
rees.byars

Constructor Summary
ConversationUtil()
           
 
Method Summary
static ConversationContext begin(String name, ConversationAdapter adapter, long maxIdleTimeMillis)
          A convenience method for beginning a conversation programmatically
static ConversationContext begin(String name, long maxIdleTimeMillis)
          A convenience method for beginning a conversation programmatically
static ConversationContext end(String name)
          A convenience method for ending a conversation programmatically.
static ConversationContext end(String name, ConversationAdapter adapter)
          A convenience method for ending a conversation programmatically.
static ConversationContext getContext(String name)
          Given the conversation name, returns that conversation's context for the current request.
static String[] getConversations()
          An array of all active conversations for the current request.
static Object getField(String fieldName)
          Given a conversation field's name, the value of the field is returned from a conversation map in the current thread.
static
<T> T
getField(String fieldName, Class<T> fieldClass)
          Given a conversation field's name and class, the value of the field is returned from a conversation map in the current thread.
static
<T> T
getField(String fieldName, Class<T> fieldClass, String[] conversations)
          Given a conversation field's name and class and an Array of conversation names, the value of the field is returned from the first conversation in the Array that contains an instance of the field.
static String getId(String conversationName)
          Given a conversation name, returns the ID of the conversation for the currently executing thread.
static String[] getIds()
          Returns an array of all the conversation IDs on the current request
static ConversationContext persist(String name)
          Persist a conversation programmatically
static ConversationContext persist(String name, ConversationAdapter adapter)
          Persist a conversation programmatically
static String sanitizeName(String conversationName)
          Used to remove undesired characters from conversation names
static void setField(String fieldName, Object fieldValue)
          Given a conversation field's name and an instance, the value is set for the field in all active conversations of which the field is a member.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConversationUtil

public ConversationUtil()
Method Detail

getId

public static String getId(String conversationName)
Given a conversation name, returns the ID of the conversation for the currently executing thread.

Parameters:
conversationName -
Returns:

getField

public static Object getField(String fieldName)
Given a conversation field's name, the value of the field is returned from a conversation map in the current thread.

Parameters:
fieldName -
Returns:

getField

public static <T> T getField(String fieldName,
                             Class<T> fieldClass)
Given a conversation field's name and class, the value of the field is returned from a conversation map in the current thread.

Type Parameters:
T -
Parameters:
fieldName -
fieldClass -
Returns:

getField

public static <T> T getField(String fieldName,
                             Class<T> fieldClass,
                             String[] conversations)
Given a conversation field's name and class and an Array of conversation names, the value of the field is returned from the first conversation in the Array that contains an instance of the field.

Type Parameters:
T -
Parameters:
fieldName -
fieldClass -
conversations -
Returns:

setField

public static void setField(String fieldName,
                            Object fieldValue)
Given a conversation field's name and an instance, the value is set for the field in all active conversations of which the field is a member.

Parameters:
fieldName -
fieldValue -

begin

public static ConversationContext begin(String name,
                                        long maxIdleTimeMillis)
A convenience method for beginning a conversation programmatically

Parameters:
name -
maxIdleTimeMillis -
Returns:

begin

public static ConversationContext begin(String name,
                                        ConversationAdapter adapter,
                                        long maxIdleTimeMillis)
A convenience method for beginning a conversation programmatically

Parameters:
name -
adapter -
maxIdleTimeMillis -
Returns:

persist

public static ConversationContext persist(String name)
Persist a conversation programmatically

Parameters:
name -
Returns:
The ConversationContext or null if the conversation is not active

persist

public static ConversationContext persist(String name,
                                          ConversationAdapter adapter)
Persist a conversation programmatically

Parameters:
name -
Returns:
The ConversationContext or null if the conversation is not active

end

public static ConversationContext end(String name)
A convenience method for ending a conversation programmatically.

Parameters:
name -
Returns:
The ConversationContext or null if the conversation is not active

end

public static ConversationContext end(String name,
                                      ConversationAdapter adapter)
A convenience method for ending a conversation programmatically.

Parameters:
name -
Returns:
The ConversationContext or null if the conversation is not active

getContext

public static ConversationContext getContext(String name)
Given the conversation name, returns that conversation's context for the current request.

Parameters:
name -
Returns:
The ConversationContext or null if the conversation is not active

getConversations

public static String[] getConversations()
An array of all active conversations for the current request.

Returns:

getIds

public static String[] getIds()
Returns an array of all the conversation IDs on the current request

Returns:

sanitizeName

public static String sanitizeName(String conversationName)
Used to remove undesired characters from conversation names

Parameters:
conversationName -
Returns:


Copyright © 2012-2013. All Rights Reserved.