[jboss-cvs] JBoss Profiler SVN: r574 - in branches/JBossProfiler2/src/main: www and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Oct 28 20:42:40 EDT 2009
Author: jesper.pedersen
Date: 2009-10-28 20:42:40 -0400 (Wed, 28 Oct 2009)
New Revision: 574
Modified:
branches/JBossProfiler2/src/main/org/jboss/profiler/client/web/BasicOptBean.java
branches/JBossProfiler2/src/main/www/index.xhtml
branches/JBossProfiler2/src/main/www/setup.xhtml
branches/JBossProfiler2/src/main/www/template/template.xhtml
Log:
[JBPROFILER-102] connection error handling
Modified: branches/JBossProfiler2/src/main/org/jboss/profiler/client/web/BasicOptBean.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/client/web/BasicOptBean.java 2009-10-28 20:39:39 UTC (rev 573)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/client/web/BasicOptBean.java 2009-10-29 00:42:40 UTC (rev 574)
@@ -31,8 +31,10 @@
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Iterator;
import java.util.List;
+import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.faces.model.SelectItem;
import javax.servlet.http.HttpServletResponse;
@@ -44,7 +46,6 @@
*/
public class BasicOptBean implements Serializable
{
- private String lastestOpts = "";
// private String addClass="org.jboss.profiler.*";
private String addClass = "";
@@ -82,25 +83,8 @@
private org.jboss.remoting.Client remotingClient;
private Boolean connectionSuccessful;
+
/**
- * Get latest opts
- * @return The value
- */
- public String getLastestOpts()
- {
- return lastestOpts;
- }
-
- /**
- * Set latest opts
- * @param lastestOpts The value
- */
- public void setLastestOpts(String lastestOpts)
- {
- this.lastestOpts = lastestOpts;
- }
-
- /**
* Get add class
* @return The value
*/
@@ -270,18 +254,28 @@
*/
public void clickStart() throws Throwable
{
- locator = new org.jboss.remoting.InvokerLocator(this.protocol +
- "://" + this.host + ":" + this.port);
- remotingClient = new org.jboss.remoting.Client(locator);
+ try
+ {
+ locator = new org.jboss.remoting.InvokerLocator(this.protocol +
+ "://" + this.host + ":" + this.port);
+ remotingClient = new org.jboss.remoting.Client(locator);
+
+ remotingClient.connect();
+
+ Command cmd = new Command(CommandType.START_PROFILER);
+ String response = (String)remotingClient.invoke(cmd);
+
+ FacesMessage fm = new FacesMessage("Profiler has started: " + response);
+ addUniqueMessage(fm);
+
+ remotingClient.disconnect();
+ }
+ catch (Throwable e)
+ {
+ FacesMessage fm = new FacesMessage("Connection Error: " + e.getMessage());
+ addUniqueMessage(fm);
- remotingClient.connect();
- this.connect();
-
- Command cmd = new Command(CommandType.START_PROFILER);
- String response = (String)remotingClient.invoke(cmd);
- this.setLastestOpts("Profiler has started.");
-
- remotingClient.disconnect();
+ }
}
/**
@@ -290,16 +284,27 @@
*/
public void clickStop() throws Throwable
{
- locator = new org.jboss.remoting.InvokerLocator(this.protocol +
- "://" + this.host + ":" + this.port);
- remotingClient = new org.jboss.remoting.Client(locator);
- remotingClient.connect();
+ try
+ {
+ locator = new org.jboss.remoting.InvokerLocator(this.protocol +
+ "://" + this.host + ":" + this.port);
+ remotingClient = new org.jboss.remoting.Client(locator);
+ remotingClient.connect();
+
+ Command cmd3 = new Command(CommandType.STOP_PROFILER);
+ String response = (String)remotingClient.invoke(cmd3);
- Command cmd3 = new Command(CommandType.STOP_PROFILER);
- String response = (String)remotingClient.invoke(cmd3);
- this.setLastestOpts("Profiler has stopped.");
+ FacesMessage fm = new FacesMessage("Profiler has stopped: " + response);
+ addUniqueMessage(fm);
+
+ remotingClient.disconnect();
+ }
+ catch (Throwable e)
+ {
+ FacesMessage fm = new FacesMessage("Connection Error: " + e.getMessage());
+ addUniqueMessage(fm);
- remotingClient.disconnect();
+ }
}
/**
@@ -316,7 +321,7 @@
Command cmd1 = new Command(CommandType.ENABLE);
String response = (String)remotingClient.invoke(cmd1);
- this.setLastestOpts("Profiler has enabled.");
+
remotingClient.disconnect();
}
@@ -335,7 +340,6 @@
Command cmd2 = new Command(CommandType.DISABLE);
String response = (String)remotingClient.invoke(cmd2);
- this.setLastestOpts("Profiler has disabled.");
remotingClient.disconnect();
}
@@ -355,7 +359,6 @@
Command cmd = new Command(CommandType.GC);
String response = (String)remotingClient.invoke(cmd);
- this.setLastestOpts("begins garbage collection.");
remotingClient.disconnect();
}
@@ -366,20 +369,30 @@
*/
public void takeSnapshot() throws Throwable
{
- locator = new org.jboss.remoting.InvokerLocator(this.protocol +
- "://" + this.host + ":" + this.port);
- remotingClient = new org.jboss.remoting.Client(locator);
-
- remotingClient.connect();
-
- Command cmd = new Command(CommandType.SNAPSHOT);
-
- Snapshot snapshot = (Snapshot)remotingClient.invoke(cmd);
- if (snapshot != null)
+
+ try
{
- snapshotsList.add(snapshot);
+ locator = new org.jboss.remoting.InvokerLocator(this.protocol +
+ "://" + this.host + ":" + this.port);
+ remotingClient = new org.jboss.remoting.Client(locator);
+
+ remotingClient.connect();
+
+ Command cmd = new Command(CommandType.SNAPSHOT);
+
+ Snapshot snapshot = (Snapshot)remotingClient.invoke(cmd);
+ if (snapshot != null)
+ {
+ snapshotsList.add(snapshot);
+ }
+ remotingClient.disconnect();
}
- remotingClient.disconnect();
+ catch (Throwable e)
+ {
+ FacesMessage fm = new FacesMessage("Connection Error: " + e.getMessage());
+ addUniqueMessage(fm);
+
+ }
}
/**
@@ -388,20 +401,30 @@
*/
public void clearSnapshot() throws Throwable
{
- locator = new org.jboss.remoting.InvokerLocator(this.protocol +
- "://" + this.host + ":" + this.port);
- remotingClient = new org.jboss.remoting.Client(locator);
+ try
+ {
+ locator = new org.jboss.remoting.InvokerLocator(this.protocol +
+ "://" + this.host + ":" + this.port);
+ remotingClient = new org.jboss.remoting.Client(locator);
+
+ remotingClient.connect();
+
+ Command cmd = new Command(CommandType.CLEAR_SNAPSHOTS);
+
+ String response = (String)remotingClient.invoke(cmd);
+
+ this.snapshotsList.clear();
+
+ remotingClient.disconnect();
+ selectedSnapshot = null;
+ currentSnapshot = null;
+ }
+ catch (Throwable e)
+ {
+ FacesMessage fm = new FacesMessage("Connection Error: " + e.getMessage());
+ addUniqueMessage(fm);
- remotingClient.connect();
-
- Command cmd = new Command(CommandType.CLEAR_SNAPSHOTS);
-
- String response = (String)remotingClient.invoke(cmd);
-
- this.snapshotsList.clear();
-
- remotingClient.disconnect();
- selectedSnapshot = null;
+ }
currentSnapshot = null;
}
@@ -412,16 +435,27 @@
*/
public List<String> getSnapshots() throws Throwable
{
- locator = new org.jboss.remoting.InvokerLocator(this.protocol +
- "://" + this.host + ":" + this.port);
- remotingClient = new org.jboss.remoting.Client(locator);
- remotingClient.connect();
- Command cmd = new Command(CommandType.LIST_SNAPSHOTS);
- String[] snapshots = (String[])remotingClient.invoke(cmd);
- remotingClient.disconnect();
+ try
+ {
+ locator = new org.jboss.remoting.InvokerLocator(this.protocol +
+ "://" + this.host + ":" + this.port);
+
+ remotingClient = new org.jboss.remoting.Client(locator);
+ remotingClient.connect();
+ Command cmd = new Command(CommandType.LIST_SNAPSHOTS);
+ String[] snapshots = (String[])remotingClient.invoke(cmd);
+ remotingClient.disconnect();
+
+ return Arrays.asList(snapshots);
+ }
+ catch (Throwable e)
+ {
+ FacesMessage fm = new FacesMessage("Connection Error: " + e.getMessage());
+ addUniqueMessage(fm);
+ }
- return Arrays.asList(snapshots);
+ return new ArrayList<String>();
}
@@ -685,12 +719,20 @@
org.jboss.remoting.Client remotingClient = new org.jboss.remoting.Client(locator);
remotingClient.connect();
+
+ Command cmd3 = new Command(CommandType.START_PROFILER);
+ String response = (String)remotingClient.invoke(cmd3);
+
remotingClient.disconnect();
- connectionSuccessful = true;
+
+ FacesMessage fm = new FacesMessage("Setup verified!");
+ addUniqueMessage(fm);
}
- catch (Throwable e)
+ catch (Throwable e)
{
- connectionSuccessful = false;
+ FacesMessage fm = new FacesMessage("Connection Error: " + e.getMessage());
+ addUniqueMessage(fm);
+
}
}
@@ -752,5 +794,24 @@
{
return currentSnapshot;
}
+
+ /**
+ * make sure no messages are repeats
+ * @param fm the message
+ */
+ protected void addUniqueMessage(FacesMessage fm)
+ {
+ Iterator<FacesMessage> it = FacesContext.getCurrentInstance().getMessages();
+ while (it.hasNext())
+ {
+ if (it.next().getSummary().equals(fm.getSummary()))
+ {
+ return;
+ }
+ }
+
+ FacesContext.getCurrentInstance().addMessage("", fm);
+ }
+
}
Modified: branches/JBossProfiler2/src/main/www/index.xhtml
===================================================================
--- branches/JBossProfiler2/src/main/www/index.xhtml 2009-10-28 20:39:39 UTC (rev 573)
+++ branches/JBossProfiler2/src/main/www/index.xhtml 2009-10-29 00:42:40 UTC (rev 574)
@@ -26,9 +26,9 @@
<h:panelGrid columns="1" width="100%">
<f:subview>
Profiler
- <h:commandLink value="Start" action="#{basicOptBean.clickStart}"/>
+ <a4j:commandLink value="Start" action="#{basicOptBean.clickStart}"/>
/
- <h:commandLink value="Stop" action="#{basicOptBean.clickStop}"/>
+ <a4j:commandLink value="Stop" action="#{basicOptBean.clickStop}"/>
</f:subview>
</h:panelGrid>
<h:panelGrid columns="1" width="100%">
Modified: branches/JBossProfiler2/src/main/www/setup.xhtml
===================================================================
--- branches/JBossProfiler2/src/main/www/setup.xhtml 2009-10-28 20:39:39 UTC (rev 573)
+++ branches/JBossProfiler2/src/main/www/setup.xhtml 2009-10-29 00:42:40 UTC (rev 574)
@@ -49,9 +49,7 @@
<a4j:support event="onkeyup" reRender="testConnection" action="#{basicOptBean.settingsChanged}"/>
</h:inputText>
<a4j:outputPanel id="testConnection">
- <a4j:commandButton disabled="#{basicOptBean.connectionSuccessful}" id="connectbutton" value="Verify setup" action="#{basicOptBean.connect}" onclick="this.disable=true" reRender="testConnection"/>
- <br/>
- <h:outputText value="#{basicOptBean.connectionSuccessful?'Connection test successful':'Connection test failed'}" rendered="#{!empty basicOptBean.connectionSuccessful}"/>
+ <a4j:commandButton disabled="#{basicOptBean.connectionSuccessful}" id="connectbutton" value="Verify setup" action="#{basicOptBean.connect}" onclick="this.disable=true" reRender="testConnection"/>
</a4j:outputPanel>
<br/>
</h:panelGrid>
Modified: branches/JBossProfiler2/src/main/www/template/template.xhtml
===================================================================
--- branches/JBossProfiler2/src/main/www/template/template.xhtml 2009-10-28 20:39:39 UTC (rev 573)
+++ branches/JBossProfiler2/src/main/www/template/template.xhtml 2009-10-29 00:42:40 UTC (rev 574)
@@ -50,6 +50,9 @@
<tr>
<td class="dataContent">
<f:subview id="content">
+ <a4j:outputPanel id="messages" ajaxRendered="true">
+ <h:messages />
+ </a4j:outputPanel>
<ui:insert name="mainContent"/>
</f:subview>
</td>
More information about the jboss-cvs-commits
mailing list