diff --git a/camel-core/src/main/java/org/apache/camel/CamelContext.java b/camel-core/src/main/java/org/apache/camel/CamelContext.java index df87a448932c7..19c308b2155a7 100644 --- a/camel-core/src/main/java/org/apache/camel/CamelContext.java +++ b/camel-core/src/main/java/org/apache/camel/CamelContext.java @@ -1128,6 +1128,30 @@ public interface CamelContext extends SuspendableService, RuntimeConfiguration { @Deprecated void setLazyLoadTypeConverters(Boolean lazyLoadTypeConverters); + /** + * Whether or not type converter statistics is enabled. + *

+ * By default the type converter utilization statistics is disabled. + * Notice: If enabled then there is a slight performance impact under very heavy load. + * + * @return true if enabled, false if disabled (default). + */ + Boolean isTypeConverterStatisticsEnabled(); + + /** + * Sets whether or not type converter statistics is enabled. + *

+ * By default the type converter utilization statistics is disabled. + * Notice: If enabled then there is a slight performance impact under very heavy load. + *

+ * You can enable/disable the statistics at runtime using the + * {@link org.apache.camel.spi.TypeConverterRegistry#getStatistics()#setTypeConverterStatisticsEnabled(Boolean)} method, + * or from JMX on the {@link org.apache.camel.api.management.mbean.ManagedTypeConverterRegistryMBean} mbean. + * + * @param typeConverterStatisticsEnabled true to enable, false to disable + */ + void setTypeConverterStatisticsEnabled(Boolean typeConverterStatisticsEnabled); + /** * Whether or not MDC logging is being enabled. * diff --git a/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedTypeConverterRegistryMBean.java b/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedTypeConverterRegistryMBean.java index b0aeab8b0e64c..a7f53aefbf6aa 100644 --- a/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedTypeConverterRegistryMBean.java +++ b/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedTypeConverterRegistryMBean.java @@ -39,4 +39,10 @@ public interface ManagedTypeConverterRegistryMBean extends ManagedServiceMBean { @ManagedOperation(description = "Resets the type conversion counters") void resetTypeConversionCounters(); + @ManagedAttribute(description = "Utilization statistics enabled") + boolean isStatisticsEnabled(); + + @ManagedAttribute(description = "Utilization statistics enabled") + void setStatisticsEnabled(boolean statisticsEnabled); + } diff --git a/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java b/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java index 555502dcc2773..a511943cf2708 100644 --- a/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java +++ b/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java @@ -500,7 +500,7 @@ protected MethodInfo chooseMethod(Object pojo, Exchange exchange, String name) t if (noParameters && localOperationsWithNoBody.size() == 1) { // if there was a method name configured and it has no parameters, then use the method with no body (eg no parameters) return localOperationsWithNoBody.get(0); - } else if (localOperationsWithBody.size() == 1) { + } else if (!noParameters && localOperationsWithBody.size() == 1) { // if there is one method with body then use that one return localOperationsWithBody.get(0); } @@ -874,9 +874,15 @@ private boolean matchMethod(Method method, String methodName) { return false; } + // is it a method with no parameters + boolean noParameters = methodName.endsWith("()"); + if (noParameters) { + return method.getParameterTypes().length == 0; + } + // match qualifier types which is used to select among overloaded methods String types = ObjectHelper.between(methodName, "(", ")"); - if (types != null) { + if (ObjectHelper.isNotEmpty(types)) { // we must qualify based on types to match method String[] parameters = StringQuoteHelper.splitSafeQuote(types, ','); Iterator it = ObjectHelper.createIterator(parameters); diff --git a/camel-core/src/main/java/org/apache/camel/component/bean/MethodInfo.java b/camel-core/src/main/java/org/apache/camel/component/bean/MethodInfo.java index 473fee6eb965b..44622d12f92be 100644 --- a/camel-core/src/main/java/org/apache/camel/component/bean/MethodInfo.java +++ b/camel-core/src/main/java/org/apache/camel/component/bean/MethodInfo.java @@ -426,8 +426,8 @@ public T evaluate(Exchange exchange, Class type) { if (methodParameters != null) { // split the parameters safely separated by comma, but beware that we can have // quoted parameters which contains comma as well, so do a safe quote split - String[] parameters = StringQuoteHelper.splitSafeQuote(methodParameters, ','); - it = ObjectHelper.createIterator(parameters); + String[] parameters = StringQuoteHelper.splitSafeQuote(methodParameters, ',', false); + it = ObjectHelper.createIterator(parameters, ",", true); } // remove headers as they should not be propagated @@ -490,8 +490,6 @@ private Object evaluateParameterValue(Exchange exchange, int index, Object param // convert the parameter value to a String String exp = exchange.getContext().getTypeConverter().convertTo(String.class, exchange, parameterValue); if (exp != null) { - // must trim first as there may be spaces between parameters - exp = exp.trim(); // check if its a valid parameter value boolean valid = BeanHelper.isValidParameterValue(exp); diff --git a/camel-core/src/main/java/org/apache/camel/component/directvm/DirectVmProcessor.java b/camel-core/src/main/java/org/apache/camel/component/directvm/DirectVmProcessor.java index 26cedfe9a62b9..5cec883212011 100644 --- a/camel-core/src/main/java/org/apache/camel/component/directvm/DirectVmProcessor.java +++ b/camel-core/src/main/java/org/apache/camel/component/directvm/DirectVmProcessor.java @@ -16,9 +16,10 @@ */ package org.apache.camel.component.directvm; +import org.apache.camel.AsyncCallback; import org.apache.camel.Exchange; import org.apache.camel.Processor; -import org.apache.camel.processor.DelegateProcessor; +import org.apache.camel.processor.DelegateAsyncProcessor; import org.apache.camel.util.ExchangeHelper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -26,7 +27,7 @@ /** * */ -public final class DirectVmProcessor extends DelegateProcessor { +public final class DirectVmProcessor extends DelegateAsyncProcessor { private static final transient Logger LOG = LoggerFactory.getLogger(DirectVmProcessor.class); private final DirectVmEndpoint endpoint; @@ -37,9 +38,9 @@ public DirectVmProcessor(Processor processor, DirectVmEndpoint endpoint) { } @Override - public void process(Exchange exchange) throws Exception { + public boolean process(final Exchange exchange, final AsyncCallback callback) { // need to use a copy of the incoming exchange, so we route using this camel context - Exchange copy = prepareExchange(exchange); + final Exchange copy = prepareExchange(exchange); ClassLoader current = Thread.currentThread().getContextClassLoader(); boolean changed = false; @@ -51,10 +52,19 @@ public void process(Exchange exchange) throws Exception { Thread.currentThread().setContextClassLoader(appClassLoader); changed = true; } - getProcessor().process(copy); + return getProcessor().process(copy, new AsyncCallback() { + @Override + public void done(boolean done) { + try { + // make sure to copy results back + ExchangeHelper.copyResults(exchange, copy); + } finally { + // must call callback when we are done + callback.done(done); + } + } + }); } finally { - // make sure to copy results back - ExchangeHelper.copyResults(exchange, copy); // restore TCCL if it was changed during processing if (changed) { LOG.trace("Restoring Thread ContextClassLoader to {}", current); diff --git a/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java b/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java index a911c1fb90d67..3e270637240b7 100644 --- a/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java +++ b/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java @@ -175,6 +175,7 @@ public class DefaultCamelContext extends ServiceSupport implements ModelCamelCon private Boolean handleFault = Boolean.FALSE; private Boolean disableJMX = Boolean.FALSE; private Boolean lazyLoadTypeConverters = Boolean.FALSE; + private Boolean typeConverterStatisticsEnabled = Boolean.FALSE; private Boolean useMDCLogging = Boolean.FALSE; private Boolean useBreadcrumb = Boolean.TRUE; private Long delay; @@ -2152,6 +2153,10 @@ protected void forceLazyInitialization() { getLanguageResolver(); getTypeConverterRegistry(); getTypeConverter(); + + if (isTypeConverterStatisticsEnabled() != null) { + getTypeConverterRegistry().getStatistics().setStatisticsEnabled(isTypeConverterStatisticsEnabled()); + } } /** @@ -2422,6 +2427,14 @@ public void setLazyLoadTypeConverters(Boolean lazyLoadTypeConverters) { this.lazyLoadTypeConverters = lazyLoadTypeConverters; } + public Boolean isTypeConverterStatisticsEnabled() { + return typeConverterStatisticsEnabled != null && typeConverterStatisticsEnabled; + } + + public void setTypeConverterStatisticsEnabled(Boolean typeConverterStatisticsEnabled) { + this.typeConverterStatisticsEnabled = typeConverterStatisticsEnabled; + } + public Boolean isUseMDCLogging() { return useMDCLogging != null && useMDCLogging; } diff --git a/camel-core/src/main/java/org/apache/camel/impl/converter/BaseTypeConverterRegistry.java b/camel-core/src/main/java/org/apache/camel/impl/converter/BaseTypeConverterRegistry.java index b57015cff41f6..a00f62cbe3531 100644 --- a/camel-core/src/main/java/org/apache/camel/impl/converter/BaseTypeConverterRegistry.java +++ b/camel-core/src/main/java/org/apache/camel/impl/converter/BaseTypeConverterRegistry.java @@ -107,10 +107,14 @@ public T convertTo(Class type, Exchange exchange, Object value) { Object answer; try { - attemptCounter.incrementAndGet(); + if (statistics.isStatisticsEnabled()) { + attemptCounter.incrementAndGet(); + } answer = doConvertTo(type, exchange, value, false); } catch (Exception e) { - failedCounter.incrementAndGet(); + if (statistics.isStatisticsEnabled()) { + failedCounter.incrementAndGet(); + } // if its a ExecutionException then we have rethrow it as its not due to failed conversion // this is special for FutureTypeConverter boolean execution = ObjectHelper.getException(ExecutionException.class, e) != null @@ -127,12 +131,15 @@ public T convertTo(Class type, Exchange exchange, Object value) { } } if (answer == Void.TYPE) { - // Could not find suitable conversion - missCounter.incrementAndGet(); + if (statistics.isStatisticsEnabled()) { + missCounter.incrementAndGet(); + } // Could not find suitable conversion return null; } else { - hitCounter.incrementAndGet(); + if (statistics.isStatisticsEnabled()) { + hitCounter.incrementAndGet(); + } return (T) answer; } } @@ -151,10 +158,14 @@ public T mandatoryConvertTo(Class type, Exchange exchange, Object value) Object answer; try { - attemptCounter.incrementAndGet(); + if (statistics.isStatisticsEnabled()) { + attemptCounter.incrementAndGet(); + } answer = doConvertTo(type, exchange, value, false); } catch (Exception e) { - failedCounter.incrementAndGet(); + if (statistics.isStatisticsEnabled()) { + failedCounter.incrementAndGet(); + } // error occurred during type conversion if (e instanceof TypeConversionException) { throw (TypeConversionException) e; @@ -163,12 +174,15 @@ public T mandatoryConvertTo(Class type, Exchange exchange, Object value) } } if (answer == Void.TYPE || value == null) { - // Could not find suitable conversion - missCounter.incrementAndGet(); + if (statistics.isStatisticsEnabled()) { + missCounter.incrementAndGet(); + } // Could not find suitable conversion throw new NoTypeConversionAvailableException(value, type); } else { - hitCounter.incrementAndGet(); + if (statistics.isStatisticsEnabled()) { + hitCounter.incrementAndGet(); + } return (T) answer; } } @@ -187,18 +201,26 @@ public T tryConvertTo(Class type, Exchange exchange, Object value) { Object answer; try { - attemptCounter.incrementAndGet(); + if (statistics.isStatisticsEnabled()) { + attemptCounter.incrementAndGet(); + } answer = doConvertTo(type, exchange, value, true); } catch (Exception e) { - failedCounter.incrementAndGet(); + if (statistics.isStatisticsEnabled()) { + failedCounter.incrementAndGet(); + } return null; } if (answer == Void.TYPE) { - missCounter.incrementAndGet(); // Could not find suitable conversion + if (statistics.isStatisticsEnabled()) { + missCounter.incrementAndGet(); + } return null; } else { - hitCounter.incrementAndGet(); + if (statistics.isStatisticsEnabled()) { + hitCounter.incrementAndGet(); + } return (T) answer; } } @@ -517,9 +539,11 @@ protected void doStart() throws Exception { @Override protected void doStop() throws Exception { // log utilization statistics when stopping, including mappings - String info = statistics.toString(); - info += String.format(" mappings[total=%s, misses=%s]", typeMappings.size(), misses.size()); - log.info(info); + if (statistics.isStatisticsEnabled()) { + String info = statistics.toString(); + info += String.format(" mappings[total=%s, misses=%s]", typeMappings.size(), misses.size()); + log.info(info); + } typeMappings.clear(); misses.clear(); @@ -531,6 +555,8 @@ protected void doStop() throws Exception { */ private final class UtilizationStatistics implements Statistics { + private boolean statisticsEnabled; + @Override public long getAttemptCounter() { return attemptCounter.get(); @@ -559,6 +585,16 @@ public void reset() { failedCounter.set(0); } + @Override + public boolean isStatisticsEnabled() { + return statisticsEnabled; + } + + @Override + public void setStatisticsEnabled(boolean statisticsEnabled) { + this.statisticsEnabled = statisticsEnabled; + } + @Override public String toString() { return String.format("TypeConverterRegistry utilization[attempts=%s, hits=%s, misses=%s, failures=%s]", diff --git a/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedTypeConverterRegistry.java b/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedTypeConverterRegistry.java index 5b2ea41fcc250..55af467a0a7b1 100644 --- a/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedTypeConverterRegistry.java +++ b/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedTypeConverterRegistry.java @@ -57,4 +57,12 @@ public long getFailedCounter() { public void resetTypeConversionCounters() { registry.getStatistics().reset(); } + + public boolean isStatisticsEnabled() { + return registry.getStatistics().isStatisticsEnabled(); + } + + public void setStatisticsEnabled(boolean statisticsEnabled) { + registry.getStatistics().setStatisticsEnabled(statisticsEnabled); + } } diff --git a/camel-core/src/main/java/org/apache/camel/spi/TypeConverterRegistry.java b/camel-core/src/main/java/org/apache/camel/spi/TypeConverterRegistry.java index 719e692033b5e..b7c90e2b85a20 100644 --- a/camel-core/src/main/java/org/apache/camel/spi/TypeConverterRegistry.java +++ b/camel-core/src/main/java/org/apache/camel/spi/TypeConverterRegistry.java @@ -21,6 +21,9 @@ /** * Registry for type converters. + *

+ * The utilization {@link Statistics} is by default disabled, as it has a slight performance impact under very high + * concurrent load. The statistics can be enabled using {@link Statistics#setStatisticsEnabled(boolean)} method. * * @version */ @@ -55,6 +58,18 @@ interface Statistics { * Reset the counters */ void reset(); + + /** + * Whether statistics is enabled. + */ + boolean isStatisticsEnabled(); + + /** + * Sets whether statistics is enabled. + * + * @param statisticsEnabled true to enable + */ + void setStatisticsEnabled(boolean statisticsEnabled); } /** diff --git a/camel-core/src/main/java/org/apache/camel/support/ServiceSupport.java b/camel-core/src/main/java/org/apache/camel/support/ServiceSupport.java index 52e07067d18b9..85864c0a7e49b 100644 --- a/camel-core/src/main/java/org/apache/camel/support/ServiceSupport.java +++ b/camel-core/src/main/java/org/apache/camel/support/ServiceSupport.java @@ -22,6 +22,7 @@ import org.apache.camel.ServiceStatus; import org.apache.camel.StatefulService; +import org.apache.camel.util.IOHelper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -277,17 +278,21 @@ public synchronized String getVersion() { if (version != null) { return version; } - + InputStream is = null; // try to load from maven properties first try { Properties p = new Properties(); - InputStream is = getClass().getResourceAsStream("/META-INF/maven/org.apache.camel/camel-core/pom.properties"); + is = getClass().getResourceAsStream("/META-INF/maven/org.apache.camel/camel-core/pom.properties"); if (is != null) { p.load(is); version = p.getProperty("version", ""); } } catch (Exception e) { // ignore + } finally { + if (is != null) { + IOHelper.close(is); + } } // fallback to using Java API diff --git a/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java b/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java index 361c22260ef73..f6be206ec051b 100755 --- a/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java +++ b/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java @@ -225,11 +225,15 @@ public static boolean getProperties(Object target, Map propertie if (info.isGetter && info.hasGetterAndSetter) { String name = info.getterOrSetterShorthandName; try { + // we may want to set options on classes that has package view visibility, so override the accessible + method.setAccessible(true); Object value = method.invoke(target); properties.put(optionPrefix + name, value); rc = true; } catch (Exception e) { - // ignore + if (LOG.isTraceEnabled()) { + LOG.trace("Error invoking getter method " + method + ". This exception is ignored.", e); + } } } } @@ -483,6 +487,8 @@ public static boolean setProperty(CamelContext context, TypeConverter typeConver try { // If the type is null or it matches the needed type, just use the value directly if (value == null || parameterType.isAssignableFrom(ref.getClass())) { + // we may want to set options on classes that has package view visibility, so override the accessible + setter.setAccessible(true); setter.invoke(target, ref); if (LOG.isDebugEnabled()) { LOG.debug("Configured property: {} on bean: {} with value: {}", new Object[]{name, target, ref}); @@ -491,6 +497,8 @@ public static boolean setProperty(CamelContext context, TypeConverter typeConver } else { // We need to convert it Object convertedValue = convert(typeConverter, parameterType, ref); + // we may want to set options on classes that has package view visibility, so override the accessible + setter.setAccessible(true); setter.invoke(target, convertedValue); if (LOG.isDebugEnabled()) { LOG.debug("Configured property: {} on bean: {} with value: {}", new Object[]{name, target, ref}); @@ -509,6 +517,8 @@ public static boolean setProperty(CamelContext context, TypeConverter typeConver } } // ignore exceptions as there could be another setter method where we could type convert successfully + } catch (SecurityException e) { + typeConversionFailed = e; } catch (NoTypeConversionAvailableException e) { typeConversionFailed = e; } catch (IllegalArgumentException e) { diff --git a/camel-core/src/main/java/org/apache/camel/util/MessageHelper.java b/camel-core/src/main/java/org/apache/camel/util/MessageHelper.java index 7bab1342b5f3c..61be0f0a5afdf 100644 --- a/camel-core/src/main/java/org/apache/camel/util/MessageHelper.java +++ b/camel-core/src/main/java/org/apache/camel/util/MessageHelper.java @@ -23,6 +23,7 @@ import java.io.Writer; import java.util.Map; import java.util.TreeMap; +import javax.xml.transform.Source; import javax.xml.transform.stream.StreamSource; import org.apache.camel.BytesSource; @@ -185,9 +186,8 @@ public static String extractBodyForLogging(Message message, String prepend) { * @param message the message * @param prepend a message to prepend * @param allowStreams whether or not streams is allowed - * @param allowFiles whether or not files is allowed - * @param maxChars limit to maximum number of chars. Use 0 or negative value - * to not limit at all. + * @param allowFiles whether or not files is allowed (currently not in use) + * @param maxChars limit to maximum number of chars. Use 0 or negative value to not limit at all. * @return the logging message */ public static String extractBodyForLogging(Message message, String prepend, boolean allowStreams, boolean allowFiles, int maxChars) { @@ -197,12 +197,10 @@ public static String extractBodyForLogging(Message message, String prepend, bool } if (!allowStreams) { - if (obj instanceof StreamSource && !(obj instanceof StringSource || obj instanceof BytesSource)) { - /* - * Generally do not log StreamSources but as StringSource and - * ByteSource are memory based they are ok - */ - return prepend + "[Body is instance of java.xml.transform.StreamSource]"; + if (obj instanceof Source && !(obj instanceof StringSource || obj instanceof BytesSource)) { + // for Source its only StringSource or BytesSource that is okay as they are memory based + // all other kinds we should not touch the body + return prepend + "[Body is instance of java.xml.transform.Source]"; } else if (obj instanceof StreamCache) { return prepend + "[Body is instance of org.apache.camel.StreamCache]"; } else if (obj instanceof InputStream) { diff --git a/camel-core/src/main/java/org/apache/camel/util/StringQuoteHelper.java b/camel-core/src/main/java/org/apache/camel/util/StringQuoteHelper.java index 3efa4debc18ab..452f459ba12fd 100644 --- a/camel-core/src/main/java/org/apache/camel/util/StringQuoteHelper.java +++ b/camel-core/src/main/java/org/apache/camel/util/StringQuoteHelper.java @@ -61,21 +61,40 @@ public static String[] splitSafeQuote(String input, char separator, boolean trim return null; } + if (input.indexOf(separator) == -1) { + // no separator in data, so return single string with input as is + return new String[]{trim ? input.trim() : input}; + } + List answer = new ArrayList(); StringBuilder sb = new StringBuilder(); boolean singleQuoted = false; boolean doubleQuoted = false; + boolean skipLeadingWhitespace = true; for (int i = 0; i < input.length(); i++) { char ch = input.charAt(i); + char prev = i > 0 ? input.charAt(i - 1) : 0; if (ch == '\'') { + if (singleQuoted && prev == ch && sb.length() == 0) { + // its an empty quote so add empty text + answer.add(""); + } singleQuoted = !singleQuoted; continue; } else if (ch == '"') { + if (doubleQuoted && prev == ch && sb.length() == 0) { + // its an empty quote so add empty text + answer.add(""); + } doubleQuoted = !doubleQuoted; continue; + } else if (ch == ' ') { + if (!singleQuoted && !doubleQuoted && skipLeadingWhitespace) { + continue; + } } else if (ch == separator) { // add as answer if we are not in a quote if (!singleQuoted && !doubleQuoted && sb.length() > 0) { diff --git a/camel-core/src/test/java/org/apache/camel/component/xslt/SAXSourceLogBodyTest.java b/camel-core/src/test/java/org/apache/camel/component/xslt/SAXSourceLogBodyTest.java new file mode 100644 index 0000000000000..219f8be00356b --- /dev/null +++ b/camel-core/src/test/java/org/apache/camel/component/xslt/SAXSourceLogBodyTest.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.component.xslt; + +import java.io.File; +import java.io.InputStream; +import javax.xml.transform.sax.SAXSource; + +import org.xml.sax.InputSource; +import org.xml.sax.XMLReader; +import org.xml.sax.helpers.XMLReaderFactory; + +import org.apache.camel.ContextTestSupport; +import org.apache.camel.Exchange; +import org.apache.camel.LoggingLevel; +import org.apache.camel.Processor; +import org.apache.camel.builder.RouteBuilder; + +/** + * + */ +public class SAXSourceLogBodyTest extends ContextTestSupport { + + public void testSAXSource() throws Exception { + getMockEndpoint("mock:result").expectedMessageCount(1); + + template.sendBody("direct:start", new File("src/test/resources/xslt/staff/staff.xml")); + + assertMockEndpointsSatisfied(); + } + + @Override + protected RouteBuilder createRouteBuilder() throws Exception { + return new RouteBuilder() { + @Override + public void configure() throws Exception { + from("direct:start").streamCaching() + // attach a SaxSource to body + .process(new Processor() { + @Override + public void process(Exchange exchange) throws Exception { + byte[] data = exchange.getIn().getBody(byte[].class); + InputStream is = exchange.getContext().getTypeConverter().convertTo(InputStream.class, data); + XMLReader xmlReader = XMLReaderFactory.createXMLReader(); + exchange.getIn().setBody(new SAXSource(xmlReader, new InputSource(is))); + } + }) + // The ${body} will toString the body and print it, so we need to enable stream caching + .log(LoggingLevel.WARN, "${body}") + .to("xslt:xslt/common/staff_template.xsl") + .to("log:result") + .to("mock:result"); + } + }; + } +} diff --git a/camel-core/src/test/java/org/apache/camel/impl/TypeConverterRegistryPerformanceTest.java b/camel-core/src/test/java/org/apache/camel/impl/TypeConverterRegistryPerformanceTest.java new file mode 100644 index 0000000000000..0bdbe0c2c659d --- /dev/null +++ b/camel-core/src/test/java/org/apache/camel/impl/TypeConverterRegistryPerformanceTest.java @@ -0,0 +1,75 @@ +/** + * 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.util.concurrent.CountDownLatch; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; + +import org.w3c.dom.Document; + +import org.apache.camel.ContextTestSupport; +import org.apache.camel.util.StopWatch; + +public class TypeConverterRegistryPerformanceTest extends ContextTestSupport { + + private int pool = 100; + private int inner = 10; + private int size = 20000; + + private ExecutorService executorService; + private CountDownLatch latch; + + public void testManual() throws Exception { + // noop + } + + public void disbledtestPerformance() throws Exception { + // force converter to be loaded on startup + Document dom = context.getTypeConverter().convertTo(Document.class, "World"); + assertNotNull(dom); + + StopWatch watch = new StopWatch(); + + latch = new CountDownLatch(size); + executorService = Executors.newFixedThreadPool(pool); + + for (int i = 0; i < size; i++) { + executorService.submit(new Runnable() { + @Override + public void run() { + for (int j = 0; j < inner; j++) { + Document dom = context.getTypeConverter().convertTo(Document.class, "World"); + assertNotNull(dom); + } + latch.countDown(); + } + }); + } + + assertTrue("Should all work", latch.await(2, TimeUnit.MINUTES)); + log.info("Took " + watch.taken()); + + executorService.shutdownNow(); + } + + @Override + public boolean isUseRouteBuilder() { + return false; + } +} diff --git a/camel-core/src/test/java/org/apache/camel/impl/TypeConverterRegistryStatisticsEnabledTest.java b/camel-core/src/test/java/org/apache/camel/impl/TypeConverterRegistryStatisticsEnabledTest.java new file mode 100644 index 0000000000000..609c61d9d0177 --- /dev/null +++ b/camel-core/src/test/java/org/apache/camel/impl/TypeConverterRegistryStatisticsEnabledTest.java @@ -0,0 +1,86 @@ +/** + * 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 org.apache.camel.CamelContext; +import org.apache.camel.ContextTestSupport; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.spi.TypeConverterRegistry; + +/** + * @version + */ +public class TypeConverterRegistryStatisticsEnabledTest extends ContextTestSupport { + + @Override + protected CamelContext createCamelContext() throws Exception { + CamelContext context = super.createCamelContext(); + context.setTypeConverterStatisticsEnabled(true); + return context; + } + + public void testTypeConverterRegistry() throws Exception { + getMockEndpoint("mock:a").expectedMessageCount(2); + + template.sendBody("direct:start", "3"); + template.sendBody("direct:start", "7"); + + assertMockEndpointsSatisfied(); + + TypeConverterRegistry reg = context.getTypeConverterRegistry(); + assertTrue("Should be enabled", reg.getStatistics().isStatisticsEnabled()); + + Long failed = reg.getStatistics().getFailedCounter(); + assertEquals(0, failed.intValue()); + Long miss = reg.getStatistics().getMissCounter(); + assertEquals(0, miss.intValue()); + + try { + template.sendBody("direct:start", "foo"); + fail("Should have thrown exception"); + } catch (Exception e) { + // expected + } + + // should now have a failed + failed = reg.getStatistics().getFailedCounter(); + assertEquals(1, failed.intValue()); + miss = reg.getStatistics().getMissCounter(); + assertEquals(0, miss.intValue()); + + // reset + reg.getStatistics().reset(); + + failed = reg.getStatistics().getFailedCounter(); + assertEquals(0, failed.intValue()); + miss = reg.getStatistics().getMissCounter(); + assertEquals(0, miss.intValue()); + } + + @Override + protected RouteBuilder createRouteBuilder() throws Exception { + return new RouteBuilder() { + @Override + public void configure() throws Exception { + from("direct:start").routeId("foo") + .convertBodyTo(int.class) + .to("mock:a"); + } + }; + } + +} diff --git a/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java b/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java index f268980012e4c..6240ff38556bc 100644 --- a/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java +++ b/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java @@ -1124,6 +1124,16 @@ public void testBodyOgnlReplaceEscapedBackslashChar() throws Exception { assertExpression("${body.replace('\\', '\\\\')}", "foo\\\\bar\\\\baz"); } + public void testBodyOgnlReplaceFirst() throws Exception { + exchange.getIn().setBody("http:camel.apache.org"); + + assertExpression("${body.replaceFirst('http:', 'http4:')}", "http4:camel.apache.org"); + assertExpression("${body.replaceFirst('http:', '')}", "camel.apache.org"); + assertExpression("${body.replaceFirst('http:', ' ')}", " camel.apache.org"); + assertExpression("${body.replaceFirst('http:', ' ')}", " camel.apache.org"); + assertExpression("${body.replaceFirst('http:',' ')}", " camel.apache.org"); + } + public void testClassSimpleName() throws Exception { Animal tiger = new Animal("Tony the Tiger", 13); exchange.getIn().setBody(tiger); diff --git a/camel-core/src/test/java/org/apache/camel/management/ManagedTypeConverterRegistryTest.java b/camel-core/src/test/java/org/apache/camel/management/ManagedTypeConverterRegistryTest.java index 957d2a2e29c6b..e0f9483a5a708 100644 --- a/camel-core/src/test/java/org/apache/camel/management/ManagedTypeConverterRegistryTest.java +++ b/camel-core/src/test/java/org/apache/camel/management/ManagedTypeConverterRegistryTest.java @@ -17,6 +17,7 @@ package org.apache.camel.management; import java.util.Set; +import javax.management.Attribute; import javax.management.MBeanServer; import javax.management.ObjectName; @@ -50,6 +51,13 @@ public void testTypeConverterRegistry() throws Exception { } assertNotNull("Cannot find DefaultTypeConverter", name); + // is disabled by default + Boolean enabled = (Boolean) mbeanServer.getAttribute(name, "StatisticsEnabled"); + assertEquals(Boolean.FALSE, enabled); + + // need to enable statistics + mbeanServer.setAttribute(name, new Attribute("StatisticsEnabled", Boolean.TRUE)); + Long failed = (Long) mbeanServer.getAttribute(name, "FailedCounter"); assertEquals(0, failed.intValue()); Long miss = (Long) mbeanServer.getAttribute(name, "MissCounter"); diff --git a/camel-core/src/test/java/org/apache/camel/util/StingQuoteHelperTest.java b/camel-core/src/test/java/org/apache/camel/util/StingQuoteHelperTest.java index af3452169e04b..fea93b91829ca 100644 --- a/camel-core/src/test/java/org/apache/camel/util/StingQuoteHelperTest.java +++ b/camel-core/src/test/java/org/apache/camel/util/StingQuoteHelperTest.java @@ -27,7 +27,8 @@ public void testSplitSafeQuote() throws Exception { assertEquals(null, StringQuoteHelper.splitSafeQuote(null, ',')); String[] out = StringQuoteHelper.splitSafeQuote("", ','); - assertEquals(0, out.length); + assertEquals(1, out.length); + assertEquals("", out[0]); out = StringQuoteHelper.splitSafeQuote(" ", ','); assertEquals(1, out.length); @@ -82,10 +83,38 @@ public void testSplitSafeQuote() throws Exception { assertEquals("Hello Camel", out[0]); assertEquals("Bye World", out[1]); - out = StringQuoteHelper.splitSafeQuote("'Hello Camel', 'Bye World'", ',', false); + out = StringQuoteHelper.splitSafeQuote("'Hello Camel', ' Bye World'", ',', false); assertEquals(2, out.length); assertEquals("Hello Camel", out[0]); assertEquals(" Bye World", out[1]); + + out = StringQuoteHelper.splitSafeQuote("'http:', ' '", ',', false); + assertEquals(2, out.length); + assertEquals("http:", out[0]); + assertEquals(" ", out[1]); + + out = StringQuoteHelper.splitSafeQuote("'http:', ''", ',', false); + assertEquals(2, out.length); + assertEquals("http:", out[0]); + assertEquals("", out[1]); + + out = StringQuoteHelper.splitSafeQuote("'Hello Camel', 5, true", ',', false); + assertEquals(3, out.length); + assertEquals("Hello Camel", out[0]); + assertEquals("5", out[1]); + assertEquals("true", out[2]); + + out = StringQuoteHelper.splitSafeQuote("'Hello Camel',5,true", ',', false); + assertEquals(3, out.length); + assertEquals("Hello Camel", out[0]); + assertEquals("5", out[1]); + assertEquals("true", out[2]); + + out = StringQuoteHelper.splitSafeQuote(" 'Hello Camel', 5 , true ", ',', false); + assertEquals(3, out.length); + assertEquals("Hello Camel", out[0]); + assertEquals("5", out[1]); + assertEquals("true", out[2]); } } diff --git a/camel-core/src/test/resources/xslt/staff/staff.xml b/camel-core/src/test/resources/xslt/staff/staff.xml new file mode 100644 index 0000000000000..681fd0af6db24 --- /dev/null +++ b/camel-core/src/test/resources/xslt/staff/staff.xml @@ -0,0 +1,60 @@ + + + + + + Bugs Bunny + 03/21/1970 + 31 +

4895 Wabbit Hole Road
+ 865-111-1111 + + + + Daisy Duck + 08/09/1949 + 51 +
748 Golden Pond
+ 865-222-2222 +
+ + + Minnie Mouse + 04/13/1977 + 24 +
4064 Cheese Factory Blvd
+ 865-333-3333 +
+ + + Pluto + 07/04/1979 + 21 +
414 Dog Lane
+ 865-333-3333 +
+ + + Road Runner + 01/19/1953 + 48 +
135 Desert View Street
+ none +
+ + \ No newline at end of file diff --git a/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Consumer.java b/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Consumer.java index 58b157edcf66b..0128df0d83b7b 100644 --- a/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Consumer.java +++ b/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Consumer.java @@ -27,6 +27,7 @@ import com.amazonaws.services.s3.model.S3Object; import com.amazonaws.services.s3.model.S3ObjectSummary; +import org.apache.camel.AsyncCallback; import org.apache.camel.Exchange; import org.apache.camel.NoFactoryAvailableException; import org.apache.camel.Processor; @@ -58,7 +59,7 @@ protected int poll() throws Exception { pendingExchanges = 0; String bucketName = getConfiguration().getBucketName(); - LOG.trace("Quering objects in bucket [{}]...", bucketName); + LOG.trace("Queueing objects in bucket [{}]...", bucketName); ListObjectsRequest listObjectsRequest = new ListObjectsRequest(); listObjectsRequest.setBucketName(bucketName); @@ -66,15 +67,19 @@ protected int poll() throws Exception { listObjectsRequest.setMaxKeys(maxMessagesPerPoll); ObjectListing listObjects = getAmazonS3Client().listObjects(listObjectsRequest); - - LOG.trace("Found {} objects in bucket [{}]...", listObjects.getObjectSummaries().size(), bucketName); + + if (LOG.isTraceEnabled()) { + LOG.trace("Found {} objects in bucket [{}]...", listObjects.getObjectSummaries().size(), bucketName); + } Queue exchanges = createExchanges(listObjects.getObjectSummaries()); return processBatch(CastUtils.cast(exchanges)); } protected Queue createExchanges(List s3ObjectSummaries) { - LOG.trace("Received {} messages in this poll", s3ObjectSummaries.size()); + if (LOG.isTraceEnabled()) { + LOG.trace("Received {} messages in this poll", s3ObjectSummaries.size()); + } Queue answer = new LinkedList(); for (S3ObjectSummary s3ObjectSummary : s3ObjectSummaries) { @@ -91,7 +96,7 @@ public int processBatch(Queue exchanges) throws Exception { for (int index = 0; index < total && isBatchAllowed(); index++) { // only loop if we are started (allowed to run) - Exchange exchange = ObjectHelper.cast(Exchange.class, exchanges.poll()); + final Exchange exchange = ObjectHelper.cast(Exchange.class, exchanges.poll()); // add current index and total as properties exchange.setProperty(Exchange.BATCH_INDEX, index); exchange.setProperty(Exchange.BATCH_SIZE, total); @@ -117,8 +122,12 @@ public String toString() { }); LOG.trace("Processing exchange [{}]...", exchange); - - getProcessor().process(exchange); + getAsyncProcessor().process(exchange, new AsyncCallback() { + @Override + public void done(boolean doneSync) { + LOG.trace("Processing exchange [{}] done.", exchange); + } + }); } return total; @@ -138,12 +147,11 @@ protected void processCommit(Exchange exchange) { LOG.trace("Deleting object from bucket {} with key {}...", bucketName, key); getAmazonS3Client().deleteObject(bucketName, key); - - LOG.trace("Object deleted"); + + LOG.trace("Deleted object from bucket {} with key {}...", bucketName, key); } } catch (AmazonClientException e) { - LOG.warn("Error occurred during deleting object", e); - exchange.setException(e); + getExceptionHandler().handleException("Error occurred during deleting object. This exception is ignored.", exchange, e); } } diff --git a/components/camel-aws/src/main/java/org/apache/camel/component/aws/sqs/SqsConsumer.java b/components/camel-aws/src/main/java/org/apache/camel/component/aws/sqs/SqsConsumer.java index 5ed50487af68f..241b13e92f4ec 100644 --- a/components/camel-aws/src/main/java/org/apache/camel/component/aws/sqs/SqsConsumer.java +++ b/components/camel-aws/src/main/java/org/apache/camel/component/aws/sqs/SqsConsumer.java @@ -33,6 +33,7 @@ import com.amazonaws.services.sqs.model.ReceiveMessageRequest; import com.amazonaws.services.sqs.model.ReceiveMessageResult; +import org.apache.camel.AsyncCallback; import org.apache.camel.Exchange; import org.apache.camel.NoFactoryAvailableException; import org.apache.camel.Processor; @@ -74,15 +75,19 @@ protected int poll() throws Exception { LOG.trace("Receiving messages with request [{}]...", request); ReceiveMessageResult messageResult = getClient().receiveMessage(request); - - LOG.trace("Received {} messages", messageResult.getMessages().size()); + + if (LOG.isTraceEnabled()) { + LOG.trace("Received {} messages", messageResult.getMessages().size()); + } Queue exchanges = createExchanges(messageResult.getMessages()); return processBatch(CastUtils.cast(exchanges)); } protected Queue createExchanges(List messages) { - LOG.trace("Received {} messages in this poll", messages.size()); + if (LOG.isTraceEnabled()) { + LOG.trace("Received {} messages in this poll", messages.size()); + } Queue answer = new LinkedList(); for (Message message : messages) { @@ -98,7 +103,7 @@ public int processBatch(Queue exchanges) throws Exception { for (int index = 0; index < total && isBatchAllowed(); index++) { // only loop if we are started (allowed to run) - Exchange exchange = ObjectHelper.cast(Exchange.class, exchanges.poll()); + final Exchange exchange = ObjectHelper.cast(Exchange.class, exchanges.poll()); // add current index and total as properties exchange.setProperty(Exchange.BATCH_INDEX, index); exchange.setProperty(Exchange.BATCH_SIZE, total); @@ -112,11 +117,11 @@ public int processBatch(Queue exchanges) throws Exception { if (this.scheduledExecutor != null && visibilityTimeout != null && (visibilityTimeout.intValue() / 2) > 0) { int delay = visibilityTimeout.intValue() / 2; int period = visibilityTimeout.intValue(); - LOG.debug("Scheduled TimeoutExtender task to start after {} delay, and run with {} period (seconds) to extend exchangeId: {}", - new Object[]{delay, period, exchange.getExchangeId()}); - int repeatSeconds = new Double(visibilityTimeout.doubleValue() * 1.5).intValue(); // - LOG.debug("period :" + period); - LOG.debug("repeatSeconds :" + repeatSeconds); + int repeatSeconds = new Double(visibilityTimeout.doubleValue() * 1.5).intValue(); + if (LOG.isDebugEnabled()) { + LOG.debug("Scheduled TimeoutExtender task to start after {} delay, and run with {}/{} period/repeat (seconds), to extend exchangeId: {}", + new Object[]{delay, period, repeatSeconds, exchange.getExchangeId()}); + } final ScheduledFuture scheduledFuture = this.scheduledExecutor.scheduleAtFixedRate( new TimeoutExtender(exchange, repeatSeconds), delay, period, TimeUnit.SECONDS); exchange.addOnCompletion(new Synchronization() { @@ -157,12 +162,12 @@ public String toString() { LOG.trace("Processing exchange [{}]...", exchange); - try { - // This blocks while message is consumed. - getProcessor().process(exchange); - } finally { - LOG.trace("Processing exchange [{}] done.", exchange); - } + getAsyncProcessor().process(exchange, new AsyncCallback() { + @Override + public void done(boolean doneSync) { + LOG.trace("Processing exchange [{}] done.", exchange); + } + }); } return total; @@ -183,10 +188,10 @@ protected void processCommit(Exchange exchange) { getClient().deleteMessage(deleteRequest); - LOG.trace("Message deleted"); + LOG.trace("Deleted message with receipt handle {}...", receiptHandle); } } catch (AmazonClientException e) { - getExceptionHandler().handleException("Error occurred during deleting message.", e); + getExceptionHandler().handleException("Error occurred during deleting message. This exception is ignored.", exchange, e); } } diff --git a/components/camel-bam/src/main/java/org/apache/camel/bam/processor/ActivityMonitorEngine.java b/components/camel-bam/src/main/java/org/apache/camel/bam/processor/ActivityMonitorEngine.java index 99da337161910..df8fdb7c46723 100644 --- a/components/camel-bam/src/main/java/org/apache/camel/bam/processor/ActivityMonitorEngine.java +++ b/components/camel-bam/src/main/java/org/apache/camel/bam/processor/ActivityMonitorEngine.java @@ -94,11 +94,11 @@ protected void doInTransactionWithoutResult(TransactionStatus status) { try { Thread.sleep(timeToSleep); } catch (InterruptedException e) { - LOG.debug("Caught: " + e, e); + // ignore } } } catch (Exception e) { - LOG.error("Caught: " + e, e); + LOG.warn("Error during running ActivityMonitorEngine. This exception is ignored.", e); } } } @@ -110,9 +110,9 @@ protected void fireExpiredEvent(final ActivityState activityState) { public Object doInJpa(EntityManager entityManager) throws PersistenceException { // let's try locking the object first if (isUseLocking()) { - LOG.info("Attempting to lock: " + activityState); + LOG.debug("Attempting to lock: {}", activityState); entityManager.lock(activityState, LockModeType.WRITE); - LOG.info("Grabbed lock: " + activityState); + LOG.debug("Grabbed lock: {}", activityState); } try { diff --git a/components/camel-bam/src/main/java/org/apache/camel/bam/processor/BamProcessorSupport.java b/components/camel-bam/src/main/java/org/apache/camel/bam/processor/BamProcessorSupport.java index 2b6b669b04978..b2886c33c3585 100644 --- a/components/camel-bam/src/main/java/org/apache/camel/bam/processor/BamProcessorSupport.java +++ b/components/camel-bam/src/main/java/org/apache/camel/bam/processor/BamProcessorSupport.java @@ -82,7 +82,7 @@ public void process(final Exchange exchange) { try { Thread.sleep(retrySleep); } catch (InterruptedException e) { - LOG.debug("Caught: " + e, e); + // ignore } } try { @@ -104,11 +104,11 @@ public T doInTransaction(TransactionStatus status) { } }); if (i > 1) { - LOG.info("Attempt {} worked!", i); + LOG.debug("Attempt {} worked!", i); } return; } catch (Exception e) { - LOG.warn("Failed to complete transaction: " + e, e); + LOG.warn("Failed to complete transaction. This exception is ignored.", e); } } } @@ -147,7 +147,7 @@ protected Object getCorrelationKey(Exchange exchange) throws NoCorrelationKeyExc protected void onError(TransactionStatus status, Exception e) throws RuntimeCamelException { status.setRollbackOnly(); - LOG.error("Caught: " + e, e); + LOG.warn("Caught: " + e, e); throw wrapRuntimeCamelException(e); } diff --git a/components/camel-bam/src/main/java/org/apache/camel/bam/processor/JpaBamProcessorSupport.java b/components/camel-bam/src/main/java/org/apache/camel/bam/processor/JpaBamProcessorSupport.java index f5d60057a3fa0..3b64bb23b11ec 100644 --- a/components/camel-bam/src/main/java/org/apache/camel/bam/processor/JpaBamProcessorSupport.java +++ b/components/camel-bam/src/main/java/org/apache/camel/bam/processor/JpaBamProcessorSupport.java @@ -115,7 +115,7 @@ public void setCorrelationKeyIsPrimary(boolean correlationKeyIsPrimary) { protected T loadEntity(Exchange exchange, Object key) throws Exception { LOCK.lock(); try { - LOG.info(">> LoadEntity call"); + LOG.trace("LoadEntity call"); T entity = findEntityByCorrelationKey(key); if (entity == null) { entity = createEntity(exchange, key); @@ -127,7 +127,7 @@ protected T loadEntity(Exchange exchange, Object key) throws Exception { // Now we must flush to avoid concurrent updates clashing trying to // insert the same row - LOG.debug("About to flush on entity: " + entity + " with key: " + key); + LOG.debug("About to flush on entity: {} with key: {}", entity, key); template.flush(); } return entity; @@ -157,7 +157,7 @@ protected Class getKeyType() { Method getter = IntrospectionSupport.getPropertyGetter(getEntityType(), getKeyPropertyName()); return getter.getReturnType(); } catch (NoSuchMethodException e) { - LOG.warn("no such getter for: " + getKeyPropertyName() + " on " + getEntityType() + ". Reason: " + e, e); + LOG.warn("no such getter for: " + getKeyPropertyName() + " on " + getEntityType() + ". This exception will be ignored.", e); return null; } } diff --git a/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java b/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java index 949c48d54952f..b89d06634a938 100644 --- a/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java +++ b/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java @@ -105,6 +105,8 @@ public class CamelContextFactoryBean extends AbstractCamelContextFactoryBean getBuilderRefs(); @@ -561,6 +563,9 @@ protected void initCamelContext(T ctx) throws Exception { if (getDataFormats() != null) { ctx.setDataFormats(getDataFormats().asMap()); } + if (getTypeConverterStatisticsEnabled() != null) { + ctx.setTypeConverterStatisticsEnabled(getTypeConverterStatisticsEnabled()); + } } protected void initThreadPoolProfiles(T context) throws Exception { diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/blueprint/RsClientDefinitionParser.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/blueprint/RsClientDefinitionParser.java index 59c685280afb3..0777ef6812cb6 100644 --- a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/blueprint/RsClientDefinitionParser.java +++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/blueprint/RsClientDefinitionParser.java @@ -69,8 +69,7 @@ public Metadata parse(Element element, ParserContext context) { Metadata list = parseListData(context, beanMetadata, elem); beanMetadata.addProperty(name, list); } else if ("features".equals(name) || "providers".equals(name) - || "schemaLocations".equals(name) || "modelBeans".equals(name) - || "serviceBeans".equals(name)) { + || "schemaLocations".equals(name) || "modelBeans".equals(name)) { Metadata list = parseListData(context, beanMetadata, elem); beanMetadata.addProperty(name, list); } else if ("model".equals(name)) { @@ -81,6 +80,7 @@ public Metadata parse(Element element, ParserContext context) { } else { setFirstChildAsProperty(elem, context, beanMetadata, name); } + elem = DOMUtils.getNextElement(elem); } if (StringUtils.isEmpty(bus)) { diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/blueprint/RsServerDefinitionParser.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/blueprint/RsServerDefinitionParser.java index 7f24df83091ae..c333cfb7b1a16 100644 --- a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/blueprint/RsServerDefinitionParser.java +++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/blueprint/RsServerDefinitionParser.java @@ -71,7 +71,8 @@ public Metadata parse(Element element, ParserContext context) { Metadata list = parseListData(context, beanMetadata, elem); beanMetadata.addProperty(name, list); } else if ("features".equals(name) || "providers".equals(name) - || "schemaLocations".equals(name) || "modelBeans".equals(name)) { + || "schemaLocations".equals(name) || "modelBeans".equals(name) + || "serviceBeans".equals(name)) { Metadata list = parseListData(context, beanMetadata, elem); beanMetadata.addProperty(name, list); } else if ("model".equals(name)) { @@ -82,6 +83,7 @@ public Metadata parse(Element element, ParserContext context) { } else { setFirstChildAsProperty(elem, context, beanMetadata, name); } + elem = DOMUtils.getNextElement(elem); } if (StringUtils.isEmpty(bus)) { diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsHeaderFilterStrategy.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsHeaderFilterStrategy.java index 650701feb92d9..50a31e06fb391 100644 --- a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsHeaderFilterStrategy.java +++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsHeaderFilterStrategy.java @@ -39,6 +39,8 @@ protected void initialize() { getOutFilter().add(Exchange.HTTP_METHOD); getOutFilter().add(Exchange.HTTP_PATH); getOutFilter().add(Exchange.DESTINATION_OVERRIDE_URL); + // filter headers begin with "Camel" or "org.apache.camel" + setOutFilterPattern("(Camel|org\\.apache\\.camel)[\\.|a-z|A-z|0-9]*"); } diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/DefaultCxfRsBinding.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/DefaultCxfRsBinding.java index 02fde54a60636..2bf135efc4067 100644 --- a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/DefaultCxfRsBinding.java +++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/DefaultCxfRsBinding.java @@ -132,8 +132,15 @@ public MultivaluedMap bindCamelHeadersToRequestHeaders(Map answer = new MetadataMap(); for (Map.Entry entry : camelHeaders.entrySet()) { + // Need to make sure the cxf needed header will not be filtered + if (headerFilterStrategy.applyFilterToCamelHeaders(entry.getKey(), entry.getValue(), camelExchange) + && camelToCxfHeaderMap.get(entry.getKey()) == null) { + LOG.trace("Drop Camel header: {}={}", entry.getKey(), entry.getValue()); + continue; + } - if (headerFilterStrategy.applyFilterToCamelHeaders(entry.getKey(), entry.getValue(), camelExchange)) { + // we need to make sure the entry value is not null + if (entry.getValue() == null) { LOG.trace("Drop Camel header: {}={}", entry.getKey(), entry.getValue()); continue; } @@ -250,7 +257,9 @@ protected void copyMessageHeader(org.apache.cxf.message.Message cxfMessage, Mess protected void copyProtocolHeader(org.apache.cxf.message.Message cxfMessage, Message camelMessage, Exchange camelExchange) { Map> headers = (Map>)cxfMessage.get(org.apache.cxf.message.Message.PROTOCOL_HEADERS); for (Map.Entry>entry : headers.entrySet()) { - if (headerFilterStrategy.applyFilterToCamelHeaders(entry.getKey(), entry.getValue(), camelExchange)) { + // just make sure the first String element is not null + if (headerFilterStrategy.applyFilterToCamelHeaders(entry.getKey(), entry.getValue(), camelExchange) + || entry.getValue().get(0) == null) { LOG.trace("Drop CXF message protocol header: {}={}", entry.getKey(), entry.getValue()); } else { // just put the first String element, as the complex one is filtered diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsRouterTest.java b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsRouterTest.java index be4649be36298..ddb3ecbd988b2 100644 --- a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsRouterTest.java +++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsRouterTest.java @@ -33,10 +33,14 @@ import org.springframework.context.support.ClassPathXmlApplicationContext; public class CxfRsRouterTest extends CamelSpringTestSupport { - private static final int PORT0 = CXFTestSupport.getPort1(); + private static final int PORT = CXFTestSupport.getPort1(); private static final String PUT_REQUEST = "Mary123"; private static final String POST_REQUEST = "Jack"; + + protected int getPort() { + return PORT; + } @Override protected AbstractXmlApplicationContext createApplicationContext() { @@ -55,7 +59,7 @@ public void testEndpointUris() throws Exception { @Test public void testGetCustomer() throws Exception { - HttpGet get = new HttpGet("http://localhost:" + PORT0 + "/CxfRsRouterTest/route/customerservice/customers/123"); + HttpGet get = new HttpGet("http://localhost:" + getPort() + "/CxfRsRouterTest/route/customerservice/customers/123"); get.addHeader("Accept" , "application/json"); HttpClient httpclient = new DefaultHttpClient(); @@ -72,7 +76,7 @@ public void testGetCustomer() throws Exception { @Test public void testGetCustomerWithQuery() throws Exception { - HttpGet get = new HttpGet("http://localhost:" + PORT0 + "/CxfRsRouterTest/route/customerservice/customers?id=123"); + HttpGet get = new HttpGet("http://localhost:" + getPort() + "/CxfRsRouterTest/route/customerservice/customers?id=123"); get.addHeader("Accept" , "application/json"); HttpClient httpclient = new DefaultHttpClient(); @@ -87,8 +91,8 @@ public void testGetCustomerWithQuery() throws Exception { } @Test - public void testGetCustomers() throws Exception { - HttpGet get = new HttpGet("http://localhost:" + PORT0 + "/CxfRsRouterTest/route/customerservice/customers/"); + public void testGetCustomers() throws Exception { + HttpGet get = new HttpGet("http://localhost:" + getPort() + "/CxfRsRouterTest/route/customerservice/customers/"); get.addHeader("Accept" , "application/xml"); HttpClient httpclient = new DefaultHttpClient(); @@ -111,7 +115,7 @@ public void testGetCustomers() throws Exception { @Test public void testGetSubResource() throws Exception { - HttpGet get = new HttpGet("http://localhost:" + PORT0 + "/CxfRsRouterTest/route/customerservice/orders/223/products/323"); + HttpGet get = new HttpGet("http://localhost:" + getPort() + "/CxfRsRouterTest/route/customerservice/orders/223/products/323"); get.addHeader("Accept" , "application/json"); HttpClient httpclient = new DefaultHttpClient(); @@ -127,7 +131,7 @@ public void testGetSubResource() throws Exception { @Test public void testPutConsumer() throws Exception { - HttpPut put = new HttpPut("http://localhost:" + PORT0 + "/CxfRsRouterTest/route/customerservice/customers"); + HttpPut put = new HttpPut("http://localhost:" + getPort() + "/CxfRsRouterTest/route/customerservice/customers"); StringEntity entity = new StringEntity(PUT_REQUEST, "ISO-8859-1"); entity.setContentType("text/xml; charset=ISO-8859-1"); put.setEntity(entity); @@ -144,7 +148,7 @@ public void testPutConsumer() throws Exception { @Test public void testPostConsumer() throws Exception { - HttpPost post = new HttpPost("http://localhost:" + PORT0 + "/CxfRsRouterTest/route/customerservice/customers"); + HttpPost post = new HttpPost("http://localhost:" + getPort() + "/CxfRsRouterTest/route/customerservice/customers"); post.addHeader("Accept" , "text/xml"); StringEntity entity = new StringEntity(POST_REQUEST, "ISO-8859-1"); entity.setContentType("text/xml; charset=ISO-8859-1"); @@ -157,7 +161,7 @@ public void testPostConsumer() throws Exception { assertEquals("124Jack", EntityUtils.toString(response.getEntity())); - HttpDelete del = new HttpDelete("http://localhost:" + PORT0 + "/CxfRsRouterTest/route/customerservice/customers/124/"); + HttpDelete del = new HttpDelete("http://localhost:" + getPort() + "/CxfRsRouterTest/route/customerservice/customers/124/"); httpclient.execute(del); } finally { httpclient.getConnectionManager().shutdown(); @@ -167,7 +171,7 @@ public void testPostConsumer() throws Exception { @Test public void testPostConsumerUniqueResponseCode() throws Exception { - HttpPost post = new HttpPost("http://localhost:" + PORT0 + "/CxfRsRouterTest/route/customerservice/customersUniqueResponseCode"); + HttpPost post = new HttpPost("http://localhost:" + getPort() + "/CxfRsRouterTest/route/customerservice/customersUniqueResponseCode"); post.addHeader("Accept" , "text/xml"); StringEntity entity = new StringEntity(POST_REQUEST, "ISO-8859-1"); entity.setContentType("text/xml; charset=ISO-8859-1"); @@ -180,7 +184,7 @@ public void testPostConsumerUniqueResponseCode() throws Exception { assertEquals("124Jack", EntityUtils.toString(response.getEntity())); - HttpDelete del = new HttpDelete("http://localhost:" + PORT0 + "/CxfRsRouterTest/route/customerservice/customers/124/"); + HttpDelete del = new HttpDelete("http://localhost:" + getPort() + "/CxfRsRouterTest/route/customerservice/customers/124/"); httpclient.execute(del); } finally { httpclient.getConnectionManager().shutdown(); diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/JettyCxfRsRouterTest.java b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/JettyCxfRsRouterTest.java new file mode 100644 index 0000000000000..7843e960ddc2f --- /dev/null +++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/JettyCxfRsRouterTest.java @@ -0,0 +1,41 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.cxf.jaxrs; + +import org.apache.camel.component.cxf.CXFTestSupport; +import org.junit.Test; +import org.springframework.context.support.AbstractXmlApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; + +public class JettyCxfRsRouterTest extends CxfRsRouterTest { + private static final int PORT2 = CXFTestSupport.getPort5(); + @Override + protected int getPort() { + return PORT2; + } + + @Override + protected AbstractXmlApplicationContext createApplicationContext() { + return new ClassPathXmlApplicationContext("org/apache/camel/component/cxf/jaxrs/JettyCxfRsSpringRouter.xml"); + } + + @Test + public void testEndpointUris() throws Exception { + // Don't test anything here + } + +} diff --git a/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/JettyCxfRsSpringRouter.xml b/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/JettyCxfRsSpringRouter.xml new file mode 100644 index 0000000000000..074bf89a428a7 --- /dev/null +++ b/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/JettyCxfRsSpringRouter.xml @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + True + + + + + + + diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/CamelServlet.java b/components/camel-http/src/main/java/org/apache/camel/component/http/CamelServlet.java index 5587afb83abb4..1957873330a7c 100644 --- a/components/camel-http/src/main/java/org/apache/camel/component/http/CamelServlet.java +++ b/components/camel-http/src/main/java/org/apache/camel/component/http/CamelServlet.java @@ -98,11 +98,18 @@ protected void service(HttpServletRequest request, HttpServletResponse response) ClassLoader oldTccl = overrideTccl(exchange); HttpHelper.setCharsetFromContentType(request.getContentType(), exchange); exchange.setIn(new HttpMessage(exchange, request, response)); - // set context path as header String contextPath = consumer.getEndpoint().getPath(); exchange.getIn().setHeader("CamelServletContextPath", contextPath); + String httpPath = (String)exchange.getIn().getHeader(Exchange.HTTP_PATH); + // here we just remove the CamelServletContextPath part from the HTTP_PATH + if (contextPath != null + && httpPath.startsWith(contextPath)) { + exchange.getIn().setHeader(Exchange.HTTP_PATH, + httpPath.substring(contextPath.length())); + } + try { log.trace("Processing request for exchangeId: {}", exchange.getExchangeId()); // process the exchange diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/helper/HttpHelper.java b/components/camel-http/src/main/java/org/apache/camel/component/http/helper/HttpHelper.java index 79cc9e847d8fe..e98f2bb75087c 100644 --- a/components/camel-http/src/main/java/org/apache/camel/component/http/helper/HttpHelper.java +++ b/components/camel-http/src/main/java/org/apache/camel/component/http/helper/HttpHelper.java @@ -180,32 +180,10 @@ public static String createURL(Exchange exchange, HttpEndpoint endpoint) { // append HTTP_PATH to HTTP_URI if it is provided in the header String path = exchange.getIn().getHeader(Exchange.HTTP_PATH, String.class); + // NOW the HTTP_PATH is just related path, we don't need to trim it if (path != null) { if (path.startsWith("/")) { - URI baseURI; - String baseURIString = exchange.getIn().getHeader(Exchange.HTTP_BASE_URI, String.class); - try { - if (baseURIString == null) { - if (exchange.getFromEndpoint() != null) { - baseURIString = exchange.getFromEndpoint().getEndpointUri(); - } else { - // will set a default one for it - baseURIString = "/"; - } - } - baseURI = new URI(baseURIString); - String basePath = baseURI.getPath(); - if (path.startsWith(basePath)) { - path = path.substring(basePath.length()); - if (path.startsWith("/")) { - path = path.substring(1); - } - } else { - throw new RuntimeExchangeException("Cannot analyze the Exchange.HTTP_PATH header, due to: cannot find the right HTTP_BASE_URI", exchange); - } - } catch (Throwable t) { - throw new RuntimeExchangeException("Cannot analyze the Exchange.HTTP_PATH header, due to: " + t.getMessage(), exchange, t); - } + path = path.substring(1); } if (path.length() > 0) { // make sure that there is exactly one "/" between HTTP_URI and diff --git a/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/HttpHelper.java b/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/HttpHelper.java index 0ac342ca4dd4d..1ae38f90cba72 100644 --- a/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/HttpHelper.java +++ b/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/HttpHelper.java @@ -180,33 +180,10 @@ public static String createURL(Exchange exchange, HttpEndpoint endpoint) { // append HTTP_PATH to HTTP_URI if it is provided in the header String path = exchange.getIn().getHeader(Exchange.HTTP_PATH, String.class); + // NOW the HTTP_PATH is just related path, we don't need to trim it if (path != null) { if (path.startsWith("/")) { - URI baseURI; - String baseURIString = exchange.getIn().getHeader(Exchange.HTTP_BASE_URI, String.class); - try { - if (baseURIString == null) { - if (exchange.getFromEndpoint() != null) { - baseURIString = exchange.getFromEndpoint().getEndpointUri(); - } else { - // will set a default one for it - baseURIString = "/"; - } - } - baseURI = new URI(baseURIString); - String basePath = baseURI.getPath(); - if (path.startsWith(basePath)) { - path = path.substring(basePath.length()); - if (path.startsWith("/")) { - path = path.substring(1); - } - } else { - throw new RuntimeExchangeException("Cannot analyze the Exchange.HTTP_PATH header, due to: cannot find the right HTTP_BASE_URI", exchange); - } - } catch (Throwable t) { - throw new RuntimeExchangeException("Cannot analyze the Exchange.HTTP_PATH header, due to: " + t.getMessage(), exchange, t); - } - + path = path.substring(1); } if (path.length() > 0) { // make sure that there is exactly one "/" between HTTP_URI and diff --git a/components/camel-jclouds/pom.xml b/components/camel-jclouds/pom.xml index e84565d12589d..8c9ed66bea5b7 100644 --- a/components/camel-jclouds/pom.xml +++ b/components/camel-jclouds/pom.xml @@ -34,6 +34,7 @@ org.apache.camel.component.jclouds.* org.apache.camel.spi.ComponentResolver;component=jclouds + ${jclouds-google-guava-version} diff --git a/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java b/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java index c63fa86beb581..280a5c14e86e4 100644 --- a/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java +++ b/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java @@ -108,12 +108,20 @@ protected void service(final HttpServletRequest request, final HttpServletRespon } HttpHelper.setCharsetFromContentType(request.getContentType(), exchange); + exchange.setIn(new HttpMessage(exchange, request, response)); - // set context path as header String contextPath = consumer.getEndpoint().getPath(); exchange.getIn().setHeader("CamelServletContextPath", contextPath); - + + String httpPath = (String)exchange.getIn().getHeader(Exchange.HTTP_PATH); + // here we just remove the CamelServletContextPath part from the HTTP_PATH + if (contextPath != null + && httpPath.startsWith(contextPath)) { + exchange.getIn().setHeader(Exchange.HTTP_PATH, + httpPath.substring(contextPath.length())); + } + log.trace("Suspending continuation of exchangeId: {}", exchange.getExchangeId()); continuation.setAttribute(EXCHANGE_ATTRIBUTE_ID, exchange.getExchangeId()); // must suspend before we process the exchange diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpProxyRouteTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpProxyRouteTest.java index 5cd2444be1b8d..8f932cf3393c7 100644 --- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpProxyRouteTest.java +++ b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpProxyRouteTest.java @@ -65,7 +65,7 @@ public void configure() { from("jetty://http://localhost:{{port}}/bye").transform(header("foo").prepend("Bye ")); - from("jetty://http://localhost:{{port}}/otherEndpoint?matchOnUriPrefix=true").transform(header(Exchange.HTTP_PATH)); + from("jetty://http://localhost:{{port}}/otherEndpoint?matchOnUriPrefix=true").transform(header(Exchange.HTTP_URI)); from("jetty://http://localhost:{{port}}/proxyServer") .to("http://localhost:{{port2}}/host?bridgeEndpoint=true"); diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/HttpClientRouteTest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/HttpClientRouteTest.java index 7a35afa6a96c0..b0453c2468a4f 100644 --- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/HttpClientRouteTest.java +++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/HttpClientRouteTest.java @@ -136,7 +136,9 @@ public void configure() throws Exception { from("servlet:///hello?matchOnUriPrefix=true").process(new Processor() { public void process(Exchange exchange) throws Exception { String contentType = exchange.getIn().getHeader(Exchange.CONTENT_TYPE, String.class); - String path = exchange.getIn().getHeader(Exchange.HTTP_PATH, String.class); + String path = exchange.getIn().getHeader(Exchange.HTTP_URI, String.class); + path = path.substring(path.lastIndexOf("/")); + assertEquals("Get a wrong content type", CONTENT_TYPE, contentType); // assert camel http header String charsetEncoding = exchange.getIn().getHeader(Exchange.HTTP_CHARACTER_ENCODING, String.class); diff --git a/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java b/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java index e2afc77192c03..efe23558643e4 100644 --- a/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java +++ b/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java @@ -112,6 +112,8 @@ public class CamelContextFactoryBean extends AbstractCamelContextFactoryBean + + + + + + + + + + + + + + + diff --git a/components/camel-sql/src/main/java/org/apache/camel/processor/aggregate/jdbc/ClassLoadingAwareObjectInputStream.java b/components/camel-sql/src/main/java/org/apache/camel/processor/aggregate/jdbc/ClassLoadingAwareObjectInputStream.java index e13cd7705f483..12535f33d4306 100644 --- a/components/camel-sql/src/main/java/org/apache/camel/processor/aggregate/jdbc/ClassLoadingAwareObjectInputStream.java +++ b/components/camel-sql/src/main/java/org/apache/camel/processor/aggregate/jdbc/ClassLoadingAwareObjectInputStream.java @@ -21,7 +21,6 @@ import java.io.ObjectInputStream; import java.io.ObjectStreamClass; import java.lang.reflect.Proxy; -import java.util.HashMap; import org.apache.camel.CamelContext; @@ -30,11 +29,6 @@ */ public class ClassLoadingAwareObjectInputStream extends ObjectInputStream { - /** - *

Maps primitive type names to corresponding class objects.

- */ - private static final HashMap> PRIM_CLASSES = new HashMap>(8, 1.0F); - private CamelContext camelContext; public ClassLoadingAwareObjectInputStream(CamelContext camelContext, InputStream in) throws IOException { @@ -44,16 +38,14 @@ public ClassLoadingAwareObjectInputStream(CamelContext camelContext, InputStream @Override protected Class resolveClass(ObjectStreamClass classDesc) throws IOException, ClassNotFoundException { - ClassLoader cl = Thread.currentThread().getContextClassLoader(); - return camelContext.getClassResolver().resolveClass(classDesc.getName(), cl); + return camelContext.getClassResolver().resolveClass(classDesc.getName()); } @Override protected Class resolveProxyClass(String[] interfaces) throws IOException, ClassNotFoundException { - ClassLoader cl = Thread.currentThread().getContextClassLoader(); Class[] cinterfaces = new Class[interfaces.length]; for (int i = 0; i < interfaces.length; i++) { - cinterfaces[i] = camelContext.getClassResolver().resolveClass(interfaces[i], cl); + cinterfaces[i] = camelContext.getClassResolver().resolveClass(interfaces[i]); } try { @@ -63,16 +55,4 @@ protected Class resolveProxyClass(String[] interfaces) throws IOException, Cl } } - static { - PRIM_CLASSES.put("boolean", boolean.class); - PRIM_CLASSES.put("byte", byte.class); - PRIM_CLASSES.put("char", char.class); - PRIM_CLASSES.put("short", short.class); - PRIM_CLASSES.put("int", int.class); - PRIM_CLASSES.put("long", long.class); - PRIM_CLASSES.put("float", float.class); - PRIM_CLASSES.put("double", double.class); - PRIM_CLASSES.put("void", void.class); - } - } diff --git a/components/camel-stream/src/main/java/org/apache/camel/component/stream/StreamConsumer.java b/components/camel-stream/src/main/java/org/apache/camel/component/stream/StreamConsumer.java index f16f4bccb9d8d..d9892499db20f 100644 --- a/components/camel-stream/src/main/java/org/apache/camel/component/stream/StreamConsumer.java +++ b/components/camel-stream/src/main/java/org/apache/camel/component/stream/StreamConsumer.java @@ -82,10 +82,8 @@ protected void doStart() throws Exception { @Override public void doStop() throws Exception { - // important: do not close the stream as it will close the standard - // system.in etc. if (executor != null) { - endpoint.getCamelContext().getExecutorServiceManager().shutdownGraceful(executor); + endpoint.getCamelContext().getExecutorServiceManager().shutdownNow(executor); executor = null; } lines.clear(); @@ -98,6 +96,8 @@ public void doStop() throws Exception { public void run() { try { readFromStream(); + } catch (InterruptedException e) { + // we are closing down so ignore } catch (Exception e) { getExceptionHandler().handleException(e); } diff --git a/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/TypeConverterRegistryStatisticsEnabledTest.java b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/TypeConverterRegistryStatisticsEnabledTest.java new file mode 100644 index 0000000000000..998afb9008354 --- /dev/null +++ b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/TypeConverterRegistryStatisticsEnabledTest.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.test.blueprint; + +import org.apache.camel.spi.TypeConverterRegistry; +import org.junit.Test; + +public class TypeConverterRegistryStatisticsEnabledTest extends CamelBlueprintTestSupport { + + @Override + protected String getBlueprintDescriptor() { + return "org/apache/camel/test/blueprint/typeConverterRegistryStatisticsEnabledTest.xml"; + } + + @Test + public void testTypeConverterRegistry() throws Exception { + getMockEndpoint("mock:a").expectedMessageCount(2); + + template.sendBody("direct:start", "3"); + template.sendBody("direct:start", "7"); + + assertMockEndpointsSatisfied(); + + TypeConverterRegistry reg = context.getTypeConverterRegistry(); + assertTrue("Should be enabled", reg.getStatistics().isStatisticsEnabled()); + + Long failed = reg.getStatistics().getFailedCounter(); + assertEquals(0, failed.intValue()); + Long miss = reg.getStatistics().getMissCounter(); + assertEquals(0, miss.intValue()); + + try { + template.sendBody("direct:start", "foo"); + fail("Should have thrown exception"); + } catch (Exception e) { + // expected + } + + // should now have a failed + failed = reg.getStatistics().getFailedCounter(); + assertEquals(1, failed.intValue()); + miss = reg.getStatistics().getMissCounter(); + assertEquals(0, miss.intValue()); + + // reset + reg.getStatistics().reset(); + + failed = reg.getStatistics().getFailedCounter(); + assertEquals(0, failed.intValue()); + miss = reg.getStatistics().getMissCounter(); + assertEquals(0, miss.intValue()); + } + +} diff --git a/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/typeConverterRegistryStatisticsEnabledTest.xml b/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/typeConverterRegistryStatisticsEnabledTest.xml new file mode 100644 index 0000000000000..4618eb6393720 --- /dev/null +++ b/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/typeConverterRegistryStatisticsEnabledTest.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + diff --git a/etc/pom.xml b/etc/pom.xml index 88563b80d10ac..70a0a5d66558c 100755 --- a/etc/pom.xml +++ b/etc/pom.xml @@ -24,7 +24,6 @@ org.apache.camel camel-parent 2.11-SNAPSHOT - ../parent camel-etc diff --git a/examples/camel-example-bam/README.txt b/examples/camel-example-bam/README.txt index a46778acecdf2..2cacb3ef6cf96 100644 --- a/examples/camel-example-bam/README.txt +++ b/examples/camel-example-bam/README.txt @@ -16,11 +16,6 @@ To run the example with Maven, type You can see the BAM activies defined in src/main/java/org/apache/camel/example/bam/MyActivites.java -In the HSQL Database Explorer type - select * from camel_activitystate -to see the states of the activities. Notice that one activity never receives -its expected message and when it's overdue Camel reports this as an error. - To stop the example hit ctrl + c This example is documented at diff --git a/examples/camel-example-bam/pom.xml b/examples/camel-example-bam/pom.xml index 87afe04de6214..f538f85ef6aad 100644 --- a/examples/camel-example-bam/pom.xml +++ b/examples/camel-example-bam/pom.xml @@ -54,10 +54,6 @@ org.apache.camel camel-juel - - org.springframework - spring-aop - @@ -65,11 +61,6 @@ slf4j-log4j12 - - xalan - xalan - - org.hibernate @@ -84,8 +75,8 @@ geronimo-jta_1.1_spec - commons-dbcp - commons-dbcp + commons-dbcp + commons-dbcp diff --git a/examples/camel-example-bam/src/data/invoices/invoiceA.xml b/examples/camel-example-bam/src/data/invoices/invoiceA.xml index c1c0c9928df36..f73b8f29d3b63 100644 --- a/examples/camel-example-bam/src/data/invoices/invoiceA.xml +++ b/examples/camel-example-bam/src/data/invoices/invoiceA.xml @@ -1,20 +1,4 @@ - This invoice should tie up with purchase order p1 \ No newline at end of file diff --git a/examples/camel-example-bam/src/data/invoices/invoiceC.xml b/examples/camel-example-bam/src/data/invoices/invoiceC.xml index ce00516813f00..43ce8d8511031 100644 --- a/examples/camel-example-bam/src/data/invoices/invoiceC.xml +++ b/examples/camel-example-bam/src/data/invoices/invoiceC.xml @@ -1,20 +1,4 @@ - This invoice should tie up with purchase order p3 \ No newline at end of file diff --git a/examples/camel-example-bam/src/data/purchaseOrders/po1.xml b/examples/camel-example-bam/src/data/purchaseOrders/po1.xml index 78ee21eed4a23..edec47c54ccdf 100644 --- a/examples/camel-example-bam/src/data/purchaseOrders/po1.xml +++ b/examples/camel-example-bam/src/data/purchaseOrders/po1.xml @@ -1,20 +1,4 @@ - beer 10 diff --git a/examples/camel-example-bam/src/data/purchaseOrders/po2.xml b/examples/camel-example-bam/src/data/purchaseOrders/po2.xml index 640ce5e4525f7..cc8a4a57801c3 100644 --- a/examples/camel-example-bam/src/data/purchaseOrders/po2.xml +++ b/examples/camel-example-bam/src/data/purchaseOrders/po2.xml @@ -1,20 +1,4 @@ - pizza 2 diff --git a/examples/camel-example-bam/src/data/purchaseOrders/po3.xml b/examples/camel-example-bam/src/data/purchaseOrders/po3.xml index 299ae01fb61c6..8307f482f6624 100644 --- a/examples/camel-example-bam/src/data/purchaseOrders/po3.xml +++ b/examples/camel-example-bam/src/data/purchaseOrders/po3.xml @@ -1,20 +1,4 @@ - iPhone 1 diff --git a/examples/camel-example-bam/src/main/java/org/apache/camel/example/bam/Main.java b/examples/camel-example-bam/src/main/java/org/apache/camel/example/bam/Main.java index 030f9f38a26bc..7bdb8d518e3ac 100644 --- a/examples/camel-example-bam/src/main/java/org/apache/camel/example/bam/Main.java +++ b/examples/camel-example-bam/src/main/java/org/apache/camel/example/bam/Main.java @@ -17,12 +17,16 @@ package org.apache.camel.example.bam; /** + * Main class to make it easy to run this example. + * * @version */ public final class Main { + private Main() { // do nothing here } + public static void main(String[] args) throws Exception { org.apache.camel.spring.Main.main(args); } diff --git a/examples/camel-example-bam/src/main/resources/META-INF/persistence.xml b/examples/camel-example-bam/src/main/resources/META-INF/persistence.xml index a470d0e626c93..00cb6048dfee9 100644 --- a/examples/camel-example-bam/src/main/resources/META-INF/persistence.xml +++ b/examples/camel-example-bam/src/main/resources/META-INF/persistence.xml @@ -1,18 +1,19 @@ - James Strachan diff --git a/examples/camel-example-cdi/src/data/message2.xml b/examples/camel-example-cdi/src/data/message2.xml index 6a0e717a12e80..5caa1928fe174 100644 --- a/examples/camel-example-cdi/src/data/message2.xml +++ b/examples/camel-example-cdi/src/data/message2.xml @@ -1,20 +1,4 @@ - Hiram Chirino diff --git a/examples/camel-example-cxf-proxy/README.txt b/examples/camel-example-cxf-proxy/README.txt index 9504c0450b155..bdee92fddafcb 100644 --- a/examples/camel-example-cxf-proxy/README.txt +++ b/examples/camel-example-cxf-proxy/README.txt @@ -10,18 +10,19 @@ To run the example type: mvn camel:run The proxied webservice is located at - http://localhost:9080/camel-example-cxf-proxy/webservices/incident + http://localhost:/camel-example-cxf-proxy/webservices/incident The real webservice is located at - http://localhost:9081/real-webservice + http://localhost:/real-webservice The webservice WSDL is exposed at: - http://localhost:9080/camel-example-cxf-proxy/webservices/incident?wsdl + http://localhost:/camel-example-cxf-proxy/webservices/incident?wsdl +Because we use dynamic port numbers, you have to check the console to get the used one. To stop the example hit ctrl + c To make a SOAP call open soapUI or another SOAP query tool and create a new -project w/WSDL of http://localhost:9080/camel-example-cxf-proxy/webservices/incident?wsdl. +project w/WSDL of http://localhost:/camel-example-cxf-proxy/webservices/incident?wsdl. Then make SOAP requests of this format: - + + + diff --git a/examples/camel-example-etl/src/data/row1.xml b/examples/camel-example-etl/src/data/row1.xml index 60724d8bb990f..f2158449f5676 100644 --- a/examples/camel-example-etl/src/data/row1.xml +++ b/examples/camel-example-etl/src/data/row1.xml @@ -1,20 +1,4 @@ - James Strachan diff --git a/examples/camel-example-etl/src/data/row2.xml b/examples/camel-example-etl/src/data/row2.xml index 6a0e717a12e80..5caa1928fe174 100644 --- a/examples/camel-example-etl/src/data/row2.xml +++ b/examples/camel-example-etl/src/data/row2.xml @@ -1,20 +1,4 @@ - Hiram Chirino diff --git a/examples/camel-example-guice-jms/src/data/message1.xml b/examples/camel-example-guice-jms/src/data/message1.xml index 60724d8bb990f..f2158449f5676 100644 --- a/examples/camel-example-guice-jms/src/data/message1.xml +++ b/examples/camel-example-guice-jms/src/data/message1.xml @@ -1,20 +1,4 @@ - James Strachan diff --git a/examples/camel-example-guice-jms/src/data/message2.xml b/examples/camel-example-guice-jms/src/data/message2.xml index 6a0e717a12e80..5caa1928fe174 100644 --- a/examples/camel-example-guice-jms/src/data/message2.xml +++ b/examples/camel-example-guice-jms/src/data/message2.xml @@ -1,20 +1,4 @@ - Hiram Chirino diff --git a/examples/camel-example-management/src/main/data/message.xml b/examples/camel-example-management/src/main/data/message.xml index eb49232da9471..4b8530d722a16 100644 --- a/examples/camel-example-management/src/main/data/message.xml +++ b/examples/camel-example-management/src/main/data/message.xml @@ -1,20 +1,4 @@ - Claus \ No newline at end of file diff --git a/examples/camel-example-osgi-rmi/README.txt b/examples/camel-example-osgi-rmi/README.txt index dbb713f2e3fc9..6290c7fd272fc 100644 --- a/examples/camel-example-osgi-rmi/README.txt +++ b/examples/camel-example-osgi-rmi/README.txt @@ -23,21 +23,11 @@ If using Apache Karaf / Apache ServiceMix you can install this example from the shell First the camel-rmi feature must be installed - + features:chooseurl camel ${version} features:install camel-rmi Then install the example - - osgi:install mvn:org.apache.camel/camel-example-osgi-rmi/2.8.0 - - (substitute 2.8.0 with the Camel version number) - -Then start the bundle by starting the id it was assigned during installation - - osgi:start 182 - - (substitute 182 with the id of the bundle) - + osgi:install -s mvn:org.apache.camel/camel-example-osgi-rmi/${version} If you hit an problems please let us know on the Camel Forums http://camel.apache.org/discussion-forums.html diff --git a/examples/camel-example-osgi/README.txt b/examples/camel-example-osgi/README.txt index e0084ea680dd0..f77e0c172e84d 100644 --- a/examples/camel-example-osgi/README.txt +++ b/examples/camel-example-osgi/README.txt @@ -20,20 +20,13 @@ Running inside OSGi container ============================= You will need to compile and install this example first: - mvn compile install + mvn install If using Apache Karaf / Apache ServiceMix you can install this example from the shell - - osgi:install mvn:org.apache.camel/camel-example-osgi/${version} - - -Then start the bundle by starting the id it was assigned during installation - - osgi:start 182 - - (substitute 182 with the id of the bundle) - + features:chooseurl camel ${version} + features:install camel-spring + osgi:install -s mvn:org.apache.camel/camel-example-osgi/${version} If you hit any problems please let us know on the Camel Forums http://camel.apache.org/discussion-forums.html diff --git a/examples/camel-example-osgi/src/main/resources/features.xml b/examples/camel-example-osgi/src/main/resources/features.xml index 8e87233672dfa..2a952969e5da3 100644 --- a/examples/camel-example-osgi/src/main/resources/features.xml +++ b/examples/camel-example-osgi/src/main/resources/features.xml @@ -19,7 +19,7 @@ mvn:org.apache.camel.karaf/apache-camel/${project.version}/xml/features - camel + camel-spring mvn:org.apache.camel/camel-example-osgi/${project.version} diff --git a/examples/camel-example-pojo-messaging/src/data/message1.xml b/examples/camel-example-pojo-messaging/src/data/message1.xml index 60724d8bb990f..f2158449f5676 100644 --- a/examples/camel-example-pojo-messaging/src/data/message1.xml +++ b/examples/camel-example-pojo-messaging/src/data/message1.xml @@ -1,20 +1,4 @@ - James Strachan diff --git a/examples/camel-example-pojo-messaging/src/data/message2.xml b/examples/camel-example-pojo-messaging/src/data/message2.xml index 6a0e717a12e80..5caa1928fe174 100644 --- a/examples/camel-example-pojo-messaging/src/data/message2.xml +++ b/examples/camel-example-pojo-messaging/src/data/message2.xml @@ -1,20 +1,4 @@ - Hiram Chirino diff --git a/examples/camel-example-pojo-messaging/src/data/message3.xml b/examples/camel-example-pojo-messaging/src/data/message3.xml index 9ab078d0c7bab..73bf554172066 100644 --- a/examples/camel-example-pojo-messaging/src/data/message3.xml +++ b/examples/camel-example-pojo-messaging/src/data/message3.xml @@ -1,20 +1,4 @@ - Jonathan Anstey diff --git a/examples/camel-example-reportincident-wssecurity/README.txt b/examples/camel-example-reportincident-wssecurity/README.txt index 6a30bf4fbc4d3..53e1fb6d51639 100644 --- a/examples/camel-example-reportincident-wssecurity/README.txt +++ b/examples/camel-example-reportincident-wssecurity/README.txt @@ -47,11 +47,11 @@ To run the example on Apache ServiceMix 4.x or Apache Karaf 2.x osgi:install -s mvn:org.apache.camel/camel-example-reportincident-wssecurity 4) Verify that your service is available using in the browser the following url - http://localhost:9080/camel-example-reportincident/webservices/incident?wsdl + http://localhost:9081/camel-example-reportincident/webservices/incident?wsdl 5) Start SOAPUI (2.x) Create a new project called camel-example-reportincident-wssecurity - Point to the following url : http://localhost:9080/camel-example-reportincident/webservices/incident?wsdl + Point to the following url : http://localhost:9081/camel-example-reportincident/webservices/incident?wsdl Open the request 1 (under camel-example-reportincident-wssecurity --> ReportIncidentBinding --> ReportIncident) and copy/paste the SOAP message generated by the unit test @@ -60,7 +60,7 @@ To run the example on Apache ServiceMix 4.x or Apache Karaf 2.x 2010-07-14 09:57:54,403 [main ] INFO LoggingOutInterceptor - Outbound Message --------------------------- ID: 1 - Address: http://localhost:9080/camel-example-reportincident/webservices/incident + Address: http://localhost:9081/camel-example-reportincident/webservices/incident Encoding: UTF-8 Content-Type: text/xml Headers: {SOAPAction=["http://reportincident.example.camel.apache.org/ReportIncident"], Accept=[*/*]} diff --git a/examples/camel-example-reportincident-wssecurity/pom.xml b/examples/camel-example-reportincident-wssecurity/pom.xml index bbd5d397881e8..5b420c2f3bc7e 100644 --- a/examples/camel-example-reportincident-wssecurity/pom.xml +++ b/examples/camel-example-reportincident-wssecurity/pom.xml @@ -137,14 +137,12 @@ org.apache.cxf cxf-rt-frontend-jaxrs ${cxf-version} - test org.apache.velocity velocity ${velocity-version} - test
@@ -174,19 +172,11 @@ - - + - org.mortbay.jetty - jetty-maven-plugin - - - - 9080 - 60000 - - - + org.apache.camel + camel-maven-plugin + ${project.version} diff --git a/examples/camel-example-reportincident-wssecurity/src/main/resources/META-INF/spring/camel-context.xml b/examples/camel-example-reportincident-wssecurity/src/main/resources/META-INF/spring/camel-context.xml index ae7fd98f86bc7..cc129e1884ed5 100644 --- a/examples/camel-example-reportincident-wssecurity/src/main/resources/META-INF/spring/camel-context.xml +++ b/examples/camel-example-reportincident-wssecurity/src/main/resources/META-INF/spring/camel-context.xml @@ -74,7 +74,7 @@ - + diff --git a/examples/camel-example-reportincident/src/main/resources/camel-config.xml b/examples/camel-example-reportincident/src/main/resources/camel-config.xml index 499caff59629f..c1d5442b873d3 100755 --- a/examples/camel-example-reportincident/src/main/resources/camel-config.xml +++ b/examples/camel-example-reportincident/src/main/resources/camel-config.xml @@ -21,6 +21,8 @@ xsi:schemaLocation=" http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> + + diff --git a/examples/camel-example-route-throttling/pom.xml b/examples/camel-example-route-throttling/pom.xml index 3229c260ff3f8..1bd42cafba846 100644 --- a/examples/camel-example-route-throttling/pom.xml +++ b/examples/camel-example-route-throttling/pom.xml @@ -53,6 +53,10 @@ org.apache.activemq activemq-camel + + org.apache.activemq + activemq-kahadb-store + diff --git a/examples/camel-example-servlet-tomcat-no-spring/README.txt b/examples/camel-example-servlet-tomcat-no-spring/README.txt index 6890dd7afc3b8..db3afa5ab73bd 100644 --- a/examples/camel-example-servlet-tomcat-no-spring/README.txt +++ b/examples/camel-example-servlet-tomcat-no-spring/README.txt @@ -12,10 +12,10 @@ deploy folder of Apache Tomcat. And then hit this url from a webbrowser which has further instructions (use correct version number) - http://localhost:8080/camel-example-servlet-tomcat-no-spring-2.11.0 + http://localhost:8080/camel-example-servlet-tomcat-no-spring-{version} The servlet is located at (use correct version number) - http://localhost:8080/camel-example-servlet-tomcat-no-spring-2.11.0/camel + http://localhost:8080/camel-example-servlet-tomcat-no-spring-{version}/camel This example is documented at http://camel.apache.org/servlet-tomcat-example-no-spring.html diff --git a/examples/camel-example-servlet-tomcat/README.txt b/examples/camel-example-servlet-tomcat/README.txt index 072e8171c1025..174d9417f205b 100644 --- a/examples/camel-example-servlet-tomcat/README.txt +++ b/examples/camel-example-servlet-tomcat/README.txt @@ -11,10 +11,10 @@ deploy folder of Apache Tomcat. And then hit this url from a webbrowser which has further instructions (use correct version number) - http://localhost:8080/camel-example-servlet-tomcat-2.7.0 + http://localhost:8080/camel-example-servlet-tomcat-{version} The servlet is located at (use correct version number) - http://localhost:8080/camel-example-servlet-tomcat-2.7.0/camel + http://localhost:8080/camel-example-servlet-tomcat-{version}/camel/hello This example is documented at http://camel.apache.org/servlet-tomcat-example.html diff --git a/examples/camel-example-spring-javaconfig/src/data/message1.xml b/examples/camel-example-spring-javaconfig/src/data/message1.xml index 60724d8bb990f..f2158449f5676 100644 --- a/examples/camel-example-spring-javaconfig/src/data/message1.xml +++ b/examples/camel-example-spring-javaconfig/src/data/message1.xml @@ -1,20 +1,4 @@ - James Strachan diff --git a/examples/camel-example-spring-javaconfig/src/data/message2.xml b/examples/camel-example-spring-javaconfig/src/data/message2.xml index 6a0e717a12e80..5caa1928fe174 100644 --- a/examples/camel-example-spring-javaconfig/src/data/message2.xml +++ b/examples/camel-example-spring-javaconfig/src/data/message2.xml @@ -1,20 +1,4 @@ - Hiram Chirino diff --git a/examples/camel-example-spring-jms/pom.xml b/examples/camel-example-spring-jms/pom.xml index 1aea506cd2986..831510ab95cd2 100644 --- a/examples/camel-example-spring-jms/pom.xml +++ b/examples/camel-example-spring-jms/pom.xml @@ -79,11 +79,6 @@ - - junit - junit - test - org.apache.camel camel-test-spring diff --git a/examples/camel-example-spring-jms/src/main/java/org/apache/camel/example/client/CamelClientEndpoint.java b/examples/camel-example-spring-jms/src/main/java/org/apache/camel/example/client/CamelClientEndpoint.java index b27036680c66a..6c813bd64ef1f 100644 --- a/examples/camel-example-spring-jms/src/main/java/org/apache/camel/example/client/CamelClientEndpoint.java +++ b/examples/camel-example-spring-jms/src/main/java/org/apache/camel/example/client/CamelClientEndpoint.java @@ -52,7 +52,7 @@ public static void main(final String[] args) throws Exception { // we use the in out pattern for a synchronized exchange where we expect a response Exchange exchange = endpoint.createExchange(ExchangePattern.InOut); // set the input on the in body - // must you correct type to match the expected type of an Integer object + // must be correct type to match the expected type of an Integer object exchange.getIn().setBody(11); // to send the exchange we need an producer to do it for us diff --git a/examples/camel-example-spring-jms/src/main/resources/META-INF/spring/camel-server.xml b/examples/camel-example-spring-jms/src/main/resources/META-INF/spring/camel-server.xml index f70f77436f498..d162d2dc06627 100644 --- a/examples/camel-example-spring-jms/src/main/resources/META-INF/spring/camel-server.xml +++ b/examples/camel-example-spring-jms/src/main/resources/META-INF/spring/camel-server.xml @@ -26,7 +26,7 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd - http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core-5.5.0.xsd"> + http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd"> @@ -50,7 +50,7 @@ - + diff --git a/examples/camel-example-spring-jms/src/main/resources/camel-client.xml b/examples/camel-example-spring-jms/src/main/resources/camel-client.xml index e1b9be836ac4f..729cce301f07a 100644 --- a/examples/camel-example-spring-jms/src/main/resources/camel-client.xml +++ b/examples/camel-example-spring-jms/src/main/resources/camel-client.xml @@ -20,8 +20,10 @@ @@ -31,10 +33,14 @@ + + + - + diff --git a/examples/camel-example-spring-security/README.txt b/examples/camel-example-spring-security/README.txt index ec0a07313f8bd..fc5e6508a9880 100644 --- a/examples/camel-example-spring-security/README.txt +++ b/examples/camel-example-spring-security/README.txt @@ -18,7 +18,7 @@ To stop the server hit ctrl + c Then you can use the script in the client directory to send the request and check the response, or use browser to access upper urls with the user/password -("jim/jimspassword" with the admin and user role or "rob/robspassword" with user role). +("jim/jimspassword" with the admin and user role or "bob/bobspassword" with user role). This example is documented at http://camel.apache.org/spring-security-example.html diff --git a/examples/camel-example-spring-ws/README.txt b/examples/camel-example-spring-ws/README.txt index 89774659873a7..5d8e7c0806faa 100644 --- a/examples/camel-example-spring-ws/README.txt +++ b/examples/camel-example-spring-ws/README.txt @@ -4,10 +4,10 @@ Camel Spring Web Services Example This example shows how to expose a SOAP-based web service using Camel and Spring Web Services. The web service endpoint address is: - "http://localhost:8080/increment" + http://localhost:8080/increment The WSDL is available at: - "http://localhost:8080/increment/increment.wsdl" + http://localhost:8080/increment/increment.wsdl You will need to compile this example first: mvn clean install diff --git a/examples/camel-example-spring-xquery/src/data/message1.xml b/examples/camel-example-spring-xquery/src/data/message1.xml index 60724d8bb990f..f2158449f5676 100644 --- a/examples/camel-example-spring-xquery/src/data/message1.xml +++ b/examples/camel-example-spring-xquery/src/data/message1.xml @@ -1,20 +1,4 @@ - James Strachan diff --git a/examples/camel-example-spring/src/data/message1.xml b/examples/camel-example-spring/src/data/message1.xml index 60724d8bb990f..f2158449f5676 100644 --- a/examples/camel-example-spring/src/data/message1.xml +++ b/examples/camel-example-spring/src/data/message1.xml @@ -1,20 +1,4 @@ - James Strachan diff --git a/examples/camel-example-spring/src/data/message2.xml b/examples/camel-example-spring/src/data/message2.xml index 6a0e717a12e80..5caa1928fe174 100644 --- a/examples/camel-example-spring/src/data/message2.xml +++ b/examples/camel-example-spring/src/data/message2.xml @@ -1,20 +1,4 @@ - Hiram Chirino diff --git a/examples/camel-example-ssh/README.txt b/examples/camel-example-ssh/README.txt index c10a5624acd27..44847e12644f0 100644 --- a/examples/camel-example-ssh/README.txt +++ b/examples/camel-example-ssh/README.txt @@ -28,8 +28,9 @@ You will need to compile and install this example first: If using Apache Karaf / Apache ServiceMix you can install this example from the shell - > features:addurl mvn:org.apache.camel/camel-example-ssh//xml/features - > features:install camel-example-ssh + features:chooseurl camel + features:addurl mvn:org.apache.camel/camel-example-ssh//xml/features + features:install camel-example-ssh If you hit any problems please let us know on the Camel Forums http://camel.apache.org/discussion-forums.html diff --git a/examples/camel-example-tracer/README.txt b/examples/camel-example-tracer/README.txt index af519bd7b35fd..f3e6bf4a25c93 100644 --- a/examples/camel-example-tracer/README.txt +++ b/examples/camel-example-tracer/README.txt @@ -13,18 +13,6 @@ For a background in tracer and JPA see To run the example with Maven, type mvn camel:run -In the HSQL Database Explorer type - select * from camel_messagetraced - -to see the trace events of the Exchanges. Notice how the Exchange correlates with -fromNode/toNode so you exactly can see how a given Exchange was routed in Camel. - -Using the query: - select shortExchangeId, previousNode, toNode, body from camel_messagetraced order by id - -is a bit more easier to read as it uses the fields we are most interested in to see how Exchanges -was routed in Camel. - In the console you can enter some words separated with space. Try to enter: nice beer beer whiskey diff --git a/parent/pom.xml b/parent/pom.xml index 16f722c5d4a71..17edabdb75288 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -37,7 +37,7 @@ 1.1.3 5.8.0 - 1.7.12 + 1.7.13 1.7.0_6 3.4_1 3.4_2 @@ -154,7 +154,7 @@ 1.41.5.w1 1.41.1_1 14.0.1 - 2.1.1 + 2.1.3 2.2.2 3.0_1 3.0 @@ -197,6 +197,8 @@ 1.1.4 1.0.0.Final 1.5.7 + + 13.0.1 2.0 1.1_4 1.1.3 @@ -1545,6 +1547,11 @@ spring-tx ${spring-version} + + org.springframework + spring-expression + ${spring-version} + org.springframework.osgi spring-osgi-core diff --git a/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/cxf/blueprint/CxfRsBlueprintRouter.xml b/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/cxf/blueprint/CxfRsBlueprintRouter.xml index 7ce0cde270090..a55c5a7e8258f 100644 --- a/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/cxf/blueprint/CxfRsBlueprintRouter.xml +++ b/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/cxf/blueprint/CxfRsBlueprintRouter.xml @@ -25,11 +25,19 @@ + serviceClass="org.apache.camel.itest.osgi.cxf.jaxrs.testbean.CustomerService"> + + + + + serviceClass="org.apache.camel.itest.osgi.cxf.jaxrs.testbean.CustomerService"> + + + + diff --git a/tests/camel-itest/src/test/java/org/apache/camel/itest/issues/JettyHttpTest.java b/tests/camel-itest/src/test/java/org/apache/camel/itest/issues/JettyHttpTest.java index 3e18e57cb243a..6f8b614fae2d0 100644 --- a/tests/camel-itest/src/test/java/org/apache/camel/itest/issues/JettyHttpTest.java +++ b/tests/camel-itest/src/test/java/org/apache/camel/itest/issues/JettyHttpTest.java @@ -23,9 +23,6 @@ import org.apache.camel.test.junit4.CamelTestSupport; import org.junit.Test; -/** - * @version - */ public class JettyHttpTest extends CamelTestSupport { private String targetProducerUri = "http://localhost:8542/someservice?bridgeEndpoint=true&throwExceptionOnFailure=false"; @@ -60,7 +57,7 @@ public void configure() throws Exception { from(targetConsumerUri) .process(new Processor() { public void process(Exchange exchange) throws Exception { - String path = exchange.getIn().getHeader(Exchange.HTTP_PATH, String.class); + String path = exchange.getIn().getHeader(Exchange.HTTP_URI, String.class); exchange.getOut().setBody("Hi! " + path); } }); diff --git a/tooling/archetypes/camel-archetype-blueprint/src/main/resources/archetype-resources/ReadMe.txt b/tooling/archetypes/camel-archetype-blueprint/src/main/resources/archetype-resources/ReadMe.txt index 007f894ae1db2..85f50e63d217b 100644 --- a/tooling/archetypes/camel-archetype-blueprint/src/main/resources/archetype-resources/ReadMe.txt +++ b/tooling/archetypes/camel-archetype-blueprint/src/main/resources/archetype-resources/ReadMe.txt @@ -5,14 +5,14 @@ To build this project use mvn install -To run the example you can execute the following Maven goal +To run the project you can execute the following Maven goal mvn camel:run -To deploy the example in OSGi. For example using Apache ServiceMix -or Apache Karaf. You will run the following command from its shell: +To deploy the project in OSGi. For example using Apache ServiceMix +or Apache Karaf. You can run the following command from its shell: - osgi:install -s mvn:${groupId}/${artifactId} + osgi:install -s mvn:${groupId}/${artifactId}/${version} For more help see the Apache Camel documentation diff --git a/tooling/archetypes/camel-archetype-component-scala/src/main/resources/archetype-resources/ReadMe.txt b/tooling/archetypes/camel-archetype-component-scala/src/main/resources/archetype-resources/ReadMe.txt index 00317a97b80db..5fb6f5ae40295 100644 --- a/tooling/archetypes/camel-archetype-component-scala/src/main/resources/archetype-resources/ReadMe.txt +++ b/tooling/archetypes/camel-archetype-component-scala/src/main/resources/archetype-resources/ReadMe.txt @@ -1,6 +1,7 @@ Camel Component Project -==================== -This Project is a template of a Camel component using Scala. +======================= + +This project is a template of a Camel component using Scala. To build this project use @@ -10,6 +11,13 @@ For more help see the Apache Camel documentation: http://camel.apache.org/writing-components.html -Scala should only be used for Scala-related components such as Akka or Play framework. -See http://camel.465427.n5.nabble.com/Create-a-new-Camel-component-via-Scala-Component-Archetype-td5708543.html#a5711675 + +Notice: + +We favor writing Camel components in plain Java, which allows all people to consume and use the components easily. +Writing components in Scala is intended in situations when being used together with other Scala libraries such as Akka, Play, etc. + +See discussion at: + + http://camel.465427.n5.nabble.com/Create-a-new-Camel-component-via-Scala-Component-Archetype-td5708543.html#a5711675 diff --git a/tooling/archetypes/camel-archetype-component/src/main/resources/archetype-resources/ReadMe.txt b/tooling/archetypes/camel-archetype-component/src/main/resources/archetype-resources/ReadMe.txt index 678360574f5d0..f327e1e986c80 100644 --- a/tooling/archetypes/camel-archetype-component/src/main/resources/archetype-resources/ReadMe.txt +++ b/tooling/archetypes/camel-archetype-component/src/main/resources/archetype-resources/ReadMe.txt @@ -1,7 +1,7 @@ Camel Component Project ======================= -This Project is a template of a Camel component. +This project is a template of a Camel component. To build this project use diff --git a/tooling/archetypes/camel-archetype-dataformat/src/main/resources/archetype-resources/ReadMe.txt b/tooling/archetypes/camel-archetype-dataformat/src/main/resources/archetype-resources/ReadMe.txt index 63baeeecfa2e5..65be3fa23c54e 100644 --- a/tooling/archetypes/camel-archetype-dataformat/src/main/resources/archetype-resources/ReadMe.txt +++ b/tooling/archetypes/camel-archetype-dataformat/src/main/resources/archetype-resources/ReadMe.txt @@ -1,7 +1,7 @@ Camel Data Format Project ========================= -This Project is a template of a Camel data format. +This project is a template of a Camel data format. To build this project use @@ -9,5 +9,5 @@ To build this project use For more help see the Apache Camel documentation: - http://camel.apache.org/ + http://camel.apache.org/writing-components.html diff --git a/tooling/archetypes/camel-archetype-groovy/src/main/resources-filtered/META-INF/maven/archetype-metadata.xml b/tooling/archetypes/camel-archetype-groovy/src/main/resources-filtered/META-INF/maven/archetype-metadata.xml index 67b99548e5a3f..7d806d7b31ff6 100644 --- a/tooling/archetypes/camel-archetype-groovy/src/main/resources-filtered/META-INF/maven/archetype-metadata.xml +++ b/tooling/archetypes/camel-archetype-groovy/src/main/resources-filtered/META-INF/maven/archetype-metadata.xml @@ -24,6 +24,9 @@ ${project.version} + + ${exec-maven-plugin-version} + ${log4j-version} diff --git a/tooling/archetypes/camel-archetype-groovy/src/main/resources/archetype-resources/ReadMe.txt b/tooling/archetypes/camel-archetype-groovy/src/main/resources/archetype-resources/ReadMe.txt index 55b753a471324..0e40aff80c013 100644 --- a/tooling/archetypes/camel-archetype-groovy/src/main/resources/archetype-resources/ReadMe.txt +++ b/tooling/archetypes/camel-archetype-groovy/src/main/resources/archetype-resources/ReadMe.txt @@ -5,14 +5,10 @@ To build this project use mvn install -To run this example from within Maven use +To run this project from within Maven use mvn exec:java -From a web browser access the example using - - http://localhost:8080 - For more help see the Apache Camel documentation http://camel.apache.org/ diff --git a/tooling/archetypes/camel-archetype-groovy/src/main/resources/archetype-resources/pom.xml b/tooling/archetypes/camel-archetype-groovy/src/main/resources/archetype-resources/pom.xml index 87945588cca7c..ee8233fc37beb 100644 --- a/tooling/archetypes/camel-archetype-groovy/src/main/resources/archetype-resources/pom.xml +++ b/tooling/archetypes/camel-archetype-groovy/src/main/resources/archetype-resources/pom.xml @@ -128,6 +128,7 @@ org.codehaus.mojo exec-maven-plugin + ${exec-maven-plugin-version} ${package}.MainApp false diff --git a/tooling/archetypes/camel-archetype-java/src/main/resources-filtered/META-INF/maven/archetype-metadata.xml b/tooling/archetypes/camel-archetype-java/src/main/resources-filtered/META-INF/maven/archetype-metadata.xml index 30160465149d8..99401b88355d6 100644 --- a/tooling/archetypes/camel-archetype-java/src/main/resources-filtered/META-INF/maven/archetype-metadata.xml +++ b/tooling/archetypes/camel-archetype-java/src/main/resources-filtered/META-INF/maven/archetype-metadata.xml @@ -24,6 +24,9 @@ ${project.version} + + ${exec-maven-plugin-version} + ${log4j-version} diff --git a/tooling/archetypes/camel-archetype-java/src/main/resources/archetype-resources/ReadMe.txt b/tooling/archetypes/camel-archetype-java/src/main/resources/archetype-resources/ReadMe.txt index 2487d6e46e42a..130f13429fe41 100644 --- a/tooling/archetypes/camel-archetype-java/src/main/resources/archetype-resources/ReadMe.txt +++ b/tooling/archetypes/camel-archetype-java/src/main/resources/archetype-resources/ReadMe.txt @@ -5,7 +5,7 @@ To build this project use mvn install -To run this example from within Maven use +To run this project from within Maven use mvn exec:java diff --git a/tooling/archetypes/camel-archetype-java/src/main/resources/archetype-resources/pom.xml b/tooling/archetypes/camel-archetype-java/src/main/resources/archetype-resources/pom.xml index d201db5a0b1e5..2304077dec7a7 100644 --- a/tooling/archetypes/camel-archetype-java/src/main/resources/archetype-resources/pom.xml +++ b/tooling/archetypes/camel-archetype-java/src/main/resources/archetype-resources/pom.xml @@ -90,6 +90,7 @@ org.codehaus.mojo exec-maven-plugin + ${exec-maven-plugin-version} ${package}.MainApp false diff --git a/tooling/archetypes/camel-archetype-java/src/main/resources/archetype-resources/src/main/java/MyRouteBuilder.java b/tooling/archetypes/camel-archetype-java/src/main/resources/archetype-resources/src/main/java/MyRouteBuilder.java index 86aa5b4fcb884..16c191efd526c 100644 --- a/tooling/archetypes/camel-archetype-java/src/main/resources/archetype-resources/src/main/java/MyRouteBuilder.java +++ b/tooling/archetypes/camel-archetype-java/src/main/resources/archetype-resources/src/main/java/MyRouteBuilder.java @@ -34,8 +34,10 @@ public void configure() { from("file:src/data?noop=true") .choice() .when(xpath("/person/city = 'London'")) + .log("UK message") .to("file:target/messages/uk") .otherwise() + .log("Other message") .to("file:target/messages/others"); } diff --git a/tooling/archetypes/camel-archetype-scala/src/main/resources/archetype-resources/ReadMe.txt b/tooling/archetypes/camel-archetype-scala/src/main/resources/archetype-resources/ReadMe.txt index dd27a9db8cc13..5806db3cd36d8 100644 --- a/tooling/archetypes/camel-archetype-scala/src/main/resources/archetype-resources/ReadMe.txt +++ b/tooling/archetypes/camel-archetype-scala/src/main/resources/archetype-resources/ReadMe.txt @@ -5,7 +5,7 @@ To build this project use mvn install -To run this example +To run this project mvn exec:java diff --git a/tooling/archetypes/camel-archetype-spring-dm/src/main/resources/archetype-resources/ReadMe.txt b/tooling/archetypes/camel-archetype-spring-dm/src/main/resources/archetype-resources/ReadMe.txt index aea5809d01c96..5bf30807c17c6 100644 --- a/tooling/archetypes/camel-archetype-spring-dm/src/main/resources/archetype-resources/ReadMe.txt +++ b/tooling/archetypes/camel-archetype-spring-dm/src/main/resources/archetype-resources/ReadMe.txt @@ -5,15 +5,14 @@ To build this project use mvn install -You can run this example from the command line using -the following Maven goal: +You can run this project using he following Maven goal: mvn camel:run -To deploy the example in OSGi. For example using Apache ServiceMix +To deploy the project in OSGi. For example using Apache ServiceMix or Apache Karaf. You will run the following command from its shell: - osgi:install -s mvn:${groupId}/${artifactId} + osgi:install -s mvn:${groupId}/${artifactId}/${version} For more help see the Apache Camel documentation diff --git a/tooling/archetypes/camel-archetype-spring/src/main/resources/archetype-resources/ReadMe.txt b/tooling/archetypes/camel-archetype-spring/src/main/resources/archetype-resources/ReadMe.txt index 7d3750a1d39b8..3d20ae801b717 100644 --- a/tooling/archetypes/camel-archetype-spring/src/main/resources/archetype-resources/ReadMe.txt +++ b/tooling/archetypes/camel-archetype-spring/src/main/resources/archetype-resources/ReadMe.txt @@ -5,8 +5,7 @@ To build this project use mvn install -To run this example either embed the jar inside Spring -or to run the route from within Maven try +To run this project with Maven use mvn camel:run