Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

KARAF-1794 - Extend Camel plugin with support for suspending/resuming…

… context

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

git-svn-id: https://svn.apache.org/repos/asf/karaf/webconsole/trunk@1381415 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
commit 17f74ddbdbf09d93567c4779a45755f57a1fbe00 1 parent 8ff8d2d
@splatch splatch authored
View
12 ...src/main/java/org/apache/karaf/webconsole/camel/internal/context/ContextActionsPanel.java
@@ -20,6 +20,8 @@
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 void onClick() {
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;
}
View
41 camel/src/main/java/org/apache/karaf/webconsole/camel/internal/context/link/ContextLink.java
@@ -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);
+
+}
View
43 camel/src/main/java/org/apache/karaf/webconsole/camel/internal/context/link/ResumeLink.java
@@ -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());
+ }
+ }
+
+}
View
43 camel/src/main/java/org/apache/karaf/webconsole/camel/internal/context/link/SuspendLink.java
@@ -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());
+ }
+ }
+
+}
Please sign in to comment.
Something went wrong with that request. Please try again.