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/0b246429 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/0b246429 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/0b246429 Branch: refs/heads/master Commit: 0b246429b8b7594bf4ef0e099f35e2254ef92e4f Parents: 10af880 Author: Claus Ibsen <davscl...@apache.org> Authored: Wed Jul 22 11:20:02 2015 +0200 Committer: Claus Ibsen <davscl...@apache.org> Committed: Wed Jul 22 11:20:02 2015 +0200 ---------------------------------------------------------------------- .../mbean/ManagedThrowExceptionMBean.java | 29 +++++++++++ .../DefaultManagementObjectStrategy.java | 4 ++ .../management/mbean/ManagedThrowException.java | 53 ++++++++++++++++++++ 3 files changed, 86 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/0b246429/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedThrowExceptionMBean.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedThrowExceptionMBean.java b/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedThrowExceptionMBean.java new file mode 100644 index 0000000..8571b9f --- /dev/null +++ b/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedThrowExceptionMBean.java @@ -0,0 +1,29 @@ +/** + * 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 ManagedThrowExceptionMBean extends ManagedProcessorMBean { + + @ManagedAttribute(description = "To create a new exception instance and use the given message as caused message (supports simple language)") + String getMessage(); + + @ManagedAttribute(description = "The class of the exception to create using the message") + String getExceptionType(); + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/0b246429/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 1704715..b20525f 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 @@ -80,6 +80,7 @@ import org.apache.camel.management.mbean.ManagedThreadPool; import org.apache.camel.management.mbean.ManagedThreads; import org.apache.camel.management.mbean.ManagedThrottler; import org.apache.camel.management.mbean.ManagedThroughputLogger; +import org.apache.camel.management.mbean.ManagedThrowException; import org.apache.camel.management.mbean.ManagedTransformer; import org.apache.camel.management.mbean.ManagedValidate; import org.apache.camel.management.mbean.ManagedWireTapProcessor; @@ -121,6 +122,7 @@ import org.apache.camel.processor.StreamResequencer; import org.apache.camel.processor.ThreadsProcessor; import org.apache.camel.processor.Throttler; import org.apache.camel.processor.ThroughputLogger; +import org.apache.camel.processor.ThrowExceptionProcessor; import org.apache.camel.processor.TransformProcessor; import org.apache.camel.processor.WireTapProcessor; import org.apache.camel.processor.aggregate.AggregateProcessor; @@ -307,6 +309,8 @@ public class DefaultManagementObjectStrategy implements ManagementObjectStrategy answer = new ManagedStop(context, (StopProcessor) target, definition); } else if (target instanceof ThreadsProcessor) { answer = new ManagedThreads(context, (ThreadsProcessor) target, definition); + } else if (target instanceof ThrowExceptionProcessor) { + answer = new ManagedThrowException(context, (ThrowExceptionProcessor) target, definition); } else if (target instanceof TransformProcessor) { answer = new ManagedTransformer(context, (TransformProcessor) target, definition); } else if (target instanceof PredicateValidatingProcessor) { http://git-wip-us.apache.org/repos/asf/camel/blob/0b246429/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedThrowException.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedThrowException.java b/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedThrowException.java new file mode 100644 index 0000000..ee23988 --- /dev/null +++ b/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedThrowException.java @@ -0,0 +1,53 @@ +/** + * 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.ManagedThrowExceptionMBean; +import org.apache.camel.model.ProcessorDefinition; +import org.apache.camel.processor.ThrowExceptionProcessor; +import org.apache.camel.util.ObjectHelper; + +/** + * @version + */ +@ManagedResource(description = "Managed ThrowException") +public class ManagedThrowException extends ManagedProcessor implements ManagedThrowExceptionMBean { + private final ThrowExceptionProcessor processor; + + public ManagedThrowException(CamelContext context, ThrowExceptionProcessor processor, ProcessorDefinition<?> definition) { + super(context, processor, definition); + this.processor = processor; + } + + @Override + public String getMessage() { + return processor.getMessage(); + } + + @Override + public String getExceptionType() { + if (processor.getType() != null) { + return ObjectHelper.name(processor.getType()); + } else if (processor.getException() != null) { + return ObjectHelper.className(processor.getException()); + } else { + return null; + } + } +}