Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Temp conversation test piggybacking on the numberguess build
- Loading branch information
Showing
2 changed files
with
97 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
72 changes: 72 additions & 0 deletions
72
numberguess/src/main/java/org/jboss/webbeans/examples/numberguess/Conversations.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
|
||
} |