[jboss-cvs] JBoss Profiler SVN: r575 - in branches/JBossProfiler2/src/main: www and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Oct 30 08:45:30 EDT 2009
Author: jesper.pedersen
Date: 2009-10-30 08:45:29 -0400 (Fri, 30 Oct 2009)
New Revision: 575
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/snapshotoperations.xhtml
Log:
[JBPROFILER-104] slight cleanup of BasicOptBean and added functions to setup.xhtml
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-29 00:42:40 UTC (rev 574)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/client/web/BasicOptBean.java 2009-10-30 12:45:29 UTC (rev 575)
@@ -250,220 +250,149 @@
/**
* Click start
- * @exception Throwable If an error occurs
*/
- public void clickStart() throws Throwable
+ public void clickStart()
{
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();
+ String response = (String)invokeAgent(new Command(CommandType.START_PROFILER));
+ addUniqueMessage("Profiler has started: " + response);
}
catch (Throwable e)
{
- FacesMessage fm = new FacesMessage("Connection Error: " + e.getMessage());
- addUniqueMessage(fm);
-
+ addUniqueMessage("Connection Error: " + e.getMessage());
}
}
/**
* Click stop
- * @exception Throwable If an error occurs
*/
- public void clickStop() throws Throwable
+ public void clickStop()
{
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);
-
- FacesMessage fm = new FacesMessage("Profiler has stopped: " + response);
- addUniqueMessage(fm);
-
- remotingClient.disconnect();
+ String response = (String)invokeAgent(new Command(CommandType.STOP_PROFILER));
+ addUniqueMessage("Profiler has stopped: " + response);
}
catch (Throwable e)
{
- FacesMessage fm = new FacesMessage("Connection Error: " + e.getMessage());
- addUniqueMessage(fm);
-
+ addUniqueMessage("Connection Error: " + e.getMessage());
}
}
/**
* Click enable
- * @exception Throwable If an error occurs
*/
- public void clickEnable() throws Throwable
+ public void clickEnable()
{
- locator = new org.jboss.remoting.InvokerLocator(this.protocol +
- "://" + this.host + ":" + this.port);
- remotingClient = new org.jboss.remoting.Client(locator);
-
- remotingClient.connect();
-
- Command cmd1 = new Command(CommandType.ENABLE);
- String response = (String)remotingClient.invoke(cmd1);
-
-
- remotingClient.disconnect();
+ try
+ {
+ String response = (String)invokeAgent(new Command(CommandType.ENABLE));
+ addUniqueMessage("Profiler is enabled: " + response);
+ }
+ catch (Throwable e)
+ {
+ addUniqueMessage("Connection Error: " + e.getMessage());
+ }
}
/**
* Click disable
- * @exception Throwable If an error occurs
*/
- public void clickDisable() throws Throwable
+ public void clickDisable()
{
- locator = new org.jboss.remoting.InvokerLocator(this.protocol +
- "://" + this.host + ":" + this.port);
- remotingClient = new org.jboss.remoting.Client(locator);
-
- remotingClient.connect();
-
- Command cmd2 = new Command(CommandType.DISABLE);
- String response = (String)remotingClient.invoke(cmd2);
-
- remotingClient.disconnect();
+ try
+ {
+ String response = (String)invokeAgent(new Command(CommandType.DISABLE));
+ addUniqueMessage("Profiler is disabled: " + response);
+ }
+ catch (Throwable e)
+ {
+ addUniqueMessage("Connection Error: " + e.getMessage());
+ }
}
/**
* GC
- * @exception Throwable If an error occurs
*/
- public void gc() throws Throwable
+ public void gc()
{
- locator = new org.jboss.remoting.InvokerLocator(this.protocol +
- "://" + this.host + ":" + this.port);
- remotingClient = new org.jboss.remoting.Client(locator);
-
- remotingClient.connect();
- this.connect();
-
- Command cmd = new Command(CommandType.GC);
- String response = (String)remotingClient.invoke(cmd);
-
- remotingClient.disconnect();
+ try
+ {
+ String response = (String)invokeAgent(new Command(CommandType.GC));
+ addUniqueMessage("Garbage collected: " + response);
+ }
+ catch (Throwable e)
+ {
+ addUniqueMessage("Connection Error: " + e.getMessage());
+ }
}
/**
* Take snapshot
- * @exception Throwable If an error occurs
*/
- public void takeSnapshot() throws Throwable
+ public void takeSnapshot()
{
-
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.SNAPSHOT);
-
- Snapshot snapshot = (Snapshot)remotingClient.invoke(cmd);
- if (snapshot != null)
- {
- snapshotsList.add(snapshot);
- }
- remotingClient.disconnect();
+ Snapshot snapshot = (Snapshot)invokeAgent(new Command(CommandType.SNAPSHOT));
+
+ snapshotsList.add(snapshot);
+ addUniqueMessage("Snapshot taken: " + SnapshotHelper.getName(snapshot));
}
catch (Throwable e)
{
- FacesMessage fm = new FacesMessage("Connection Error: " + e.getMessage());
- addUniqueMessage(fm);
-
+ addUniqueMessage("Connection Error: " + e.getMessage());
}
}
/**
* Clear snapshots
- * @exception Throwable If an error occurs
*/
- public void clearSnapshot() throws Throwable
+ public void clearSnapshot()
{
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);
-
+ String response = (String)invokeAgent(new Command(CommandType.CLEAR_SNAPSHOTS));
+
this.snapshotsList.clear();
- remotingClient.disconnect();
selectedSnapshot = null;
currentSnapshot = null;
+
+ addUniqueMessage("Snapshot list cleared");
}
catch (Throwable e)
{
- FacesMessage fm = new FacesMessage("Connection Error: " + e.getMessage());
- addUniqueMessage(fm);
-
+ addUniqueMessage("Connection Error: " + e.getMessage());
}
- currentSnapshot = null;
}
/**
* Get snapshots
* @return all the snapshots string from the agent side
- * @throws Throwable If an error occurs
*/
- public List<String> getSnapshots() throws Throwable
+ public List<String> getSnapshots()
{
-
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);
+ String[] snapshots = (String[])invokeAgent(new Command(CommandType.LIST_SNAPSHOTS));
+ return Arrays.asList(snapshots);
}
catch (Throwable e)
{
- FacesMessage fm = new FacesMessage("Connection Error: " + e.getMessage());
- addUniqueMessage(fm);
+ addUniqueMessage("Connection Error: " + e.getMessage());
}
-
return new ArrayList<String>();
+
+
}
/**
* sends the snapshot file to browser
- * @throws Throwable If an error occurs
*/
- public void saveSnapshot() throws Throwable
+ public void saveSnapshot()
{
File fileToSend = new File(SnapshotHelper.getName(currentSnapshot));
@@ -487,6 +416,10 @@
this.saveSnapshotName = "";
}
+ catch (Exception e)
+ {
+ addUniqueMessage("Error saving snapshot: " + e.getMessage());
+ }
finally
{
fileToSend.delete();
@@ -496,14 +429,23 @@
/**
* ui selects a snapshot
- * @throws Throwable If an error occurs
*/
- public void selectSnapshot() throws Throwable
+ public void selectSnapshot()
{
FacesContext facesContext = FacesContext.getCurrentInstance();
selectedSnapshot = (String)facesContext.getApplication()
.getVariableResolver().resolveVariable(facesContext, "snapshot");
- currentSnapshot = snapshotsList.get(getSnapshots().indexOf(selectedSnapshot));
+
+ try
+ {
+ currentSnapshot = (Snapshot)invokeAgent(
+ new Command(CommandType.GET_SNAPSHOT, new Object[]{getSnapshots().indexOf(selectedSnapshot) + 1})
+ );
+ }
+ catch (Throwable e)
+ {
+ addUniqueMessage("Connection Error: " + e.getMessage());
+ }
}
/**
@@ -522,14 +464,11 @@
/**
* Add class action
- * @exception Throwable If an error occurs
*/
- public void addClassAction() throws Throwable
+ public void addClassAction()
{
- locator = new org.jboss.remoting.InvokerLocator(this.protocol +
- "://" + this.host + ":" + this.port);
- remotingClient = new org.jboss.remoting.Client(locator);
- remotingClient.connect();
+
+
String clz = this.addClass;
Visibility v = Visibility.PUBLIC;
@@ -546,62 +485,78 @@
{
v = Visibility.PACKAGE;
}
-
- Command cmd = new Command(CommandType.ADD_CLASSES, new Object[] {clz, v});
-
- String response = (String)remotingClient.invoke(cmd);
- // this.setLastestOpts("Profiler has disabled.");
- remotingClient.disconnect();
-
- listClassAction();
+
+ try
+ {
+ String response = (String)invokeAgent(new Command(CommandType.ADD_CLASSES, new Object[] {clz, v}));
+ listClassAction();
+ }
+ catch (Throwable e)
+ {
+ addUniqueMessage("Connection Error: " + e.getMessage());
+ }
}
/**
* Remove class action
- * @exception Throwable If an error occurs
*/
- public void removeClassAction() throws Throwable
+ public void removeClassAction()
{
- locator = new org.jboss.remoting.InvokerLocator(this.protocol +
- "://" + this.host + ":" + this.port);
- remotingClient = new org.jboss.remoting.Client(locator);
- remotingClient.connect();
-
- String clz = this.removeClass;
- Command cmd = new Command(CommandType.REMOVE_CLASSES, new Object[] {clz});
-
- String response = (String)remotingClient.invoke(cmd);
-
- remotingClient.disconnect();
-
- listClassAction();
+ try
+ {
+ String clz = this.removeClass;
+ String response = (String)invokeAgent(new Command(CommandType.REMOVE_CLASSES, new Object[] {clz}));
+ listClassAction();
+ }
+ catch (Throwable e)
+ {
+ addUniqueMessage("Connection Error: " + e.getMessage());
+ }
}
/**
* List class action
- * @exception Throwable If an error occurs
*/
- public void listClassAction() throws Throwable
+ public void listClassAction()
{
+ try
+ {
+ this.interceptClassList.clear();
+ String[] result = (String[])invokeAgent(new Command(CommandType.LIST_CLASSES));
+ if (result != null)
+ {
+ for (int j = 0; j < result.length; j++)
+ {
+ this.interceptClassList.add(result[j]);
+ }
+ }
+ }
+ catch (Throwable e)
+ {
+ addUniqueMessage("Connection Error: " + e.getMessage());
+ }
+ }
+
+ /**
+ *
+ * @param cmd the command to invoke
+ * @return response that gets returned
+ * @throws Throwable if error occurrs
+ */
+ public Object invokeAgent(Command cmd) 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_CLASSES);
-
- this.interceptClassList.clear();
- String[] result = (String[])remotingClient.invoke(cmd);
- if (result != null)
- {
- for (int j = 0; j < result.length; j++)
- {
- this.interceptClassList.add(result[j]);
- }
- }
+ Object response = remotingClient.invoke(cmd);
remotingClient.disconnect();
- }
+
+ return response;
+ }
+
/**
* Get the protocol
* @return The value
@@ -714,24 +669,12 @@
{
try
{
- locator = new org.jboss.remoting.InvokerLocator(this.protocol +
- "://" + this.host + ":" + this.port);
- 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();
-
- FacesMessage fm = new FacesMessage("Setup verified!");
- addUniqueMessage(fm);
+ invokeAgent(new Command(CommandType.START_PROFILER));
+ addUniqueMessage("Setup verified!");
}
catch (Throwable e)
{
- FacesMessage fm = new FacesMessage("Connection Error: " + e.getMessage());
- addUniqueMessage(fm);
+ addUniqueMessage("Connection Error: " + e.getMessage());
}
@@ -797,10 +740,12 @@
/**
* make sure no messages are repeats
- * @param fm the message
+ * @param msg the message
*/
- protected void addUniqueMessage(FacesMessage fm)
+ protected void addUniqueMessage(String msg)
{
+ FacesMessage fm = new FacesMessage(msg);
+
Iterator<FacesMessage> it = FacesContext.getCurrentInstance().getMessages();
while (it.hasNext())
{
Modified: branches/JBossProfiler2/src/main/www/index.xhtml
===================================================================
--- branches/JBossProfiler2/src/main/www/index.xhtml 2009-10-29 00:42:40 UTC (rev 574)
+++ branches/JBossProfiler2/src/main/www/index.xhtml 2009-10-30 12:45:29 UTC (rev 575)
@@ -24,12 +24,7 @@
<h:commandLink value="Setup" action="go_setup"/>
</h:panelGrid>
<h:panelGrid columns="1" width="100%">
- <f:subview>
- Profiler
- <a4j:commandLink value="Start" action="#{basicOptBean.clickStart}"/>
- /
- <a4j:commandLink value="Stop" action="#{basicOptBean.clickStop}"/>
- </f:subview>
+ Profiler
</h:panelGrid>
<h:panelGrid columns="1" width="100%">
<h:commandLink value="Snapshots" action="go_snapshots"/>
Modified: branches/JBossProfiler2/src/main/www/setup.xhtml
===================================================================
--- branches/JBossProfiler2/src/main/www/setup.xhtml 2009-10-29 00:42:40 UTC (rev 574)
+++ branches/JBossProfiler2/src/main/www/setup.xhtml 2009-10-30 12:45:29 UTC (rev 575)
@@ -48,12 +48,46 @@
<f:validateLongRange minimum="1" maximum="65535"></f:validateLongRange>
<a4j:support event="onkeyup" reRender="testConnection" action="#{basicOptBean.settingsChanged}"/>
</h:inputText>
+
+ <h:outputText value="threshold"/>
+ <h:inputText value="#{basicOptBean.threshold}" size="20">
+ <f:validateDoubleRange maximum="100" minimum="0"></f:validateDoubleRange>
+ </h:inputText>
+
+ <h:outputText value="plugin.1"/>
+ <h:inputText value="#{basicOptBean.plugin}" size="30">
+ <f:validateLength maximum="100"/>
+ </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"/>
</a4j:outputPanel>
<br/>
</h:panelGrid>
</rich:panel>
+
+ <rich:panel>
+ <h:panelGrid columns="2" title="jboss-profiler.properties">
+ <h:outputText value="Operations" style="bg-color:"/>
+ <h:outputText value="Description"/>
+
+ <a4j:commandLink value="Start Profiler" action="#{basicOptBean.clickStart}"/>
+ <h:outputText value="start profiler in the server."/>
+
+ <a4j:commandLink value="Stop Profiler" action="#{basicOptBean.clickStop}"/>
+ <h:outputText value="Stop profiler in the server."/>
+
+ <a4j:commandLink value="Enable Profiler" action="#{basicOptBean.clickEnable}"/>
+ <h:outputText value="Enable profiler in the server. "/>
+
+ <a4j:commandLink value="Disable Profiler" action="#{basicOptBean.clickDisable}"/>
+ <h:outputText value="Disable profiler in the server."/>
+
+ <a4j:commandLink value="Garbage Collection" action="#{basicOptBean.gc}"/>
+ <h:outputText value="Begins Garbage Collection in the server."/>
+ </h:panelGrid>
+ </rich:panel>
</h:panelGroup>
</a4j:outputPanel>
</a4j:form>
Modified: branches/JBossProfiler2/src/main/www/snapshotoperations.xhtml
===================================================================
--- branches/JBossProfiler2/src/main/www/snapshotoperations.xhtml 2009-10-29 00:42:40 UTC (rev 574)
+++ branches/JBossProfiler2/src/main/www/snapshotoperations.xhtml 2009-10-30 12:45:29 UTC (rev 575)
@@ -23,7 +23,7 @@
<rich:dataTable id="snapshotsTable" rows="10" value="#{basicOptBean.snapshots}" var="snapshot" width="500px" columnClasses="center" onRowMouseOver="this.style.backgroundColor='#F1F1F1'" onRowMouseOut="this.style.backgroundColor='#FFFFFF'">
<rich:column style="width:500px" sortBy="#{snapshot}">
- <a4j:commandLink value="#{snapshot}" reRender="selectedSnapshotSection,snapshotsTable" action="#{basicOptBean.selectSnapshot}"/>
+ <a4j:commandLink value="#{snapshot}" reRender="selectedSnapshotSection" action="#{basicOptBean.selectSnapshot}"/>
<rich:toolTip direction="top-right" showDelay="500">
<span style="white-space:nowrap"> Click to choose one snapshot for save!<br/></span>
</rich:toolTip>
More information about the jboss-cvs-commits
mailing list