Author: alessio.soldano(a)jboss.com
Date: 2013-01-20 06:29:27 -0500 (Sun, 20 Jan 2013)
New Revision: 454
Modified:
webgui/branches/cdi-jsf/pom.xml
webgui/branches/cdi-jsf/src/main/java/org/jboss/wise/gui/ClientConversationBean.java
webgui/branches/cdi-jsf/src/main/webapp/index.xhtml
Log:
Misc fixes on conversation handling and for cleaning up wise clients
Modified: webgui/branches/cdi-jsf/pom.xml
===================================================================
--- webgui/branches/cdi-jsf/pom.xml 2013-01-19 00:33:39 UTC (rev 453)
+++ webgui/branches/cdi-jsf/pom.xml 2013-01-20 11:29:27 UTC (rev 454)
@@ -133,6 +133,12 @@
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>org.jboss.spec.javax.ejb</groupId>
+ <artifactId>jboss-ejb-api_3.1_spec</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
<!-- Import the RichFaces core library -->
<dependency>
<groupId>org.richfaces.core</groupId>
Modified:
webgui/branches/cdi-jsf/src/main/java/org/jboss/wise/gui/ClientConversationBean.java
===================================================================
---
webgui/branches/cdi-jsf/src/main/java/org/jboss/wise/gui/ClientConversationBean.java 2013-01-19
00:33:39 UTC (rev 453)
+++
webgui/branches/cdi-jsf/src/main/java/org/jboss/wise/gui/ClientConversationBean.java 2013-01-20
11:29:27 UTC (rev 454)
@@ -28,6 +28,7 @@
import java.util.Map.Entry;
import java.util.StringTokenizer;
+import javax.annotation.PostConstruct;
import javax.enterprise.context.Conversation;
import javax.enterprise.context.ConversationScoped;
import javax.inject.Inject;
@@ -52,8 +53,10 @@
public class ClientConversationBean implements Serializable {
private static final long serialVersionUID = 1L;
-
+
+ private static final int CONVERSATION_TIMEOUT = 15 * 60 * 1000; //15 mins instead of
default 30 mins
private static WSDynamicClientBuilder clientBuilder;
+ private static CleanupTask<WSDynamicClient> cleanupTask = new
CleanupTask<WSDynamicClient>(true);
@Inject Conversation conversation;
private WSDynamicClient client;
@@ -64,9 +67,25 @@
private TreeNodeImpl outputTree;
private UITree inTree;
- public void init() throws ConnectException {
- client =
getClientBuilder().tmpDir("/tmp/wise").verbose(true).keepSource(true).wsdlURL(getWsdlUrl()).build();
- conversation.begin(); //TODO!!!
+ @PostConstruct
+ public void init() {
+ //this is called each time a new browser tab is used and whenever the conversation
expires (hence a new bean is created)
+ conversation.begin();
+ conversation.setTimeout(CONVERSATION_TIMEOUT);
+ }
+
+ public void readWsdl() throws ConnectException {
+ cleanup();
+ //restart conversation
+ conversation.end();
+ conversation.begin();
+ client =
getClientBuilder().tmpDir("/tmp/wise").verbose(true).keepSource(true).wsdlURL(getWsdlUrl()).maxThreadPoolSize(1).build();
+ cleanupTask.addRef(client, System.currentTimeMillis() + CONVERSATION_TIMEOUT, new
CleanupTask.CleanupCallback<WSDynamicClient>() {
+ @Override
+ public void cleanup(WSDynamicClient data) {
+ data.close();
+ }
+ });
services = convertServicesToGui(client.processServices());
}
@@ -164,17 +183,26 @@
return services;
}
- public void close() {
- conversation.end(); //TODO!!!
+ public void updateCurrentOperation(ItemChangeEvent event){
+ setCurrentOperation(event.getNewItemName());
+ }
+
+ private void cleanup() {
if (client != null) {
- client.close();
+ cleanupTask.removeRef(client);
+ client.close();
+ client = null;
}
+ services = null;
+ currentOperation = null;
+ inputTree = null;
+ outputTree = null;
+ if (inTree != null) {
+ inTree.clearInitialState();
+ }
+ inputTree = null;
}
- public void updateCurrentOperation(ItemChangeEvent event){
- setCurrentOperation(event.getNewItemName());
- }
-
public String getWsdlUrl() {
return wsdlUrl;
}
Modified: webgui/branches/cdi-jsf/src/main/webapp/index.xhtml
===================================================================
--- webgui/branches/cdi-jsf/src/main/webapp/index.xhtml 2013-01-19 00:33:39 UTC (rev 453)
+++ webgui/branches/cdi-jsf/src/main/webapp/index.xhtml 2013-01-20 11:29:27 UTC (rev 454)
@@ -20,7 +20,7 @@
<h:form id="wsdlSelection">
<h:outputLabel value="URL:"
for="wsdlUrlInput"/>
<h:inputText id="wsdlUrlInput"
value="#{clientConversationBean.wsdlUrl}" />
- <a4j:commandButton value="OK"
render="opSelectionPanel" action="#{clientConversationBean.init}"
/>
+ <a4j:commandButton value="OK"
render="opSelectionPanel" action="#{clientConversationBean.readWsdl}"
/>
</h:form>
</rich:panel>
<br />