Skip to content

Commit

Permalink
Temp conversation test piggybacking on the numberguess build
Browse files Browse the repository at this point in the history
  • Loading branch information
nickarls committed Mar 5, 2009
1 parent 627e033 commit 5a8f9be
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 0 deletions.
25 changes: 25 additions & 0 deletions numberguess/WebContent/conversations.xhtml
@@ -0,0 +1,25 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">

<ui:composition template="template.xhtml">
<ui:define name="content">
<h:form>
<h:panelGrid columns="1">
<h:outputText value="Long-running: #{conversations.conversationList}"/>
<h:outputText value="Current: #{conversation}"/>
<h:panelGroup>
<h:commandButton action="#{conversation.begin}" value="begin"/>
<h:commandButton action="#{conversations.noop}" value="noop"/>
<h:commandButton action="#{conversation.end}" value="end"/>
<h:commandButton action="#{conversations.abandon}" value="abandon"/>
</h:panelGroup>
<h:inputText value="#{conversations.cid}"/>
<h:commandButton action="#{conversations.switchConversation}" value="switch"/>
</h:panelGrid>
</h:form>
</ui:define>
</ui:composition>
</html>
@@ -0,0 +1,72 @@
package org.jboss.webbeans.examples.numberguess;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Named;
import javax.context.Conversation;
import javax.context.SessionScoped;
import javax.faces.model.SelectItem;
import javax.inject.Current;
import javax.inject.Produces;

import java.io.Serializable;

import org.jboss.webbeans.conversation.ConversationIdGenerator;
import org.jboss.webbeans.conversation.ConversationManager;
import org.jboss.webbeans.conversation.bindings.ConversationInactivityTimeout;

@SessionScoped
@Named("conversations")
public class Conversations implements Serializable {

@Current private Conversation conversation;
@Current private ConversationIdGenerator id;
@Current private ConversationManager conversationManager;
private String cid;

public Conversations()
{
}

public void abandon()
{
conversation.begin(id.nextId());
}

public void noop()
{

}

public Iterable<Conversation> getConversationList()
{
return conversationManager.getLongRunningConversations();
}

public List<SelectItem> getLongRunningConversations()
{
List<SelectItem> longRunningConversations = new ArrayList<SelectItem>();
for (Conversation conversation : conversationManager.getLongRunningConversations())
{
longRunningConversations.add(new SelectItem(conversation.getId(), conversation.getId()));
}
return longRunningConversations;
}

public void switchConversation()
{
conversation.begin(cid);
}

public String getCid()
{
return cid;
}

public void setCid(String cid)
{
this.cid = cid;
}

}

0 comments on commit 5a8f9be

Please sign in to comment.