Author: davsclaus Date: Fri Feb 19 14:09:58 2010 New Revision: 911816 URL: http://svn.apache.org/viewvc?rev=911816&view=rev Log: CAMEL-2358: package and packageScan now supports property placeholders.
Added: camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelPropertyPlaceholderDefinition.java (with props) camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/properties/SpringPackagePropertiesTest.java (with props) camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/properties/SpringPackageScanPropertiesTest.java (with props) camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/properties/route/ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/properties/route/SpringSimpleRoute.java (with props) camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/properties/SpringPackagePropertiesTest.xml - copied, changed from r911715, camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/properties/SpringPropertiesResolverTest.xml camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/properties/SpringPackageScanPropertiesTest.xml (with props) camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/properties/myprop.properties - copied, changed from r911715, camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/properties/cheese.properties Removed: camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelPropertiesComponentFactoryBean.java Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContext.java camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java camel/trunk/components/camel-spring/src/main/resources/org/apache/camel/spring/jaxb.index camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/scan/SpringComponentScanTest.java camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/properties/SpringPropertiesComponent2Test.xml camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/properties/SpringPropertiesResolver2Test.xml Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContext.java URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContext.java?rev=911816&r1=911815&r2=911816&view=diff ============================================================================== --- camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContext.java (original) +++ camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContext.java Fri Feb 19 14:09:58 2010 @@ -403,6 +403,15 @@ Language resolveLanguage(String language); /** + * Parses the given text and resolve any property placeholders - using #{key}. + * + * @param text the text such as an endpoint uri or the likes + * @return the text with resolved property placeholders + * @throws Exception is thrown if property placeholders was used and there was an error resolving them + */ + String resolvePropertyPlaceholders(String text) throws Exception; + + /** * Gets a readonly list with the names of the languages currently registered. * * @return a readonly list with the names of the the languages Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java?rev=911816&r1=911815&r2=911816&view=diff ============================================================================== --- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java (original) +++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java Fri Feb 19 14:09:58 2010 @@ -685,6 +685,26 @@ return answer; } + public String resolvePropertyPlaceholders(String uri) throws Exception { + // do not parse uris that are designated for the properties component as it will handle that itself + if (!uri.startsWith("properties:") && uri.contains("#{")) { + // the uri contains property placeholders so lookup mandatory properties component and let it parse it + Component component = hasComponent("properties"); + if (component == null) { + throw new IllegalArgumentException("PropertiesComponent with name properties must be defined" + + " in CamelContext to support property placeholders in endpoint URIs"); + } + PropertiesComponent pc = getTypeConverter().mandatoryConvertTo(PropertiesComponent.class, component); + // the parser will throw exception if property key was not found + String answer = pc.parseUri(uri); + if (LOG.isDebugEnabled()) { + LOG.debug("Resolved uri: " + uri + " --> " + answer); + } + return answer; + } + return uri; + } + // Properties // ----------------------------------------------------------------------- @@ -1511,26 +1531,6 @@ return answer; } - protected String resolvePropertyPlaceholders(String uri) throws Exception { - // do not parse uris that are designated for the properties component as it will handle that itself - if (!uri.startsWith("properties:") && uri.contains("#{")) { - // the uri contains property placeholders so lookup mandatory properties component and let it parse it - Component component = hasComponent("properties"); - if (component == null) { - throw new IllegalArgumentException("PropertiesComponent with name properties must be defined" - + " in CamelContext to support property placeholders in endpoint URIs"); - } - PropertiesComponent pc = getTypeConverter().mandatoryConvertTo(PropertiesComponent.class, component); - // the parser will throw exception if property key was not found - String answer = pc.parseUri(uri); - if (LOG.isDebugEnabled()) { - LOG.debug("Resolved uri: " + uri + " --> " + answer); - } - return answer; - } - return uri; - } - @Override public String toString() { return "CamelContext(" + getName() + ")"; Modified: camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java?rev=911816&r1=911815&r2=911816&view=diff ============================================================================== --- camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java (original) +++ camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java Fri Feb 19 14:09:58 2010 @@ -19,7 +19,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; - import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAttribute; @@ -28,12 +27,15 @@ import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlTransient; +import org.apache.camel.CamelContext; import org.apache.camel.CamelException; import org.apache.camel.RoutesBuilder; import org.apache.camel.ShutdownRoute; import org.apache.camel.ShutdownRunningTask; import org.apache.camel.builder.ErrorHandlerBuilderRef; import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.properties.PropertiesComponent; +import org.apache.camel.component.properties.PropertiesResolver; import org.apache.camel.management.DefaultManagementAgent; import org.apache.camel.management.DefaultManagementLifecycleStrategy; import org.apache.camel.management.DefaultManagementStrategy; @@ -70,6 +72,7 @@ import org.apache.camel.spi.PackageScanClassResolver; import org.apache.camel.spi.Registry; import org.apache.camel.spi.ShutdownStrategy; +import org.apache.camel.util.CamelContextHelper; import org.apache.camel.util.EndpointHelper; import org.apache.camel.util.ObjectHelper; import org.apache.commons.logging.Log; @@ -117,6 +120,8 @@ private ShutdownRunningTask shutdownRunningTask; @XmlElement(name = "properties", required = false) private PropertiesDefinition properties; + @XmlElement(name = "propertyPlaceholder", type = CamelPropertyPlaceholderDefinition.class, required = false) + private CamelPropertyPlaceholderDefinition camelPropertyPlaceholder; @XmlElement(name = "package", required = false) private String[] packages = {}; @XmlElement(name = "packageScan", type = PackageScanDefinition.class, required = false) @@ -124,7 +129,6 @@ @XmlElement(name = "jmxAgent", type = CamelJMXAgentDefinition.class, required = false) private CamelJMXAgentDefinition camelJMXAgent; @XmlElements({ - @XmlElement(name = "propertyPlaceholder", type = CamelPropertiesComponentFactoryBean.class, required = false), @XmlElement(name = "beanPostProcessor", type = CamelBeanPostProcessor.class, required = false), @XmlElement(name = "template", type = CamelProducerTemplateFactoryBean.class, required = false), @XmlElement(name = "consumerTemplate", type = CamelConsumerTemplateFactoryBean.class, required = false), @@ -213,6 +217,9 @@ getContext().setRegistry(registry); } + // setup property placeholder so we got it as early as possible + initPropertyPlaceholder(); + Tracer tracer = getBeanForType(Tracer.class); if (tracer != null) { // use formatter if there is a TraceFormatter bean defined @@ -565,6 +572,25 @@ } } + private void initPropertyPlaceholder() throws Exception { + if (getCamelPropertyPlaceholder() != null) { + CamelPropertyPlaceholderDefinition def = getCamelPropertyPlaceholder(); + + PropertiesComponent pc = new PropertiesComponent(); + pc.setLocation(def.getLocation()); + + // if using a custom resolver + if (ObjectHelper.isNotEmpty(def.getPropertiesResolverRef())) { + PropertiesResolver resolver = CamelContextHelper.mandatoryLookup(getContext(), def.getPropertiesResolverRef(), + PropertiesResolver.class); + pc.setPropertiesResolver(resolver); + } + + // register the properties component + getContext().addComponent("properties", pc); + } + } + @SuppressWarnings("unchecked") private <T> T getBeanForType(Class<T> clazz) { T bean = null; @@ -708,6 +734,14 @@ this.packageScan = packageScan; } + public CamelPropertyPlaceholderDefinition getCamelPropertyPlaceholder() { + return camelPropertyPlaceholder; + } + + public void setCamelPropertyPlaceholder(CamelPropertyPlaceholderDefinition camelPropertyPlaceholder) { + this.camelPropertyPlaceholder = camelPropertyPlaceholder; + } + public void setBeanPostProcessor(BeanPostProcessor postProcessor) { this.beanPostProcessor = postProcessor; } @@ -917,11 +951,18 @@ if (packageScanDef != null && packageScanDef.getPackages().size() > 0) { // use package scan filter PatternBasedPackageScanFilter filter = new PatternBasedPackageScanFilter(); - filter.addIncludePatterns(packageScanDef.getIncludes()); - filter.addExcludePatterns(packageScanDef.getExcludes()); + // support property placeholders in include and exclude + for (String include : packageScanDef.getIncludes()) { + include = getContext().resolvePropertyPlaceholders(include); + filter.addIncludePattern(include); + } + for (String exclude : packageScanDef.getExcludes()) { + exclude = getContext().resolvePropertyPlaceholders(exclude); + filter.addExcludePattern(exclude); + } resolver.addFilter(filter); - String[] normalized = normalizePackages(packageScanDef.getPackages()); + String[] normalized = normalizePackages(getContext(), packageScanDef.getPackages()); RouteBuilderFinder finder = new RouteBuilderFinder(getContext(), normalized, getContextClassLoaderOnStart(), getBeanPostProcessor(), getContext().getPackageScanClassResolver()); finder.appendBuilders(builders); @@ -943,9 +984,11 @@ } } - private String[] normalizePackages(List<String> unnormalized) { + private String[] normalizePackages(CamelContext context, List<String> unnormalized) throws Exception { List<String> packages = new ArrayList<String>(); for (String name : unnormalized) { + // it may use property placeholders + name = context.resolvePropertyPlaceholders(name); name = ObjectHelper.normalizeClassName(name); if (ObjectHelper.isNotEmpty(name)) { if (LOG.isTraceEnabled()) { Added: camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelPropertyPlaceholderDefinition.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelPropertyPlaceholderDefinition.java?rev=911816&view=auto ============================================================================== --- camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelPropertyPlaceholderDefinition.java (added) +++ camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelPropertyPlaceholderDefinition.java Fri Feb 19 14:09:58 2010 @@ -0,0 +1,57 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.spring; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlRootElement; + +import org.apache.camel.model.IdentifiedType; + +/** + * <code>PropertyPlaceholderDefinition</code> represents a <propertyPlaceholder/> element. + * + * @version $Revision$ + */ +...@xmlrootelement(name = "propertyPlaceholder") +...@xmlaccessortype(XmlAccessType.FIELD) +public class CamelPropertyPlaceholderDefinition extends IdentifiedType { + + @XmlAttribute(required = true) + private String location; + + @XmlAttribute + private String propertiesResolverRef; + + public String getLocation() { + return location; + } + + public void setLocation(String location) { + this.location = location; + } + + public String getPropertiesResolverRef() { + return propertiesResolverRef; + } + + public void setPropertiesResolverRef(String propertiesResolverRef) { + this.propertiesResolverRef = propertiesResolverRef; + } + +} Propchange: camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelPropertyPlaceholderDefinition.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelPropertyPlaceholderDefinition.java ------------------------------------------------------------------------------ svn:keywords = Rev Date Modified: camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java?rev=911816&r1=911815&r2=911816&view=diff ============================================================================== --- camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java (original) +++ camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java Fri Feb 19 14:09:58 2010 @@ -26,6 +26,7 @@ import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; +import org.apache.camel.spring.CamelPropertyPlaceholderDefinition; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; @@ -41,7 +42,6 @@ import org.apache.camel.spring.CamelEndpointFactoryBean; import org.apache.camel.spring.CamelJMXAgentDefinition; import org.apache.camel.spring.CamelProducerTemplateFactoryBean; -import org.apache.camel.spring.CamelPropertiesComponentFactoryBean; import org.apache.camel.spring.remoting.CamelProxyFactoryBean; import org.apache.camel.spring.remoting.CamelServiceExporter; import org.apache.camel.util.ObjectHelper; @@ -73,7 +73,7 @@ public static void renameNamespaceRecursive(Node node) { if (node.getNodeType() == Node.ELEMENT_NODE) { Document doc = node.getOwnerDocument(); - if (((Element) node).getNamespaceURI().startsWith(SPRING_NS + "/v")) { + if ((node).getNamespaceURI().startsWith(SPRING_NS + "/v")) { doc.renameNode(node, SPRING_NS, node.getNodeName()); } } @@ -88,18 +88,15 @@ } public void init() { - addBeanDefinitionParser("proxy", CamelProxyFactoryBean.class, true); addBeanDefinitionParser("template", CamelProducerTemplateFactoryBean.class, true); addBeanDefinitionParser("consumerTemplate", CamelConsumerTemplateFactoryBean.class, true); addBeanDefinitionParser("export", CamelServiceExporter.class, true); - addBeanDefinitionParser("propertyPlaceholder", CamelPropertiesComponentFactoryBean.class, true); + addBeanDefinitionParser("endpoint", CamelEndpointFactoryBean.class, true); - // jmx agent cannot be used outside of the camel context + // jmx agent and property placeholder cannot be used outside of the camel context addBeanDefinitionParser("jmxAgent", CamelJMXAgentDefinition.class, false); - - // endpoint - addBeanDefinitionParser("endpoint", CamelEndpointFactoryBean.class, true); + addBeanDefinitionParser("propertyPlaceholder", CamelPropertyPlaceholderDefinition.class, false); // camel context boolean osgi = false; @@ -109,7 +106,7 @@ osgi = true; } catch (Throwable t) { // not running with camel-osgi so we fallback to the regular factory bean - LOG.trace("Cannot find class so assuming not running in OSGI container: " + t.getMessage()); + LOG.trace("Cannot find class so assuming not running in OSGi container: " + t.getMessage()); } if (osgi) { @@ -230,6 +227,8 @@ if (factoryBean.getPackages().length > 0) { builder.addPropertyValue("packages", factoryBean.getPackages()); } + builder.addPropertyValue("camelPropertyPlaceholder", factoryBean.getCamelPropertyPlaceholder()); + builder.addPropertyValue("camelJMXAgent", factoryBean.getCamelJMXAgent()); } boolean createdBeanPostProcessor = false; @@ -252,13 +251,9 @@ String id = childElement.getAttribute("id"); if (ObjectHelper.isNotEmpty(id)) { parserContext.registerComponent(new BeanComponentDefinition(definition, id)); - if (localName.equals("jmxAgent")) { - builder.addPropertyReference("camelJMXAgent", id); - } - // set the templates with the camel context + // set the templates with the camel context if (localName.equals("template") || localName.equals("consumerTemplate") - || localName.equals("proxy") || localName.equals("export") - || localName.equals("propertyPlaceholder")) { + || localName.equals("proxy") || localName.equals("export")) { // set the camel context definition.getPropertyValues().addPropertyValue("camelContext", new RuntimeBeanReference(contextId)); } @@ -351,7 +346,7 @@ } } - // either we have not used templat before or we have auto registered it already and therefore we + // either we have not used template before or we have auto registered it already and therefore we // need it to allow to do it so it can remove the existing auto registered as there is now a clash id // since we have multiple camel contexts boolean canDoTemplate = autoRegisterMap.get("template") != null @@ -368,7 +363,7 @@ autoRegisterBeanDefinition(id, definition, parserContext, contextId); } - // either we have not used templat before or we have auto registered it already and therefore we + // either we have not used template before or we have auto registered it already and therefore we // need it to allow to do it so it can remove the existing auto registered as there is now a clash id // since we have multiple camel contexts boolean canDoConsumerTemplate = autoRegisterMap.get("consumerTemplate") != null Modified: camel/trunk/components/camel-spring/src/main/resources/org/apache/camel/spring/jaxb.index URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/main/resources/org/apache/camel/spring/jaxb.index?rev=911816&r1=911815&r2=911816&view=diff ============================================================================== --- camel/trunk/components/camel-spring/src/main/resources/org/apache/camel/spring/jaxb.index (original) +++ camel/trunk/components/camel-spring/src/main/resources/org/apache/camel/spring/jaxb.index Fri Feb 19 14:09:58 2010 @@ -20,6 +20,6 @@ CamelEndpointFactoryBean CamelJMXAgentDefinition CamelProducerTemplateFactoryBean -CamelPropertiesComponentFactoryBean +CamelPropertyPlaceholderDefinition CamelProxyFactoryDefinition CamelServiceExporterDefinition Added: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/properties/SpringPackagePropertiesTest.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/properties/SpringPackagePropertiesTest.java?rev=911816&view=auto ============================================================================== --- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/properties/SpringPackagePropertiesTest.java (added) +++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/properties/SpringPackagePropertiesTest.java Fri Feb 19 14:09:58 2010 @@ -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.properties; + +import org.apache.camel.spring.SpringTestSupport; +import org.springframework.context.support.AbstractXmlApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; + +/** + * @version $Revision$ + */ +public class SpringPackagePropertiesTest extends SpringTestSupport { + + @Override + protected AbstractXmlApplicationContext createApplicationContext() { + return new ClassPathXmlApplicationContext("org/apache/camel/component/properties/SpringPackagePropertiesTest.xml"); + } + + public void testSpringPackageProperties() throws Exception { + getMockEndpoint("#{result}").expectedMessageCount(1); + + template.sendBody("direct:start", "Hello World"); + + assertMockEndpointsSatisfied(); + } + +} Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/properties/SpringPackagePropertiesTest.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/properties/SpringPackagePropertiesTest.java ------------------------------------------------------------------------------ svn:keywords = Rev Date Added: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/properties/SpringPackageScanPropertiesTest.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/properties/SpringPackageScanPropertiesTest.java?rev=911816&view=auto ============================================================================== --- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/properties/SpringPackageScanPropertiesTest.java (added) +++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/properties/SpringPackageScanPropertiesTest.java Fri Feb 19 14:09:58 2010 @@ -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.properties; + +import org.apache.camel.spring.SpringTestSupport; +import org.springframework.context.support.AbstractXmlApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; + +/** + * @version $Revision$ + */ +public class SpringPackageScanPropertiesTest extends SpringTestSupport { + + @Override + protected AbstractXmlApplicationContext createApplicationContext() { + return new ClassPathXmlApplicationContext("org/apache/camel/component/properties/SpringPackageScanPropertiesTest.xml"); + } + + public void testSpringPackageProperties() throws Exception { + getMockEndpoint("#{result}").expectedMessageCount(1); + + template.sendBody("direct:start", "Hello World"); + + assertMockEndpointsSatisfied(); + } + +} \ No newline at end of file Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/properties/SpringPackageScanPropertiesTest.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/properties/SpringPackageScanPropertiesTest.java ------------------------------------------------------------------------------ svn:keywords = Rev Date Added: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/properties/route/SpringSimpleRoute.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/properties/route/SpringSimpleRoute.java?rev=911816&view=auto ============================================================================== --- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/properties/route/SpringSimpleRoute.java (added) +++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/properties/route/SpringSimpleRoute.java Fri Feb 19 14:09:58 2010 @@ -0,0 +1,31 @@ +/** + * 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.properties.route; + +import org.apache.camel.spring.SpringRouteBuilder; + +/** + * @version $Revision$ + */ +public class SpringSimpleRoute extends SpringRouteBuilder { + + @Override + public void configure() throws Exception { + from("direct:start").to("#{result}"); + } + +} Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/properties/route/SpringSimpleRoute.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/properties/route/SpringSimpleRoute.java ------------------------------------------------------------------------------ svn:keywords = Rev Date Modified: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/scan/SpringComponentScanTest.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/scan/SpringComponentScanTest.java?rev=911816&r1=911815&r2=911816&view=diff ============================================================================== --- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/scan/SpringComponentScanTest.java (original) +++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/scan/SpringComponentScanTest.java Fri Feb 19 14:09:58 2010 @@ -14,7 +14,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.apache.camel.spring.config.scan; import java.util.concurrent.TimeUnit; @@ -33,7 +32,6 @@ ApplicationContext c = new ClassPathXmlApplicationContext("org/apache/camel/spring/config/scan/componentScan.xml"); context = (CamelContext)c.getBean("camelContext"); template = context.createProducerTemplate(); - } public void testExcludedRoute() throws InterruptedException { Copied: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/properties/SpringPackagePropertiesTest.xml (from r911715, camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/properties/SpringPropertiesResolverTest.xml) URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/properties/SpringPackagePropertiesTest.xml?p2=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/properties/SpringPackagePropertiesTest.xml&p1=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/properties/SpringPropertiesResolverTest.xml&r1=911715&r2=911816&rev=911816&view=diff ============================================================================== --- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/properties/SpringPropertiesResolverTest.xml (original) +++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/properties/SpringPackagePropertiesTest.xml Fri Feb 19 14:09:58 2010 @@ -22,18 +22,10 @@ http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd "> - <bean id="myResolver" class="org.apache.camel.component.properties.PropertiesResolverTest$MyCustomResolver"/> - - <bean id="properties" class="org.apache.camel.component.properties.PropertiesComponent"> - <property name="location" value="foo"/> - <property name="propertiesResolver" ref="myResolver"/> - </bean> - <camelContext xmlns="http://camel.apache.org/schema/spring"> - <route> - <from uri="direct:start"/> - <to uri="properties:#{foo}"/> - </route> + <propertyPlaceholder id="properties" location="org/apache/camel/component/properties/myprop.properties"/> + <package>#{routebuilders}</package> + <jmxAgent id="agent"/> </camelContext> </beans> Added: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/properties/SpringPackageScanPropertiesTest.xml URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/properties/SpringPackageScanPropertiesTest.xml?rev=911816&view=auto ============================================================================== --- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/properties/SpringPackageScanPropertiesTest.xml (added) +++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/properties/SpringPackageScanPropertiesTest.xml Fri Feb 19 14:09:58 2010 @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation=" + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd + http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd + "> + + <camelContext xmlns="http://camel.apache.org/schema/spring"> + <propertyPlaceholder id="properties" location="org/apache/camel/component/properties/myprop.properties"/> + <packageScan> + <package>org.apache.camel.#{routescan}</package> + <includes>#{routeincludes}</includes> + </packageScan> + <jmxAgent id="agent"/> + </camelContext> + +</beans> Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/properties/SpringPackageScanPropertiesTest.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/properties/SpringPackageScanPropertiesTest.xml ------------------------------------------------------------------------------ svn:keywords = Rev Date Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/properties/SpringPackageScanPropertiesTest.xml ------------------------------------------------------------------------------ svn:mime-type = text/xml Modified: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/properties/SpringPropertiesComponent2Test.xml URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/properties/SpringPropertiesComponent2Test.xml?rev=911816&r1=911815&r2=911816&view=diff ============================================================================== --- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/properties/SpringPropertiesComponent2Test.xml (original) +++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/properties/SpringPropertiesComponent2Test.xml Fri Feb 19 14:09:58 2010 @@ -22,12 +22,12 @@ http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd "> - <propertyPlaceholder id="properties" - location="classpath:org/apache/camel/component/properties/cheese.properties" - xmlns="http://camel.apache.org/schema/spring"/> - <camelContext xmlns="http://camel.apache.org/schema/spring"> + <propertyPlaceholder id="properties" + location="classpath:org/apache/camel/component/properties/cheese.properties" + xmlns="http://camel.apache.org/schema/spring"/> + <route> <from uri="direct:start"/> <to uri="properties:#{cool.end}"/> Modified: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/properties/SpringPropertiesResolver2Test.xml URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/properties/SpringPropertiesResolver2Test.xml?rev=911816&r1=911815&r2=911816&view=diff ============================================================================== --- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/properties/SpringPropertiesResolver2Test.xml (original) +++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/properties/SpringPropertiesResolver2Test.xml Fri Feb 19 14:09:58 2010 @@ -24,12 +24,10 @@ <bean id="myResolver" class="org.apache.camel.component.properties.PropertiesResolverTest$MyCustomResolver"/> - <propertyPlaceholder id="properties" - location="foo" - propertiesResolverRef="myResolver" - xmlns="http://camel.apache.org/schema/spring"/> - <camelContext xmlns="http://camel.apache.org/schema/spring"> + <propertyPlaceholder id="properties" + location="foo" + propertiesResolverRef="myResolver"/> <route> <from uri="direct:start"/> <to uri="properties:#{foo}"/> Copied: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/properties/myprop.properties (from r911715, camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/properties/cheese.properties) URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/properties/myprop.properties?p2=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/properties/myprop.properties&p1=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/properties/cheese.properties&r1=911715&r2=911816&rev=911816&view=diff ============================================================================== --- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/properties/cheese.properties (original) +++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/properties/myprop.properties Fri Feb 19 14:09:58 2010 @@ -15,5 +15,7 @@ ## limitations under the License. ## ------------------------------------------------------------------------ -cool.end=mock:result -cool.bar=bar \ No newline at end of file +routebuilders=org.apache.camel.component.properties.route +routescan=component.properties.route +routeincludes=*Simple* +result=mock:result \ No newline at end of file