You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by ld...@apache.org on 2012/09/06 00:08:41 UTC

svn commit: r1381415 - in /karaf/webconsole/trunk/camel/src/main/java/org/apache/karaf/webconsole/camel/internal/context: ContextActionsPanel.java link/ link/ContextLink.java link/ResumeLink.java link/SuspendLink.java

Author: ldywicki
Date: Wed Sep  5 22:08:41 2012
New Revision: 1381415

URL: http://svn.apache.org/viewvc?rev=1381415&view=rev
Log:
KARAF-1794 - Extend Camel plugin with support for suspending/resuming context

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

Added:
    karaf/webconsole/trunk/camel/src/main/java/org/apache/karaf/webconsole/camel/internal/context/link/
    karaf/webconsole/trunk/camel/src/main/java/org/apache/karaf/webconsole/camel/internal/context/link/ContextLink.java
    karaf/webconsole/trunk/camel/src/main/java/org/apache/karaf/webconsole/camel/internal/context/link/ResumeLink.java
    karaf/webconsole/trunk/camel/src/main/java/org/apache/karaf/webconsole/camel/internal/context/link/SuspendLink.java
Modified:
    karaf/webconsole/trunk/camel/src/main/java/org/apache/karaf/webconsole/camel/internal/context/ContextActionsPanel.java

Modified: karaf/webconsole/trunk/camel/src/main/java/org/apache/karaf/webconsole/camel/internal/context/ContextActionsPanel.java
URL: http://svn.apache.org/viewvc/karaf/webconsole/trunk/camel/src/main/java/org/apache/karaf/webconsole/camel/internal/context/ContextActionsPanel.java?rev=1381415&r1=1381414&r2=1381415&view=diff
==============================================================================
--- karaf/webconsole/trunk/camel/src/main/java/org/apache/karaf/webconsole/camel/internal/context/ContextActionsPanel.java (original)
+++ karaf/webconsole/trunk/camel/src/main/java/org/apache/karaf/webconsole/camel/internal/context/ContextActionsPanel.java Wed Sep  5 22:08:41 2012
@@ -20,6 +20,8 @@ import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.camel.CamelContext;
+import org.apache.karaf.webconsole.camel.internal.context.link.ResumeLink;
+import org.apache.karaf.webconsole.camel.internal.context.link.SuspendLink;
 import org.apache.karaf.webconsole.camel.internal.tracking.TraceContainer;
 import org.apache.karaf.webconsole.core.table.ActionsPanel;
 import org.apache.wicket.Session;
@@ -85,6 +87,16 @@ public class ContextActionsPanel extends
             links.add(link);
         }
 
+        if (!object.isSuspended()) {
+            Link link = new SuspendLink(linkId, getModel());
+            link.add(new Label(labelId, "Suspend"));
+            links.add(link);
+        } else {
+            Link link = new ResumeLink(linkId, getModel());
+            link.add(new Label(labelId, "Resume"));
+            links.add(link);
+        }
+
         return links;
     }
 

Added: karaf/webconsole/trunk/camel/src/main/java/org/apache/karaf/webconsole/camel/internal/context/link/ContextLink.java
URL: http://svn.apache.org/viewvc/karaf/webconsole/trunk/camel/src/main/java/org/apache/karaf/webconsole/camel/internal/context/link/ContextLink.java?rev=1381415&view=auto
==============================================================================
--- karaf/webconsole/trunk/camel/src/main/java/org/apache/karaf/webconsole/camel/internal/context/link/ContextLink.java (added)
+++ karaf/webconsole/trunk/camel/src/main/java/org/apache/karaf/webconsole/camel/internal/context/link/ContextLink.java Wed Sep  5 22:08:41 2012
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.karaf.webconsole.camel.internal.context.link;
+
+import org.apache.camel.CamelContext;
+import org.apache.wicket.markup.html.link.Link;
+import org.apache.wicket.model.IModel;
+
+/**
+ * Base link for context releated stuff.
+ */
+public abstract class ContextLink extends Link<CamelContext> {
+
+    private static final long serialVersionUID = 1L;
+
+    public ContextLink(String id, IModel<CamelContext> model) {
+        super(id, model);
+    }
+
+    @Override
+    public void onClick() {
+        onClick((CamelContext) getDefaultModelObject());
+    }
+
+    protected abstract void onClick(CamelContext context);
+
+}

Added: karaf/webconsole/trunk/camel/src/main/java/org/apache/karaf/webconsole/camel/internal/context/link/ResumeLink.java
URL: http://svn.apache.org/viewvc/karaf/webconsole/trunk/camel/src/main/java/org/apache/karaf/webconsole/camel/internal/context/link/ResumeLink.java?rev=1381415&view=auto
==============================================================================
--- karaf/webconsole/trunk/camel/src/main/java/org/apache/karaf/webconsole/camel/internal/context/link/ResumeLink.java (added)
+++ karaf/webconsole/trunk/camel/src/main/java/org/apache/karaf/webconsole/camel/internal/context/link/ResumeLink.java Wed Sep  5 22:08:41 2012
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.karaf.webconsole.camel.internal.context.link;
+
+import org.apache.camel.CamelContext;
+import org.apache.wicket.model.IModel;
+
+/**
+ * Link which resume context.
+ */
+public class ResumeLink extends ContextLink {
+
+    private static final long serialVersionUID = 1L;
+
+    public ResumeLink(String id, IModel<CamelContext> model) {
+        super(id, model);
+    }
+
+    @Override
+    protected void onClick(CamelContext context) {
+        try {
+            context.resume();
+            info("Resume context " + context.getName() + " successfull");
+        } catch (Exception e) {
+            warn("Exception during resuming context " + e.getMessage());
+        }
+    }
+
+}

Added: karaf/webconsole/trunk/camel/src/main/java/org/apache/karaf/webconsole/camel/internal/context/link/SuspendLink.java
URL: http://svn.apache.org/viewvc/karaf/webconsole/trunk/camel/src/main/java/org/apache/karaf/webconsole/camel/internal/context/link/SuspendLink.java?rev=1381415&view=auto
==============================================================================
--- karaf/webconsole/trunk/camel/src/main/java/org/apache/karaf/webconsole/camel/internal/context/link/SuspendLink.java (added)
+++ karaf/webconsole/trunk/camel/src/main/java/org/apache/karaf/webconsole/camel/internal/context/link/SuspendLink.java Wed Sep  5 22:08:41 2012
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.karaf.webconsole.camel.internal.context.link;
+
+import org.apache.camel.CamelContext;
+import org.apache.wicket.model.IModel;
+
+/**
+ * Link which suspends context.
+ */
+public class SuspendLink extends ContextLink {
+
+    private static final long serialVersionUID = 1L;
+
+    public SuspendLink(String id, IModel<CamelContext> model) {
+        super(id, model);
+    }
+
+    @Override
+    protected void onClick(CamelContext context) {
+        try {
+            context.suspend();
+            info("Suspended context " + context.getName() + " successfull");
+        } catch (Exception e) {
+            warn("Exception during suspending context " + e.getMessage());
+        }
+    }
+
+}