Repository: camel
Updated Branches:
  refs/heads/master a01d49f80 -> dfa458a2e


CAMEL-8526: Add more EIP as specialized mbeans


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/6b0765b5
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/6b0765b5
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/6b0765b5

Branch: refs/heads/master
Commit: 6b0765b5ffb75e165912fa9e1c9a5a846aaaf02f
Parents: a01d49f
Author: Claus Ibsen <davscl...@apache.org>
Authored: Wed Jul 22 07:41:49 2015 +0200
Committer: Claus Ibsen <davscl...@apache.org>
Committed: Wed Jul 22 07:41:49 2015 +0200

----------------------------------------------------------------------
 .../management/mbean/ManagedSplitterMBean.java  | 26 ++++++
 .../DefaultManagementObjectStrategy.java        |  4 +
 .../camel/management/mbean/ManagedSplitter.java | 41 +++++++++
 .../camel/management/ManagedSplitterTest.java   | 89 ++++++++++++++++++++
 4 files changed, 160 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/6b0765b5/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedSplitterMBean.java
----------------------------------------------------------------------
diff --git 
a/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedSplitterMBean.java
 
b/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedSplitterMBean.java
new file mode 100644
index 0000000..ee72f51
--- /dev/null
+++ 
b/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedSplitterMBean.java
@@ -0,0 +1,26 @@
+/**
+ * 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.camel.api.management.mbean;
+
+import org.apache.camel.api.management.ManagedAttribute;
+
+public interface ManagedSplitterMBean extends ManagedMulticastMBean {
+
+    @ManagedAttribute(description = "Expression of how to split the message 
body, such as as-is, using a tokenizer, or using an xpath.")
+    String getExpression();
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/6b0765b5/camel-core/src/main/java/org/apache/camel/management/DefaultManagementObjectStrategy.java
----------------------------------------------------------------------
diff --git 
a/camel-core/src/main/java/org/apache/camel/management/DefaultManagementObjectStrategy.java
 
b/camel-core/src/main/java/org/apache/camel/management/DefaultManagementObjectStrategy.java
index b55f466..76c57bb 100644
--- 
a/camel-core/src/main/java/org/apache/camel/management/DefaultManagementObjectStrategy.java
+++ 
b/camel-core/src/main/java/org/apache/camel/management/DefaultManagementObjectStrategy.java
@@ -63,6 +63,7 @@ import org.apache.camel.management.mbean.ManagedService;
 import org.apache.camel.management.mbean.ManagedSetBody;
 import org.apache.camel.management.mbean.ManagedSetHeader;
 import org.apache.camel.management.mbean.ManagedSetProperty;
+import org.apache.camel.management.mbean.ManagedSplitter;
 import org.apache.camel.management.mbean.ManagedSuspendableRoute;
 import org.apache.camel.management.mbean.ManagedThreadPool;
 import org.apache.camel.management.mbean.ManagedThrottler;
@@ -91,6 +92,7 @@ import org.apache.camel.processor.SendProcessor;
 import org.apache.camel.processor.SetBodyProcessor;
 import org.apache.camel.processor.SetHeaderProcessor;
 import org.apache.camel.processor.SetPropertyProcessor;
+import org.apache.camel.processor.Splitter;
 import org.apache.camel.processor.StreamResequencer;
 import org.apache.camel.processor.Throttler;
 import org.apache.camel.processor.ThroughputLogger;
@@ -237,6 +239,8 @@ public class DefaultManagementObjectStrategy implements 
ManagementObjectStrategy
                 answer = new ManagedLoop(context, (LoopProcessor) target, 
definition);
             } else if (target instanceof RecipientList) {
                 answer = new ManagedRecipientList(context, (RecipientList) 
target, definition);
+            } else if (target instanceof Splitter) {
+                answer = new ManagedSplitter(context, (Splitter) target, 
definition);
             } else if (target instanceof MulticastProcessor) {
                 answer = new ManagedMulticast(context, (MulticastProcessor) 
target, definition);
             } else if (target instanceof SamplingThrottler) {

http://git-wip-us.apache.org/repos/asf/camel/blob/6b0765b5/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedSplitter.java
----------------------------------------------------------------------
diff --git 
a/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedSplitter.java
 
b/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedSplitter.java
new file mode 100644
index 0000000..b2b1733
--- /dev/null
+++ 
b/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedSplitter.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.camel.management.mbean;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.api.management.ManagedResource;
+import org.apache.camel.api.management.mbean.ManagedSplitterMBean;
+import org.apache.camel.model.ProcessorDefinition;
+import org.apache.camel.processor.Splitter;
+
+/**
+ * @version 
+ */
+@ManagedResource(description = "Managed Splitter")
+public class ManagedSplitter extends ManagedMulticast implements 
ManagedSplitterMBean {
+    private final Splitter processor;
+
+    public ManagedSplitter(CamelContext context, Splitter processor, 
ProcessorDefinition<?> definition) {
+        super(context, processor, definition);
+        this.processor = processor;
+    }
+
+    @Override
+    public String getExpression() {
+        return processor.getExpression().toString();
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/6b0765b5/camel-core/src/test/java/org/apache/camel/management/ManagedSplitterTest.java
----------------------------------------------------------------------
diff --git 
a/camel-core/src/test/java/org/apache/camel/management/ManagedSplitterTest.java 
b/camel-core/src/test/java/org/apache/camel/management/ManagedSplitterTest.java
new file mode 100644
index 0000000..1f90754
--- /dev/null
+++ 
b/camel-core/src/test/java/org/apache/camel/management/ManagedSplitterTest.java
@@ -0,0 +1,89 @@
+/**
+ * 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.camel.management;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import javax.management.openmbean.TabularData;
+
+import org.apache.camel.ServiceStatus;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+
+/**
+ * @version 
+ */
+public class ManagedSplitterTest extends ManagementTestSupport {
+
+    public void testManageSplitter() throws Exception {
+        // JMX tests dont work well on AIX CI servers (hangs them)
+        if (isPlatform("aix")) {
+            return;
+        }
+
+        MockEndpoint foo = getMockEndpoint("mock:foo");
+        foo.expectedMessageCount(2);
+
+        template.sendBody("direct:start", "Hello,World");
+
+        assertMockEndpointsSatisfied();
+
+        // get the stats for the route
+        MBeanServer mbeanServer = getMBeanServer();
+
+        // get the object name for the delayer
+        ObjectName on = 
ObjectName.getInstance("org.apache.camel:context=camel-1,type=processors,name=\"mysend\"");
+
+        // should be on route1
+        String routeId = (String) mbeanServer.getAttribute(on, "RouteId");
+        assertEquals("route1", routeId);
+
+        String camelId = (String) mbeanServer.getAttribute(on, "CamelId");
+        assertEquals("camel-1", camelId);
+
+        String state = (String) mbeanServer.getAttribute(on, "State");
+        assertEquals(ServiceStatus.Started.name(), state);
+
+        String uri = (String) mbeanServer.getAttribute(on, "Expression");
+        assertEquals("tokenize(body, ,)", uri);
+
+        TabularData data = (TabularData) mbeanServer.invoke(on, "explain", new 
Object[]{false}, new String[]{"boolean"});
+        assertNotNull(data);
+        assertEquals(3, data.size());
+
+        data = (TabularData) mbeanServer.invoke(on, "explain", new 
Object[]{true}, new String[]{"boolean"});
+        assertNotNull(data);
+        assertEquals(15, data.size());
+
+        String json = (String) mbeanServer.invoke(on, "informationJson", null, 
null);
+        assertNotNull(json);
+        assertTrue(json.contains("\"description\": \"Splits a single message 
into many sub-messages."));
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start")
+                    .split(body().tokenize(",")).id("mysend")
+                        .to("mock:foo");
+            }
+        };
+    }
+
+}

Reply via email to