KARAF-1795 Fix camel widget and provide additional information about delpoyed contexts
authorŁukasz Dywicki <ldywicki@apache.org>
Wed, 5 Sep 2012 22:09:02 +0000 (22:09 +0000)
committerŁukasz Dywicki <ldywicki@apache.org>
Wed, 5 Sep 2012 22:09:02 +0000 (22:09 +0000)
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

camel/src/main/java/org/apache/karaf/webconsole/camel/internal/widget/CamelWidget.java
camel/src/main/java/org/apache/karaf/webconsole/camel/internal/widget/CamelWidgetProvider.java
camel/src/main/resources/OSGI-INF/blueprint/camel.xml
camel/src/main/resources/org/apache/karaf/webconsole/camel/internal/widget/CamelWidget.html

index a7289b6..0e59506 100644 (file)
@@ -25,6 +25,7 @@ import org.apache.wicket.markup.html.link.BookmarkablePageLink;
 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 @@ public class CamelWidget extends Panel {
 
     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()));
             }
         });
 
index d99fee0..f7f8aed 100644 (file)
  */
 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);
     }
 
 }
index 3113b1e..decf9e3 100644 (file)
 
     <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">
index f238052..c7df241 100644 (file)
    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>