You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by sk...@apache.org on 2008/07/03 23:58:25 UTC
svn commit: r673833 [8/18] - in /myfaces/tomahawk/trunk:
core/src/main/java/org/apache/myfaces/component/
core/src/main/java/org/apache/myfaces/component/html/ext/
core/src/main/java/org/apache/myfaces/component/html/util/
core/src/main/java/org/apache...
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationManager.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationManager.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationManager.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationManager.java Thu Jul 3 14:58:05 2008
@@ -42,551 +42,551 @@
*/
public class ConversationManager implements Serializable
{
- private final static Log log = LogFactory.getLog(ConversationManager.class);
+ private final static Log log = LogFactory.getLog(ConversationManager.class);
- public final static String CONVERSATION_CONTEXT_PARAM = "conversationContext";
+ public final static String CONVERSATION_CONTEXT_PARAM = "conversationContext";
- private final static String INIT_PERSISTENCE_MANAGER_FACOTRY = "org.apache.myfaces.conversation.PERSISTENCE_MANAGER_FACTORY";
- private final static String INIT_MESSAGER = "org.apache.myfaces.conversation.MESSAGER";
- private final static String INIT_BEAN_ELEVATOR = "org.apache.myfaces.conversation.BEAN_ELEVATOR";
-
- private final static String CONVERSATION_MANAGER_KEY = "org.apache.myfaces.ConversationManager";
- private final static String CONVERSATION_CONTEXT_REQ = "org.apache.myfaces.ConversationManager.conversationContext";
-
- private static long NEXT_CONVERSATION_CONTEXT = 1;
-
- private PersistenceManagerFactory persistenceManagerFactory;
- private ConversationMessager conversationMessager;
- private ConversationBeanElevator conversationBeanElevator;
-
- private final Map conversationContexts = new HashMap();
-
- // private final List registeredEndConversations = new ArrayList(10);
-
- private class ContextWiperThread extends Thread
- {
- private final static long CHECK_TIME = 5 * 60 * 1000; // every 5 min
- public ContextWiperThread()
- {
- setDaemon(true);
- setName("ConversationManager.ContextWiperThread");
- }
-
- public void run()
- {
- while (!isInterrupted())
- {
- checkContextTimeout();
-
- try
- {
- Thread.sleep(CHECK_TIME);
- }
- catch (InterruptedException e)
- {
- log.warn(e.getLocalizedMessage(), e);
- }
- }
- }
- }
- private ContextWiperThread wiperThread = new ContextWiperThread();
-
- protected ConversationManager()
- {
- wiperThread.start();
- }
-
- /**
- * Get the conversation manager
- */
- public static ConversationManager getInstance()
- {
- FacesContext context = FacesContext.getCurrentInstance();
- if (context == null)
- {
- // check if we have a chance outside the FacesContext
- ConversationManager cm = ConversationServletFilter.getConversationManager();
- if (cm != null)
- {
- return cm;
- }
-
- throw new IllegalStateException("no faces context available");
- }
- return getInstance(context);
- }
-
- /**
- * Get the conversation manager
- */
- public static ConversationManager getInstance(FacesContext context)
- {
- ConversationManager conversationManager = (ConversationManager) context.getExternalContext().getSessionMap().get(CONVERSATION_MANAGER_KEY);
- if (conversationManager == null)
- {
- if (!Boolean.TRUE.equals(context.getExternalContext().getRequestMap().get(ConversationServletFilter.CONVERSATION_FILTER_CALLED)))
- {
- throw new IllegalStateException("ConversationServletFilter not called. Please configure the filter org.apache.myfaces.custom.conversation.ConversationServletFilter in your web.xml to cover your faces requests.");
- }
-
- conversationManager = createConversationManager();
-
- // initialize environmental systems
- RequestParameterProviderManager.getInstance(context).register(new ConversationRequestParameterProvider());
-
- // set mark
- context.getExternalContext().getSessionMap().put(CONVERSATION_MANAGER_KEY, conversationManager);
- }
-
- return conversationManager;
- }
-
- protected static ConversationManager createConversationManager()
- {
- ConversationManager conversationManager;
-
- // create manager
- conversationManager = new ConversationManager();
-
- // initialize the messager
- conversationManager.createMessager();
-
- // initialize the bean elevator
- conversationManager.createBeanElevator();
-
- return conversationManager;
- }
-
- /**
- * Get the conversation manager from the http session. This will <b>not</b> create a conversation manager if none exists.
- */
- public static ConversationManager getInstance(HttpSession session)
- {
- if (session == null)
- {
- return null;
- }
- return (ConversationManager) session.getAttribute(CONVERSATION_MANAGER_KEY);
- }
-
- /**
- * Get the current, or create a new unique conversationContextId.<br />
- * The current conversationContextId will retrieved from the request parameters, if we cant find it there
- * a new one will be created. In either case the result will be stored within the request for faster lookup.
- */
- protected Long getConversationContextId()
- {
- Map requestMap;
- Map requestParameterMap;
-
- FacesContext context = FacesContext.getCurrentInstance();
- if (context != null)
- {
- requestMap = context.getExternalContext().getRequestMap();
- requestParameterMap = context.getExternalContext().getRequestParameterMap();
- }
- else
- {
- ConversationExternalContext ccontext = ConversationServletFilter.getConversationExternalContext();
- if (ccontext != null)
- {
- requestMap = ccontext.getRequestMap();
- requestParameterMap = ccontext.getRequestParameterMap();
- }
- else
- {
- throw new IllegalStateException("cant find a requestMap or requestParameterMap");
- }
- }
-
- Long conversationContextId = (Long) requestMap.get(CONVERSATION_CONTEXT_REQ);
- if (conversationContextId == null)
- {
- if (requestParameterMap.containsKey(CONVERSATION_CONTEXT_PARAM))
- {
- String urlConversationContextId = requestParameterMap.get(CONVERSATION_CONTEXT_PARAM).toString();
- conversationContextId = new Long(Long.parseLong(urlConversationContextId, Character.MAX_RADIX));
- }
- else
- {
- synchronized (ConversationManager.class)
- {
- conversationContextId = new Long(NEXT_CONVERSATION_CONTEXT);
- NEXT_CONVERSATION_CONTEXT++;
- }
- }
-
- requestMap.put(CONVERSATION_CONTEXT_REQ, conversationContextId);
- }
-
- return conversationContextId;
- }
-
- /**
- * Get the conversation context for the given id
- */
- protected ConversationContext getConversationContext(Long conversationContextId)
- {
- synchronized (conversationContexts)
- {
- return (ConversationContext) conversationContexts.get(conversationContextId);
- }
- }
-
- /**
- * Get the conversation context for the given id. <br />
- * If there is no conversation context a new one will be created
- */
- protected ConversationContext getOrCreateConversationContext(Long conversationContextId)
- {
- synchronized (conversationContexts)
- {
- ConversationContext conversationContext = (ConversationContext) conversationContexts.get(conversationContextId);
- if (conversationContext == null)
- {
- conversationContext = new ConversationContext(conversationContextId.longValue());
- conversationContexts.put(conversationContextId, conversationContext);
- }
-
- return conversationContext;
- }
- }
-
- /**
- * Destroy the given conversation context
- */
- protected void destroyConversationContext(Long conversationContextId)
- {
- synchronized (conversationContexts)
- {
- conversationContexts.remove(conversationContextId);
- }
- }
-
- /**
- * Start a conversation
- * @see ConversationContext#startConversation(String, boolean)
- */
- public void startConversation(String name, boolean persistence)
- {
- Long conversationContextId = getConversationContextId();
- ConversationContext conversationContext = getOrCreateConversationContext(conversationContextId);
- conversationContext.startConversation(name, persistence);
- }
-
- /**
- * End a conversation
- * @see ConversationContext#endConversation(String, boolean)
- */
- public void endConversation(String name, boolean regularEnd)
- {
- Long conversationContextId = getConversationContextId();
- ConversationContext conversationContext = getConversationContext(conversationContextId);
- if (conversationContext != null)
- {
- conversationContext.endConversation(name, regularEnd);
-
- if (!conversationContext.hasConversations())
- {
- destroyConversationContext(conversationContextId);
- }
- }
- }
-
- /**
- * Get the conversation with the given name
- *
- * @return null if no conversation context is active or if the conversation did not exist.
- */
- public Conversation getConversation(String name)
- {
- ConversationContext conversationContext = getConversationContext();
- if (conversationContext == null)
- {
- return null;
- }
- return conversationContext.getConversation(name);
- }
-
- /**
- * Find the conversation which holds the given instance
- *
- * @return null if no conversation context is active or if the conversation did not exist.
- */
- public Conversation findConversation(Object instance)
- {
- ConversationContext conversationContext = getConversationContext();
- if (conversationContext == null)
- {
- return null;
- }
- return conversationContext.findConversation(instance);
- }
-
- /**
- * check if the given conversation is active
- */
- public boolean hasConversation(String name)
- {
- ConversationContext conversationContext = getConversationContext();
- if (conversationContext == null)
- {
- return false;
- }
- return conversationContext.hasConversation(name);
- }
-
- /**
- * Get the current conversation context.
- * @return null if there is no context active
- */
- protected ConversationContext getConversationContext()
- {
- Long conversationContextId = getConversationContextId();
- ConversationContext conversationContext = getConversationContext(conversationContextId);
- return conversationContext;
- }
-
- /**
- * Register the conversation to be ended after the cycle
- protected void registerEndConversation(String conversationName)
- {
- synchronized (registeredEndConversations)
- {
- registeredEndConversations.add(conversationName);
- }
- }
- */
-
- /**
- * Get all registered conversations
- protected List getRegisteredEndConversations()
- {
- return registeredEndConversations;
- }
- */
-
- /**
- * check if we have a conversation context
- */
- public boolean hasConversationContext()
- {
- FacesContext context = FacesContext.getCurrentInstance();
-
- return
- (context.getExternalContext().getRequestMap().containsKey(CONVERSATION_CONTEXT_REQ) ||
- context.getExternalContext().getRequestParameterMap().containsKey(CONVERSATION_CONTEXT_PARAM)) &&
- getConversationContext() != null;
- }
-
- /**
- * get the persistence manager responsible for the current conversation
- */
- public PersistenceManager getPersistenceManager()
- {
- ConversationContext conversationContext = getConversationContext();
- if (conversationContext == null)
- {
- return null;
- }
-
- return conversationContext.getPersistenceManager();
- }
-
- /**
- * create a persistence manager
- */
- protected PersistenceManager createPersistenceManager()
- {
- return getPersistenceManagerFactory().create();
- }
-
- /**
- * Get the Messager used to inform the user about anomalies.<br />
- * The factory can be configured in your web.xml using the init parameter named
- * <code>org.apache.myfaces.conversation.MESSAGER</code>
- */
- protected ConversationMessager getMessager()
- {
- return conversationMessager;
- }
-
- /**
- * Create the Messager used to inform the user about anomalies.<br />
- * The factory can be configured in your web.xml using the init parameter named
- * <code>org.apache.myfaces.conversation.MESSAGER</code>
- */
- protected void createMessager()
- {
- String conversationMessagerName = FacesContext.getCurrentInstance().getExternalContext().getInitParameter(INIT_MESSAGER);
- if (conversationMessagerName == null)
- {
- conversationMessager = new DefaultConversationMessager();
- }
- else
- {
- try
- {
- conversationMessager = (ConversationMessager) ClassUtils.classForName(conversationMessagerName).newInstance();
- }
- catch (InstantiationException e)
- {
- throw new FacesException("error creating messager: " + conversationMessagerName, e);
- }
- catch (IllegalAccessException e)
- {
- throw new FacesException("error creating messager: " + conversationMessagerName, e);
- }
- catch (ClassNotFoundException e)
- {
- throw new FacesException("error creating messager: " + conversationMessagerName, e);
- }
- }
- }
-
- /**
- * Create the BeanElevator used to find a bean within the different contexts and elevate it
- * into the conversation scope.<br />
- * You can configure it in your web.xml using the init parameter named
- * <code>org.apache.myfaces.conversation.BEAN_ELEVATOR</code>
- */
- protected void createBeanElevator()
- {
- String conversationBeanElevatorName = FacesContext.getCurrentInstance().getExternalContext().getInitParameter(INIT_BEAN_ELEVATOR);
- if (conversationBeanElevatorName == null)
- {
- conversationBeanElevator = new DefaultConversationBeanElevator();
- }
- else
- {
- try
- {
- conversationBeanElevator = (DefaultConversationBeanElevator) ClassUtils.classForName(conversationBeanElevatorName).newInstance();
- }
- catch (InstantiationException e)
- {
- throw new FacesException("error creating bean elevator: " + conversationBeanElevatorName, e);
- }
- catch (IllegalAccessException e)
- {
- throw new FacesException("error creating bean elevator: " + conversationBeanElevatorName, e);
- }
- catch (ClassNotFoundException e)
- {
- throw new FacesException("error creating bean elevator: " + conversationBeanElevatorName, e);
- }
- }
- }
-
- /**
- * Get the persistenceManagerFactory.<br />
- * The factory can be configured in your web.xml using the init parameter named
- * <code>org.apache.myfaces.conversation.PERSISTENCE_MANAGER_FACTORY</code>
- */
- protected PersistenceManagerFactory getPersistenceManagerFactory()
- {
- if (persistenceManagerFactory == null)
- {
- String persistenceManagerFactoryName = (String) ConversationServletFilter.getConversationExternalContext().getInitParameterMap().get(INIT_PERSISTENCE_MANAGER_FACOTRY);
- if (persistenceManagerFactoryName == null)
- {
- throw new IllegalArgumentException("please configure '" + INIT_PERSISTENCE_MANAGER_FACOTRY + "' in your web.xml");
- }
- try
- {
- persistenceManagerFactory = (PersistenceManagerFactory) ClassUtils.classForName(persistenceManagerFactoryName).newInstance();
- }
- catch (InstantiationException e)
- {
- throw new FacesException("error creating persistenceManagerFactory named: " + persistenceManagerFactoryName, e);
- }
- catch (IllegalAccessException e)
- {
- throw new FacesException("error creating persistenceManagerFactory named: " + persistenceManagerFactoryName, e);
- }
- catch (ClassNotFoundException e)
- {
- throw new FacesException("error creating persistenceManagerFactory named: " + persistenceManagerFactoryName, e);
- }
- }
-
- return persistenceManagerFactory;
- }
-
- protected void attachPersistence()
- {
- ConversationContext conversationContext = getConversationContext();
- if (conversationContext != null)
- {
- conversationContext.attachPersistence();
- }
- }
-
- protected void detachPersistence()
- {
- ConversationContext conversationContext = getConversationContext();
- if (conversationContext != null)
- {
- conversationContext.detachPersistence();
- }
- }
-
- protected void purgePersistence()
- {
- ConversationContext conversationContext = getConversationContext();
- if (conversationContext != null)
- {
- conversationContext.purgePersistence();
- }
- }
-
- protected void checkContextTimeout()
- {
- synchronized (conversationContexts)
- {
- long timeToLive = 30 * 60 * 1000;
- long checkTime = System.currentTimeMillis();
-
- Iterator iterContexts = conversationContexts.values().iterator();
- while (iterContexts.hasNext())
- {
- ConversationContext conversationContext = (ConversationContext) iterContexts.next();
- if (conversationContext.getLastAccess() + timeToLive < checkTime)
- {
- if (log.isDebugEnabled())
- {
- log.debug("end conversation context due to timeout: " + conversationContext.getId());
- }
- conversationContext.shutdownContext();
- iterContexts.remove();
- }
- }
- }
- }
-
-
- /**
- * the bean elevator used to get beans int the conversation scope
- */
- public ConversationBeanElevator getConversationBeanElevator()
- {
- return conversationBeanElevator;
- }
-
- private void writeObject(java.io.ObjectOutputStream out) throws IOException
- {
- // the conversation manager is not (yet) serializable, we just implement it
- // to make it work with distributed sessions
- }
-
- private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException
- {
- // nothing written, so nothing to read
- }
-
- private Object readResolve() throws ObjectStreamException
- {
- // do not return a real object, that way on first request a new conversation manager will be created
- return null;
- }
+ private final static String INIT_PERSISTENCE_MANAGER_FACOTRY = "org.apache.myfaces.conversation.PERSISTENCE_MANAGER_FACTORY";
+ private final static String INIT_MESSAGER = "org.apache.myfaces.conversation.MESSAGER";
+ private final static String INIT_BEAN_ELEVATOR = "org.apache.myfaces.conversation.BEAN_ELEVATOR";
+
+ private final static String CONVERSATION_MANAGER_KEY = "org.apache.myfaces.ConversationManager";
+ private final static String CONVERSATION_CONTEXT_REQ = "org.apache.myfaces.ConversationManager.conversationContext";
+
+ private static long NEXT_CONVERSATION_CONTEXT = 1;
+
+ private PersistenceManagerFactory persistenceManagerFactory;
+ private ConversationMessager conversationMessager;
+ private ConversationBeanElevator conversationBeanElevator;
+
+ private final Map conversationContexts = new HashMap();
+
+ // private final List registeredEndConversations = new ArrayList(10);
+
+ private class ContextWiperThread extends Thread
+ {
+ private final static long CHECK_TIME = 5 * 60 * 1000; // every 5 min
+ public ContextWiperThread()
+ {
+ setDaemon(true);
+ setName("ConversationManager.ContextWiperThread");
+ }
+
+ public void run()
+ {
+ while (!isInterrupted())
+ {
+ checkContextTimeout();
+
+ try
+ {
+ Thread.sleep(CHECK_TIME);
+ }
+ catch (InterruptedException e)
+ {
+ log.warn(e.getLocalizedMessage(), e);
+ }
+ }
+ }
+ }
+ private ContextWiperThread wiperThread = new ContextWiperThread();
+
+ protected ConversationManager()
+ {
+ wiperThread.start();
+ }
+
+ /**
+ * Get the conversation manager
+ */
+ public static ConversationManager getInstance()
+ {
+ FacesContext context = FacesContext.getCurrentInstance();
+ if (context == null)
+ {
+ // check if we have a chance outside the FacesContext
+ ConversationManager cm = ConversationServletFilter.getConversationManager();
+ if (cm != null)
+ {
+ return cm;
+ }
+
+ throw new IllegalStateException("no faces context available");
+ }
+ return getInstance(context);
+ }
+
+ /**
+ * Get the conversation manager
+ */
+ public static ConversationManager getInstance(FacesContext context)
+ {
+ ConversationManager conversationManager = (ConversationManager) context.getExternalContext().getSessionMap().get(CONVERSATION_MANAGER_KEY);
+ if (conversationManager == null)
+ {
+ if (!Boolean.TRUE.equals(context.getExternalContext().getRequestMap().get(ConversationServletFilter.CONVERSATION_FILTER_CALLED)))
+ {
+ throw new IllegalStateException("ConversationServletFilter not called. Please configure the filter org.apache.myfaces.custom.conversation.ConversationServletFilter in your web.xml to cover your faces requests.");
+ }
+
+ conversationManager = createConversationManager();
+
+ // initialize environmental systems
+ RequestParameterProviderManager.getInstance(context).register(new ConversationRequestParameterProvider());
+
+ // set mark
+ context.getExternalContext().getSessionMap().put(CONVERSATION_MANAGER_KEY, conversationManager);
+ }
+
+ return conversationManager;
+ }
+
+ protected static ConversationManager createConversationManager()
+ {
+ ConversationManager conversationManager;
+
+ // create manager
+ conversationManager = new ConversationManager();
+
+ // initialize the messager
+ conversationManager.createMessager();
+
+ // initialize the bean elevator
+ conversationManager.createBeanElevator();
+
+ return conversationManager;
+ }
+
+ /**
+ * Get the conversation manager from the http session. This will <b>not</b> create a conversation manager if none exists.
+ */
+ public static ConversationManager getInstance(HttpSession session)
+ {
+ if (session == null)
+ {
+ return null;
+ }
+ return (ConversationManager) session.getAttribute(CONVERSATION_MANAGER_KEY);
+ }
+
+ /**
+ * Get the current, or create a new unique conversationContextId.<br />
+ * The current conversationContextId will retrieved from the request parameters, if we cant find it there
+ * a new one will be created. In either case the result will be stored within the request for faster lookup.
+ */
+ protected Long getConversationContextId()
+ {
+ Map requestMap;
+ Map requestParameterMap;
+
+ FacesContext context = FacesContext.getCurrentInstance();
+ if (context != null)
+ {
+ requestMap = context.getExternalContext().getRequestMap();
+ requestParameterMap = context.getExternalContext().getRequestParameterMap();
+ }
+ else
+ {
+ ConversationExternalContext ccontext = ConversationServletFilter.getConversationExternalContext();
+ if (ccontext != null)
+ {
+ requestMap = ccontext.getRequestMap();
+ requestParameterMap = ccontext.getRequestParameterMap();
+ }
+ else
+ {
+ throw new IllegalStateException("cant find a requestMap or requestParameterMap");
+ }
+ }
+
+ Long conversationContextId = (Long) requestMap.get(CONVERSATION_CONTEXT_REQ);
+ if (conversationContextId == null)
+ {
+ if (requestParameterMap.containsKey(CONVERSATION_CONTEXT_PARAM))
+ {
+ String urlConversationContextId = requestParameterMap.get(CONVERSATION_CONTEXT_PARAM).toString();
+ conversationContextId = new Long(Long.parseLong(urlConversationContextId, Character.MAX_RADIX));
+ }
+ else
+ {
+ synchronized (ConversationManager.class)
+ {
+ conversationContextId = new Long(NEXT_CONVERSATION_CONTEXT);
+ NEXT_CONVERSATION_CONTEXT++;
+ }
+ }
+
+ requestMap.put(CONVERSATION_CONTEXT_REQ, conversationContextId);
+ }
+
+ return conversationContextId;
+ }
+
+ /**
+ * Get the conversation context for the given id
+ */
+ protected ConversationContext getConversationContext(Long conversationContextId)
+ {
+ synchronized (conversationContexts)
+ {
+ return (ConversationContext) conversationContexts.get(conversationContextId);
+ }
+ }
+
+ /**
+ * Get the conversation context for the given id. <br />
+ * If there is no conversation context a new one will be created
+ */
+ protected ConversationContext getOrCreateConversationContext(Long conversationContextId)
+ {
+ synchronized (conversationContexts)
+ {
+ ConversationContext conversationContext = (ConversationContext) conversationContexts.get(conversationContextId);
+ if (conversationContext == null)
+ {
+ conversationContext = new ConversationContext(conversationContextId.longValue());
+ conversationContexts.put(conversationContextId, conversationContext);
+ }
+
+ return conversationContext;
+ }
+ }
+
+ /**
+ * Destroy the given conversation context
+ */
+ protected void destroyConversationContext(Long conversationContextId)
+ {
+ synchronized (conversationContexts)
+ {
+ conversationContexts.remove(conversationContextId);
+ }
+ }
+
+ /**
+ * Start a conversation
+ * @see ConversationContext#startConversation(String, boolean)
+ */
+ public void startConversation(String name, boolean persistence)
+ {
+ Long conversationContextId = getConversationContextId();
+ ConversationContext conversationContext = getOrCreateConversationContext(conversationContextId);
+ conversationContext.startConversation(name, persistence);
+ }
+
+ /**
+ * End a conversation
+ * @see ConversationContext#endConversation(String, boolean)
+ */
+ public void endConversation(String name, boolean regularEnd)
+ {
+ Long conversationContextId = getConversationContextId();
+ ConversationContext conversationContext = getConversationContext(conversationContextId);
+ if (conversationContext != null)
+ {
+ conversationContext.endConversation(name, regularEnd);
+
+ if (!conversationContext.hasConversations())
+ {
+ destroyConversationContext(conversationContextId);
+ }
+ }
+ }
+
+ /**
+ * Get the conversation with the given name
+ *
+ * @return null if no conversation context is active or if the conversation did not exist.
+ */
+ public Conversation getConversation(String name)
+ {
+ ConversationContext conversationContext = getConversationContext();
+ if (conversationContext == null)
+ {
+ return null;
+ }
+ return conversationContext.getConversation(name);
+ }
+
+ /**
+ * Find the conversation which holds the given instance
+ *
+ * @return null if no conversation context is active or if the conversation did not exist.
+ */
+ public Conversation findConversation(Object instance)
+ {
+ ConversationContext conversationContext = getConversationContext();
+ if (conversationContext == null)
+ {
+ return null;
+ }
+ return conversationContext.findConversation(instance);
+ }
+
+ /**
+ * check if the given conversation is active
+ */
+ public boolean hasConversation(String name)
+ {
+ ConversationContext conversationContext = getConversationContext();
+ if (conversationContext == null)
+ {
+ return false;
+ }
+ return conversationContext.hasConversation(name);
+ }
+
+ /**
+ * Get the current conversation context.
+ * @return null if there is no context active
+ */
+ protected ConversationContext getConversationContext()
+ {
+ Long conversationContextId = getConversationContextId();
+ ConversationContext conversationContext = getConversationContext(conversationContextId);
+ return conversationContext;
+ }
+
+ /**
+ * Register the conversation to be ended after the cycle
+ protected void registerEndConversation(String conversationName)
+ {
+ synchronized (registeredEndConversations)
+ {
+ registeredEndConversations.add(conversationName);
+ }
+ }
+ */
+
+ /**
+ * Get all registered conversations
+ protected List getRegisteredEndConversations()
+ {
+ return registeredEndConversations;
+ }
+ */
+
+ /**
+ * check if we have a conversation context
+ */
+ public boolean hasConversationContext()
+ {
+ FacesContext context = FacesContext.getCurrentInstance();
+
+ return
+ (context.getExternalContext().getRequestMap().containsKey(CONVERSATION_CONTEXT_REQ) ||
+ context.getExternalContext().getRequestParameterMap().containsKey(CONVERSATION_CONTEXT_PARAM)) &&
+ getConversationContext() != null;
+ }
+
+ /**
+ * get the persistence manager responsible for the current conversation
+ */
+ public PersistenceManager getPersistenceManager()
+ {
+ ConversationContext conversationContext = getConversationContext();
+ if (conversationContext == null)
+ {
+ return null;
+ }
+
+ return conversationContext.getPersistenceManager();
+ }
+
+ /**
+ * create a persistence manager
+ */
+ protected PersistenceManager createPersistenceManager()
+ {
+ return getPersistenceManagerFactory().create();
+ }
+
+ /**
+ * Get the Messager used to inform the user about anomalies.<br />
+ * The factory can be configured in your web.xml using the init parameter named
+ * <code>org.apache.myfaces.conversation.MESSAGER</code>
+ */
+ protected ConversationMessager getMessager()
+ {
+ return conversationMessager;
+ }
+
+ /**
+ * Create the Messager used to inform the user about anomalies.<br />
+ * The factory can be configured in your web.xml using the init parameter named
+ * <code>org.apache.myfaces.conversation.MESSAGER</code>
+ */
+ protected void createMessager()
+ {
+ String conversationMessagerName = FacesContext.getCurrentInstance().getExternalContext().getInitParameter(INIT_MESSAGER);
+ if (conversationMessagerName == null)
+ {
+ conversationMessager = new DefaultConversationMessager();
+ }
+ else
+ {
+ try
+ {
+ conversationMessager = (ConversationMessager) ClassUtils.classForName(conversationMessagerName).newInstance();
+ }
+ catch (InstantiationException e)
+ {
+ throw new FacesException("error creating messager: " + conversationMessagerName, e);
+ }
+ catch (IllegalAccessException e)
+ {
+ throw new FacesException("error creating messager: " + conversationMessagerName, e);
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new FacesException("error creating messager: " + conversationMessagerName, e);
+ }
+ }
+ }
+
+ /**
+ * Create the BeanElevator used to find a bean within the different contexts and elevate it
+ * into the conversation scope.<br />
+ * You can configure it in your web.xml using the init parameter named
+ * <code>org.apache.myfaces.conversation.BEAN_ELEVATOR</code>
+ */
+ protected void createBeanElevator()
+ {
+ String conversationBeanElevatorName = FacesContext.getCurrentInstance().getExternalContext().getInitParameter(INIT_BEAN_ELEVATOR);
+ if (conversationBeanElevatorName == null)
+ {
+ conversationBeanElevator = new DefaultConversationBeanElevator();
+ }
+ else
+ {
+ try
+ {
+ conversationBeanElevator = (DefaultConversationBeanElevator) ClassUtils.classForName(conversationBeanElevatorName).newInstance();
+ }
+ catch (InstantiationException e)
+ {
+ throw new FacesException("error creating bean elevator: " + conversationBeanElevatorName, e);
+ }
+ catch (IllegalAccessException e)
+ {
+ throw new FacesException("error creating bean elevator: " + conversationBeanElevatorName, e);
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new FacesException("error creating bean elevator: " + conversationBeanElevatorName, e);
+ }
+ }
+ }
+
+ /**
+ * Get the persistenceManagerFactory.<br />
+ * The factory can be configured in your web.xml using the init parameter named
+ * <code>org.apache.myfaces.conversation.PERSISTENCE_MANAGER_FACTORY</code>
+ */
+ protected PersistenceManagerFactory getPersistenceManagerFactory()
+ {
+ if (persistenceManagerFactory == null)
+ {
+ String persistenceManagerFactoryName = (String) ConversationServletFilter.getConversationExternalContext().getInitParameterMap().get(INIT_PERSISTENCE_MANAGER_FACOTRY);
+ if (persistenceManagerFactoryName == null)
+ {
+ throw new IllegalArgumentException("please configure '" + INIT_PERSISTENCE_MANAGER_FACOTRY + "' in your web.xml");
+ }
+ try
+ {
+ persistenceManagerFactory = (PersistenceManagerFactory) ClassUtils.classForName(persistenceManagerFactoryName).newInstance();
+ }
+ catch (InstantiationException e)
+ {
+ throw new FacesException("error creating persistenceManagerFactory named: " + persistenceManagerFactoryName, e);
+ }
+ catch (IllegalAccessException e)
+ {
+ throw new FacesException("error creating persistenceManagerFactory named: " + persistenceManagerFactoryName, e);
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new FacesException("error creating persistenceManagerFactory named: " + persistenceManagerFactoryName, e);
+ }
+ }
+
+ return persistenceManagerFactory;
+ }
+
+ protected void attachPersistence()
+ {
+ ConversationContext conversationContext = getConversationContext();
+ if (conversationContext != null)
+ {
+ conversationContext.attachPersistence();
+ }
+ }
+
+ protected void detachPersistence()
+ {
+ ConversationContext conversationContext = getConversationContext();
+ if (conversationContext != null)
+ {
+ conversationContext.detachPersistence();
+ }
+ }
+
+ protected void purgePersistence()
+ {
+ ConversationContext conversationContext = getConversationContext();
+ if (conversationContext != null)
+ {
+ conversationContext.purgePersistence();
+ }
+ }
+
+ protected void checkContextTimeout()
+ {
+ synchronized (conversationContexts)
+ {
+ long timeToLive = 30 * 60 * 1000;
+ long checkTime = System.currentTimeMillis();
+
+ Iterator iterContexts = conversationContexts.values().iterator();
+ while (iterContexts.hasNext())
+ {
+ ConversationContext conversationContext = (ConversationContext) iterContexts.next();
+ if (conversationContext.getLastAccess() + timeToLive < checkTime)
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug("end conversation context due to timeout: " + conversationContext.getId());
+ }
+ conversationContext.shutdownContext();
+ iterContexts.remove();
+ }
+ }
+ }
+ }
+
+
+ /**
+ * the bean elevator used to get beans int the conversation scope
+ */
+ public ConversationBeanElevator getConversationBeanElevator()
+ {
+ return conversationBeanElevator;
+ }
+
+ private void writeObject(java.io.ObjectOutputStream out) throws IOException
+ {
+ // the conversation manager is not (yet) serializable, we just implement it
+ // to make it work with distributed sessions
+ }
+
+ private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException
+ {
+ // nothing written, so nothing to read
+ }
+
+ private Object readResolve() throws ObjectStreamException
+ {
+ // do not return a real object, that way on first request a new conversation manager will be created
+ return null;
+ }
}
\ No newline at end of file
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationMessager.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationMessager.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationMessager.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationMessager.java Thu Jul 3 14:58:05 2008
@@ -27,13 +27,13 @@
*/
public interface ConversationMessager
{
- /**
- * exception happened e.g. during endConversation action
- */
- public void setConversationException(FacesContext context, Throwable t);
+ /**
+ * exception happened e.g. during endConversation action
+ */
+ public void setConversationException(FacesContext context, Throwable t);
- /**
- * message about a not active conversation (close before the redirect)
- */
- public void setConversationNotActive(FacesContext context, String name);
+ /**
+ * message about a not active conversation (close before the redirect)
+ */
+ public void setConversationNotActive(FacesContext context, String name);
}
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationRequestParameterProvider.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationRequestParameterProvider.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationRequestParameterProvider.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationRequestParameterProvider.java Thu Jul 3 14:58:05 2008
@@ -27,48 +27,48 @@
*/
public class ConversationRequestParameterProvider implements RequestParameterProvider
{
- private final static String[] REQUEST_PARAMETERS = new String[]
+ private final static String[] REQUEST_PARAMETERS = new String[]
{
- ConversationManager.CONVERSATION_CONTEXT_PARAM
+ ConversationManager.CONVERSATION_CONTEXT_PARAM
};
-
- public String getFieldValue(String field)
- {
- if (UISeparateConversationContext.isInSeparationMode())
- {
- return null;
- }
-
- ConversationManager conversationManager = ConversationManager.getInstance();
- if (conversationManager == null)
- {
- throw new IllegalStateException("can find the conversationManager");
- }
- if (!conversationManager.hasConversationContext())
- {
- return null;
- }
-
- return Long.toString(conversationManager.getConversationContextId().longValue(), Character.MAX_RADIX);
- }
+
+ public String getFieldValue(String field)
+ {
+ if (UISeparateConversationContext.isInSeparationMode())
+ {
+ return null;
+ }
+
+ ConversationManager conversationManager = ConversationManager.getInstance();
+ if (conversationManager == null)
+ {
+ throw new IllegalStateException("can find the conversationManager");
+ }
+ if (!conversationManager.hasConversationContext())
+ {
+ return null;
+ }
+
+ return Long.toString(conversationManager.getConversationContextId().longValue(), Character.MAX_RADIX);
+ }
- public String[] getFields()
- {
- if (UISeparateConversationContext.isInSeparationMode())
- {
- return null;
- }
+ public String[] getFields()
+ {
+ if (UISeparateConversationContext.isInSeparationMode())
+ {
+ return null;
+ }
- ConversationManager conversationManager = ConversationManager.getInstance();
- if (conversationManager == null)
- {
- throw new IllegalStateException("can find the conversationManager");
- }
- if (!conversationManager.hasConversationContext())
- {
- return null;
- }
-
- return REQUEST_PARAMETERS;
- }
+ ConversationManager conversationManager = ConversationManager.getInstance();
+ if (conversationManager == null)
+ {
+ throw new IllegalStateException("can find the conversationManager");
+ }
+ if (!conversationManager.hasConversationContext())
+ {
+ return null;
+ }
+
+ return REQUEST_PARAMETERS;
+ }
}
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationServletFilter.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationServletFilter.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationServletFilter.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationServletFilter.java Thu Jul 3 14:58:05 2008
@@ -33,86 +33,86 @@
public class ConversationServletFilter implements Filter
{
- public final static String CONVERSATION_FILTER_CALLED = "org.apache.myfaces.conversation.ConversationServletFilter.CALLED";
+ public final static String CONVERSATION_FILTER_CALLED = "org.apache.myfaces.conversation.ConversationServletFilter.CALLED";
- private final static ThreadLocal externalContextTL = new ThreadLocal();
- private final static ThreadLocal conversationManagerTL = new ThreadLocal();
+ private final static ThreadLocal externalContextTL = new ThreadLocal();
+ private final static ThreadLocal conversationManagerTL = new ThreadLocal();
- private ServletContext servletContext;
+ private ServletContext servletContext;
- public void init(FilterConfig arg0) throws ServletException
- {
- servletContext = arg0.getServletContext();
- }
-
- public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
- {
- ConversationManager conversationManager = null;
-
- if (!Boolean.TRUE.equals(request.getAttribute(CONVERSATION_FILTER_CALLED)))
- {
- if (request instanceof HttpServletRequest)
- {
- HttpServletRequest httpRequest = (HttpServletRequest) request;
- externalContextTL.set(ConversationExternalContext.create(servletContext, httpRequest));
-
- HttpSession httpSession = httpRequest.getSession(false);
- if (httpSession != null)
- {
- conversationManager = ConversationManager.getInstance(httpSession);
- if (conversationManager != null)
- {
- conversationManagerTL.set(conversationManager);
-
- conversationManager.attachPersistence();
- }
- }
- }
-
- request.setAttribute(CONVERSATION_FILTER_CALLED, Boolean.TRUE);
- }
-
- boolean ok = false;
- try
- {
- chain.doFilter(request, response);
- ok = true;
- }
- finally
- {
- if (conversationManager != null)
- {
- try
- {
- if (!ok)
- {
- conversationManager.purgePersistence();
- }
- else
- {
- conversationManager.detachPersistence();
- }
- }
- finally
- {
- externalContextTL.set(null);
- conversationManagerTL.set(null);
- }
- }
- }
- }
-
- public void destroy()
- {
- }
-
- static ConversationExternalContext getConversationExternalContext()
- {
- return (ConversationExternalContext) externalContextTL.get();
- }
-
- static ConversationManager getConversationManager()
- {
- return (ConversationManager) conversationManagerTL.get();
- }
+ public void init(FilterConfig arg0) throws ServletException
+ {
+ servletContext = arg0.getServletContext();
+ }
+
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
+ {
+ ConversationManager conversationManager = null;
+
+ if (!Boolean.TRUE.equals(request.getAttribute(CONVERSATION_FILTER_CALLED)))
+ {
+ if (request instanceof HttpServletRequest)
+ {
+ HttpServletRequest httpRequest = (HttpServletRequest) request;
+ externalContextTL.set(ConversationExternalContext.create(servletContext, httpRequest));
+
+ HttpSession httpSession = httpRequest.getSession(false);
+ if (httpSession != null)
+ {
+ conversationManager = ConversationManager.getInstance(httpSession);
+ if (conversationManager != null)
+ {
+ conversationManagerTL.set(conversationManager);
+
+ conversationManager.attachPersistence();
+ }
+ }
+ }
+
+ request.setAttribute(CONVERSATION_FILTER_CALLED, Boolean.TRUE);
+ }
+
+ boolean ok = false;
+ try
+ {
+ chain.doFilter(request, response);
+ ok = true;
+ }
+ finally
+ {
+ if (conversationManager != null)
+ {
+ try
+ {
+ if (!ok)
+ {
+ conversationManager.purgePersistence();
+ }
+ else
+ {
+ conversationManager.detachPersistence();
+ }
+ }
+ finally
+ {
+ externalContextTL.set(null);
+ conversationManagerTL.set(null);
+ }
+ }
+ }
+ }
+
+ public void destroy()
+ {
+ }
+
+ static ConversationExternalContext getConversationExternalContext()
+ {
+ return (ConversationExternalContext) externalContextTL.get();
+ }
+
+ static ConversationManager getConversationManager()
+ {
+ return (ConversationManager) conversationManagerTL.get();
+ }
}
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationUtils.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationUtils.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationUtils.java Thu Jul 3 14:58:05 2008
@@ -28,85 +28,85 @@
public class ConversationUtils
{
- private ConversationUtils()
- {
- }
-
- /**
- * Find the first parent which is a command
- */
- public static UICommand findParentCommand(UIComponent base)
- {
- UIComponent parent = base;
- do
- {
- parent = parent.getParent();
- if (parent instanceof UICommand)
- {
- return (UICommand) parent;
- }
- }
- while (parent != null);
-
- return null;
- }
-
- /**
- * Find a child start or end conversation component for the given conversation name
- */
- public static AbstractConversationComponent findStartOrEndConversationComponent(UIComponent component, String conversationName)
- {
- Iterator iterComponents = component.getFacetsAndChildren();
- while (iterComponents.hasNext())
- {
- Object child = iterComponents.next();
- AbstractConversationComponent conversation;
-
- if (child instanceof UIStartConversation || child instanceof UIEndConversation)
- {
- conversation = (AbstractConversationComponent) child;
- if (conversation.getName().equals(conversationName))
- {
- return conversation;
- }
- }
- else if (child instanceof UIComponent)
- {
- conversation = findStartOrEndConversationComponent((UIComponent) child, conversationName);
- if (conversation != null)
- {
- return conversation;
- }
- }
- }
-
- return null;
- }
-
- public static String extractBeanName(ValueBinding vb)
- {
- String valueBinding = vb.getExpressionString();
- return valueBinding.substring(2, valueBinding.length()-1);
- }
-
- /**
- * end and restart a conversation
- */
- static void endAndRestartConversation(FacesContext context, String conversationName, Boolean restart, MethodBinding restartAction)
- {
- ConversationManager conversationManager = ConversationManager.getInstance(context);
- Conversation conversation = conversationManager.getConversation(conversationName);
-
- conversationManager.endConversation(conversationName, true);
-
- if (restart != null && restart.booleanValue() && conversation != null)
- {
- conversationManager.startConversation(conversationName, conversation.isPersistence());
-
- if (restartAction != null)
- {
- restartAction.invoke(context, null);
- }
- }
- }
+ private ConversationUtils()
+ {
+ }
+
+ /**
+ * Find the first parent which is a command
+ */
+ public static UICommand findParentCommand(UIComponent base)
+ {
+ UIComponent parent = base;
+ do
+ {
+ parent = parent.getParent();
+ if (parent instanceof UICommand)
+ {
+ return (UICommand) parent;
+ }
+ }
+ while (parent != null);
+
+ return null;
+ }
+
+ /**
+ * Find a child start or end conversation component for the given conversation name
+ */
+ public static AbstractConversationComponent findStartOrEndConversationComponent(UIComponent component, String conversationName)
+ {
+ Iterator iterComponents = component.getFacetsAndChildren();
+ while (iterComponents.hasNext())
+ {
+ Object child = iterComponents.next();
+ AbstractConversationComponent conversation;
+
+ if (child instanceof UIStartConversation || child instanceof UIEndConversation)
+ {
+ conversation = (AbstractConversationComponent) child;
+ if (conversation.getName().equals(conversationName))
+ {
+ return conversation;
+ }
+ }
+ else if (child instanceof UIComponent)
+ {
+ conversation = findStartOrEndConversationComponent((UIComponent) child, conversationName);
+ if (conversation != null)
+ {
+ return conversation;
+ }
+ }
+ }
+
+ return null;
+ }
+
+ public static String extractBeanName(ValueBinding vb)
+ {
+ String valueBinding = vb.getExpressionString();
+ return valueBinding.substring(2, valueBinding.length()-1);
+ }
+
+ /**
+ * end and restart a conversation
+ */
+ static void endAndRestartConversation(FacesContext context, String conversationName, Boolean restart, MethodBinding restartAction)
+ {
+ ConversationManager conversationManager = ConversationManager.getInstance(context);
+ Conversation conversation = conversationManager.getConversation(conversationName);
+
+ conversationManager.endConversation(conversationName, true);
+
+ if (restart != null && restart.booleanValue() && conversation != null)
+ {
+ conversationManager.startConversation(conversationName, conversation.isPersistence());
+
+ if (restartAction != null)
+ {
+ restartAction.invoke(context, null);
+ }
+ }
+ }
}
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationVariableResolver.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationVariableResolver.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationVariableResolver.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationVariableResolver.java Thu Jul 3 14:58:05 2008
@@ -24,26 +24,26 @@
public class ConversationVariableResolver extends VariableResolver
{
- private final VariableResolver original;
-
- public ConversationVariableResolver(VariableResolver original)
- {
- this.original = original;
- }
-
- public Object resolveVariable(FacesContext context, String name) throws EvaluationException
- {
- ConversationManager conversationManager = ConversationManager.getInstance(context);
- if (conversationManager.hasConversationContext())
- {
- Object bean = conversationManager.getConversationContext().findBean(name);
- if (bean != null)
- {
- return bean;
- }
- }
-
- return original.resolveVariable(context, name);
- }
+ private final VariableResolver original;
+
+ public ConversationVariableResolver(VariableResolver original)
+ {
+ this.original = original;
+ }
+
+ public Object resolveVariable(FacesContext context, String name) throws EvaluationException
+ {
+ ConversationManager conversationManager = ConversationManager.getInstance(context);
+ if (conversationManager.hasConversationContext())
+ {
+ Object bean = conversationManager.getConversationContext().findBean(name);
+ if (bean != null)
+ {
+ return bean;
+ }
+ }
+
+ return original.resolveVariable(context, name);
+ }
}
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/DefaultConversationBeanElevator.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/DefaultConversationBeanElevator.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/DefaultConversationBeanElevator.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/DefaultConversationBeanElevator.java Thu Jul 3 14:58:05 2008
@@ -26,14 +26,14 @@
*/
public class DefaultConversationBeanElevator implements ConversationBeanElevator
{
- public void elevateBean(FacesContext context, Conversation conversation, ValueBinding valueBinding)
- {
- String name = ConversationUtils.extractBeanName(valueBinding);
+ public void elevateBean(FacesContext context, Conversation conversation, ValueBinding valueBinding)
+ {
+ String name = ConversationUtils.extractBeanName(valueBinding);
- conversation.putBean(context, name, valueBinding.getValue(context));
+ conversation.putBean(context, name, valueBinding.getValue(context));
- // remove it from the other contexts
- context.getExternalContext().getRequestMap().remove(name);
- context.getExternalContext().getSessionMap().remove(name);
- }
+ // remove it from the other contexts
+ context.getExternalContext().getRequestMap().remove(name);
+ context.getExternalContext().getSessionMap().remove(name);
+ }
}
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/DefaultConversationMessager.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/DefaultConversationMessager.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/DefaultConversationMessager.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/DefaultConversationMessager.java Thu Jul 3 14:58:05 2008
@@ -30,25 +30,25 @@
*/
public class DefaultConversationMessager implements ConversationMessager
{
- public void setConversationException(FacesContext context, Throwable t)
- {
- context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, t.getLocalizedMessage(), getThrowableText(t)));
- }
+ public void setConversationException(FacesContext context, Throwable t)
+ {
+ context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, t.getLocalizedMessage(), getThrowableText(t)));
+ }
- public void setConversationNotActive(FacesContext context, String name)
- {
- String message = "Conversation not active";
- String messageDtl = "Conversation not active. Please start over. (Conversation Name:" + name + ")";
-
- context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, message, messageDtl));
- }
+ public void setConversationNotActive(FacesContext context, String name)
+ {
+ String message = "Conversation not active";
+ String messageDtl = "Conversation not active. Please start over. (Conversation Name:" + name + ")";
+
+ context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, message, messageDtl));
+ }
- protected String getThrowableText(Throwable t)
- {
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
- t.printStackTrace(pw);
- pw.close();
- return sw.toString();
- }
+ protected String getThrowableText(Throwable t)
+ {
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ t.printStackTrace(pw);
+ pw.close();
+ return sw.toString();
+ }
}
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/EndConversationMethodBindingFacade.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/EndConversationMethodBindingFacade.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/EndConversationMethodBindingFacade.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/EndConversationMethodBindingFacade.java Thu Jul 3 14:58:05 2008
@@ -34,133 +34,133 @@
*/
public class EndConversationMethodBindingFacade extends MethodBinding implements StateHolder
{
- private MethodBinding original;
- private String conversationName;
- private Collection onOutcomes;
- private String errorOutcome;
- private Boolean restart;
- private MethodBinding restartAction;
-
- private boolean _transient = false;
-
- public EndConversationMethodBindingFacade()
- {
- }
-
- public EndConversationMethodBindingFacade(
- String conversation, Collection onOutcomes, MethodBinding original,
- String errorOutcome, Boolean restart, MethodBinding restartAction)
- {
- this.original = original;
- this.conversationName = conversation;
- this.onOutcomes = onOutcomes;
- this.errorOutcome = errorOutcome;
- this.restart = restart;
- this.restartAction = restartAction;
- }
-
- public String getConversationName()
- {
- return conversationName;
- }
-
- public String getExpressionString()
- {
- if (original == null)
- {
- return null;
- }
- return original.getExpressionString();
- }
-
- public Class getType(FacesContext context) throws MethodNotFoundException
- {
- if (original == null)
- {
- return null;
- }
- return original.getType(context);
- }
-
- public Object invoke(FacesContext context, Object[] values) throws EvaluationException, MethodNotFoundException
- {
- boolean ok = false;
- Object returnValue = null;
- try
- {
- if (original != null)
- {
- returnValue = original.invoke(context, values);
- }
- ok = true;
- }
- catch (Throwable t)
- {
- ConversationManager conversationManager = ConversationManager.getInstance(context);
- conversationManager.purgePersistence();
-
- if (errorOutcome != null)
- {
- conversationManager.getMessager().setConversationException(context, t);
-
- returnValue = errorOutcome;
- }
- else
- {
- throw new FacesException(t);
- }
- }
- finally
- {
- boolean end = true;
- if (ok)
- {
- if (onOutcomes != null && onOutcomes.size() > 0)
- {
- end = onOutcomes.contains(returnValue);
- }
-
- if (end)
- {
- ConversationUtils.endAndRestartConversation(context, conversationName, restart, restartAction);
- }
- }
- }
- return returnValue;
- }
-
- public void setTransient(boolean newTransientValue)
- {
- _transient = newTransientValue;
- }
-
- public boolean isTransient()
- {
- return _transient;
- }
-
- public void restoreState(FacesContext context, Object states)
- {
- Object[] state = (Object[]) states;
-
- original = (MethodBinding) UIComponentBase.restoreAttachedState(context, state[0]);
- conversationName = (String) state[1];
- onOutcomes = (Collection) state[2];
- errorOutcome = (String) state[3];
- restart = (Boolean) state[4];
- restartAction = (MethodBinding) UIComponentBase.restoreAttachedState(context, state[5]);
- }
-
- public Object saveState(FacesContext context)
- {
- return new Object[]
- {
- UIComponentBase.saveAttachedState(context, original),
- conversationName,
- onOutcomes,
- errorOutcome,
- restart,
- UIComponentBase.saveAttachedState(context, restartAction)
- };
- }
+ private MethodBinding original;
+ private String conversationName;
+ private Collection onOutcomes;
+ private String errorOutcome;
+ private Boolean restart;
+ private MethodBinding restartAction;
+
+ private boolean _transient = false;
+
+ public EndConversationMethodBindingFacade()
+ {
+ }
+
+ public EndConversationMethodBindingFacade(
+ String conversation, Collection onOutcomes, MethodBinding original,
+ String errorOutcome, Boolean restart, MethodBinding restartAction)
+ {
+ this.original = original;
+ this.conversationName = conversation;
+ this.onOutcomes = onOutcomes;
+ this.errorOutcome = errorOutcome;
+ this.restart = restart;
+ this.restartAction = restartAction;
+ }
+
+ public String getConversationName()
+ {
+ return conversationName;
+ }
+
+ public String getExpressionString()
+ {
+ if (original == null)
+ {
+ return null;
+ }
+ return original.getExpressionString();
+ }
+
+ public Class getType(FacesContext context) throws MethodNotFoundException
+ {
+ if (original == null)
+ {
+ return null;
+ }
+ return original.getType(context);
+ }
+
+ public Object invoke(FacesContext context, Object[] values) throws EvaluationException, MethodNotFoundException
+ {
+ boolean ok = false;
+ Object returnValue = null;
+ try
+ {
+ if (original != null)
+ {
+ returnValue = original.invoke(context, values);
+ }
+ ok = true;
+ }
+ catch (Throwable t)
+ {
+ ConversationManager conversationManager = ConversationManager.getInstance(context);
+ conversationManager.purgePersistence();
+
+ if (errorOutcome != null)
+ {
+ conversationManager.getMessager().setConversationException(context, t);
+
+ returnValue = errorOutcome;
+ }
+ else
+ {
+ throw new FacesException(t);
+ }
+ }
+ finally
+ {
+ boolean end = true;
+ if (ok)
+ {
+ if (onOutcomes != null && onOutcomes.size() > 0)
+ {
+ end = onOutcomes.contains(returnValue);
+ }
+
+ if (end)
+ {
+ ConversationUtils.endAndRestartConversation(context, conversationName, restart, restartAction);
+ }
+ }
+ }
+ return returnValue;
+ }
+
+ public void setTransient(boolean newTransientValue)
+ {
+ _transient = newTransientValue;
+ }
+
+ public boolean isTransient()
+ {
+ return _transient;
+ }
+
+ public void restoreState(FacesContext context, Object states)
+ {
+ Object[] state = (Object[]) states;
+
+ original = (MethodBinding) UIComponentBase.restoreAttachedState(context, state[0]);
+ conversationName = (String) state[1];
+ onOutcomes = (Collection) state[2];
+ errorOutcome = (String) state[3];
+ restart = (Boolean) state[4];
+ restartAction = (MethodBinding) UIComponentBase.restoreAttachedState(context, state[5]);
+ }
+
+ public Object saveState(FacesContext context)
+ {
+ return new Object[]
+ {
+ UIComponentBase.saveAttachedState(context, original),
+ conversationName,
+ onOutcomes,
+ errorOutcome,
+ restart,
+ UIComponentBase.saveAttachedState(context, restartAction)
+ };
+ }
}
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/FakeMap.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/FakeMap.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/FakeMap.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/FakeMap.java Thu Jul 3 14:58:05 2008
@@ -29,63 +29,63 @@
*/
public class FakeMap implements Map
{
- public void clear()
- {
- throw new UnsupportedOperationException();
- }
-
- public boolean containsKey(Object key)
- {
- throw new UnsupportedOperationException();
- }
-
- public boolean containsValue(Object value)
- {
- throw new UnsupportedOperationException();
- }
-
- public Set entrySet()
- {
- throw new UnsupportedOperationException();
- }
-
- public Object get(Object key)
- {
- throw new UnsupportedOperationException();
- }
-
- public boolean isEmpty()
- {
- throw new UnsupportedOperationException();
- }
-
- public Set keySet()
- {
- throw new UnsupportedOperationException();
- }
-
- public Object put(Object arg0, Object arg1)
- {
- throw new UnsupportedOperationException();
- }
-
- public void putAll(Map arg0)
- {
- throw new UnsupportedOperationException();
- }
-
- public Object remove(Object key)
- {
- throw new UnsupportedOperationException();
- }
-
- public int size()
- {
- throw new UnsupportedOperationException();
- }
-
- public Collection values()
- {
- throw new UnsupportedOperationException();
- }
+ public void clear()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean containsKey(Object key)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean containsValue(Object value)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public Set entrySet()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public Object get(Object key)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isEmpty()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public Set keySet()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public Object put(Object arg0, Object arg1)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void putAll(Map arg0)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public Object remove(Object key)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public int size()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public Collection values()
+ {
+ throw new UnsupportedOperationException();
+ }
}
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/PersistenceManager.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/PersistenceManager.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/PersistenceManager.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/PersistenceManager.java Thu Jul 3 14:58:05 2008
@@ -25,28 +25,28 @@
*/
public interface PersistenceManager
{
- /**
- * commit the transaction
- */
- public void commit();
+ /**
+ * commit the transaction
+ */
+ public void commit();
- /**
- * rollback the transaction
- */
- public void rollback();
+ /**
+ * rollback the transaction
+ */
+ public void rollback();
- /**
- * attach to your underlaying persistence
- */
- public void attach();
+ /**
+ * attach to your underlaying persistence
+ */
+ public void attach();
- /**
- * detach from your underlaying persistence
- */
- public void detach();
+ /**
+ * detach from your underlaying persistence
+ */
+ public void detach();
- /**
- * purge this persistence manager - e.g. throw away your session due to some exceptions
- */
- void purge();
+ /**
+ * purge this persistence manager - e.g. throw away your session due to some exceptions
+ */
+ void purge();
}
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/PersistenceManagerFactory.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/PersistenceManagerFactory.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/PersistenceManagerFactory.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/PersistenceManagerFactory.java Thu Jul 3 14:58:05 2008
@@ -27,5 +27,5 @@
*/
public interface PersistenceManagerFactory
{
- public PersistenceManager create();
+ public PersistenceManager create();
}
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/SpringConversationScope.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/SpringConversationScope.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/SpringConversationScope.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/SpringConversationScope.java Thu Jul 3 14:58:05 2008
@@ -30,109 +30,109 @@
*/
public class SpringConversationScope implements Scope
{
- private final static Log log = LogFactory.getLog(SpringConversationScope.class);
+ private final static Log log = LogFactory.getLog(SpringConversationScope.class);
- public String getConversationId()
- {
- FacesContext facesContext = FacesContext.getCurrentInstance();
- ConversationManager manager = ConversationManager.getInstance(facesContext);
- if (manager.hasConversationContext())
- {
- return Long.toString(manager.getConversationContextId().longValue(), 10);
- }
-
- return null;
- }
-
- /**
- * get the conversation bean.<br />
- * this will start a new conversation with the same name in case a conversation
- * is not existent yet.
- */
- public Object get(String name, ObjectFactory objectFactory)
- {
- name = buildBeanName(name);
-
- FacesContext facesContext = FacesContext.getCurrentInstance();
-
- ConversationManager manager = ConversationManager.getInstance(facesContext);
-
- Object value = null;
- boolean created = false;
-
- // check if we have a conversation
- if (!manager.hasConversation(name))
- {
- // ... no ... create the object to ...
- value = objectFactory.getObject();
- created = true;
-
- // ... determine if it should deal with persistence.
- boolean isPersistent = (value instanceof PersistentConversation);
-
- // start the conversation
- manager.startConversation(name, isPersistent);
- }
-
- // get the conversation
- Conversation conversation = manager.getConversation(name);
- if (!conversation.hasBean(name))
- {
- // create the bean (if not already done)
- if (!created)
- {
- value = objectFactory.getObject();
- }
-
- conversation.putBean(facesContext, name, value);
- }
-
- // get the bean
- return conversation.getBean(name);
- }
-
- /**
- * strip off any spring namespace.
- * TODO: Is this valid?
- */
- protected String buildBeanName(String name)
- {
- if (name == null)
- {
- return null;
- }
-
- int pos = name.lastIndexOf('.');
- if (pos < 0)
- {
- return name;
- }
-
- return name.substring(pos+1);
- }
-
- /**
- * remove the bean from the conversation.
- * TODO: when will this be called .. and should we close the conversation then?
- */
- public Object remove(String name)
- {
- FacesContext facesContext = FacesContext.getCurrentInstance();
-
- ConversationManager manager = ConversationManager.getInstance(facesContext);
- if (!manager.hasConversation(name))
- {
- return null;
- }
-
- return manager.getConversation(name).removeBean(name);
- }
-
- public void registerDestructionCallback(String name, Runnable runnable)
- {
- if (log.isWarnEnabled())
- {
- log.warn("SpringConversationScope: registerDestructionCallback not yet supported. Name=" + name);
- }
- }
+ public String getConversationId()
+ {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ ConversationManager manager = ConversationManager.getInstance(facesContext);
+ if (manager.hasConversationContext())
+ {
+ return Long.toString(manager.getConversationContextId().longValue(), 10);
+ }
+
+ return null;
+ }
+
+ /**
+ * get the conversation bean.<br />
+ * this will start a new conversation with the same name in case a conversation
+ * is not existent yet.
+ */
+ public Object get(String name, ObjectFactory objectFactory)
+ {
+ name = buildBeanName(name);
+
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+
+ ConversationManager manager = ConversationManager.getInstance(facesContext);
+
+ Object value = null;
+ boolean created = false;
+
+ // check if we have a conversation
+ if (!manager.hasConversation(name))
+ {
+ // ... no ... create the object to ...
+ value = objectFactory.getObject();
+ created = true;
+
+ // ... determine if it should deal with persistence.
+ boolean isPersistent = (value instanceof PersistentConversation);
+
+ // start the conversation
+ manager.startConversation(name, isPersistent);
+ }
+
+ // get the conversation
+ Conversation conversation = manager.getConversation(name);
+ if (!conversation.hasBean(name))
+ {
+ // create the bean (if not already done)
+ if (!created)
+ {
+ value = objectFactory.getObject();
+ }
+
+ conversation.putBean(facesContext, name, value);
+ }
+
+ // get the bean
+ return conversation.getBean(name);
+ }
+
+ /**
+ * strip off any spring namespace.
+ * TODO: Is this valid?
+ */
+ protected String buildBeanName(String name)
+ {
+ if (name == null)
+ {
+ return null;
+ }
+
+ int pos = name.lastIndexOf('.');
+ if (pos < 0)
+ {
+ return name;
+ }
+
+ return name.substring(pos+1);
+ }
+
+ /**
+ * remove the bean from the conversation.
+ * TODO: when will this be called .. and should we close the conversation then?
+ */
+ public Object remove(String name)
+ {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+
+ ConversationManager manager = ConversationManager.getInstance(facesContext);
+ if (!manager.hasConversation(name))
+ {
+ return null;
+ }
+
+ return manager.getConversation(name).removeBean(name);
+ }
+
+ public void registerDestructionCallback(String name, Runnable runnable)
+ {
+ if (log.isWarnEnabled())
+ {
+ log.warn("SpringConversationScope: registerDestructionCallback not yet supported. Name=" + name);
+ }
+ }
}
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/UIConversation.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/UIConversation.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/UIConversation.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/UIConversation.java Thu Jul 3 14:58:05 2008
@@ -40,42 +40,42 @@
*/
public class UIConversation extends AbstractConversationComponent
{
- private final static Log log = LogFactory.getLog(UIConversation.class);
+ private final static Log log = LogFactory.getLog(UIConversation.class);
- public static final String COMPONENT_TYPE = "org.apache.myfaces.Conversation";
+ public static final String COMPONENT_TYPE = "org.apache.myfaces.Conversation";
- public void encodeBegin(FacesContext context) throws IOException
- {
- super.encodeBegin(context);
-
- UIComponent cmp = getParent();
- if (cmp instanceof UIStartConversation)
- {
- // start conversation should to the work
- return;
- }
-
- if (getName() == null)
- {
- throw new IllegalArgumentException("conversation name (attribute name=) required if used outside of startConversation tag");
- }
-
- elevateBean(context, getName(), getBeanBinding());
- }
-
- ValueBinding getBeanBinding()
- {
- return getValueBinding("value");
- }
-
- public static void elevateBean(FacesContext context, String conversationName, ValueBinding valueBinding)
- {
- Conversation conversation = ConversationManager.getInstance().getConversation(conversationName);
- if (conversation == null)
- {
- log.debug("no conversation named '" + conversationName + "' running - can't elevate bean '" + valueBinding.getExpressionString());
- return;
- }
- ConversationManager.getInstance().getConversationBeanElevator().elevateBean(context, conversation, valueBinding);
- }
+ public void encodeBegin(FacesContext context) throws IOException
+ {
+ super.encodeBegin(context);
+
+ UIComponent cmp = getParent();
+ if (cmp instanceof UIStartConversation)
+ {
+ // start conversation should to the work
+ return;
+ }
+
+ if (getName() == null)
+ {
+ throw new IllegalArgumentException("conversation name (attribute name=) required if used outside of startConversation tag");
+ }
+
+ elevateBean(context, getName(), getBeanBinding());
+ }
+
+ ValueBinding getBeanBinding()
+ {
+ return getValueBinding("value");
+ }
+
+ public static void elevateBean(FacesContext context, String conversationName, ValueBinding valueBinding)
+ {
+ Conversation conversation = ConversationManager.getInstance().getConversation(conversationName);
+ if (conversation == null)
+ {
+ log.debug("no conversation named '" + conversationName + "' running - can't elevate bean '" + valueBinding.getExpressionString());
+ return;
+ }
+ ConversationManager.getInstance().getConversationBeanElevator().elevateBean(context, conversation, valueBinding);
+ }
}