Permalink
Browse files

KARAF-1795 Fix camel widget and provide additional information about …

…delpoyed contexts

Signed-off-by: Lukasz Dywicki <luke@code-house.org>

git-svn-id: https://svn.apache.org/repos/asf/karaf/webconsole/trunk@1381416 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
1 parent 17f74dd commit 0cdd2de99cbc306bf0f422f2ff13d08626129e05 @splatch splatch committed Sep 5, 2012
@@ -25,6 +25,7 @@
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.markup.html.panel.Panel;
+import org.ops4j.pax.wicket.api.PaxWicketBean;
/**
* Widget with list of camel contexts.
@@ -33,21 +34,22 @@
private static final long serialVersionUID = 1L;
+ @PaxWicketBean(name = "contexts")
+ private List<CamelContext> contexts;
+
@SuppressWarnings("serial")
- public CamelWidget(String id, List<CamelContext> contexts) {
+ public CamelWidget(String id) {
super(id);
-// List<CamelContext> subList = new ArrayList<CamelContext>(contexts);
-// if (subList.size() > 4) {
-// subList = subList.subList(0, 4);
-// }
add(new Label("count", "" + contexts.size()));
- add(new ListView<CamelContext>("contexts"/*, subList*/) {
+ add(new ListView<CamelContext>("contexts", contexts) {
@Override
protected void populateItem(ListItem<CamelContext> item) {
CamelContext model = item.getModelObject();
- add(new Label("name", model.getName()));
+ item.add(new Label("name", model.getName()));
+ item.add(new Label("uptime", model.getUptime()));
+ item.add(new Label("routeCount", ""+ model.getRouteDefinitions().size()));
}
});
@@ -16,22 +16,13 @@
*/
package org.apache.karaf.webconsole.camel.internal.widget;
-import java.util.List;
-
-import org.apache.camel.CamelContext;
import org.apache.karaf.webconsole.core.widget.WidgetProvider;
import org.apache.wicket.markup.html.panel.Panel;
public class CamelWidgetProvider implements WidgetProvider {
- private final List<CamelContext> contexts;
-
- public CamelWidgetProvider(List<CamelContext> contexts) {
- this.contexts = contexts;
- }
-
public Panel createPanel(String id) {
- return new CamelWidget(id, contexts);
+ return new CamelWidget(id);
}
}
@@ -23,17 +23,15 @@
<bean id="tracer" class="org.apache.karaf.webconsole.camel.internal.tracking.DefaultTracerContainer" />
- <reference-list id="contexts" interface="org.apache.camel.CamelContext"/>
+ <reference-list id="contexts" interface="org.apache.camel.CamelContext" availability="optional" />
- <service ref="widgetProvider" interface="org.apache.karaf.webconsole.core.widget.WidgetProvider">
+ <service interface="org.apache.karaf.webconsole.core.widget.WidgetProvider">
<service-properties>
<entry key="intention" value="dashboard" />
</service-properties>
+ <bean class="org.apache.karaf.webconsole.camel.internal.widget.CamelWidgetProvider" />
</service>
- <bean id="widgetProvider" class="org.apache.karaf.webconsole.camel.internal.widget.CamelWidgetProvider">
- <argument ref="contexts" />
- </bean>
<service auto-export="interfaces">
<bean class="org.apache.karaf.webconsole.camel.internal.tracking.TraceInterceptStrategy">
@@ -16,17 +16,21 @@
limitations under the License.
-->
<wicket:panel xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
- <div class="grid_6 widget">
+ <div class="span6 widget">
<h1>Deployed camel contexts</h1>
- <p>You have <span wicket:id="count">13</span> camel contexts deployed. First four are:</p>
+ <p>You have <span wicket:id="count">13</span> camel contexts deployed.</p>
<table class="table table-striped table-condensed">
<tr>
<th>Name</th>
+ <th>Uptime</th>
+ <th title="Number of all routes">Routes</th>
</tr>
<tr wicket:id="contexts">
- <td><span wicket:id="name">.test-context</span></td>
+ <td><span wicket:id="name"></span></td>
+ <td><span wicket:id="uptime"></span></td>
+ <td><span wicket:id="routeCount"></span></td>
</tr>
</table>

0 comments on commit 0cdd2de

Please sign in to comment.