Hi Willem

Please try to avoid backporting to much when you fix something in 1.x.
Its important that we keep 1.x as the same as much as possible.
For example you have just backported # lookup in 1.x which then is not
a documented feature and a feature we DO NOT want to support on 1.x.

So could you please revisit and fix it without the # lookup in 1.x


On Mon, Feb 1, 2010 at 1:52 PM,  <ningji...@apache.org> wrote:
> Author: ningjiang
> Date: Mon Feb  1 12:52:16 2010
> New Revision: 905273
>
> URL: http://svn.apache.org/viewvc?rev=905273&view=rev
> Log:
> CAMEL-2433, CAMEL-2434 Fixed the cxf configure issue in camel-cxf
>
> Added:
>    
> camel/branches/camel-1.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfTimeoutTest.java
>      - copied, changed from r905241, 
> camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfTimeoutTest.java
>    
> camel/branches/camel-1.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/GreeterImplWithSleep.java
>      - copied unchanged from r905241, 
> camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/GreeterImplWithSleep.java
>    
> camel/branches/camel-1.x/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/cxfConduitTimeOutContext.xml
>      - copied, changed from r905241, 
> camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/cxfConduitTimeOutContext.xml
> Modified:
>    camel/branches/camel-1.x/   (props changed)
>    
> camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/impl/DefaultComponent.java
>    
> camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java
>
> Propchange: camel/branches/camel-1.x/
> ------------------------------------------------------------------------------
> --- svn:mergeinfo (original)
> +++ svn:mergeinfo Mon Feb  1 12:52:16 2010
> @@ -1 +1 @@
> -/camel/trunk:736980,739733,739904,740251,740295,740306,740596,740663,741848,742231,742705,742739,742854,742856,742898,742906,743613,743762,743773,743920,743959-743960,744123,745105,745367,745541,745751,745826,745978,746269,746872,746895,746962,747258,747678-747704,748392,748436,748821,749563-749564,749574,749628-749629,749936,749956,750017,750334,750396,750761,750796,752068,752117,752418,752751-752755,752764-752773,752956,753087,753101,753175,755136,755487,756313,756348,756870,756939,757636,757693,757743,757865,758539,758563,758600,758617,758692,758990,759362,759453,759887,759931,760003,760890,760909,760937,761194,761536,761583,761607,762047,762633,762650,762935,763095,763484,763551,765154,765686,765729,765743,765824,766016,766289,766584,766588,766590,766602,766673,767403,767824,768342,769239,769346,769368,769434,770172,770906,771303,773193,773446,773781,774192,774383,774658-774659,776198,776289,776504,776975,778102,778689-778701,779121,779143,779489,781314-781349,781775,781
>  923,781974,781993,782557,782594,782681,782886,782918-782923,783204,783248,783363,783639,783704,785564,785584,785599,787206,787581,787598,787605,787928,788393,789121,789703,790560,790936,791379,791476,791767,792038,792381,792398,792899,793359,793518,793547-793555,793862,793935,794237,794368,794550,794967,795790,798027,798052,798063,798489,798864,799252,800340,800785,800797,801084,801196,801960,802307,802478,803559,807476,810751,812937,814493,816105,817654,818063,818182-818354,818744,818747,819475,819956,820152,820168,821272,821290,822655,823013,823018,823031,823102,823177,823575,824218,824721,825760,825765,828288,828333,832647,833285,833289,833350,833370,833381,833419,835511,880655,880667,883713,884525,884750,885876,887196,895119,896772,898201,901634,902688,903638,903970,904365,904440,904442,905171
> +/camel/trunk:736980,739733,739904,740251,740295,740306,740596,740663,741848,742231,742705,742739,742854,742856,742898,742906,743613,743762,743773,743920,743959-743960,744123,745105,745367,745541,745751,745826,745978,746269,746872,746895,746962,747258,747678-747704,748392,748436,748821,749563-749564,749574,749628-749629,749936,749956,750017,750334,750396,750761,750796,752068,752117,752418,752751-752755,752764-752773,752956,753087,753101,753175,755136,755487,756313,756348,756870,756939,757636,757693,757743,757865,758539,758563,758600,758617,758692,758990,759362,759453,759887,759931,760003,760890,760909,760937,761194,761536,761583,761607,762047,762633,762650,762935,763095,763484,763551,765154,765686,765729,765743,765824,766016,766289,766584,766588,766590,766602,766673,767403,767824,768342,769239,769346,769368,769434,770172,770906,771303,773193,773446,773781,774192,774383,774658-774659,776198,776289,776504,776975,778102,778689-778701,779121,779143,779489,781314-781349,781775,781
>  923,781974,781993,782557,782594,782681,782886,782918-782923,783204,783248,783363,783639,783704,785564,785584,785599,787206,787581,787598,787605,787928,788393,789121,789703,790560,790936,791379,791476,791767,792038,792381,792398,792899,793359,793518,793547-793555,793862,793935,794237,794368,794550,794967,795790,798027,798052,798063,798489,798864,799252,800340,800785,800797,801084,801196,801960,802307,802478,803559,807476,810751,812937,814493,816105,817654,818063,818182-818354,818744,818747,819475,819956,820152,820168,821272,821290,822655,823013,823018,823031,823102,823177,823575,824218,824721,825760,825765,828288,828333,832647,833285,833289,833350,833370,833381,833419,835511,880655,880667,883713,884525,884750,885876,887196,895119,896772,898201,901634,902688,903638,903970,904365,904440,904442,905171,905241
>
> Propchange: camel/branches/camel-1.x/
> ------------------------------------------------------------------------------
> Binary property 'svnmerge-integrated' - no diff available.
>
> Modified: 
> camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/impl/DefaultComponent.java
> URL: 
> http://svn.apache.org/viewvc/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/impl/DefaultComponent.java?rev=905273&r1=905272&r2=905273&view=diff
> ==============================================================================
> --- 
> camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/impl/DefaultComponent.java
>  (original)
> +++ 
> camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/impl/DefaultComponent.java
>  Mon Feb  1 12:52:16 2010
> @@ -186,6 +186,8 @@
>      * Sets the bean properties on the given bean
>      */
>     protected void setProperties(Object bean, Map parameters) throws 
> Exception {
> +        // set reference properties first as they use # syntax that fools 
> the regular properties setter
> +        IntrospectionSupport.setReferenceProperties(getCamelContext(), bean, 
> parameters);
>         
> IntrospectionSupport.setProperties(getCamelContext().getTypeConverter(), 
> bean, parameters);
>     }
>
>
> Modified: 
> camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java
> URL: 
> http://svn.apache.org/viewvc/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java?rev=905273&r1=905272&r2=905273&view=diff
> ==============================================================================
> --- 
> camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java
>  (original)
> +++ 
> camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java
>  Mon Feb  1 12:52:16 2010
> @@ -32,6 +32,7 @@
>  import java.util.Map;
>  import java.util.Set;
>
> +import org.apache.camel.CamelContext;
>  import org.apache.camel.NoTypeConversionAvailableException;
>  import org.apache.camel.TypeConverter;
>  import org.apache.commons.logging.Log;
> @@ -49,6 +50,87 @@
>      */
>     private IntrospectionSupport() {
>     }
> +
> +    /**
> +     * Sets the reference properties on the given bean
> +     * <p/>
> +     * This is convention over configuration, setting all reference 
> parameters (using {...@link #isReferenceParameter(String)}
> +     * by looking it up in registry and setting it on the bean if possible.
> +     *
> +     * @param context the camel context
> +     * @param bean the bean
> +     * @param parameters parameters
> +     * @throws Exception is thrown if setting property fails
> +     */
> +    public static void setReferenceProperties(CamelContext context, Object 
> bean, Map<String, Object> parameters) throws Exception {
> +        Iterator<Map.Entry<String, Object>> it = 
> parameters.entrySet().iterator();
> +        while (it.hasNext()) {
> +            Map.Entry<String, Object> entry = it.next();
> +            String name = entry.getKey();
> +            Object v = entry.getValue();
> +            String value = v != null ? v.toString() : null;
> +            if (value != null && isReferenceParameter(value)) {
> +                // For backwards-compatibility reasons, no mandatory lookup 
> is done here
> +                Object ref = resolveReferenceParameter(context, value, 
> Object.class, false);
> +                if (ref != null) {
> +                    boolean hit = setProperty(context.getTypeConverter(), 
> bean, name, ref);
> +                    if (hit) {
> +                        if (LOG.isDebugEnabled()) {
> +                            LOG.debug("Configured property: " + name + " on 
> bean: " + bean + " with value: " + ref);
> +                        }
> +                        // must remove as its a valid option and we could 
> configure it
> +                        it.remove();
> +                    }
> +                }
> +            }
> +        }
> +    }
> +
> +    /**
> +     * Resolves a reference parameter by making a lookup in the registry.
> +     *
> +     * @param <T> type of object to lookup.
> +     * @param context Camel context to use for lookup.
> +     * @param value reference parameter value.
> +     * @param type type of object to lookup.
> +     * @return lookup result.
> +     * @throws IllegalArgumentException if referenced object was not found in
> +     *         registry.
> +     */
> +    public static <T> T resolveReferenceParameter(CamelContext context, 
> String value, Class<T> type) {
> +        return resolveReferenceParameter(context, value, type, true);
> +    }
> +
> +    /**
> +     * Resolves a reference parameter by making a lookup in the registry.
> +     *
> +     * @param <T> type of object to lookup.
> +     * @param context Camel context to use for lookup.
> +     * @param value reference parameter value.
> +     * @param type type of object to lookup.
> +     * @return lookup result (or <code>null</code> only if
> +     *         <code>mandatory</code> is <code>false</code>).
> +     * @throws IllegalArgumentException if object was not found in registry 
> and
> +     *         <code>mandatory</code> is <code>true</code>.
> +     */
> +    public static <T> T resolveReferenceParameter(CamelContext context, 
> String value, Class<T> type, boolean mandatory) {
> +        String valueNoHash = value.replaceAll("#", "");
> +        if (mandatory) {
> +            return CamelContextHelper.mandatoryLookup(context, valueNoHash, 
> type);
> +        } else {
> +            return CamelContextHelper.lookup(context, valueNoHash, type);
> +        }
> +    }
> +
> +    /**
> +     * Is the given parameter a reference parameter (starting with a # char)
> +     *
> +     * @param parameter the parameter
> +     * @return <tt>true</tt> if its a reference parameter
> +     */
> +    public static boolean isReferenceParameter(String parameter) {
> +        return parameter != null && parameter.trim().startsWith("#");
> +    }
>
>     public static boolean getProperties(Object target, Map props, String 
> optionPrefix) {
>         boolean rc = false;
>
> Copied: 
> camel/branches/camel-1.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfTimeoutTest.java
>  (from r905241, 
> camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfTimeoutTest.java)
> URL: 
> http://svn.apache.org/viewvc/camel/branches/camel-1.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfTimeoutTest.java?p2=camel/branches/camel-1.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfTimeoutTest.java&p1=camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfTimeoutTest.java&r1=905241&r2=905273&rev=905273&view=diff
> ==============================================================================
> --- 
> camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfTimeoutTest.java
>  (original)
> +++ 
> camel/branches/camel-1.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfTimeoutTest.java
>  Mon Feb  1 12:52:16 2010
> @@ -22,39 +22,57 @@
>
>  import javax.xml.ws.Endpoint;
>
> +import org.apache.camel.CamelContext;
>  import org.apache.camel.Exchange;
>  import org.apache.camel.Processor;
>  import org.apache.camel.RuntimeCamelException;
> -import org.apache.camel.test.junit4.CamelSpringTestSupport;
> +import org.apache.camel.spring.SpringCamelContext;
>  import org.apache.hello_world_soap_http.Greeter;
> -import org.junit.BeforeClass;
> -import org.junit.Test;
>  import org.springframework.context.support.AbstractXmlApplicationContext;
>  import org.springframework.context.support.ClassPathXmlApplicationContext;
>
> -public class CxfTimeoutTest extends CamelSpringTestSupport {
> -
> +public class CxfTimeoutTest extends CxfRouterTestSupport {
> +
>     protected static final String GREET_ME_OPERATION = "greetMe";
>     protected static final String TEST_MESSAGE = "Hello World!";
>     protected static final String JAXWS_SERVER_ADDRESS = 
> "http://localhost:9023/SoapContext/SoapPort";;
>
> -   �...@beforeclass
> -    public static void startService() {
> +    protected AbstractXmlApplicationContext applicationContext;
> +
> +   �...@override
> +    protected void setUp() throws Exception {
> +        applicationContext = createApplicationContext();
> +        super.setUp();
> +        assertNotNull("Should have created a valid spring context", 
> applicationContext);
> +
> +
> +    }
> +
> +   �...@override
> +    protected void tearDown() throws Exception {
> +        if (applicationContext != null) {
> +            applicationContext.destroy();
> +        }
> +        super.tearDown();
> +    }
> +
> +   �...@override
> +    protected void startService() {
>         Greeter implementor = new GreeterImplWithSleep();
>         Endpoint.publish(JAXWS_SERVER_ADDRESS, implementor);
>     }
>
> -   �...@test
> +
>     public void testInvokingJaxWsServerWithBusUriParams() throws Exception {
>         sendTimeOutMessage("cxf://" + JAXWS_SERVER_ADDRESS + 
> "?serviceClass=org.apache.hello_world_soap_http.Greeter&bus=#cxf");
>     }
>
> -   �...@test
> +
>     public void testInvokingJaxWsServerWithoutBusUriParams() throws Exception 
> {
>         sendTimeOutMessage("cxf://" + JAXWS_SERVER_ADDRESS + 
> "?serviceClass=org.apache.hello_world_soap_http.Greeter");
>     }
>
> -   �...@test
> +
>     public void testInvokingJaxWsServerWithCxfEndpoint() throws Exception {
>         sendTimeOutMessage("cxf://bean:springEndpoint");
>     }
> @@ -80,11 +98,16 @@
>         });
>         return exchange;
>     }
> -
> +
>     @Override
> -    protected AbstractXmlApplicationContext createApplicationContext() {
> -        // we can put the http conduit configuration here
> +    protected CamelContext createCamelContext() throws Exception {
> +        return SpringCamelContext.springCamelContext(applicationContext);
> +    }
> +
> +
> +    protected ClassPathXmlApplicationContext createApplicationContext() {
>         return new 
> ClassPathXmlApplicationContext("org/apache/camel/component/cxf/cxfConduitTimeOutContext.xml");
>     }
> +
>
>  }
> \ No newline at end of file
>
> Copied: 
> camel/branches/camel-1.x/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/cxfConduitTimeOutContext.xml
>  (from r905241, 
> camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/cxfConduitTimeOutContext.xml)
> URL: 
> http://svn.apache.org/viewvc/camel/branches/camel-1.x/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/cxfConduitTimeOutContext.xml?p2=camel/branches/camel-1.x/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/cxfConduitTimeOutContext.xml&p1=camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/cxfConduitTimeOutContext.xml&r1=905241&r2=905273&rev=905273&view=diff
> ==============================================================================
> --- 
> camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/cxfConduitTimeOutContext.xml
>  (original)
> +++ 
> camel/branches/camel-1.x/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/cxfConduitTimeOutContext.xml
>  Mon Feb  1 12:52:16 2010
> @@ -17,13 +17,13 @@
>  -->
>  <beans xmlns="http://www.springframework.org/schema/beans";
>        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> -       xmlns:cxf="http://camel.apache.org/schema/cxf";
> +       xmlns:cxf="http://activemq.apache.org/camel/schema/cxfEndpoint";
>        xmlns:http-conf="http://cxf.apache.org/transports/http/configuration";
>        xsi:schemaLocation="
>        http://www.springframework.org/schema/beans 
> http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
> -       http://camel.apache.org/schema/cxf 
> http://camel.apache.org/schema/cxf/camel-cxf.xsd
> +       http://activemq.apache.org/camel/schema/cxfEndpoint 
> http://activemq.apache.org/camel/schema/cxfEndpoint/camel-cxf.xsd
>        http://cxf.apache.org/transports/http/configuration 
> http://cxf.apache.org/schemas/configuration/http-conf.xsd
> -       http://camel.apache.org/schema/spring 
> http://camel.apache.org/schema/spring/camel-spring.xsd
> +       http://activemq.apache.org/camel/schema/spring 
> http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
>     ">
>    <import resource="classpath:META-INF/cxf/cxf.xml"/>
>    <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
> @@ -36,8 +36,8 @@
>    <cxf:cxfEndpoint id="springEndpoint" 
> address="http://localhost:9023/SoapContext/SoapPort";
>                serviceClass="org.apache.hello_world_soap_http.Greeter"/>
>
> -   <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring"; 
> errorHandlerRef="noErrorHandler">
> -     <route errorHandlerRef="noErrorHandler">
> +   <camelContext id="camel" 
> xmlns="http://activemq.apache.org/camel/schema/spring"; 
> errorHandlerRef="noErrorHandler">
> +     <route>
>         <from uri="direct:start"/>
>         <to uri="cxf:bean:springEndpoint"/>
>      </route>
>
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Reply via email to