Author: bvahdat Date: Fri Mar 9 10:17:47 2012 New Revision: 1298780 URL: http://svn.apache.org/viewvc?rev=1298780&view=rev Log: CAMEL-5068: Allow to configure cache option on propertiesPlaceholder in XML DSL.
Added: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/properties/SpringPropertiesComponentCacheDisabledTest.java (with props) camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/properties/SpringPropertiesComponentCacheDisabledTest.xml (with props) Modified: camel/trunk/components/camel-blueprint/src/test/java/org/apache/camel/blueprint/BlueprintJaxbTest.java camel/trunk/components/camel-blueprint/src/test/resources/test.xml camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/CamelPropertyPlaceholderDefinition.java Modified: camel/trunk/components/camel-blueprint/src/test/java/org/apache/camel/blueprint/BlueprintJaxbTest.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-blueprint/src/test/java/org/apache/camel/blueprint/BlueprintJaxbTest.java?rev=1298780&r1=1298779&r2=1298780&view=diff ============================================================================== --- camel/trunk/components/camel-blueprint/src/test/java/org/apache/camel/blueprint/BlueprintJaxbTest.java (original) +++ camel/trunk/components/camel-blueprint/src/test/java/org/apache/camel/blueprint/BlueprintJaxbTest.java Fri Mar 9 10:17:47 2012 @@ -27,6 +27,7 @@ import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.apache.camel.blueprint.handler.CamelNamespaceHandler; + import org.junit.Test; import static org.junit.Assert.assertEquals; @@ -70,5 +71,7 @@ public class BlueprintJaxbTest { assertEquals(1, ((CamelContextFactoryBean) object).getRoutes().get(0).getInputs().size()); assertNotNull(((CamelContextFactoryBean) object).getRoutes().get(0).getOutputs()); assertEquals(1, ((CamelContextFactoryBean) object).getRoutes().get(0).getOutputs().size()); + assertTrue(((CamelContextFactoryBean) object).getCamelPropertyPlaceholder().isCache()); + assertTrue(((CamelContextFactoryBean) object).getCamelPropertyPlaceholder().isIgnoreMissingLocation()); } } Modified: camel/trunk/components/camel-blueprint/src/test/resources/test.xml URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-blueprint/src/test/resources/test.xml?rev=1298780&r1=1298779&r2=1298780&view=diff ============================================================================== --- camel/trunk/components/camel-blueprint/src/test/resources/test.xml (original) +++ camel/trunk/components/camel-blueprint/src/test/resources/test.xml Fri Mar 9 10:17:47 2012 @@ -20,6 +20,7 @@ <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"> <camelContext xmlns="http://camel.apache.org/schema/blueprint"> + <propertyPlaceholder cache="true" ignoreMissingLocation="true" location="classpath:org/apache/camel/component/properties/cheese.properties"/> <route> <from uri="timer:test"/> <to uri="log:test"/> @@ -27,4 +28,3 @@ </camelContext> </blueprint> - Modified: camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java?rev=1298780&r1=1298779&r2=1298780&view=diff ============================================================================== --- camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java (original) +++ camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java Fri Mar 9 10:17:47 2012 @@ -396,6 +396,10 @@ public abstract class AbstractCamelConte PropertiesComponent pc = new PropertiesComponent(); pc.setLocation(def.getLocation()); + if (def.isCache() != null) { + pc.setCache(def.isCache()); + } + if (def.isIgnoreMissingLocation() != null) { pc.setIgnoreMissingLocation(def.isIgnoreMissingLocation()); } Modified: camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/CamelPropertyPlaceholderDefinition.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/CamelPropertyPlaceholderDefinition.java?rev=1298780&r1=1298779&r2=1298780&view=diff ============================================================================== --- camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/CamelPropertyPlaceholderDefinition.java (original) +++ camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/CamelPropertyPlaceholderDefinition.java Fri Mar 9 10:17:47 2012 @@ -36,6 +36,9 @@ public class CamelPropertyPlaceholderDef private String location; @XmlAttribute + private Boolean cache; + + @XmlAttribute private Boolean ignoreMissingLocation; @XmlAttribute @@ -67,6 +70,14 @@ public class CamelPropertyPlaceholderDef this.location = location; } + public Boolean isCache() { + return cache; + } + + public void setCache(Boolean cache) { + this.cache = cache; + } + public String getPropertiesResolverRef() { return propertiesResolverRef; } Added: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/properties/SpringPropertiesComponentCacheDisabledTest.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/properties/SpringPropertiesComponentCacheDisabledTest.java?rev=1298780&view=auto ============================================================================== --- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/properties/SpringPropertiesComponentCacheDisabledTest.java (added) +++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/properties/SpringPropertiesComponentCacheDisabledTest.java Fri Mar 9 10:17:47 2012 @@ -0,0 +1,40 @@ +/** + * 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.springframework.context.support.AbstractXmlApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; + +/** + * @version + */ +public class SpringPropertiesComponentCacheDisabledTest extends SpringPropertiesComponentTest { + + @Override + protected AbstractXmlApplicationContext createApplicationContext() { + return new ClassPathXmlApplicationContext("org/apache/camel/component/properties/SpringPropertiesComponentCacheDisabledTest.xml"); + } + + @Override + protected void tearDown() throws Exception { + PropertiesComponent component = context.getComponent("properties", PropertiesComponent.class); + assertFalse("Cache should be disabled", component.isCache()); + + super.tearDown(); + } + +} \ No newline at end of file Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/properties/SpringPropertiesComponentCacheDisabledTest.java ------------------------------------------------------------------------------ svn:eol-style = native Added: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/properties/SpringPropertiesComponentCacheDisabledTest.xml URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/properties/SpringPropertiesComponentCacheDisabledTest.xml?rev=1298780&view=auto ============================================================================== --- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/properties/SpringPropertiesComponentCacheDisabledTest.xml (added) +++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/properties/SpringPropertiesComponentCacheDisabledTest.xml Fri Mar 9 10:17:47 2012 @@ -0,0 +1,49 @@ +<?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.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="classpath:org/apache/camel/component/properties/cheese.properties" + cache="false" prefixToken="[[" suffixToken="]]" propertyPrefix="cool." xmlns="http://camel.apache.org/schema/spring" /> + + <route> + <from uri="direct:start" /> + <to uri="properties:[[end]]" /> + </route> + + <route> + <from uri="direct:bar" /> + <to uri="properties:mock:[[bar]]" /> + </route> + + <route> + <from uri="direct:start2" /> + <to uri="[[end]]" /> + </route> + + <route> + <from uri="direct:bar2" /> + <to uri="mock:[[bar]]" /> + </route> + </camelContext> + +</beans> Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/properties/SpringPropertiesComponentCacheDisabledTest.xml ------------------------------------------------------------------------------ svn:eol-style = native