[maven-scm] copy for tag camel-2.3.0
git-svn-id: https://svn.apache.org/repos/asf/camel/tags/camel-2.3.0@947328 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/camel-core/src/main/java/org/apache/camel/Message.java b/camel-core/src/main/java/org/apache/camel/Message.java
index b6f2a5a..792f896 100644
--- a/camel-core/src/main/java/org/apache/camel/Message.java
+++ b/camel-core/src/main/java/org/apache/camel/Message.java
@@ -140,7 +140,7 @@
* See {@link org.apache.camel.impl.DefaultMessage DefaultMessage} for how headers
* is represented in Camel using a {@link org.apache.camel.util.CaseInsensitiveMap CaseInsensitiveMap}.
* <p/>
- * If you want to walk the returned Map and fetch all the keys and values, you should use
+ * <b>Important:</b> If you want to walk the returned {@link Map} and fetch all the keys and values, you should use
* the {@link java.util.Map#entrySet()} method, which ensure you get the keys in the original case.
*
* @return all the headers in a Map
diff --git a/camel-core/src/main/java/org/apache/camel/component/file/FileOperations.java b/camel-core/src/main/java/org/apache/camel/component/file/FileOperations.java
index 53ad552..71d5b5e 100644
--- a/camel-core/src/main/java/org/apache/camel/component/file/FileOperations.java
+++ b/camel-core/src/main/java/org/apache/camel/component/file/FileOperations.java
@@ -31,6 +31,7 @@
import org.apache.camel.InvalidPayloadException;
import org.apache.camel.util.ExchangeHelper;
import org.apache.camel.util.FileUtil;
+import org.apache.camel.util.IOHelper;
import org.apache.camel.util.ObjectHelper;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -255,8 +256,8 @@
position += in.transferTo(position, endpoint.getBufferSize(), out);
}
} finally {
- ObjectHelper.close(in, source.getName(), LOG);
- ObjectHelper.close(out, source.getName(), LOG);
+ IOHelper.close(in, source.getName(), LOG);
+ IOHelper.close(out, source.getName(), LOG);
}
}
@@ -280,8 +281,8 @@
byteBuffer.clear();
}
} finally {
- ObjectHelper.close(in, target.getName(), LOG);
- ObjectHelper.close(out, target.getName(), LOG);
+ IOHelper.close(in, target.getName(), LOG);
+ IOHelper.close(out, target.getName(), LOG);
}
}
diff --git a/camel-core/src/main/java/org/apache/camel/component/file/GenericFileProducer.java b/camel-core/src/main/java/org/apache/camel/component/file/GenericFileProducer.java
index c85b664..8e5493c 100644
--- a/camel-core/src/main/java/org/apache/camel/component/file/GenericFileProducer.java
+++ b/camel-core/src/main/java/org/apache/camel/component/file/GenericFileProducer.java
@@ -25,6 +25,7 @@
import org.apache.camel.spi.Language;
import org.apache.camel.util.ExchangeHelper;
import org.apache.camel.util.FileUtil;
+import org.apache.camel.util.IOHelper;
import org.apache.camel.util.ObjectHelper;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -214,7 +215,7 @@
}
} finally {
- ObjectHelper.close(payload, "Closing payload", log);
+ IOHelper.close(payload, "Closing payload", log);
}
}
diff --git a/camel-core/src/main/java/org/apache/camel/component/file/strategy/FileLockExclusiveReadLockStrategy.java b/camel-core/src/main/java/org/apache/camel/component/file/strategy/FileLockExclusiveReadLockStrategy.java
index d0507d0..becbef8 100644
--- a/camel-core/src/main/java/org/apache/camel/component/file/strategy/FileLockExclusiveReadLockStrategy.java
+++ b/camel-core/src/main/java/org/apache/camel/component/file/strategy/FileLockExclusiveReadLockStrategy.java
@@ -29,7 +29,7 @@
import org.apache.camel.component.file.GenericFileExclusiveReadLockStrategy;
import org.apache.camel.component.file.GenericFileOperations;
import org.apache.camel.util.ExchangeHelper;
-import org.apache.camel.util.ObjectHelper;
+import org.apache.camel.util.IOHelper;
import org.apache.camel.util.StopWatch;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -126,7 +126,7 @@
lock.release();
} finally {
// must close channel first
- ObjectHelper.close(channel, "while acquiring exclusive read lock for file: " + lockFileName, LOG);
+ IOHelper.close(channel, "while acquiring exclusive read lock for file: " + lockFileName, LOG);
}
}
diff --git a/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java b/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java
index db73284..5ffd8cf 100644
--- a/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java
+++ b/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java
@@ -35,6 +35,7 @@
import org.apache.camel.Endpoint;
import org.apache.camel.Exchange;
import org.apache.camel.Expression;
+import org.apache.camel.Handler;
import org.apache.camel.Message;
import org.apache.camel.Predicate;
import org.apache.camel.Processor;
@@ -221,6 +222,21 @@
// -------------------------------------------------------------------------
/**
+ * Handles the incoming exchange.
+ * <p/>
+ * This method turns this mock endpoint into a bean which you can use
+ * in the Camel routes, which allows you to inject MockEndpoint as beans
+ * in your routes and use the features of the mock to control the bean.
+ *
+ * @param exchange the exchange
+ * @throws Exception can be thrown
+ */
+ @Handler
+ public void handle(Exchange exchange) throws Exception {
+ onExchange(exchange);
+ }
+
+ /**
* Set the processor that will be invoked when the index
* message is received.
*/
diff --git a/camel-core/src/main/java/org/apache/camel/converter/IOConverter.java b/camel-core/src/main/java/org/apache/camel/converter/IOConverter.java
index 2bf8cb4..96af65b 100644
--- a/camel-core/src/main/java/org/apache/camel/converter/IOConverter.java
+++ b/camel-core/src/main/java/org/apache/camel/converter/IOConverter.java
@@ -40,7 +40,6 @@
import java.io.UnsupportedEncodingException;
import java.io.Writer;
import java.net.URL;
-import java.nio.charset.Charset;
import org.apache.camel.Converter;
import org.apache.camel.Exchange;
@@ -177,7 +176,7 @@
try {
return toBytes(is);
} finally {
- ObjectHelper.close(is, "file", LOG);
+ IOHelper.close(is, "file", LOG);
}
}
@@ -206,7 +205,7 @@
try {
return toString(is, exchange);
} finally {
- ObjectHelper.close(is, "url", LOG);
+ IOHelper.close(is, "url", LOG);
}
}
@@ -237,7 +236,7 @@
}
}
} finally {
- ObjectHelper.close(reader, "reader", LOG);
+ IOHelper.close(reader, "reader", LOG);
}
return sb.toString();
@@ -303,7 +302,7 @@
IOHelper.copy(stream, bos);
return bos.toByteArray();
} finally {
- ObjectHelper.close(bos, "stream", LOG);
+ IOHelper.close(bos, "stream", LOG);
}
}
diff --git a/camel-core/src/main/java/org/apache/camel/converter/NIOConverter.java b/camel-core/src/main/java/org/apache/camel/converter/NIOConverter.java
index 4e0fa6f..4c75fe9 100644
--- a/camel-core/src/main/java/org/apache/camel/converter/NIOConverter.java
+++ b/camel-core/src/main/java/org/apache/camel/converter/NIOConverter.java
@@ -26,7 +26,7 @@
import org.apache.camel.Converter;
import org.apache.camel.Exchange;
-import org.apache.camel.util.ObjectHelper;
+import org.apache.camel.util.IOHelper;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -76,7 +76,7 @@
}
return ByteBuffer.wrap(buf);
} finally {
- ObjectHelper.close(in, "Failed to close file stream: " + file.getPath(), LOG);
+ IOHelper.close(in, "Failed to close file stream: " + file.getPath(), LOG);
}
}
diff --git a/camel-core/src/main/java/org/apache/camel/impl/DefaultFactoryFinder.java b/camel-core/src/main/java/org/apache/camel/impl/DefaultFactoryFinder.java
index ae1fe2a..44c9adb 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/DefaultFactoryFinder.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/DefaultFactoryFinder.java
@@ -30,7 +30,7 @@
import org.apache.camel.spi.FactoryFinder;
import org.apache.camel.spi.Injector;
import org.apache.camel.util.CastUtils;
-import org.apache.camel.util.ObjectHelper;
+import org.apache.camel.util.IOHelper;
/**
* Default factory finder.
@@ -143,8 +143,8 @@
properties.load(reader);
return properties;
} finally {
- ObjectHelper.close(reader, key, null);
- ObjectHelper.close(in, key, null);
+ IOHelper.close(reader, key, null);
+ IOHelper.close(in, key, null);
}
}
}
diff --git a/camel-core/src/main/java/org/apache/camel/impl/DefaultPackageScanClassResolver.java b/camel-core/src/main/java/org/apache/camel/impl/DefaultPackageScanClassResolver.java
index 4b91fbe..c4aba97 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/DefaultPackageScanClassResolver.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/DefaultPackageScanClassResolver.java
@@ -41,7 +41,7 @@
import org.apache.camel.impl.scan.CompositePackageScanFilter;
import org.apache.camel.spi.PackageScanClassResolver;
import org.apache.camel.spi.PackageScanFilter;
-import org.apache.camel.util.ObjectHelper;
+import org.apache.camel.util.IOHelper;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -386,7 +386,7 @@
log.warn("Cannot search jar file '" + urlPath + "' for classes matching criteria: " + test
+ " due to an IOException: " + ioe.getMessage(), ioe);
} finally {
- ObjectHelper.close(jarStream, urlPath, log);
+ IOHelper.close(jarStream, urlPath, log);
}
}
diff --git a/camel-core/src/main/java/org/apache/camel/impl/GzipDataFormat.java b/camel-core/src/main/java/org/apache/camel/impl/GzipDataFormat.java
index 1621485..9ab9fa7 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/GzipDataFormat.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/GzipDataFormat.java
@@ -36,9 +36,9 @@
try {
IOHelper.copy(is, zipOutput);
} finally {
- zipOutput.close();
+ IOHelper.close(is);
+ IOHelper.close(zipOutput);
}
-
}
public Object unmarshal(Exchange exchange, InputStream stream) throws Exception {
@@ -47,8 +47,12 @@
// Create an expandable byte array to hold the inflated data
ByteArrayOutputStream bos = new ByteArrayOutputStream();
- IOHelper.copy(unzipInput, bos);
- return bos.toByteArray();
+ try {
+ IOHelper.copy(unzipInput, bos);
+ return bos.toByteArray();
+ } finally {
+ IOHelper.close(unzipInput);
+ }
}
}
diff --git a/camel-core/src/main/java/org/apache/camel/impl/ZipDataFormat.java b/camel-core/src/main/java/org/apache/camel/impl/ZipDataFormat.java
index f447072..9808947 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/ZipDataFormat.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/ZipDataFormat.java
@@ -47,7 +47,8 @@
try {
IOHelper.copy(is, zipOutput);
} finally {
- zipOutput.close();
+ IOHelper.close(is);
+ IOHelper.close(zipOutput);
}
}
@@ -61,8 +62,7 @@
IOHelper.copy(unzipInput, bos);
return bos.toByteArray();
} finally {
- unzipInput.close();
- bos.close();
+ IOHelper.close(unzipInput);
}
}
diff --git a/camel-core/src/main/java/org/apache/camel/impl/converter/AnnotationTypeConverterLoader.java b/camel-core/src/main/java/org/apache/camel/impl/converter/AnnotationTypeConverterLoader.java
index f8ee14b..3fd9ba7 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/converter/AnnotationTypeConverterLoader.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/converter/AnnotationTypeConverterLoader.java
@@ -37,6 +37,7 @@
import org.apache.camel.spi.PackageScanClassResolver;
import org.apache.camel.spi.TypeConverterRegistry;
import org.apache.camel.util.CastUtils;
+import org.apache.camel.util.IOHelper;
import org.apache.camel.util.ObjectHelper;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -117,7 +118,7 @@
tokenize(packages, line);
}
} finally {
- ObjectHelper.close(reader, null, LOG);
+ IOHelper.close(reader, null, LOG);
}
}
}
diff --git a/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java b/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java
index 6942e08..415ddd7 100644
--- a/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java
+++ b/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java
@@ -45,6 +45,7 @@
import org.apache.camel.builder.ExpressionBuilder;
import org.apache.camel.builder.ExpressionClause;
import org.apache.camel.builder.ProcessorBuilder;
+import org.apache.camel.builder.ValueBuilder;
import org.apache.camel.model.language.ConstantExpression;
import org.apache.camel.model.language.ExpressionDefinition;
import org.apache.camel.model.language.LanguageExpression;
@@ -1108,8 +1109,50 @@
public FilterDefinition filter(String language, String expression) {
return filter(new LanguageExpression(language, expression));
}
+
+ /**
+ * Creates a validation expression which only if it is <tt>true</tt> then the
+ * exchange is forwarded to the destination.
+ * Otherwise a {@link org.apache.camel.processor.validation.PredicateValidationException} is thrown.
+ *
+ * @param expression the expression
+ * @return the builder
+ */
+ public ValidateDefinition validate(Expression expression) {
+ ValidateDefinition answer = new ValidateDefinition();
+ answer.setExpression(new ExpressionDefinition(expression));
+ addOutput(answer);
+ return answer;
+ }
/**
+ * Creates a validation expression which only if it is <tt>true</tt> then the
+ * exchange is forwarded to the destination.
+ * Otherwise a {@link org.apache.camel.processor.validation.PredicateValidationException} is thrown.
+ *
+ * @param predicate the predicate
+ * @return the builder
+ */
+ public ValidateDefinition validate(Predicate predicate) {
+ ValidateDefinition answer = new ValidateDefinition();
+ answer.setExpression(new ExpressionDefinition(predicate));
+ addOutput(answer);
+ return answer;
+ }
+
+ /**
+ * Creates a validation expression which only if it is <tt>true</tt> then the
+ * exchange is forwarded to the destination.
+ * Otherwise a {@link org.apache.camel.processor.validation.PredicateValidationException} is thrown.
+ *
+ * @return the builder
+ */
+ public ExpressionClause<ValidateDefinition> validate() {
+ ValidateDefinition answer = new ValidateDefinition();
+ addOutput(answer);
+ return ExpressionClause.createAndSetExpression(answer);
+ }
+ /**
* <a href="http://camel.apache.org/load-balancer.html">Load Balancer EIP:</a>
* Creates a loadbalance
*
diff --git a/camel-core/src/main/java/org/apache/camel/model/ValidateDefinition.java b/camel-core/src/main/java/org/apache/camel/model/ValidateDefinition.java
new file mode 100644
index 0000000..59efc8b
--- /dev/null
+++ b/camel-core/src/main/java/org/apache/camel/model/ValidateDefinition.java
@@ -0,0 +1,57 @@
+/**
+ * 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.model;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.camel.Processor;
+import org.apache.camel.processor.validation.PredicateValidatingProcessor;
+import org.apache.camel.spi.RouteContext;
+
+/**
+ * Represents an XML <validate/> element
+ *
+ * @version $Revision$
+ */
+@XmlRootElement(name = "validate")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class ValidateDefinition extends ExpressionNode {
+
+ public ValidateDefinition() {
+ super();
+ }
+
+ @Override
+ public String toString() {
+ return "Validate[" + getExpression() + " -> " + getOutputs() + "]";
+ }
+
+ @Override
+ public String getShortName() {
+ return "validate";
+ }
+
+
+ @Override
+ public PredicateValidatingProcessor createProcessor(RouteContext routeContext) throws Exception {
+ Processor childProcessor = routeContext.createProcessor(this);
+ return new PredicateValidatingProcessor(getExpression().createPredicate(routeContext), childProcessor);
+ }
+
+}
\ No newline at end of file
diff --git a/camel-core/src/main/java/org/apache/camel/model/language/ExpressionDefinition.java b/camel-core/src/main/java/org/apache/camel/model/language/ExpressionDefinition.java
index c8ab456..2710490 100644
--- a/camel-core/src/main/java/org/apache/camel/model/language/ExpressionDefinition.java
+++ b/camel-core/src/main/java/org/apache/camel/model/language/ExpressionDefinition.java
@@ -92,15 +92,15 @@
if (getLanguage() != null) {
sb.append(getLanguage()).append("{");
}
- if (getExpression() != null) {
- sb.append(getExpression());
- }
if (getPredicate() != null) {
sb.append(getPredicate().toString());
}
if (getExpressionValue() != null) {
sb.append(getExpressionValue().toString());
}
+ if (getPredicate() == null && getExpressionValue() == null && getExpression() != null) {
+ sb.append(getExpression());
+ }
if (getLanguage() != null) {
sb.append("}");
}
diff --git a/camel-core/src/main/java/org/apache/camel/processor/aggregate/AggregateProcessor.java b/camel-core/src/main/java/org/apache/camel/processor/aggregate/AggregateProcessor.java
index c866110..bf63210 100644
--- a/camel-core/src/main/java/org/apache/camel/processor/aggregate/AggregateProcessor.java
+++ b/camel-core/src/main/java/org/apache/camel/processor/aggregate/AggregateProcessor.java
@@ -195,7 +195,7 @@
* @param exchange the exchange
* @return the aggregated exchange
*/
- private Exchange doAggregation(String key, Exchange exchange) {
+ private Exchange doAggregation(String key, Exchange exchange) throws CamelExchangeException {
if (LOG.isTraceEnabled()) {
LOG.trace("onAggregation +++ start +++ with correlation key: " + key);
}
@@ -223,6 +223,10 @@
// prepare the exchanges for aggregation and aggregate it
ExchangeHelper.prepareAggregation(oldExchange, newExchange);
answer = onAggregation(oldExchange, exchange);
+ if (answer == null) {
+ throw new CamelExchangeException("AggregationStrategy " + aggregationStrategy + " returned null which is not allowed", exchange);
+ }
+
// update the aggregated size
answer.setProperty(Exchange.AGGREGATED_SIZE, size);
diff --git a/camel-core/src/main/java/org/apache/camel/processor/idempotent/FileIdempotentRepository.java b/camel-core/src/main/java/org/apache/camel/processor/idempotent/FileIdempotentRepository.java
index ae96baf..257b53e 100644
--- a/camel-core/src/main/java/org/apache/camel/processor/idempotent/FileIdempotentRepository.java
+++ b/camel-core/src/main/java/org/apache/camel/processor/idempotent/FileIdempotentRepository.java
@@ -24,6 +24,7 @@
import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.camel.spi.IdempotentRepository;
+import org.apache.camel.util.IOHelper;
import org.apache.camel.util.LRUCache;
import org.apache.camel.util.ObjectHelper;
import org.apache.commons.logging.Log;
@@ -218,7 +219,7 @@
} catch (IOException e) {
throw ObjectHelper.wrapRuntimeCamelException(e);
} finally {
- ObjectHelper.close(fos, "Appending to file idempotent repository", LOG);
+ IOHelper.close(fos, "Appending to file idempotent repository", LOG);
}
}
@@ -240,7 +241,7 @@
} catch (IOException e) {
throw ObjectHelper.wrapRuntimeCamelException(e);
} finally {
- ObjectHelper.close(fos, "Trunking file idempotent repository", LOG);
+ IOHelper.close(fos, "Trunking file idempotent repository", LOG);
}
}
diff --git a/camel-core/src/main/java/org/apache/camel/processor/validation/PredicateValidatingProcessor.java b/camel-core/src/main/java/org/apache/camel/processor/validation/PredicateValidatingProcessor.java
new file mode 100644
index 0000000..f5eaa95
--- /dev/null
+++ b/camel-core/src/main/java/org/apache/camel/processor/validation/PredicateValidatingProcessor.java
@@ -0,0 +1,70 @@
+/**
+ * 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.processor.validation;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Predicate;
+import org.apache.camel.Processor;
+import org.apache.camel.processor.DelegateProcessor;
+import org.apache.camel.processor.Traceable;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * A processor which validates the content of the inbound message body
+ * against a regular expression.
+ *
+ * @version $Revision$
+ */
+public class PredicateValidatingProcessor extends DelegateProcessor implements Traceable {
+
+ private static final Log LOG = LogFactory.getLog(PredicateValidatingProcessor.class);
+
+ private final Predicate predicate;
+
+ public PredicateValidatingProcessor(Predicate predicate, Processor processor) {
+ super(processor);
+ this.predicate = predicate;
+ }
+
+ public void process(Exchange exchange) throws Exception {
+ boolean matches = predicate.matches(exchange);
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Validation " + (matches ? "succeed " : "failed ") + "for " + exchange + " with Predicate[" + predicate + "]");
+ }
+
+ if (matches) {
+ super.process(exchange);
+ } else {
+ throw new PredicateValidationException(exchange, predicate);
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "validate[" + predicate + "]";
+ }
+
+ public String getTraceLabel() {
+ return "validate";
+ }
+
+ public Predicate getPredicate() {
+ return predicate;
+ }
+}
\ No newline at end of file
diff --git a/camel-core/src/main/java/org/apache/camel/processor/validation/PredicateValidationException.java b/camel-core/src/main/java/org/apache/camel/processor/validation/PredicateValidationException.java
new file mode 100644
index 0000000..a5d0914
--- /dev/null
+++ b/camel-core/src/main/java/org/apache/camel/processor/validation/PredicateValidationException.java
@@ -0,0 +1,49 @@
+/**
+ * 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.processor.validation;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Predicate;
+import org.apache.camel.ValidationException;
+
+/**
+ * A predicate validation exception occurred
+ *
+ * @version $Revision$
+ */
+public class PredicateValidationException extends ValidationException {
+
+ private static final long serialVersionUID = 5767438583860347105L;
+
+ private final Predicate predicate;
+
+ public PredicateValidationException(Exchange exchange, Predicate predicate) {
+ super(exchange, buildMessage(predicate, exchange));
+ this.predicate = predicate;
+ }
+
+ protected static String buildMessage(Predicate predicate, Exchange exchange) {
+ StringBuilder builder = new StringBuilder("Validation failed for Predicate[");
+ builder.append(predicate.toString());
+ builder.append("]");
+ return builder.toString();
+ }
+
+ public Predicate getPredicate() {
+ return predicate;
+ }
+}
\ No newline at end of file
diff --git a/camel-core/src/main/java/org/apache/camel/util/CaseInsensitiveMap.java b/camel-core/src/main/java/org/apache/camel/util/CaseInsensitiveMap.java
index 38e7e52..9f4395c 100644
--- a/camel-core/src/main/java/org/apache/camel/util/CaseInsensitiveMap.java
+++ b/camel-core/src/main/java/org/apache/camel/util/CaseInsensitiveMap.java
@@ -24,7 +24,7 @@
/**
* A map that uses case insensitive keys, but preserves the original keys in the keySet.
* <p/>
- * This map allows you to do lookup using case insenstive keys so you can retrieve the value without worring about
+ * This map allows you to do lookup using case insensitive keys so you can retrieve the value without worrying about
* whether some transport protocol affects the keys such as Http and Mail protocols can do.
* <p/>
* When copying from this map to a regular Map such as {@link java.util.HashMap} then the original keys are
diff --git a/camel-core/src/main/java/org/apache/camel/util/IOHelper.java b/camel-core/src/main/java/org/apache/camel/util/IOHelper.java
index 17a2c2d..a638cae 100644
--- a/camel-core/src/main/java/org/apache/camel/util/IOHelper.java
+++ b/camel-core/src/main/java/org/apache/camel/util/IOHelper.java
@@ -16,12 +16,16 @@
*/
package org.apache.camel.util;
+import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
/**
* IO helper class.
*
@@ -29,6 +33,7 @@
*/
public final class IOHelper {
+ private static final transient Log LOG = LogFactory.getLog(IOHelper.class);
private static final int DEFAULT_BUFFER_SIZE = 1024 * 4;
private static final Charset UTF8_CHARSET = Charset.forName("UTF-8");
@@ -104,11 +109,55 @@
public static void copyAndCloseInput(InputStream input, OutputStream output) throws IOException {
copy(input, output);
- input.close();
+ close(input, null, LOG);
}
public static void copyAndCloseInput(InputStream input, OutputStream output, int bufferSize) throws IOException {
copy(input, output, bufferSize);
- input.close();
+ close(input, null, LOG);
}
+
+ /**
+ * Closes the given resource if it is available, logging any closing
+ * exceptions to the given log
+ *
+ * @param closeable the object to close
+ * @param name the name of the resource
+ * @param log the log to use when reporting closure warnings
+ */
+ public static void close(Closeable closeable, String name, Log log) {
+ if (closeable != null) {
+ try {
+ closeable.close();
+ } catch (IOException e) {
+ if (log != null) {
+ if (name != null) {
+ log.warn("Cannot close: " + name + ". Reason: " + e.getMessage(), e);
+ } else {
+ log.warn("Cannot close. Reason: " + e.getMessage(), e);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Closes the given resource if it is available.
+ *
+ * @param closeable the object to close
+ * @param name the name of the resource
+ */
+ public static void close(Closeable closeable, String name) {
+ close(closeable, name, LOG);
+ }
+
+ /**
+ * Closes the given resource if it is available.
+ *
+ * @param closeable the object to close
+ */
+ public static void close(Closeable closeable) {
+ close(closeable, null, LOG);
+ }
+
}
diff --git a/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java b/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java
index e5fa303..6aafeaf 100644
--- a/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java
+++ b/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java
@@ -581,9 +581,8 @@
/**
* A helper method to access a camel context properties with a prefix
*
- * @param name the name of the system property required
- * @param defaultValue the default value to use if the property is not
- * available or a security exception prevents access
+ * @param prefix the prefix
+ * @param camelContext the camel context
* @return the properties which holds the camel context properties with the prefix,
* and the key omit the prefix part
*/
@@ -993,19 +992,14 @@
* @param closeable the object to close
* @param name the name of the resource
* @param log the log to use when reporting closure warnings
+ * @deprecated use {@link org.apache.camel.util.IOHelper#close(java.io.Closeable, String, org.apache.commons.logging.Log)}
*/
+ @Deprecated
public static void close(Closeable closeable, String name, Log log) {
- if (closeable != null) {
- try {
- closeable.close();
- } catch (IOException e) {
- if (log != null) {
- log.warn("Cannot close: " + name + ". Reason: " + e, e);
- }
- }
- }
+ IOHelper.close(closeable, name, log);
}
+
/**
* Converts the given value to the required type or throw a meaningful exception
*/
diff --git a/camel-core/src/main/resources/org/apache/camel/model/jaxb.index b/camel-core/src/main/resources/org/apache/camel/model/jaxb.index
index 7bc0914..07bf86d 100644
--- a/camel-core/src/main/resources/org/apache/camel/model/jaxb.index
+++ b/camel-core/src/main/resources/org/apache/camel/model/jaxb.index
@@ -79,5 +79,6 @@
TransformDefinition
TryDefinition
UnmarshalDefinition
+ValidateDefinition
WhenDefinition
WireTapDefinition
diff --git a/camel-core/src/test/java/org/apache/camel/component/mock/MockAsBeanTest.java b/camel-core/src/test/java/org/apache/camel/component/mock/MockAsBeanTest.java
new file mode 100644
index 0000000..05ec8a6
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/component/mock/MockAsBeanTest.java
@@ -0,0 +1,76 @@
+/**
+ * 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.component.mock;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.impl.JndiRegistry;
+
+/**
+ * @version $Revision$
+ */
+public class MockAsBeanTest extends ContextTestSupport {
+
+ // create foo bean as a mock endpoint
+ private MockEndpoint foo = new MockEndpoint();
+
+ @Override
+ protected JndiRegistry createRegistry() throws Exception {
+ JndiRegistry jndi = super.createRegistry();
+ jndi.bind("foo", foo);
+ return jndi;
+ }
+
+ // START SNIPPET: e1
+ public void testMockAsBean() throws Exception {
+ // we should expect to receive the transformed message
+ getMockEndpoint("mock:result").expectedBodiesReceived("Bye World");
+
+ // the foo bean is a MockEndpoint which we use in this test to transform
+ // the message
+ foo.whenAnyExchangeReceived(new Processor() {
+ public void process(Exchange exchange) throws Exception {
+ String in = exchange.getIn().getBody(String.class);
+ exchange.getIn().setBody("Bye " + in);
+ }
+ });
+
+ template.sendBody("direct:start", "World");
+
+ assertMockEndpointsSatisfied();
+ }
+ // END SNIPPET: e1
+
+ @Override
+ // START SNIPPET: e2
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("direct:start")
+ // send to foo bean
+ .beanRef("foo")
+ // and then to result mock
+ .to("mock:result");
+ }
+ };
+ }
+ // END SNIPPET: e2
+
+}
diff --git a/camel-core/src/test/java/org/apache/camel/impl/GzipDataFormatFileDeleteTest.java b/camel-core/src/test/java/org/apache/camel/impl/GzipDataFormatFileDeleteTest.java
new file mode 100644
index 0000000..99ff713
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/impl/GzipDataFormatFileDeleteTest.java
@@ -0,0 +1,65 @@
+/**
+ * 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.impl;
+
+import java.io.File;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+
+/**
+ * @version $Revision$
+ */
+public class GzipDataFormatFileDeleteTest extends ContextTestSupport {
+
+ @Override
+ protected void setUp() throws Exception {
+ deleteDirectory("target/gzip");
+ super.setUp();
+ }
+
+ public void testGzipFileDelete() throws Exception {
+ getMockEndpoint("mock:result").expectedMessageCount(1);
+
+ template.sendBodyAndHeader("file:target/gzip", "Hello World", Exchange.FILE_NAME, "hello.txt");
+
+ assertMockEndpointsSatisfied();
+
+ //give a bit time
+ Thread.sleep(1000);
+
+ File in = new File("target/gzip/hello.txt").getAbsoluteFile();
+ assertFalse("Should have been deleted " + in, in.exists());
+
+ File out = new File("target/gzip/out/hello.txt.gz").getAbsoluteFile();
+ assertTrue("Should have been created " + out, out.exists());
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("file:target/gzip?delete=true")
+ .marshal().gzip()
+ .to("file:target/gzip/out?fileName=${file:name}.gz")
+ .to("mock:result");
+ }
+ };
+ }
+}
diff --git a/camel-core/src/test/java/org/apache/camel/impl/GzipDataFormatFileUnmarshalDeleteTest.java b/camel-core/src/test/java/org/apache/camel/impl/GzipDataFormatFileUnmarshalDeleteTest.java
new file mode 100644
index 0000000..1634d63
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/impl/GzipDataFormatFileUnmarshalDeleteTest.java
@@ -0,0 +1,68 @@
+/**
+ * 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.impl;
+
+import java.io.File;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+
+/**
+ * @version $Revision$
+ */
+public class GzipDataFormatFileUnmarshalDeleteTest extends ContextTestSupport {
+
+ @Override
+ protected void setUp() throws Exception {
+ deleteDirectory("target/gzip");
+ super.setUp();
+ }
+
+ public void testGzipFileUnmarshalDelete() throws Exception {
+ getMockEndpoint("mock:result").expectedBodiesReceived("Hello World");
+
+ template.sendBodyAndHeader("file:target/gzip", "Hello World", Exchange.FILE_NAME, "hello.txt");
+
+ assertMockEndpointsSatisfied();
+
+ //give a bit time
+ Thread.sleep(1000);
+
+ File in = new File("target/gzip/hello.txt").getAbsoluteFile();
+ assertFalse("Should have been deleted " + in, in.exists());
+
+ File out = new File("target/gzip/out/hello.txt.gz").getAbsoluteFile();
+ assertFalse("Should have been deleted " + out, out.exists());
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("file:target/gzip?delete=true")
+ .marshal().gzip()
+ .to("file:target/gzip/out?fileName=${file:name}.gz");
+
+ from("file:target/gzip/out?delete=true")
+ .unmarshal().gzip()
+ .to("mock:result");
+ }
+ };
+ }
+}
\ No newline at end of file
diff --git a/camel-core/src/test/java/org/apache/camel/impl/ZipDataFormatFileDeleteTest.java b/camel-core/src/test/java/org/apache/camel/impl/ZipDataFormatFileDeleteTest.java
new file mode 100644
index 0000000..4bf55ef
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/impl/ZipDataFormatFileDeleteTest.java
@@ -0,0 +1,65 @@
+/**
+ * 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.impl;
+
+import java.io.File;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+
+/**
+ * @version $Revision$
+ */
+public class ZipDataFormatFileDeleteTest extends ContextTestSupport {
+
+ @Override
+ protected void setUp() throws Exception {
+ deleteDirectory("target/zip");
+ super.setUp();
+ }
+
+ public void testZipFileDelete() throws Exception {
+ getMockEndpoint("mock:result").expectedMessageCount(1);
+
+ template.sendBodyAndHeader("file:target/zip", "Hello World", Exchange.FILE_NAME, "hello.txt");
+
+ assertMockEndpointsSatisfied();
+
+ //give a bit time
+ Thread.sleep(1000);
+
+ File in = new File("target/zip/hello.txt").getAbsoluteFile();
+ assertFalse("Should have been deleted " + in, in.exists());
+
+ File out = new File("target/zip/out/hello.txt.zip").getAbsoluteFile();
+ assertTrue("Should have been created " + out, out.exists());
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("file:target/zip?delete=true")
+ .marshal().zip()
+ .to("file:target/zip/out?fileName=${file:name}.zip")
+ .to("mock:result");
+ }
+ };
+ }
+}
\ No newline at end of file
diff --git a/camel-core/src/test/java/org/apache/camel/impl/ZipDataFormatFileUnmarshalDeleteTest.java b/camel-core/src/test/java/org/apache/camel/impl/ZipDataFormatFileUnmarshalDeleteTest.java
new file mode 100644
index 0000000..b4015d6
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/impl/ZipDataFormatFileUnmarshalDeleteTest.java
@@ -0,0 +1,68 @@
+/**
+ * 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.impl;
+
+import java.io.File;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+
+/**
+ * @version $Revision$
+ */
+public class ZipDataFormatFileUnmarshalDeleteTest extends ContextTestSupport {
+
+ @Override
+ protected void setUp() throws Exception {
+ deleteDirectory("target/zip");
+ super.setUp();
+ }
+
+ public void testZipFileUnmarshalDelete() throws Exception {
+ getMockEndpoint("mock:result").expectedBodiesReceived("Hello World");
+
+ template.sendBodyAndHeader("file:target/zip", "Hello World", Exchange.FILE_NAME, "hello.txt");
+
+ assertMockEndpointsSatisfied();
+
+ //give a bit time
+ Thread.sleep(1000);
+
+ File in = new File("target/zip/hello.txt").getAbsoluteFile();
+ assertFalse("Should have been deleted " + in, in.exists());
+
+ File out = new File("target/zip/out/hello.txt.zip").getAbsoluteFile();
+ assertFalse("Should have been deleted " + out, out.exists());
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("file:target/zip?delete=true")
+ .marshal().zip()
+ .to("file:target/zip/out?fileName=${file:name}.zip");
+
+ from("file:target/zip/out?delete=true")
+ .unmarshal().zip()
+ .to("mock:result");
+ }
+ };
+ }
+}
\ No newline at end of file
diff --git a/camel-core/src/test/java/org/apache/camel/processor/ValidateRegExpTest.java b/camel-core/src/test/java/org/apache/camel/processor/ValidateRegExpTest.java
new file mode 100644
index 0000000..708f615
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/processor/ValidateRegExpTest.java
@@ -0,0 +1,77 @@
+/**
+ * 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.processor;
+
+import org.apache.camel.CamelExecutionException;
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Endpoint;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.processor.validation.PredicateValidationException;
+
+/**
+ * @version $Revision$
+ */
+public class ValidateRegExpTest extends ContextTestSupport {
+
+ private Endpoint startEndpoint;
+ private MockEndpoint resultEndpoint;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ startEndpoint = resolveMandatoryEndpoint("direct:start", Endpoint.class);
+ resultEndpoint = resolveMandatoryEndpoint("mock:result", MockEndpoint.class);
+ }
+
+ public void testSendMatchingMessage() throws Exception {
+ resultEndpoint.expectedMessageCount(1);
+
+ template.sendBody(startEndpoint, "01.01.2010");
+
+ assertMockEndpointsSatisfied();
+ }
+
+ public void testSendNotMatchingMessage() throws Exception {
+ resultEndpoint.expectedMessageCount(0);
+
+ try {
+ template.sendBody(startEndpoint, "1.1.2010");
+ fail("CamelExecutionException expected");
+ } catch (CamelExecutionException e) {
+ // expected
+ assertIsInstanceOf(PredicateValidationException.class, e.getCause());
+ // as the Expression could be different between the DSL and simple language, here we just check part of the message
+ assertTrue("Get a wrong exception message", e.getCause().getMessage().startsWith("Validation failed for Predicate[bodyAs[java.lang.String]"));
+ assertTrue("Get a wrong exception message", e.getCause().getMessage().endsWith("Exchange[Message: 1.1.2010]"));
+ }
+
+ assertMockEndpointsSatisfied();
+ }
+
+
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ public void configure() {
+ from("direct:start")
+ .validate(body(String.class).regex("^\\d{2}\\.\\d{2}\\.\\d{4}$"))
+ .to("mock:result");
+ }
+ };
+ }
+}
\ No newline at end of file
diff --git a/camel-core/src/test/java/org/apache/camel/processor/ValidateSimpleTest.java b/camel-core/src/test/java/org/apache/camel/processor/ValidateSimpleTest.java
new file mode 100644
index 0000000..71a4c45
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/processor/ValidateSimpleTest.java
@@ -0,0 +1,76 @@
+/**
+ * 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.processor;
+
+import org.apache.camel.CamelExecutionException;
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Endpoint;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.processor.validation.PredicateValidationException;
+
+/**
+ * @version $Revision$
+ */
+public class ValidateSimpleTest extends ContextTestSupport {
+
+ private Endpoint startEndpoint;
+ private MockEndpoint resultEndpoint;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ startEndpoint = resolveMandatoryEndpoint("direct:start", Endpoint.class);
+ resultEndpoint = resolveMandatoryEndpoint("mock:result", MockEndpoint.class);
+ }
+
+ public void testSendMatchingMessage() throws Exception {
+ resultEndpoint.expectedMessageCount(1);
+
+ template.sendBody(startEndpoint, "Hello Camel");
+
+ assertMockEndpointsSatisfied();
+ }
+
+ public void testSendNotMatchingMessage() throws Exception {
+ resultEndpoint.expectedMessageCount(0);
+
+ try {
+ template.sendBody(startEndpoint, "Bye World");
+ fail("CamelExecutionException expected");
+ } catch (CamelExecutionException e) {
+ // expected
+ assertIsInstanceOf(PredicateValidationException.class, e.getCause());
+ assertEquals("Validation failed for Predicate[body contains Camel]."
+ + " Exchange[Message: Bye World]", e.getCause().getMessage());
+ }
+
+ assertMockEndpointsSatisfied();
+ }
+
+
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ public void configure() {
+ from("direct:start")
+ .validate().simple("${body} contains 'Camel'")
+ .to("mock:result");
+ }
+ };
+ }
+}
\ No newline at end of file
diff --git a/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateRepositoryReturnNullTest.java b/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateRepositoryReturnNullTest.java
new file mode 100644
index 0000000..84447f3
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateRepositoryReturnNullTest.java
@@ -0,0 +1,61 @@
+/**
+ * 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.processor.aggregator;
+
+import org.apache.camel.CamelExchangeException;
+import org.apache.camel.CamelExecutionException;
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.processor.aggregate.AggregationStrategy;
+
+/**
+ * @version $Revision$
+ */
+public class AggregateRepositoryReturnNullTest extends ContextTestSupport {
+
+ public void testAggregateRepositoryReturnNull() throws Exception {
+ try {
+ template.sendBodyAndHeader("direct:start", "Hello World", "id", 123);
+ fail("Should throw exception");
+ } catch (CamelExecutionException e) {
+ assertIsInstanceOf(CamelExchangeException.class, e.getCause());
+ assertTrue(e.getCause().getMessage().startsWith("AggregationStrategy"));
+ assertTrue(e.getCause().getMessage().contains("returned null which is not allowed"));
+ }
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("direct:start")
+ .aggregate(header("id"), new MyNullAggregationStrategy()).completionSize(3)
+ .to("mock:result");
+ }
+ };
+ }
+
+ private class MyNullAggregationStrategy implements AggregationStrategy {
+ public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
+ // on purpose
+ return null;
+ }
+ }
+
+}
diff --git a/components/camel-bean-validator/pom.xml b/components/camel-bean-validator/pom.xml
index 641bd57..77b2906 100644
--- a/components/camel-bean-validator/pom.xml
+++ b/components/camel-bean-validator/pom.xml
@@ -84,4 +84,4 @@
</dependencies>
-</project>
\ No newline at end of file
+</project>
diff --git a/components/camel-castor/pom.xml b/components/camel-castor/pom.xml
index 646a1e8..cec8610 100644
--- a/components/camel-castor/pom.xml
+++ b/components/camel-castor/pom.xml
@@ -103,4 +103,4 @@
</dependency>
</dependencies>
-</project>
\ No newline at end of file
+</project>
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java b/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java
index a3a12387..19d1871 100644
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java
@@ -90,10 +90,10 @@
popluateRequestParameters(request, message);
- // reset the stream cache
- StreamCache cache = message.getBody(StreamCache.class);
- if (cache != null) {
- cache.reset();
+ Object body = message.getBody();
+ // reset the stream cache if the body is the instance of StreamCache
+ if (body instanceof StreamCache) {
+ ((StreamCache)body).reset();
}
// store the method and query and other info in headers
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java
index 670c519..5bb84e2 100644
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java
@@ -65,10 +65,10 @@
HeaderFilterStrategy strategy = getEndpoint().getHeaderFilterStrategy();
// propagate headers as HTTP headers
- for (String headerName : in.getHeaders().keySet()) {
- String headerValue = in.getHeader(headerName, String.class);
- if (strategy != null && !strategy.applyFilterToCamelHeaders(headerName, headerValue, exchange)) {
- method.addRequestHeader(headerName, headerValue);
+ for (Map.Entry<String, Object> entry : in.getHeaders().entrySet()) {
+ String headerValue = in.getHeader(entry.getKey(), String.class);
+ if (strategy != null && !strategy.applyFilterToCamelHeaders(entry.getKey(), headerValue, exchange)) {
+ method.addRequestHeader(entry.getKey(), headerValue);
}
}
diff --git a/components/camel-http4/pom.xml b/components/camel-http4/pom.xml
index d2f1f95..88f19a6 100644
--- a/components/camel-http4/pom.xml
+++ b/components/camel-http4/pom.xml
@@ -100,4 +100,4 @@
</plugins>
</build>
-</project>
\ No newline at end of file
+</project>
diff --git a/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpProducer.java b/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpProducer.java
index 939b0b5..4a8fa79 100644
--- a/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpProducer.java
+++ b/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpProducer.java
@@ -70,13 +70,13 @@
HeaderFilterStrategy strategy = getEndpoint().getHeaderFilterStrategy();
// propagate headers as HTTP headers
- for (String headerName : in.getHeaders().keySet()) {
- String headerValue = in.getHeader(headerName, String.class);
- if (strategy != null && !strategy.applyFilterToCamelHeaders(headerName, headerValue, exchange)) {
- httpRequest.addHeader(headerName, headerValue);
+ for (Map.Entry<String, Object> entry : in.getHeaders().entrySet()) {
+ String headerValue = in.getHeader(entry.getKey(), String.class);
+ if (strategy != null && !strategy.applyFilterToCamelHeaders(entry.getKey(), headerValue, exchange)) {
+ httpRequest.addHeader(entry.getKey(), headerValue);
}
}
-
+
// lets store the result in the output message.
HttpResponse httpResponse = null;
try {
diff --git a/components/camel-jetty/pom.xml b/components/camel-jetty/pom.xml
index f503114..a07bd4a 100644
--- a/components/camel-jetty/pom.xml
+++ b/components/camel-jetty/pom.xml
@@ -125,4 +125,4 @@
</plugins>
</build>
-</project>
\ No newline at end of file
+</project>
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpHeaderTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpHeaderTest.java
new file mode 100644
index 0000000..51d8d8f
--- /dev/null
+++ b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpHeaderTest.java
@@ -0,0 +1,67 @@
+/**
+ * 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.component.jetty;
+
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.jetty.JettyContentTypeTest.MyBookService;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.camel.util.ExchangeHelper;
+import org.apache.camel.util.MessageHelper;
+import org.junit.Test;
+
+public class HttpHeaderTest extends CamelTestSupport {
+
+ @Test
+ public void testHttpHeaders() throws Exception {
+ String result = template.requestBody("direct:start", "hello", String.class);
+ assertEquals("Should send a right http header to the server.", "Find the key!", result);
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() throws Exception {
+ from("direct:start").setHeader("SOAPAction", constant("http://xxx.com/interfaces/ticket"))
+ .setHeader("Content-Type", constant("text/xml; charset=utf-8"))
+ .to("http://localhost:9080/myapp/mytest");
+
+ from("jetty:http://localhost:9080/myapp/mytest").process(new Processor() {
+
+ public void process(Exchange exchange) throws Exception {
+ Map<String, Object> headers = exchange.getIn().getHeaders();
+ for (Entry<String, Object> entry : headers.entrySet()) {
+ if ("SOAPAction".equals(entry.getKey()) && "http://xxx.com/interfaces/ticket".equals(entry.getValue())) {
+ exchange.getOut().setBody("Find the key!");
+ return;
+ }
+ }
+ exchange.getOut().setBody("Cannot find the key!");
+ }
+
+ });
+
+ }
+ };
+ }
+
+}
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpRouteTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpRouteTest.java
index e0c4d78..3ccbd8b 100644
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpRouteTest.java
+++ b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpRouteTest.java
@@ -220,9 +220,10 @@
from("jetty:http://localhost:9083/noStreamCache?disableStreamCache=true").noStreamCaching().process(new Processor() {
public void process(Exchange exchange) throws Exception {
- InputStream is = (InputStream)exchange.getIn().getBody();
- System.out.println(is.getClass());
+ InputStream is = (InputStream)exchange.getIn().getBody();
assertTrue("It should be a raw inputstream", is instanceof org.eclipse.jetty.server.HttpInput);
+ String request = exchange.getIn().getBody(String.class);
+ assertEquals("Get a wrong request", "This is a test", request);
exchange.getOut().setBody("OK");
}
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyContentTypeTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyContentTypeTest.java
index 72b2b62..22a5b56 100644
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyContentTypeTest.java
+++ b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyContentTypeTest.java
@@ -34,7 +34,8 @@
Endpoint endpoint = context.getEndpoint("http://localhost:9080/myapp/myservice");
Exchange exchange = endpoint.createExchange();
exchange.getIn().setBody("<order>123</order>");
- exchange.getIn().setHeader("user", "Claus");
+ exchange.getIn().setHeader("User", "Claus");
+ exchange.getIn().setHeader("SOAPAction", "test");
exchange.getIn().setHeader("Content-Type", "text/xml");
if (usingGZip) {
exchange.getIn().setHeader("Content-Encoding", "gzip");
@@ -81,9 +82,10 @@
public class MyBookService implements Processor {
public void process(Exchange exchange) throws Exception {
- if (exchange.getIn().getHeader("user") != null
+ if ("Claus".equals(exchange.getIn().getHeader("User", String.class))
&& exchange.getIn().getBody(String.class).equals("<order>123</order>")
&& "text/xml".equals(ExchangeHelper.getContentType(exchange))) {
+ assertEquals("test", exchange.getIn().getHeader("SOAPAction", String.class));
exchange.getOut().setBody("<order>OK</order>");
exchange.getOut().setHeader("Content-Type", "text/xml");
} else {
diff --git a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java
index b27b2e7..eca6ccd 100644
--- a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java
+++ b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java
@@ -333,7 +333,8 @@
if (value != null) {
// must encode to safe JMS header name before setting property on jmsMessage
String key = jmsKeyFormatStrategy.encodeKey(headerName);
- jmsMessage.setObjectProperty(key, value);
+ // set the property
+ JmsMessageHelper.setProperty(jmsMessage, key, value);
} else if (LOG.isDebugEnabled()) {
// okay the value is not a primitive or string so we cannot sent it over the wire
LOG.debug("Ignoring non primitive header: " + headerName + " of class: "
@@ -397,7 +398,7 @@
} else if (headerValue instanceof CharSequence) {
return headerValue.toString();
} else if (headerValue instanceof Boolean) {
- return headerValue.toString();
+ return headerValue;
} else if (headerValue instanceof Date) {
return headerValue.toString();
}
diff --git a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsMessageHelper.java b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsMessageHelper.java
index 99b8086..438c62d 100644
--- a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsMessageHelper.java
+++ b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsMessageHelper.java
@@ -91,4 +91,38 @@
return false;
}
+ /**
+ * Sets the property on the given JMS message.
+ *
+ * @param jmsMessage the JMS message
+ * @param name name of the property to set
+ * @param value the value
+ * @throws JMSException can be thrown
+ */
+ public static void setProperty(Message jmsMessage, String name, Object value) throws JMSException {
+ if (value == null) {
+ return;
+ }
+ if (value instanceof Byte) {
+ jmsMessage.setByteProperty(name, (Byte) value);
+ } else if (value instanceof Boolean) {
+ jmsMessage.setBooleanProperty(name, (Boolean) value);
+ } else if (value instanceof Double) {
+ jmsMessage.setDoubleProperty(name, (Double) value);
+ } else if (value instanceof Float) {
+ jmsMessage.setFloatProperty(name, (Float) value);
+ } else if (value instanceof Integer) {
+ jmsMessage.setIntProperty(name, (Integer) value);
+ } else if (value instanceof Long) {
+ jmsMessage.setLongProperty(name, (Long) value);
+ } else if (value instanceof Short) {
+ jmsMessage.setShortProperty(name, (Short) value);
+ } else if (value instanceof String) {
+ jmsMessage.setStringProperty(name, (String) value);
+ } else {
+ // fallback to Object
+ jmsMessage.setObjectProperty(name, value);
+ }
+ }
+
}
diff --git a/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRouteUsingDifferentHeadersTest.java b/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRouteUsingDifferentHeadersTest.java
new file mode 100644
index 0000000..608b4a9
--- /dev/null
+++ b/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRouteUsingDifferentHeadersTest.java
@@ -0,0 +1,81 @@
+/**
+ * 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.component.jms;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+import javax.jms.ConnectionFactory;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.camel.CamelContext;
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+
+import static org.apache.camel.component.jms.JmsComponent.jmsComponentClientAcknowledge;
+
+/**
+ * @version $Revision$
+ */
+public class JmsRouteUsingDifferentHeadersTest extends ContextTestSupport {
+
+ public void testUsingDifferentHeaderTypes() throws Exception {
+ Map<String, Object> headers = new LinkedHashMap<String, Object>();
+ headers.put("a", new Byte("65"));
+ headers.put("b", Boolean.TRUE);
+ headers.put("c", new Double("44444"));
+ headers.put("d", new Float("55555"));
+ headers.put("e", new Integer("222"));
+ headers.put("f", new Long("7777777"));
+ headers.put("g", new Short("333"));
+ headers.put("h", "Hello");
+
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedMessageCount(1);
+ mock.message(0).header("a").isInstanceOf(Byte.class);
+ mock.message(0).header("b").isInstanceOf(Boolean.class);
+ mock.message(0).header("c").isInstanceOf(Double.class);
+ mock.message(0).header("d").isInstanceOf(Float.class);
+ mock.message(0).header("e").isInstanceOf(Integer.class);
+ mock.message(0).header("f").isInstanceOf(Long.class);
+ mock.message(0).header("g").isInstanceOf(Short.class);
+ mock.message(0).header("h").isInstanceOf(String.class);
+
+ template.sendBodyAndHeaders("activemq:queue:foo", "Hello World", headers);
+
+ assertMockEndpointsSatisfied();
+ }
+
+ protected CamelContext createCamelContext() throws Exception {
+ CamelContext camelContext = super.createCamelContext();
+
+ ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false");
+ camelContext.addComponent("activemq", jmsComponentClientAcknowledge(connectionFactory));
+
+ return camelContext;
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("activemq:queue:foo").to("mock:result");
+ }
+ };
+ }
+}
diff --git a/components/camel-jmxconnect/pom.xml b/components/camel-jmxconnect/pom.xml
deleted file mode 100644
index 436e43b..0000000
--- a/components/camel-jmxconnect/pom.xml
+++ /dev/null
@@ -1,133 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- 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.
--->
-
-<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0">
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-parent</artifactId>
- <version>2.1-SNAPSHOT</version>
- </parent>
-
- <artifactId>camel-jmxconnect</artifactId>
- <packaging>bundle</packaging>
- <name>Camel :: JMX Connector</name>
- <description>Camel JMX Connector</description>
-
- <properties>
- <camel.osgi.export.pkg>org.apache.camel.jmxconnect.*</camel.osgi.export.pkg>
- </properties>
-
- <dependencies>
-
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-spring</artifactId>
- </dependency>
-
- <!-- TODO only used for the activemq provider - move to ActiveMQ trunk ASAP! -->
- <dependency>
- <groupId>org.apache.activemq</groupId>
- <artifactId>activemq-camel</artifactId>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-jms</artifactId>
- <optional>true</optional>
- </dependency>
-
-
- <!-- testing -->
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-test</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.activemq</groupId>
- <artifactId>activemq-core</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.xbean</groupId>
- <artifactId>xbean-spring</artifactId>
- <exclusions>
- <exclusion>
- <groupId>org.springframework</groupId>
- <artifactId>spring</artifactId>
- </exclusion>
- </exclusions>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
-
- <build>
- <plugins>
-
- <plugin>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <childDelegation>false</childDelegation>
- <useFile>true</useFile>
- <forkMode>pertest</forkMode>
- <excludes>
- <!--<exclude>**/SendMessageWithForeignReplyToRouteTest.*</exclude>-->
- </excludes>
- </configuration>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-clean-plugin</artifactId>
- <configuration>
- <filesets>
- <fileset>
- <directory>${basedir}/activemq-data</directory>
- </fileset>
- </filesets>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/components/camel-jmxconnect/src/main/java/org/apache/camel/jmxconnect/CamelJmxConnector.java b/components/camel-jmxconnect/src/main/java/org/apache/camel/jmxconnect/CamelJmxConnector.java
deleted file mode 100644
index dd66ffa..0000000
--- a/components/camel-jmxconnect/src/main/java/org/apache/camel/jmxconnect/CamelJmxConnector.java
+++ /dev/null
@@ -1,342 +0,0 @@
-/**
- * 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.jmxconnect;
-
-
-import java.io.IOException;
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicLong;
-
-import javax.management.ListenerNotFoundException;
-import javax.management.MBeanServerConnection;
-import javax.management.NotificationBroadcaster;
-import javax.management.NotificationBroadcasterSupport;
-import javax.management.NotificationEmitter;
-import javax.management.NotificationFilter;
-import javax.management.NotificationListener;
-import javax.management.remote.JMXConnectionNotification;
-import javax.management.remote.JMXConnector;
-import javax.management.remote.JMXConnectorFactory;
-import javax.management.remote.JMXServerErrorException;
-import javax.management.remote.JMXServiceURL;
-import javax.security.auth.Subject;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.CamelContextAware;
-import org.apache.camel.impl.DefaultCamelContext;
-import org.apache.camel.spring.remoting.CamelProxyFactoryBean;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * <p>
- * The client end of a JMX API connector. An object of this type can be used to establish a connection to a connector
- * server.
- * </p>
- * <p/>
- * <p>
- * A newly-created object of this type is unconnected. Its {@link #connect()} method must be called before it can
- * be used. However, objects created by {@link JMXConnectorFactory#connect(JMXServiceURL, Map)
- * JMXConnectorFactory.connect} are already connected.
- * </p>
- *
- * @version $Revision$
- */
-public class CamelJmxConnector implements JMXConnector, CamelContextAware {
- private static final Log LOG = LogFactory.getLog(JMXConnector.class);
- private NotificationBroadcasterSupport connectionNotifier = new NotificationBroadcasterSupport();
- private AtomicLong notificationNumber = new AtomicLong();
- private Map env;
- private String endpointUri;
- private CamelProxyFactoryBean proxy;
- private MBeanCamelServerConnectionClient client;
- private boolean connected;
- private CamelContext camelContext;
- private String connectionId;
-
- public CamelJmxConnector(Map env, String endpointUri) {
- this.env = env;
- this.endpointUri = endpointUri;
- }
-
- public CamelJmxConnector(Map env, JMXServiceURL url) throws IOException {
- this(env, CamelJmxConnectorSupport.getEndpointUri(url, "camel"));
- // set any props in the url
- // TODO
- // populateProperties(this, endpointUri);
- }
-
- /**
- * <p>
- * Establishes the connection to the connector server. This method is equivalent to {@link #connect(Map)
- * connect(null)}.
- * </p>
- *
- * @throws IOException if the connection could not be made because of a communication problem.
- * @throws SecurityException if the connection could not be made for security reasons.
- */
- public void connect() throws IOException {
- connect(this.env);
- }
-
- /**
- * <p>
- * Establishes the connection to the connector server.
- * </p>
- * <p/>
- * <p>
- * If <code>connect</code> has already been called successfully on this object, calling it again has no effect.
- * If, however, {@link #close} was called after <code>connect</code>, the new <code>connect</code> will throw
- * an <code>IOException</code>.
- * <p>
- * <p/>
- * <p>
- * Otherwise, either <code>connect</code> has never been called on this object, or it has been called but produced
- * an exception. Then calling <code>connect</code> will attempt to establish a connection to the connector server.
- * </p>
- *
- * @param env the properties of the connection. Properties in this map override properties in the map specified when
- * the <code>JMXConnector</code> was created, if any. This parameter can be null, which is equivalent
- * to an empty map.
- * @throws IOException if the connection could not be made because of a communication problem.
- * @throws SecurityException if the connection could not be made for security reasons.
- */
- public void connect(Map env) throws IOException {
- if (!connected) {
- try {
- proxy = new CamelProxyFactoryBean();
- proxy.setCamelContext(getCamelContext());
- proxy.setServiceInterface(javax.management.MBeanServerConnection.class);
- proxy.setServiceInterface(MBeanCamelServerConnection.class);
- proxy.setServiceUrl(endpointUri);
- proxy.afterPropertiesSet();
-
- client = new MBeanCamelServerConnectionClient((MBeanCamelServerConnection) proxy.getObject() /* TODO */);
- connectionId = client.generateId();
-
- // TODO we need to establish a replyToEndpoint and inform the server!
-
- sendConnectionNotificationOpened();
- } catch (Exception e) {
- LOG.error("Failed to connect: " + e, e);
- IOException ioe = new IOException(e.getMessage());
- throw ioe;
- }
- connected = true;
- }
- }
-
- /**
- * <p>
- * Returns an <code>MBeanServerConnection</code> object representing a remote MBean server. For a given
- * <code>JMXConnector</code>, two successful calls to this method will usually return the same
- * <code>MBeanServerConnection</code> object, though this is not required.
- * </p>
- * <p/>
- * <p>
- * For each method in the returned <code>MBeanServerConnection</code>, calling the method causes the
- * corresponding method to be called in the remote MBean server. The value returned by the MBean server method is
- * the value returned to the client. If the MBean server method produces an <code>Exception</code>, the same
- * <code>Exception</code> is seen by the client. If the MBean server method, or the attempt to call it, produces
- * an <code>Error</code>, the <code>Error</code> is wrapped in a {@link JMXServerErrorException}, which is
- * seen by the client.
- * </p>
- * <p/>
- * <p>
- * Calling this method is equivalent to calling
- * {@link #getMBeanServerConnection(Subject) getMBeanServerConnection(null)} meaning that no delegation subject is
- * specified and that all the operations called on the <code>MBeanServerConnection</code> must use the
- * authenticated subject, if any.
- * </p>
- *
- * @return an object that implements the <code>MBeanServerConnection</code> interface by forwarding its methods to
- * the remote MBean server.
- */
- public MBeanServerConnection getMBeanServerConnection() {
- return client;
- }
-
- /**
- * <p>
- * Returns an <code>MBeanServerConnection</code> object representing a remote MBean server on which operations are
- * performed on behalf of the supplied delegation subject. For a given <code>JMXConnector</code> and
- * <code>Subject</code>, two successful calls to this method will usually return the same
- * <code>MBeanServerConnection</code> object, though this is not required.
- * </p>
- * <p/>
- * <p>
- * For each method in the returned <code>MBeanServerConnection</code>, calling the method causes the
- * corresponding method to be called in the remote MBean server on behalf of the given delegation subject instead of
- * the authenticated subject. The value returned by the MBean server method is the value returned to the client. If
- * the MBean server method produces an <code>Exception</code>, the same <code>Exception</code> is seen by the
- * client. If the MBean server method, or the attempt to call it, produces an <code>Error</code>, the
- * <code>Error</code> is wrapped in a {@link JMXServerErrorException}, which is seen by the client.
- * </p>
- *
- * @param delegationSubject the <code>Subject</code> on behalf of which requests will be performed. Can be null, in which case
- * requests will be performed on behalf of the authenticated Subject, if any.
- * @return an object that implements the <code>MBeanServerConnection</code> interface by forwarding its methods to
- * the remote MBean server on behalf of a given delegation subject.
- */
- public MBeanServerConnection getMBeanServerConnection(Subject delegationSubject) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * <p>
- * Closes the client connection to its server. Any ongoing or new request using the MBeanServerConnection returned
- * by {@link #getMBeanServerConnection()} will get an <code>IOException</code>.
- * </p>
- * <p/>
- * <p>
- * If <code>close</code> has already been called successfully on this object, calling it again has no effect. If
- * <code>close</code> has never been called, or if it was called but produced an exception, an attempt will be
- * made to close the connection. This attempt can succeed, in which case <code>close</code> will return normally,
- * or it can generate an exception.
- * </p>
- * <p/>
- * <p>
- * Closing a connection is a potentially slow operation. For example, if the server has crashed, the close operation
- * might have to wait for a network protocol timeout. Callers that do not want to block in a close operation should
- * do it in a separate thread.
- * </p>
- *
- * @throws IOException if the connection cannot be closed cleanly. If this exception is thrown, it is not known whether
- * the server end of the connection has been cleanly closed.
- */
- public void close() throws IOException {
- if (connected) {
- connected = false;
- try {
- sendConnectionNotificationClosed();
- proxy.destroy();
- } catch (Exception e) {
- LOG.error("Failed to destroy proxy: " + e, e);
- throw new IOException(e.getMessage());
- }
- }
- }
-
- /**
- * <p>
- * Adds a listener to be informed of changes in connection status. The listener will receive notifications of type
- * {@link JMXConnectionNotification}. An implementation can send other types of notifications too.
- * </p>
- * <p/>
- * <p>
- * Any number of listeners can be added with this method. The same listener can be added more than once with the
- * same or different values for the filter and handback. There is no special treatment of a duplicate entry. For
- * example, if a listener is registered twice with no filter, then its <code>handleNotification</code> method will
- * be called twice for each notification.
- * </p>
- *
- * @param listener a listener to receive connection status notifications.
- * @param filter a filter to select which notifications are to be delivered to the listener, or null if all
- * notifications are to be delivered.
- * @param handback an object to be given to the listener along with each notification. Can be null.
- * @throws NullPointerException if <code>listener</code> is null.
- * @see #removeConnectionNotificationListener
- * @see NotificationBroadcaster#addNotificationListener
- */
- public void addConnectionNotificationListener(NotificationListener listener, NotificationFilter filter,
- Object handback) {
- connectionNotifier.addNotificationListener(listener, filter, handback);
- }
-
- /**
- * <p>
- * Removes a listener from the list to be informed of changes in status. The listener must previously have been
- * added. If there is more than one matching listener, all are removed.
- * </p>
- *
- * @param listener a listener to receive connection status notifications.
- * @throws NullPointerException if <code>listener</code> is null.
- * @throws ListenerNotFoundException if the listener is not registered with this <code>JMXConnector</code>.
- * @see #removeConnectionNotificationListener(NotificationListener, NotificationFilter, Object)
- * @see #addConnectionNotificationListener
- * @see NotificationEmitter#removeNotificationListener
- */
- public void removeConnectionNotificationListener(NotificationListener listener) throws ListenerNotFoundException {
- connectionNotifier.removeNotificationListener(listener);
- }
-
- /**
- * <p>
- * Removes a listener from the list to be informed of changes in status. The listener must previously have been
- * added with the same three parameters. If there is more than one matching listener, only one is removed.
- * </p>
- *
- * @param l a listener to receive connection status notifications.
- * @param f a filter to select which notifications are to be delivered to the listener. Can be null.
- * @param handback an object to be given to the listener along with each notification. Can be null.
- * @throws ListenerNotFoundException if the listener is not registered with this <code>JMXConnector</code>, or is not registered
- * with the given filter and handback.
- * @see #removeConnectionNotificationListener(NotificationListener)
- * @see #addConnectionNotificationListener
- * @see NotificationEmitter#removeNotificationListener
- */
- public void removeConnectionNotificationListener(NotificationListener l, NotificationFilter f, Object handback)
- throws ListenerNotFoundException {
- connectionNotifier.removeNotificationListener(l, f, handback);
- }
-
-
- /**
- * <p>
- * Gets this connection's ID from the connector server. For a given connector server, every connection will have a
- * unique id which does not change during the lifetime of the connection.
- * </p>
- *
- * @return the unique ID of this connection. This is the same as the ID that the connector server includes in its
- * {@link JMXConnectionNotification}s. The {@link javax.management.remote package description} describes the
- * conventions for connection IDs.
- */
- public String getConnectionId() {
- return connectionId;
- }
-
- public CamelContext getCamelContext() {
- if (camelContext == null) {
- LOG.warn("No CamelContext injected so creating a default implementation");
- // TODO should we barf or create a default one?
- camelContext = new DefaultCamelContext();
- }
- return camelContext;
- }
-
- public void setCamelContext(CamelContext camelContext) {
- this.camelContext = camelContext;
- }
-
- private void sendConnectionNotificationOpened() {
- JMXConnectionNotification notification = new JMXConnectionNotification(JMXConnectionNotification.OPENED, this,
- getConnectionId(), notificationNumber.incrementAndGet(), "Connection opened", null);
- connectionNotifier.sendNotification(notification);
- }
-
- private void sendConnectionNotificationClosed() {
- JMXConnectionNotification notification = new JMXConnectionNotification(JMXConnectionNotification.CLOSED, this,
- getConnectionId(), notificationNumber.incrementAndGet(), "Connection closed", null);
- connectionNotifier.sendNotification(notification);
- }
-
- private void sendConnectionNotificationFailed(String message) {
- JMXConnectionNotification notification = new JMXConnectionNotification(JMXConnectionNotification.FAILED, this,
- getConnectionId(), notificationNumber.incrementAndGet(), message, null);
- connectionNotifier.sendNotification(notification);
- }
-}
\ No newline at end of file
diff --git a/components/camel-jmxconnect/src/main/java/org/apache/camel/jmxconnect/CamelJmxConnectorServer.java b/components/camel-jmxconnect/src/main/java/org/apache/camel/jmxconnect/CamelJmxConnectorServer.java
deleted file mode 100644
index 5883eb8..0000000
--- a/components/camel-jmxconnect/src/main/java/org/apache/camel/jmxconnect/CamelJmxConnectorServer.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/**
- * 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.jmxconnect;
-
-import java.io.IOException;
-import java.util.Collections;
-import java.util.Map;
-
-import javax.management.MBeanServer;
-import javax.management.remote.JMXConnectorFactory;
-import javax.management.remote.JMXConnectorServer;
-import javax.management.remote.JMXServiceURL;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.CamelContextAware;
-import org.apache.camel.impl.DefaultCamelContext;
-import org.apache.camel.spring.remoting.CamelServiceExporter;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * <p>The client end of a JMX API connector. An object of this type can
- * be used to establish a connection to a connector server.</p>
- * <p/>
- * <p>A newly-created object of this type is unconnected. Its {@link#connect}
- * method must be called before it can be used.
- * However, objects created by {@link
- * JMXConnectorFactory#connect(JMXServiceURL, Map)
- * JMXConnectorFactory.connect} are already connected.</p>
- *
- * @version $Revision$
- */
-public class CamelJmxConnectorServer extends JMXConnectorServer implements CamelContextAware {
-
- private static final Log LOG = LogFactory.getLog(CamelJmxConnectorServer.class);
- private JMXServiceURL url;
- private final Map env;
- private volatile boolean stopped = true;
- private CamelServiceExporter service;
- private MBeanCamelServerConnectionImpl serverConnection;
- private String endpointUri;
- private CamelContext camelContext;
-
-
- public CamelJmxConnectorServer(JMXServiceURL url, String endpointUri, Map environment, MBeanServer server) throws IOException {
- super(server);
- this.url = url;
- this.env = environment;
- this.endpointUri = endpointUri;
- }
-
- public CamelJmxConnectorServer(JMXServiceURL url, Map environment, MBeanServer server) throws IOException {
- this(url, CamelJmxConnectorSupport.getEndpointUri(url, "camel"), environment, server);
- //set any props in the url
- // TODO
- // populateProperties(this, endpointUri);
- }
-
- /**
- * start the connector
- *
- * @throws IOException
- */
- public void start() throws IOException {
- try {
- service = new CamelServiceExporter();
- service.setCamelContext(getCamelContext());
- service.setServiceInterface(MBeanCamelServerConnection.class);
- service.setUri(endpointUri);
-
- this.serverConnection = new MBeanCamelServerConnectionImpl(getMBeanServer(), /* TODO */ null);
- service.setService(serverConnection);
-
- service.afterPropertiesSet();
- stopped = false;
- } catch (Exception e) {
- LOG.error("Failed to start ", e);
- throw new IOException(e.toString());
- }
-
- }
-
- /**
- * stop the connector
- *
- * @throws IOException
- */
- public void stop() throws IOException {
- try {
- if (!stopped) {
- stopped = true;
- service.destroy();
- }
- } catch (Exception e) {
- LOG.error("Failed to stop ", e);
- throw new IOException(e.toString());
- }
-
- }
-
- public boolean isActive() {
- return !stopped;
- }
-
- public JMXServiceURL getAddress() {
- return url;
- }
-
- public Map getAttributes() {
- return Collections.unmodifiableMap(env);
- }
-
-
- public CamelContext getCamelContext() {
- if (camelContext == null) {
- LOG.warn("No CamelContext injected so creating a default implementation");
- // TODO should we barf or create a default one?
- camelContext = new DefaultCamelContext();
- }
- return camelContext;
- }
-
- public void setCamelContext(CamelContext camelContext) {
- this.camelContext = camelContext;
- }
-}
\ No newline at end of file
diff --git a/components/camel-jmxconnect/src/main/java/org/apache/camel/jmxconnect/CamelJmxConnectorSupport.java b/components/camel-jmxconnect/src/main/java/org/apache/camel/jmxconnect/CamelJmxConnectorSupport.java
deleted file mode 100644
index 02f2eb8..0000000
--- a/components/camel-jmxconnect/src/main/java/org/apache/camel/jmxconnect/CamelJmxConnectorSupport.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * 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.jmxconnect;
-
-
-import java.io.IOException;
-import java.net.MalformedURLException;
-
-import javax.management.remote.JMXServiceURL;
-
-/**
- * @version $Revision$
- */
-public final class CamelJmxConnectorSupport {
- public static final String DEFAULT_DESTINATION_PREFIX = "org.apache.camel.jmxconnect.";
- public static final String MBEAN_SERVER_NAME = "*";
- public static final String MBEAN_GROUP_NAME = "*";
-
- private CamelJmxConnectorSupport() {
- // helper class
- }
-
- public static String getEndpointUri(JMXServiceURL serviceURL, String expectedProtocol) throws IOException {
- String protocol = serviceURL.getProtocol();
- if (!expectedProtocol.equals(protocol)) {
- throw new MalformedURLException("Wrong protocol " + protocol + " expecting " + expectedProtocol);
- }
- String path = serviceURL.getURLPath();
- while (path.startsWith("/")) {
- path = path.substring(1);
- }
- return path;
- }
-
-}
\ No newline at end of file
diff --git a/components/camel-jmxconnect/src/main/java/org/apache/camel/jmxconnect/ListenerInfo.java b/components/camel-jmxconnect/src/main/java/org/apache/camel/jmxconnect/ListenerInfo.java
deleted file mode 100644
index aa0d313..0000000
--- a/components/camel-jmxconnect/src/main/java/org/apache/camel/jmxconnect/ListenerInfo.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/**
- * 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.jmxconnect;
-
-import javax.management.NotificationFilter;
-import javax.management.NotificationListener;
-
-/**
- * @version $Revision$
- */
-class ListenerInfo {
- private String id;
- private NotificationListener listener;
- private NotificationFilter filter;
- private Object handback;
-
-
- public ListenerInfo(String id, NotificationListener listener, NotificationFilter filter, Object handback) {
- this.id = id;
- this.listener = listener;
- this.filter = filter;
- this.handback = handback;
- }
-
- /**
- * Is this info a match ?
- *
- * @param l
- * @param f
- * @param handback
- * @return true if a match
- */
- public boolean isMatch(NotificationListener l, NotificationFilter f, Object handback) {
- return listener == listener && filter == filter && handback == handback;
- }
-
- /**
- * @return Returns the filter.
- */
- public NotificationFilter getFilter() {
- return filter;
- }
-
- /**
- * @param filter The filter to set.
- */
- public void setFilter(NotificationFilter filter) {
- this.filter = filter;
- }
-
- /**
- * @return Returns the handback.
- */
- public Object getHandback() {
- return handback;
- }
-
- /**
- * @param handback The handback to set.
- */
- public void setHandback(Object handback) {
- this.handback = handback;
- }
-
- /**
- * @return Returns the id.
- */
- public String getId() {
- return id;
- }
-
- /**
- * @param id The id to set.
- */
- public void setId(String id) {
- this.id = id;
- }
-
- /**
- * @return Returns the listener.
- */
- public NotificationListener getListener() {
- return listener;
- }
-
- /**
- * @param listener The listener to set.
- */
- public void setListener(NotificationListener listener) {
- this.listener = listener;
- }
-
-}
\ No newline at end of file
diff --git a/components/camel-jmxconnect/src/main/java/org/apache/camel/jmxconnect/MBeanCamelServerConnection.java b/components/camel-jmxconnect/src/main/java/org/apache/camel/jmxconnect/MBeanCamelServerConnection.java
deleted file mode 100644
index 113fe24..0000000
--- a/components/camel-jmxconnect/src/main/java/org/apache/camel/jmxconnect/MBeanCamelServerConnection.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * 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.jmxconnect;
-
-import javax.management.MBeanServerConnection;
-import javax.management.ObjectName;
-
-import org.apache.camel.Endpoint;
-
-/**
- * @version $Revision$
- */
-public interface MBeanCamelServerConnection extends MBeanServerConnection {
-
- /**
- * Add a Notification listener
- *
- * @param listenerId
- * @param name
- * @param replyToEndpoint
- */
- void addNotificationListener(String listenerId, ObjectName name, Endpoint replyToEndpoint);
-
- /**
- * Remove a Notification listener
- *
- * @param listenerId
- */
- void removeNotificationListener(String listenerId);
-
-}
\ No newline at end of file
diff --git a/components/camel-jmxconnect/src/main/java/org/apache/camel/jmxconnect/MBeanCamelServerConnectionClient.java b/components/camel-jmxconnect/src/main/java/org/apache/camel/jmxconnect/MBeanCamelServerConnectionClient.java
deleted file mode 100644
index 60ea8e8..0000000
--- a/components/camel-jmxconnect/src/main/java/org/apache/camel/jmxconnect/MBeanCamelServerConnectionClient.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/**
- * 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.jmxconnect;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-import javax.management.ListenerNotFoundException;
-import javax.management.Notification;
-import javax.management.NotificationBroadcasterSupport;
-import javax.management.NotificationFilter;
-import javax.management.NotificationListener;
-import javax.management.ObjectName;
-
-import org.apache.camel.Endpoint;
-import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
-import org.apache.camel.util.UuidGenerator;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * @version $Revision$
- */
-public class MBeanCamelServerConnectionClient extends MBeanServerConnectionDelegate implements Processor {
- private static final Log LOG = LogFactory.getLog(MBeanCamelServerConnectionClient.class);
- private MBeanCamelServerConnection serverConnection;
- private Endpoint replyToEndpoint;
- private List listeners = new CopyOnWriteArrayList();
- private UuidGenerator idGenerator = new UuidGenerator();
- private NotificationBroadcasterSupport localNotifier = new NotificationBroadcasterSupport();
-
- public MBeanCamelServerConnectionClient(MBeanCamelServerConnection serverConnection) {
- super(serverConnection);
- this.serverConnection = serverConnection;
- }
-
- /**
- * Add a notification listener
- */
- public void addNotificationListener(ObjectName name, NotificationListener listener, NotificationFilter filter,
- Object handback) {
- String id = generateId();
- ListenerInfo info = new ListenerInfo(id, listener, filter, handback);
- listeners.add(info);
- localNotifier.addNotificationListener(listener, filter, handback);
-
- // TODO need to create an endpoint for replies!!!
- if (replyToEndpoint == null) {
- LOG.error("no replyToDestination for replies to be received!");
- }
- serverConnection.addNotificationListener(id, name, replyToEndpoint);
- }
-
- public String generateId() {
- return idGenerator.generateId();
- }
-
- /**
- * Remove a Notification Listener
- */
- public void removeNotificationListener(ObjectName name, NotificationListener listener)
- throws ListenerNotFoundException {
- for (Iterator i = listeners.iterator(); i.hasNext();) {
- ListenerInfo li = (ListenerInfo) i.next();
- if (li.getListener() == listener) {
- listeners.remove(i);
- serverConnection.removeNotificationListener(li.getId());
- break;
- }
- }
- localNotifier.removeNotificationListener(listener);
- }
-
- /**
- * Remove a Notification Listener
- */
- public void removeNotificationListener(ObjectName name, NotificationListener listener, NotificationFilter filter,
- Object handback) throws ListenerNotFoundException {
- for (Iterator i = listeners.iterator(); i.hasNext();) {
- ListenerInfo li = (ListenerInfo) i.next();
- if (li.getListener() == listener && li.getFilter() == filter && li.getHandback() == handback) {
- listeners.remove(i);
- serverConnection.removeNotificationListener(li.getId());
- }
- }
- localNotifier.removeNotificationListener(listener, filter, handback);
- }
-
-
- public void process(Exchange exchange) throws Exception {
- Notification notification = exchange.getIn().getBody(Notification.class);
- if (notification != null) {
- localNotifier.sendNotification(notification);
- } else {
- LOG.warn("Received message which is not a Notification: " + exchange);
- }
- }
-}
\ No newline at end of file
diff --git a/components/camel-jmxconnect/src/main/java/org/apache/camel/jmxconnect/MBeanCamelServerConnectionImpl.java b/components/camel-jmxconnect/src/main/java/org/apache/camel/jmxconnect/MBeanCamelServerConnectionImpl.java
deleted file mode 100644
index 7b31359..0000000
--- a/components/camel-jmxconnect/src/main/java/org/apache/camel/jmxconnect/MBeanCamelServerConnectionImpl.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/**
- * 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.jmxconnect;
-
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import javax.management.MBeanServerConnection;
-import javax.management.ObjectName;
-
-import org.apache.camel.Endpoint;
-import org.apache.camel.ProducerTemplate;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * @version $Revision$
- */
-public class MBeanCamelServerConnectionImpl extends MBeanServerConnectionDelegate implements MBeanCamelServerConnection {
- private static final Log LOG = LogFactory.getLog(MBeanCamelServerConnectionImpl.class);
- private Map notificationListeners = new ConcurrentHashMap();
- private final ProducerTemplate template;
-
- public MBeanCamelServerConnectionImpl(MBeanServerConnection connection, ProducerTemplate template) {
- super(connection);
- this.template = template;
- }
-
- /**
- * Add a Notification listener
- *
- * @param listenerId
- * @param name
- * @param replyToEndpoint
- */
- public void addNotificationListener(String listenerId, ObjectName name, Endpoint replyToEndpoint) {
- try {
- ServerListenerInfo info = new ServerListenerInfo(listenerId, notificationListeners, template, replyToEndpoint);
- notificationListeners.put(listenerId, info);
- connection.addNotificationListener(name, info, null, null);
- } catch (Exception e) {
- LOG.error("Failed to addNotificationListener ", e);
- }
-
- }
-
- /**
- * Remove a Notification listener
- *
- * @param listenerId
- */
- public void removeNotificationListener(String listenerId) {
- ServerListenerInfo info = (ServerListenerInfo) notificationListeners.remove(listenerId);
- if (info != null) {
- info.close();
- }
- }
-
-}
\ No newline at end of file
diff --git a/components/camel-jmxconnect/src/main/java/org/apache/camel/jmxconnect/MBeanServerConnectionDelegate.java b/components/camel-jmxconnect/src/main/java/org/apache/camel/jmxconnect/MBeanServerConnectionDelegate.java
deleted file mode 100644
index bbf77fe..0000000
--- a/components/camel-jmxconnect/src/main/java/org/apache/camel/jmxconnect/MBeanServerConnectionDelegate.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/**
- * 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.jmxconnect;
-
-import java.io.IOException;
-import java.util.Set;
-
-import javax.management.Attribute;
-import javax.management.AttributeList;
-import javax.management.AttributeNotFoundException;
-import javax.management.InstanceAlreadyExistsException;
-import javax.management.InstanceNotFoundException;
-import javax.management.IntrospectionException;
-import javax.management.InvalidAttributeValueException;
-import javax.management.ListenerNotFoundException;
-import javax.management.MBeanException;
-import javax.management.MBeanInfo;
-import javax.management.MBeanRegistrationException;
-import javax.management.MBeanServerConnection;
-import javax.management.NotCompliantMBeanException;
-import javax.management.NotificationFilter;
-import javax.management.NotificationListener;
-import javax.management.ObjectInstance;
-import javax.management.ObjectName;
-import javax.management.QueryExp;
-import javax.management.ReflectionException;
-
-/**
- * Acts as a delegate for the MBeanServerConnection
- *
- * @version $Revision$
- */
-public class MBeanServerConnectionDelegate implements MBeanServerConnection {
-
- protected MBeanServerConnection connection;
-
- public MBeanServerConnectionDelegate(MBeanServerConnection connection) {
- this.connection = connection;
-
- }
-
- public ObjectInstance createMBean(String className, ObjectName name)
- throws ReflectionException, InstanceAlreadyExistsException,
- MBeanRegistrationException, MBeanException, NotCompliantMBeanException,
- IOException {
- return connection.createMBean(className, name);
- }
-
- public ObjectInstance createMBean(String className, ObjectName name, ObjectName loaderName)
- throws ReflectionException, InstanceAlreadyExistsException,
- MBeanRegistrationException, MBeanException, NotCompliantMBeanException,
- InstanceNotFoundException, IOException {
-
- return connection.createMBean(className, name, loaderName);
- }
-
- public ObjectInstance createMBean(String className, ObjectName name, Object[] params, String[] signature)
- throws ReflectionException, InstanceAlreadyExistsException,
- MBeanRegistrationException, MBeanException, NotCompliantMBeanException,
- IOException {
- return connection.createMBean(className, name, params, signature);
- }
-
-
- public ObjectInstance createMBean(String className, ObjectName name, ObjectName loaderName, Object[] params, String[] signature)
- throws ReflectionException, InstanceAlreadyExistsException,
- MBeanRegistrationException, MBeanException, NotCompliantMBeanException,
- InstanceNotFoundException, IOException {
- return connection.createMBean(className, name, loaderName, params, signature);
- }
-
- public void unregisterMBean(ObjectName name) throws InstanceNotFoundException, MBeanRegistrationException, IOException {
- connection.unregisterMBean(name);
-
- }
-
- public ObjectInstance getObjectInstance(ObjectName name) throws InstanceNotFoundException, IOException {
- return connection.getObjectInstance(name);
- }
-
- public Set queryMBeans(ObjectName name, QueryExp query) throws IOException {
- return connection.queryMBeans(name, query);
- }
-
- public Set queryNames(ObjectName name, QueryExp query) throws IOException {
- return connection.queryNames(name, query);
- }
-
- public boolean isRegistered(ObjectName name) throws IOException {
- return connection.isRegistered(name);
- }
-
- public Integer getMBeanCount() throws IOException {
- return connection.getMBeanCount();
- }
-
- public Object getAttribute(ObjectName name, String attribute) throws MBeanException, AttributeNotFoundException, InstanceNotFoundException, ReflectionException, IOException {
- return connection.getAttribute(name, attribute);
- }
-
- public AttributeList getAttributes(ObjectName name, String[] attributes) throws InstanceNotFoundException, ReflectionException, IOException {
- return connection.getAttributes(name, attributes);
- }
-
- public void setAttribute(ObjectName name, Attribute attribute)
- throws InstanceNotFoundException, AttributeNotFoundException,
- InvalidAttributeValueException, MBeanException, ReflectionException,
- IOException {
- connection.setAttribute(name, attribute);
-
- }
-
- public AttributeList setAttributes(ObjectName name, AttributeList attributes) throws InstanceNotFoundException, ReflectionException, IOException {
- return connection.setAttributes(name, attributes);
- }
-
- public Object invoke(ObjectName name, String operationName, Object[] params, String[] signature) throws InstanceNotFoundException, MBeanException, ReflectionException, IOException {
- return connection.invoke(name, operationName, params, signature);
- }
-
- public String getDefaultDomain() throws IOException {
- return connection.getDefaultDomain();
- }
-
- public String[] getDomains() throws IOException {
- return connection.getDomains();
- }
-
- public void addNotificationListener(ObjectName name, NotificationListener listener, NotificationFilter filter, Object handback) throws InstanceNotFoundException, IOException {
- connection.addNotificationListener(name, listener, filter, handback);
-
- }
-
- public void addNotificationListener(ObjectName name, ObjectName listener, NotificationFilter filter, Object handback) throws InstanceNotFoundException, IOException {
- connection.addNotificationListener(name, listener, filter, handback);
-
- }
-
- public void removeNotificationListener(ObjectName name, ObjectName listener) throws InstanceNotFoundException, ListenerNotFoundException, IOException {
- connection.removeNotificationListener(name, listener);
-
- }
-
- public void removeNotificationListener(ObjectName name, ObjectName listener, NotificationFilter filter, Object handback) throws InstanceNotFoundException, ListenerNotFoundException, IOException {
- connection.removeNotificationListener(name, listener, filter, handback);
-
- }
-
- public void removeNotificationListener(ObjectName name, NotificationListener listener) throws InstanceNotFoundException, ListenerNotFoundException, IOException {
- connection.removeNotificationListener(name, listener);
-
- }
-
- public void removeNotificationListener(ObjectName name, NotificationListener listener, NotificationFilter filter, Object handback) throws InstanceNotFoundException, ListenerNotFoundException, IOException {
- connection.removeNotificationListener(name, listener, filter, handback);
-
- }
-
- public MBeanInfo getMBeanInfo(ObjectName name) throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException {
- return connection.getMBeanInfo(name);
- }
-
- public boolean isInstanceOf(ObjectName name, String className) throws InstanceNotFoundException, IOException {
- return connection.isInstanceOf(name, className);
- }
-
-
-}
\ No newline at end of file
diff --git a/components/camel-jmxconnect/src/main/java/org/apache/camel/jmxconnect/ServerListenerInfo.java b/components/camel-jmxconnect/src/main/java/org/apache/camel/jmxconnect/ServerListenerInfo.java
deleted file mode 100644
index cb20515..0000000
--- a/components/camel-jmxconnect/src/main/java/org/apache/camel/jmxconnect/ServerListenerInfo.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/**
- * 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.jmxconnect;
-
-
-import java.util.Map;
-
-import javax.management.Notification;
-import javax.management.NotificationListener;
-
-import org.apache.camel.Endpoint;
-import org.apache.camel.ProducerTemplate;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * @version $Revision$
- */
-class ServerListenerInfo implements NotificationListener {
- private static final Log LOG = LogFactory.getLog(ServerListenerInfo.class);
- private final String id;
- private final Map holder;
- private final ProducerTemplate template;
- private final Endpoint replyToEndpoint;
-
- ServerListenerInfo(String id, Map holder, ProducerTemplate template, Endpoint replyToEndpoint) {
- this.id = id;
- this.holder = holder;
- this.template = template;
- this.replyToEndpoint = replyToEndpoint;
- }
-
- /**
- * NotificationListener implementation
- *
- * @param notification
- * @param handback
- */
- public void handleNotification(Notification notification, Object handback) {
- System.out.println("Should be sending notification: " + notification);
- if (replyToEndpoint == null) {
- LOG.warn("No replyToDestination for replies to be received so cannot send notification: " + notification);
- } else {
- template.sendBody(replyToEndpoint, notification);
- }
- }
-
- /**
- * close the info if the connection times out
- * <p/>
- * TODO we should auto-detect that id has timed out and then remove this subscription
- */
- public void close() {
- holder.remove(id);
- }
-
- /**
- * @return Returns the holder.
- */
- public Map getHolder() {
- return holder;
- }
-
-
- /**
- * @return Returns the id.
- */
- public String getId() {
- return id;
- }
-
-}
\ No newline at end of file
diff --git a/components/camel-jmxconnect/src/main/java/org/apache/camel/jmxconnect/provider/activemq/ActiveMQHelper.java b/components/camel-jmxconnect/src/main/java/org/apache/camel/jmxconnect/provider/activemq/ActiveMQHelper.java
deleted file mode 100644
index af9be02..0000000
--- a/components/camel-jmxconnect/src/main/java/org/apache/camel/jmxconnect/provider/activemq/ActiveMQHelper.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * 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.jmxconnect.provider.activemq;
-
-import org.apache.activemq.camel.component.ActiveMQComponent;
-import org.apache.camel.CamelContext;
-import org.apache.camel.jmxconnect.CamelJmxConnectorSupport;
-
-/**
- * @version $Revision$
- */
-public final class ActiveMQHelper {
- private ActiveMQHelper() {
- // helper class
- }
- public static String getDefaultEndpointUri() {
- return "activemq:" + CamelJmxConnectorSupport.DEFAULT_DESTINATION_PREFIX;
- }
-
- public static void configureActiveMQComponent(CamelContext camelContext, String brokerUrl) {
- ActiveMQComponent activemqComponent = camelContext.getComponent("activemq", ActiveMQComponent.class);
- activemqComponent.setBrokerURL(brokerUrl);
- }
-}
diff --git a/components/camel-jmxconnect/src/main/java/org/apache/camel/jmxconnect/provider/activemq/ClientProvider.java b/components/camel-jmxconnect/src/main/java/org/apache/camel/jmxconnect/provider/activemq/ClientProvider.java
deleted file mode 100644
index 7bcace0..0000000
--- a/components/camel-jmxconnect/src/main/java/org/apache/camel/jmxconnect/provider/activemq/ClientProvider.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * 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.jmxconnect.provider.activemq;
-
-import java.io.IOException;
-import java.util.Map;
-
-import javax.management.remote.JMXConnector;
-import javax.management.remote.JMXConnectorProvider;
-import javax.management.remote.JMXServiceURL;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.jmxconnect.CamelJmxConnector;
-import org.apache.camel.jmxconnect.CamelJmxConnectorSupport;
-
-/**
- * @version $Revision$
- */
-public class ClientProvider implements JMXConnectorProvider {
- public JMXConnector newJMXConnector(JMXServiceURL url, Map environment) throws IOException {
- // use the remaining url as the ActiveMQ broker URI
- String brokerUrl = CamelJmxConnectorSupport.getEndpointUri(url, "activemq");
- CamelJmxConnector answer = new CamelJmxConnector(environment, ActiveMQHelper.getDefaultEndpointUri());
-
- // now lets configure the ActiveMQ component
- CamelContext camelContext = answer.getCamelContext();
- ActiveMQHelper.configureActiveMQComponent(camelContext, brokerUrl);
- return answer;
- }
-
-}
\ No newline at end of file
diff --git a/components/camel-jmxconnect/src/main/java/org/apache/camel/jmxconnect/provider/activemq/ServerProvider.java b/components/camel-jmxconnect/src/main/java/org/apache/camel/jmxconnect/provider/activemq/ServerProvider.java
deleted file mode 100644
index aa54e0e..0000000
--- a/components/camel-jmxconnect/src/main/java/org/apache/camel/jmxconnect/provider/activemq/ServerProvider.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- * 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.jmxconnect.provider.activemq;
-
-
-import java.io.IOException;
-import java.util.Map;
-
-import javax.management.MBeanServer;
-import javax.management.remote.JMXConnectorServer;
-import javax.management.remote.JMXConnectorServerProvider;
-import javax.management.remote.JMXServiceURL;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.jmxconnect.CamelJmxConnectorServer;
-import org.apache.camel.jmxconnect.CamelJmxConnectorSupport;
-
-/**
- * @version $Revision$
- */
-public class ServerProvider implements JMXConnectorServerProvider {
-
- public JMXConnectorServer newJMXConnectorServer(JMXServiceURL url, Map environment, MBeanServer server) throws IOException {
- String brokerUrl = CamelJmxConnectorSupport.getEndpointUri(url, "activemq");
- CamelJmxConnectorServer answer = new CamelJmxConnectorServer(url, ActiveMQHelper.getDefaultEndpointUri(), environment, server);
-
- // now lets configure the ActiveMQ component
- CamelContext camelContext = answer.getCamelContext();
- ActiveMQHelper.configureActiveMQComponent(camelContext, brokerUrl);
- return answer;
- }
-}
\ No newline at end of file
diff --git a/components/camel-jmxconnect/src/main/java/org/apache/camel/jmxconnect/provider/camel/ClientProvider.java b/components/camel-jmxconnect/src/main/java/org/apache/camel/jmxconnect/provider/camel/ClientProvider.java
deleted file mode 100644
index d8fe6d8..0000000
--- a/components/camel-jmxconnect/src/main/java/org/apache/camel/jmxconnect/provider/camel/ClientProvider.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
- * 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.jmxconnect.provider.camel;
-
-import java.io.IOException;
-import java.util.Map;
-
-import javax.management.remote.JMXConnector;
-import javax.management.remote.JMXConnectorProvider;
-import javax.management.remote.JMXServiceURL;
-
-import org.apache.camel.jmxconnect.CamelJmxConnector;
-
-/**
- * @version $Revision$
- */
-public class ClientProvider implements JMXConnectorProvider {
- public JMXConnector newJMXConnector(JMXServiceURL url, Map environment) throws IOException {
- return new CamelJmxConnector(environment, url);
- }
-}
diff --git a/components/camel-jmxconnect/src/main/java/org/apache/camel/jmxconnect/provider/camel/ServerProvider.java b/components/camel-jmxconnect/src/main/java/org/apache/camel/jmxconnect/provider/camel/ServerProvider.java
deleted file mode 100644
index 8cba35f..0000000
--- a/components/camel-jmxconnect/src/main/java/org/apache/camel/jmxconnect/provider/camel/ServerProvider.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * 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.jmxconnect.provider.camel;
-
-
-import java.io.IOException;
-import java.util.Map;
-
-import javax.management.MBeanServer;
-import javax.management.remote.JMXConnectorServer;
-import javax.management.remote.JMXConnectorServerProvider;
-import javax.management.remote.JMXServiceURL;
-
-import org.apache.camel.jmxconnect.CamelJmxConnectorServer;
-
-/**
- * @version $Revision$
- */
-public class ServerProvider implements JMXConnectorServerProvider {
-
- public JMXConnectorServer newJMXConnectorServer(JMXServiceURL url, Map environment, MBeanServer server) throws IOException {
- return new CamelJmxConnectorServer(url, environment, server);
- }
-}
\ No newline at end of file
diff --git a/components/camel-jmxconnect/src/test/java/org/apache/camel/jmxconnect/JmxRemoteTest.java b/components/camel-jmxconnect/src/test/java/org/apache/camel/jmxconnect/JmxRemoteTest.java
deleted file mode 100644
index 745556a..0000000
--- a/components/camel-jmxconnect/src/test/java/org/apache/camel/jmxconnect/JmxRemoteTest.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/**
- * 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.jmxconnect;
-
-
-import java.net.URI;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import javax.management.Attribute;
-import javax.management.MBeanInfo;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerConnection;
-import javax.management.MBeanServerFactory;
-import javax.management.Notification;
-import javax.management.NotificationListener;
-import javax.management.ObjectName;
-import javax.management.monitor.GaugeMonitor;
-import javax.management.remote.JMXConnector;
-import javax.management.remote.JMXConnectorFactory;
-import javax.management.remote.JMXConnectorServer;
-import javax.management.remote.JMXConnectorServerFactory;
-import javax.management.remote.JMXServiceURL;
-
-import junit.framework.TestCase;
-import org.apache.activemq.broker.BrokerFactory;
-import org.apache.activemq.broker.BrokerService;
-
-/**
- * @version $Revision$
- */
-public class JmxRemoteTest extends TestCase {
- protected String serverServiceUrl = "service:jmx:camel:///activemq:foo";
- protected String clientServiceUrl = "service:jmx:camel:///activemq:foo";
- protected String brokerUrl = "broker:(tcp://localhost:61616)/localhost?persistent=false";
- private MBeanServer server;
- private BrokerService broker;
- private JMXConnectorServer connectorServer;
- private JMXConnector connector;
- private ObjectName serviceName;
- private SimpleService service;
-
-
- protected void setUp() throws Exception {
- broker = BrokerFactory.createBroker(new URI(brokerUrl));
- broker.start();
-
- server = MBeanServerFactory.createMBeanServer();
- //register a service
- service = new SimpleService();
-
- serviceName = new ObjectName("examples", "mbean", "simple");
- server.registerMBean(service, serviceName);
- // start the connector server
-
- //START SNIPPET: serverJMX
- //The url to the JMS service
- JMXServiceURL serverURL = new JMXServiceURL(serverServiceUrl);
- Map serverEnv = new HashMap();
- serverEnv.put("jmx.remote.protocol.provider.pkgs", "org.apache.camel.jmxconnect.provider");
- connectorServer = JMXConnectorServerFactory.newJMXConnectorServer(serverURL, serverEnv, server);
- connectorServer.start();
- //END SNIPPET: serverJMX
-
- //START SNIPPET: clientJMX
- //Now connect the client-side
- //The URL to the JMS service
- JMXServiceURL clientURL = new JMXServiceURL(clientServiceUrl);
- Map clientEnv = new HashMap();
- clientEnv.put("jmx.remote.protocol.provider.pkgs", "org.apache.camel.jmxconnect.provider");
- JMXConnector clientConnector = JMXConnectorFactory.connect(clientURL, clientEnv);
- // Connect a JSR 160 JMXConnector to the server side
- connector = JMXConnectorFactory.connect(clientURL, clientEnv);
- //now test the Connection
- MBeanServerConnection connection = connector.getMBeanServerConnection();
- //END SNIPPET: clientJMX
-
- }
-
- protected void tearDown() throws Exception {
- connector.close();
- connectorServer.stop();
- broker.stop();
- }
-
-
- public void testSimpleRemoteJmx() throws Exception {
- // Retrieve an MBeanServerConnection that represent the MBeanServer the remote
- // connector server is bound to
- MBeanServerConnection connection = connector.getMBeanServerConnection();
- ObjectName queryName = new ObjectName("*:*");
- java.util.Set names = connection.queryNames(queryName, null);
- for (Iterator iter = names.iterator(); iter.hasNext();) {
- ObjectName name = (ObjectName) iter.next();
- MBeanInfo beanInfo = connection.getMBeanInfo(name);
- System.out.println("bean info = " + beanInfo.getDescription());
- System.out.println("attrs = " + Arrays.asList(beanInfo.getAttributes()));
- }
- Object value = connection.getAttribute(serviceName, "SimpleValue");
- System.out.println("SimpleValue = " + value);
- Attribute attr = new Attribute("SimpleValue", new Integer(10));
- connection.setAttribute(serviceName, attr);
- value = connection.getAttribute(serviceName, "SimpleValue");
- assertEquals("SimpleValue", value, 10);
- System.out.println("now SimpleValue = " + value);
- }
-
- // TODO not implemented yet!
- // need server side push, the client needs to register with a replyToEndpoint
- public void xtestNotificationsJmx() throws Exception {
-
- // Now let's register a Monitor
- // We would like to know if we have peaks in activity, so we can use JMX's
- // GaugeMonitor
- GaugeMonitor monitorMBean = new GaugeMonitor();
- ObjectName monitorName = new ObjectName("examples", "monitor", "gauge");
- server.registerMBean(monitorMBean, monitorName);
- // Setup the monitor: we want to be notified if we have too many clients or too less
- monitorMBean.setThresholds(new Integer(8), new Integer(4));
- // Setup the monitor: we want to know if a threshold is exceeded
- monitorMBean.setNotifyHigh(true);
- monitorMBean.setNotifyLow(true);
-
- monitorMBean.setDifferenceMode(false);
- // Setup the monitor: link to the service MBean
- monitorMBean.addObservedObject(serviceName);
- monitorMBean.setObservedAttribute("SimpleCounter");
- // Setup the monitor: a short granularity period
- monitorMBean.setGranularityPeriod(50L);
- // Setup the monitor: register a listener
- MBeanServerConnection connection = connector.getMBeanServerConnection();
- final AtomicBoolean notificationSet = new AtomicBoolean(false);
- //Add a notification listener to the connection - to
- //test for notifications across camel
- connection.addNotificationListener(monitorName, new NotificationListener() {
- public void handleNotification(Notification notification, Object handback) {
- System.out.println("Notification = " + notification);
- synchronized (notificationSet) {
- notificationSet.set(true);
- notificationSet.notify();
- }
- }
- }, null, null);
- service.start();
- monitorMBean.start();
- synchronized (notificationSet) {
- if (!notificationSet.get()) {
- notificationSet.wait(5000);
- }
- }
- assertTrue(notificationSet.get());
- }
-}
\ No newline at end of file
diff --git a/components/camel-jmxconnect/src/test/java/org/apache/camel/jmxconnect/SimpleService.java b/components/camel-jmxconnect/src/test/java/org/apache/camel/jmxconnect/SimpleService.java
deleted file mode 100644
index f2a04bd..0000000
--- a/components/camel-jmxconnect/src/test/java/org/apache/camel/jmxconnect/SimpleService.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/**
- * 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.jmxconnect;
-
-/**
- * This is based heavily on the DynamicService example from the mx4j project
- *
- * @version $Revision$
- */
-public class SimpleService implements Runnable, SimpleServiceMBean {
- private boolean running;
- private int simpleCounter;
- private int simpleValue;
-
- public void start() {
- if (!running) {
- running = true;
- Thread thread = new Thread(this);
- thread.start();
- }
- }
-
- public void stop() {
- running = false;
- }
-
- public void run() {
- while (running) {
- simpleCounter++;
- try {
- Thread.sleep(250);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- }
-
- public void setSimpleCounter(int simpleCounter) {
- this.simpleCounter = simpleCounter;
- }
-
- public int getSimpleCounter() {
- return simpleCounter;
- }
-
- public int getSimpleValue() {
- return simpleValue;
- }
-
- public void setSimpleValue(int simpleValue) {
- this.simpleValue = simpleValue;
- }
-/*
-
- protected MBeanAttributeInfo[] createMBeanAttributeInfo(){
- return new MBeanAttributeInfo[] {
- new MBeanAttributeInfo("SimpleCounter","int","test simpleCounter",true,false,false),
- new MBeanAttributeInfo("SimpleValue","int","test simpleValue",true,true,false) };
- }
-
- protected MBeanOperationInfo[] createMBeanOperationInfo(){
- return new MBeanOperationInfo[] {
- new MBeanOperationInfo("start","Starts the SimpleService",new MBeanParameterInfo[0],"void",
- MBeanOperationInfo.ACTION),
- new MBeanOperationInfo("stop","Stops the SimpleService",new MBeanParameterInfo[0],"void",
- MBeanOperationInfo.ACTION) };
- }*/
-
-
-}
diff --git a/components/camel-jmxconnect/src/test/java/org/apache/camel/jmxconnect/SimpleServiceMBean.java b/components/camel-jmxconnect/src/test/java/org/apache/camel/jmxconnect/SimpleServiceMBean.java
deleted file mode 100644
index 2841a17..0000000
--- a/components/camel-jmxconnect/src/test/java/org/apache/camel/jmxconnect/SimpleServiceMBean.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- * 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.jmxconnect;
-
-/**
- * @version $Revision$
- */
-public interface SimpleServiceMBean {
- void start();
-
- void stop();
-
- /**
- * @param simpleCounter
- * The simpleCounter to set.
- */
- void setSimpleCounter(int simpleCounter);
-
- /**
- * @return Returns the simpleCounter.
- */
- int getSimpleCounter();
-
- /**
- * @return Returns the simpleValue.
- */
- int getSimpleValue();
-
- /**
- * @param simpleValue The simpleValue to set.
- */
- void setSimpleValue(int simpleValue);
-}
diff --git a/components/camel-jmxconnect/src/test/resources/log4j.properties b/components/camel-jmxconnect/src/test/resources/log4j.properties
deleted file mode 100644
index c94e0d4..0000000
--- a/components/camel-jmxconnect/src/test/resources/log4j.properties
+++ /dev/null
@@ -1,35 +0,0 @@
-## ------------------------------------------------------------------------
-## 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.
-## ------------------------------------------------------------------------
-
-#
-# The logging properties used during tests..
-#
-log4j.rootLogger=INFO, out
-
-log4j.logger.org.apache.camel=DEBUG
-
-# CONSOLE appender not used by default
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
-
-# File appender
-log4j.appender.out=org.apache.log4j.FileAppender
-log4j.appender.out.layout=org.apache.log4j.PatternLayout
-log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
-log4j.appender.out.file=target/camel-jmxconnect-test.log
-log4j.appender.out.append=true
diff --git a/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java b/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java
index d1748cf..ce4d19b 100644
--- a/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java
+++ b/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java
@@ -50,6 +50,7 @@
import org.apache.camel.view.ModelFileGenerator;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.BeanCreationException;
import org.springframework.beans.factory.BeanDefinitionStoreException;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.RuntimeBeanReference;
@@ -404,38 +405,56 @@
}
}
- // either we have not used template before or we have auto registered it already and therefore we
- // need it to allow to do it so it can remove the existing auto registered as there is now a clash id
- // since we have multiple camel contexts
- boolean canDoTemplate = autoRegisterMap.get("template") != null
- || !parserContext.getRegistry().isBeanNameInUse("template");
- if (!template && canDoTemplate) {
- String id = "template";
- // auto create a template
- Element templateElement = element.getOwnerDocument().createElement("template");
- templateElement.setAttribute("id", id);
- BeanDefinitionParser parser = parserMap.get("template");
- BeanDefinition definition = parser.parse(templateElement, parserContext);
+ if (!template) {
+ // either we have not used template before or we have auto registered it already and therefore we
+ // need it to allow to do it so it can remove the existing auto registered as there is now a clash id
+ // since we have multiple camel contexts
+ boolean existing = autoRegisterMap.get("template") != null;
+ boolean inUse = false;
+ try {
+ inUse = parserContext.getRegistry().isBeanNameInUse("template");
+ } catch (BeanCreationException e) {
+ // Spring Eclipse Tooling may throw an exception when you edit the Spring XML online in Eclipse
+ // when the isBeanNameInUse method is invoked, so ignore this and continue (CAMEL-2739)
+ LOG.debug("Error checking isBeanNameInUse(template). This exception will be ignored", e);
+ }
+ if (!inUse || existing) {
+ String id = "template";
+ // auto create a template
+ Element templateElement = element.getOwnerDocument().createElement("template");
+ templateElement.setAttribute("id", id);
+ BeanDefinitionParser parser = parserMap.get("template");
+ BeanDefinition definition = parser.parse(templateElement, parserContext);
- // auto register it
- autoRegisterBeanDefinition(id, definition, parserContext, contextId);
+ // auto register it
+ autoRegisterBeanDefinition(id, definition, parserContext, contextId);
+ }
}
- // either we have not used template before or we have auto registered it already and therefore we
- // need it to allow to do it so it can remove the existing auto registered as there is now a clash id
- // since we have multiple camel contexts
- boolean canDoConsumerTemplate = autoRegisterMap.get("consumerTemplate") != null
- || !parserContext.getRegistry().isBeanNameInUse("consumerTemplate");
- if (!consumerTemplate && canDoConsumerTemplate) {
- String id = "consumerTemplate";
- // auto create a template
- Element templateElement = element.getOwnerDocument().createElement("consumerTemplate");
- templateElement.setAttribute("id", id);
- BeanDefinitionParser parser = parserMap.get("consumerTemplate");
- BeanDefinition definition = parser.parse(templateElement, parserContext);
+ if (!consumerTemplate) {
+ // either we have not used template before or we have auto registered it already and therefore we
+ // need it to allow to do it so it can remove the existing auto registered as there is now a clash id
+ // since we have multiple camel contexts
+ boolean existing = autoRegisterMap.get("consumerTemplate") != null;
+ boolean inUse = false;
+ try {
+ inUse = parserContext.getRegistry().isBeanNameInUse("consumerTemplate");
+ } catch (BeanCreationException e) {
+ // Spring Eclipse Tooling may throw an exception when you edit the Spring XML online in Eclipse
+ // when the isBeanNameInUse method is invoked, so ignore this and continue (CAMEL-2739)
+ LOG.debug("Error checking isBeanNameInUse(consumerTemplate). This exception will be ignored", e);
+ }
+ if (!inUse || existing) {
+ String id = "consumerTemplate";
+ // auto create a template
+ Element templateElement = element.getOwnerDocument().createElement("consumerTemplate");
+ templateElement.setAttribute("id", id);
+ BeanDefinitionParser parser = parserMap.get("consumerTemplate");
+ BeanDefinition definition = parser.parse(templateElement, parserContext);
- // auto register it
- autoRegisterBeanDefinition(id, definition, parserContext, contextId);
+ // auto register it
+ autoRegisterBeanDefinition(id, definition, parserContext, contextId);
+ }
}
}
diff --git a/components/camel-jmxconnect/src/test/java/org/apache/camel/jmxconnect/JmxActiveMQRemoteTest.java b/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringValidateRegExpTest.java
similarity index 64%
rename from components/camel-jmxconnect/src/test/java/org/apache/camel/jmxconnect/JmxActiveMQRemoteTest.java
rename to components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringValidateRegExpTest.java
index 6e5faac..b68873c 100644
--- a/components/camel-jmxconnect/src/test/java/org/apache/camel/jmxconnect/JmxActiveMQRemoteTest.java
+++ b/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringValidateRegExpTest.java
@@ -14,20 +14,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.jmxconnect;
+package org.apache.camel.spring.processor;
+import org.apache.camel.CamelContext;
+import org.apache.camel.processor.ValidateRegExpTest;
+
+import static org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;
/**
* @version $Revision$
*/
-public class JmxActiveMQRemoteTest extends JmxRemoteTest {
-
- @Override
- protected void setUp() throws Exception {
- brokerUrl = "broker:(tcp://localhost:6000)/localhost?persistent=false";
-
- clientServiceUrl = "service:jmx:activemq:///tcp://localhost:6000";
- serverServiceUrl = clientServiceUrl;
-
- super.setUp();
+public class SpringValidateRegExpTest extends ValidateRegExpTest {
+ protected CamelContext createCamelContext() throws Exception {
+ return createSpringCamelContext(this, "org/apache/camel/spring/processor/validate.xml");
}
-}
+}
\ No newline at end of file
diff --git a/components/camel-jmxconnect/src/test/java/org/apache/camel/jmxconnect/JmxActiveMQRemoteTest.java b/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringValidateSimpleTest.java
similarity index 63%
copy from components/camel-jmxconnect/src/test/java/org/apache/camel/jmxconnect/JmxActiveMQRemoteTest.java
copy to components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringValidateSimpleTest.java
index 6e5faac..79546e5 100644
--- a/components/camel-jmxconnect/src/test/java/org/apache/camel/jmxconnect/JmxActiveMQRemoteTest.java
+++ b/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringValidateSimpleTest.java
@@ -14,20 +14,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.jmxconnect;
+package org.apache.camel.spring.processor;
-/**
- * @version $Revision$
- */
-public class JmxActiveMQRemoteTest extends JmxRemoteTest {
+import org.apache.camel.CamelContext;
+import org.apache.camel.processor.ValidateSimpleTest;
- @Override
- protected void setUp() throws Exception {
- brokerUrl = "broker:(tcp://localhost:6000)/localhost?persistent=false";
+import static org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;
- clientServiceUrl = "service:jmx:activemq:///tcp://localhost:6000";
- serverServiceUrl = clientServiceUrl;
+public class SpringValidateSimpleTest extends ValidateSimpleTest {
- super.setUp();
+ protected CamelContext createCamelContext() throws Exception {
+ return createSpringCamelContext(this, "org/apache/camel/spring/processor/ValidateSimpleTest.xml");
}
-}
+}
\ No newline at end of file
diff --git a/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ValidateSimpleTest.xml b/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ValidateSimpleTest.xml
new file mode 100644
index 0000000..e41301b
--- /dev/null
+++ b/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ValidateSimpleTest.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+ http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+ ">
+
+ <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
+
+ <route>
+ <from uri="direct:start"/>
+ <validate>
+ <simple>${body} contains 'Camel'</simple>
+ </validate>
+ <to uri="mock:result"/>
+ </route>
+
+ </camelContext>
+
+</beans>
diff --git a/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/validate.xml b/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/validate.xml
new file mode 100644
index 0000000..f8473da
--- /dev/null
+++ b/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/validate.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+ http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+ ">
+
+ <!-- START SNIPPET: example -->
+ <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
+ <route>
+ <from uri="direct:start"/>
+ <validate>
+ <simple>${bodyAs(java.lang.String)} regex '^\d{2}\.\d{2}\.\d{4}$'</simple>
+ </validate>
+ <to uri="mock:result"/>
+ </route>
+ </camelContext>
+ <!-- END SNIPPET: example -->
+
+</beans>
diff --git a/components/pom.xml b/components/pom.xml
index 0e03514..71f4d4a 100644
--- a/components/pom.xml
+++ b/components/pom.xml
@@ -30,7 +30,6 @@
<packaging>pom</packaging>
<modules>
- <!--<module>camel-jmxconnect</module>-->
<module>camel-amqp</module>
<module>camel-atom</module>
<module>camel-bam</module>
@@ -81,6 +80,9 @@
<module>camel-mvel</module>
<module>camel-netty</module>
<module>camel-nagios</module>
+<!-- ode is under active development
+ <module>camel-ode</module>
+-->
<module>camel-ognl</module>
<module>camel-osgi</module>
<module>camel-printer</module>
diff --git a/examples/camel-example-axis/pom.xml b/examples/camel-example-axis/pom.xml
index 1dbb487..cba2f79 100644
--- a/examples/camel-example-axis/pom.xml
+++ b/examples/camel-example-axis/pom.xml
@@ -141,4 +141,4 @@
</plugin>
</plugins>
</build>
-</project>
\ No newline at end of file
+</project>
diff --git a/examples/camel-example-loadbalancing-mina/pom.xml b/examples/camel-example-loadbalancing-mina/pom.xml
index 279e15b..bbb42b2 100644
--- a/examples/camel-example-loadbalancing-mina/pom.xml
+++ b/examples/camel-example-loadbalancing-mina/pom.xml
@@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.camel</groupId>
<artifactId>examples</artifactId>
- <version>2.3-SNAPSHOT</version>
+ <version>2.3.0</version>
</parent>
<groupId>org.apache.camel.example</groupId>
diff --git a/examples/camel-example-loadbalancing-mina/src/main/java/org/apache/camel/example/model/Report.java b/examples/camel-example-loadbalancing-mina/src/main/java/org/apache/camel/example/model/Report.java
index 070e9d0..aa98d97 100644
--- a/examples/camel-example-loadbalancing-mina/src/main/java/org/apache/camel/example/model/Report.java
+++ b/examples/camel-example-loadbalancing-mina/src/main/java/org/apache/camel/example/model/Report.java
@@ -18,76 +18,79 @@
import java.io.Serializable;
-import sun.tools.tree.ThisExpression;
-
public class Report implements Serializable {
- private static final long serialVersionUID = 1L;
-
- private Integer id;
- private String title;
- private String content;
- private String reply;
-
- /**
- * @return the id
- */
- public Integer getId() {
- return id;
- }
- /**
- * @param id the id to set
- */
- public void setId(Integer id) {
- this.id = id;
- }
- /**
- * @return the title
- */
- public String getTitle() {
- return title;
- }
- /**
- * @param title the title to set
- */
- public void setTitle(String title) {
- this.title = title;
- }
- /**
- * @return the content
- */
- public String getContent() {
- return content;
- }
- /**
- * @param content the content to set
- */
- public void setContent(String content) {
- this.content = content;
- }
- /**
- * @return the reply
- */
- public String getReply() {
- return reply;
- }
- /**
- * @param reply the reply to set
- */
- public void setReply(String reply) {
- this.reply = reply;
- }
-
- public String toString() {
- StringBuilder result = new StringBuilder();
- result.append(">> ***********************************************" + "\n");
- result.append(">> Report id : " + this.id + "\n");
- result.append(">> Report title : " + this.title+ "\n");
- result.append(">> Report content : " + this.content+ "\n");
- result.append(">> Report reply : " + this.reply+ "\n");
- result.append(">> ***********************************************" + "\n");
- return result.toString();
-
- }
+ private static final long serialVersionUID = 1L;
+ private Integer id;
+ private String title;
+ private String content;
+ private String reply;
+
+ /**
+ * @return the id
+ */
+ public Integer getId() {
+ return id;
+ }
+
+ /**
+ * @param id the id to set
+ */
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ /**
+ * @return the title
+ */
+ public String getTitle() {
+ return title;
+ }
+
+ /**
+ * @param title the title to set
+ */
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ /**
+ * @return the content
+ */
+ public String getContent() {
+ return content;
+ }
+
+ /**
+ * @param content the content to set
+ */
+ public void setContent(String content) {
+ this.content = content;
+ }
+
+ /**
+ * @return the reply
+ */
+ public String getReply() {
+ return reply;
+ }
+
+ /**
+ * @param reply the reply to set
+ */
+ public void setReply(String reply) {
+ this.reply = reply;
+ }
+
+ public String toString() {
+ StringBuilder result = new StringBuilder();
+ result.append(">> ***********************************************" + "\n");
+ result.append(">> Report id : " + this.id + "\n");
+ result.append(">> Report title : " + this.title + "\n");
+ result.append(">> Report content : " + this.content + "\n");
+ result.append(">> Report reply : " + this.reply + "\n");
+ result.append(">> ***********************************************" + "\n");
+ return result.toString();
+ }
}
diff --git a/examples/camel-example-loadbalancing-mina/src/main/java/org/apache/camel/example/service/Generator.java b/examples/camel-example-loadbalancing-mina/src/main/java/org/apache/camel/example/service/Generator.java
index 80be5dd..6d90624 100644
--- a/examples/camel-example-loadbalancing-mina/src/main/java/org/apache/camel/example/service/Generator.java
+++ b/examples/camel-example-loadbalancing-mina/src/main/java/org/apache/camel/example/service/Generator.java
@@ -19,23 +19,20 @@
import org.apache.camel.example.model.Report;
public class Generator {
-
- private static int count = 0;
- public Report createReport() throws Exception {
-
- int counter = ++count;
-
- // Create a Report object
- Report report = new Report();
- report.setId(counter);
- report.setTitle("Report Title : " + counter);
- report.setContent("This is a dummy report");
-
- // Add the report to the Body
- return report;
- }
-
-
+ private static int count;
+ public Report createReport() throws Exception {
+
+ int counter = ++count;
+
+ // Create a Report object
+ Report report = new Report();
+ report.setId(counter);
+ report.setTitle("Report Title : " + counter);
+ report.setContent("This is a dummy report");
+
+ // Add the report to the Body
+ return report;
+ }
}
diff --git a/examples/camel-example-loadbalancing-mina/src/main/java/org/apache/camel/example/service/Reporting.java b/examples/camel-example-loadbalancing-mina/src/main/java/org/apache/camel/example/service/Reporting.java
index 3de57ab..fcf1891 100644
--- a/examples/camel-example-loadbalancing-mina/src/main/java/org/apache/camel/example/service/Reporting.java
+++ b/examples/camel-example-loadbalancing-mina/src/main/java/org/apache/camel/example/service/Reporting.java
@@ -23,20 +23,16 @@
import org.apache.camel.example.model.Report;
public class Reporting implements Processor {
-
- private static Integer count;
- public void process(Exchange exchange) throws Exception {
- }
+ private static Integer count;
- public Report updateReport(@Body Report report, @Header("minaServer") String name) throws Exception {
-
- report.setReply("Report updated from MINA server running on : " + name);
-
- // send the report updated
- return report;
- }
-
-
+ public void process(Exchange exchange) throws Exception {
+ }
+ public Report updateReport(@Body Report report, @Header("minaServer") String name) throws Exception {
+ report.setReply("Report updated from MINA server running on : " + name);
+
+ // send the report updated
+ return report;
+ }
}
diff --git a/components/camel-jmxconnect/src/main/resources/META-INF/LICENSE.txt b/examples/camel-example-loadbalancing-mina/src/main/resources/META-INF/LICENSE.txt
old mode 100644
new mode 100755
similarity index 100%
rename from components/camel-jmxconnect/src/main/resources/META-INF/LICENSE.txt
rename to examples/camel-example-loadbalancing-mina/src/main/resources/META-INF/LICENSE.txt
diff --git a/components/camel-jmxconnect/src/main/resources/META-INF/NOTICE.txt b/examples/camel-example-loadbalancing-mina/src/main/resources/META-INF/NOTICE.txt
similarity index 100%
rename from components/camel-jmxconnect/src/main/resources/META-INF/NOTICE.txt
rename to examples/camel-example-loadbalancing-mina/src/main/resources/META-INF/NOTICE.txt
diff --git a/examples/camel-example-reportincident/README.txt b/examples/camel-example-reportincident/README.txt
index 4b49fde..30c36c2 100644
--- a/examples/camel-example-reportincident/README.txt
+++ b/examples/camel-example-reportincident/README.txt
@@ -13,8 +13,8 @@
To run the example type
mvn jetty:run
-The webservice is exposed at:
- http://localhost:9080/camel-example-reportincident/webservices/incident
+The webservice will be listed in this overview:
+ http://localhost:9080/webservices/
To run the example with Ant
@@ -41,8 +41,8 @@
c. To Run using Ant, type
ant run
-The webservice is exposed at:
- http://localhost:9080/camel-example-reportincident/webservices/incident
+The webservice WSDL is exposed at:
+ http://localhost:9080/webservices/incident?wsdl
To stop the example hit ctrl + c
diff --git a/examples/camel-example-reportincident/pom.xml b/examples/camel-example-reportincident/pom.xml
index 976bc25..871c0cd 100755
--- a/examples/camel-example-reportincident/pom.xml
+++ b/examples/camel-example-reportincident/pom.xml
@@ -170,4 +170,4 @@
</plugins>
</build>
-</project>
\ No newline at end of file
+</project>
diff --git a/examples/camel-example-spring-javaconfig/pom.xml b/examples/camel-example-spring-javaconfig/pom.xml
index 5807e0e..cf707fe 100644
--- a/examples/camel-example-spring-javaconfig/pom.xml
+++ b/examples/camel-example-spring-javaconfig/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.camel</groupId>
<artifactId>examples</artifactId>
- <version>2.3-SNAPSHOT</version>
+ <version>2.3.0</version>
</parent>
<artifactId>camel-example-spring-javaconfig</artifactId>
diff --git a/examples/camel-example-spring-security/pom.xml b/examples/camel-example-spring-security/pom.xml
index f3498dd..0e2c9fc 100755
--- a/examples/camel-example-spring-security/pom.xml
+++ b/examples/camel-example-spring-security/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.camel</groupId>
<artifactId>examples</artifactId>
- <version>2.3-SNAPSHOT</version>
+ <version>2.3.0</version>
</parent>
<artifactId>camel-example-spring-security</artifactId>
diff --git a/examples/pom.xml b/examples/pom.xml
index a340f0c..116b5ee 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -59,6 +59,7 @@
<module>camel-example-gauth</module>
<module>camel-example-guice-jms</module>
<module>camel-example-jms-file</module>
+ <module>camel-example-loadbalancing-mina</module>
<module>camel-example-loan-broker</module>
<module>camel-example-management</module>
<module>camel-example-osgi</module>
@@ -66,8 +67,10 @@
<module>camel-example-reportincident</module>
<module>camel-example-route-throttling</module>
<module>camel-example-spring</module>
+ <module>camel-example-spring-javaconfig</module>
<module>camel-example-spring-jms</module>
<module>camel-example-spring-xquery</module>
+ <module>camel-example-spring-security</module>
<module>camel-example-tracer</module>
</modules>
diff --git a/parent/pom.xml b/parent/pom.xml
index 055e860..a64f5a1 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -76,7 +76,7 @@
<httpcore4-version>4.0.1</httpcore4-version>
<httpclient4-version>4.0.1</httpclient4-version>
<httpclient-version>3.1</httpclient-version>
- <jackson-version>1.4.3</jackson-version>
+ <jackson-version>1.5.2</jackson-version>
<javassist-version>3.9.0.GA</javassist-version>
<javax-mail-version>1.4.3</javax-mail-version>
<jaxb-version>2.1.12</jaxb-version>
diff --git a/pom.xml b/pom.xml
index 10ea9be..172cd94 100755
--- a/pom.xml
+++ b/pom.xml
@@ -354,7 +354,15 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
- <version>2.0.4</version>
+ <version>2.1.1</version>
+ <configuration>
+ <archive>
+ <manifestEntries>
+ <Bundle-SymbolicName>${project.groupId}.${project.artifactId}.source</Bundle-SymbolicName>
+ <Eclipse-SourceBundle>${project.groupId}.${project.artifactId};version="${camel.osgi.version.clean}"</Eclipse-SourceBundle>
+ </manifestEntries>
+ </archive>
+ </configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>