You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by Claus Ibsen <cl...@gmail.com> on 2014/12/28 15:01:33 UTC

Re: [2/3] camel git commit: CAMEL-8173 Support to set InflightRepository from Camel XML DSL

-1

You can already do this. There is no need to have an
inflightRepositoryRef option. Just declare the bean and its auto
configured which is standard already.

See
http://camel.apache.org/advanced-configuration-of-camelcontext-using-spring.html

On Tue, Dec 23, 2014 at 3:40 PM,  <ni...@apache.org> wrote:
> CAMEL-8173 Support to set InflightRepository from Camel XML DSL
>
>
> Project: http://git-wip-us.apache.org/repos/asf/camel/repo
> Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/d3d3161b
> Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/d3d3161b
> Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/d3d3161b
>
> Branch: refs/heads/master
> Commit: d3d3161b408a12349d55a26277590fcafc49c99f
> Parents: 524a4e5
> Author: Willem Jiang <wi...@gmail.com>
> Authored: Tue Dec 23 22:05:49 2014 +0800
> Committer: Willem Jiang <wi...@gmail.com>
> Committed: Tue Dec 23 22:19:49 2014 +0800
>
> ----------------------------------------------------------------------
>  .../blueprint/CamelContextFactoryBean.java      | 10 +++++
>  .../xml/AbstractCamelContextFactoryBean.java    | 11 ++++++
>  .../camel/spring/CamelContextFactoryBean.java   | 12 +++++-
>  .../spring/config/MyInflightRepositoryTest.java | 39 +++++++++++++++++++
>  .../spring/config/myInflightRepository.xml      | 40 ++++++++++++++++++++
>  5 files changed, 111 insertions(+), 1 deletion(-)
> ----------------------------------------------------------------------
>
>
> http://git-wip-us.apache.org/repos/asf/camel/blob/d3d3161b/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java
> ----------------------------------------------------------------------
> 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 56f1fba..d89f2d8 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
> @@ -107,6 +107,8 @@ public class CamelContextFactoryBean extends AbstractCamelContextFactoryBean<Blu
>      @XmlAttribute(required = false)
>      private String threadNamePattern;
>      @XmlAttribute(required = false)
> +    private String inflightRepositoryRef;
> +    @XmlAttribute(required = false)
>      private Boolean useBlueprintPropertyResolver;
>      @XmlAttribute(required = false)
>      private ShutdownRoute shutdownRoute;
> @@ -377,6 +379,14 @@ public class CamelContextFactoryBean extends AbstractCamelContextFactoryBean<Blu
>          this.threadNamePattern = threadNamePattern;
>      }
>
> +    public String getInflightRepositoryRef() {
> +        return inflightRepositoryRef;
> +    }
> +
> +    public void setInflightRepositoryRef(String inflightRepositoryRef) {
> +        this.inflightRepositoryRef = inflightRepositoryRef;
> +    }
> +
>      @Deprecated
>      public Boolean getLazyLoadTypeConverters() {
>          // use false by default
>
> http://git-wip-us.apache.org/repos/asf/camel/blob/d3d3161b/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
> ----------------------------------------------------------------------
> diff --git a/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java b/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
> index 8aca563..c12ce14 100644
> --- a/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
> +++ b/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
> @@ -24,6 +24,7 @@ import java.util.Map;
>  import java.util.Map.Entry;
>  import java.util.Set;
>  import java.util.concurrent.atomic.AtomicBoolean;
> +
>  import javax.xml.bind.annotation.XmlAccessType;
>  import javax.xml.bind.annotation.XmlAccessorType;
>  import javax.xml.bind.annotation.XmlTransient;
> @@ -672,6 +673,8 @@ public abstract class AbstractCamelContextFactoryBean<T extends ModelCamelContex
>      public abstract List<RestContextRefDefinition> getRestRefs();
>
>      public abstract String getErrorHandlerRef();
> +
> +    public abstract String getInflightRepositoryRef();
>
>      public abstract DataFormatsDefinition getDataFormats();
>
> @@ -715,6 +718,14 @@ public abstract class AbstractCamelContextFactoryBean<T extends ModelCamelContex
>          if (getErrorHandlerRef() != null) {
>              ctx.setErrorHandlerBuilder(new ErrorHandlerBuilderRef(getErrorHandlerRef()));
>          }
> +        if (getInflightRepositoryRef() != null) {
> +            InflightRepository repository = ctx.getRegistry().lookupByNameAndType(getInflightRepositoryRef(), InflightRepository.class);
> +            if (repository == null) {
> +                throw new IllegalArgumentException("Cannot not find InflightRepository instance from CamelContext registry with " + getInflightRepositoryRef());
> +            }
> +            ctx.addService(repository);
> +            ctx.setInflightRepository(repository);
> +        }
>          if (getAutoStartup() != null) {
>              ctx.setAutoStartup(CamelContextHelper.parseBoolean(getContext(), getAutoStartup()));
>          }
>
> http://git-wip-us.apache.org/repos/asf/camel/blob/d3d3161b/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
> ----------------------------------------------------------------------
> 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 0a39e2a..859b963 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
> @@ -19,6 +19,7 @@ package org.apache.camel.spring;
>  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;
> @@ -70,7 +71,6 @@ import org.springframework.context.ApplicationContextAware;
>  import org.springframework.context.ApplicationEvent;
>  import org.springframework.context.ApplicationListener;
>  import org.springframework.context.event.ContextRefreshedEvent;
> -
>  import static org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException;
>
>  /**
> @@ -118,6 +118,8 @@ public class CamelContextFactoryBean extends AbstractCamelContextFactoryBean<Spr
>      @XmlAttribute(required = false)
>      private String threadNamePattern;
>      @XmlAttribute(required = false)
> +    private String inflightRepositoryRef;
> +    @XmlAttribute(required = false)
>      private ShutdownRoute shutdownRoute;
>      @XmlAttribute(required = false)
>      private ShutdownRunningTask shutdownRunningTask;
> @@ -630,6 +632,14 @@ public class CamelContextFactoryBean extends AbstractCamelContextFactoryBean<Spr
>          this.threadNamePattern = threadNamePattern;
>      }
>
> +    public String getInflightRepositoryRef() {
> +        return inflightRepositoryRef;
> +    }
> +
> +    public void setInflightRepositoryRef(String inflightRepositoryRef) {
> +        this.inflightRepositoryRef = inflightRepositoryRef;
> +    }
> +
>      @Deprecated
>      public Boolean getLazyLoadTypeConverters() {
>          return lazyLoadTypeConverters;
>
> http://git-wip-us.apache.org/repos/asf/camel/blob/d3d3161b/components/camel-spring/src/test/java/org/apache/camel/spring/config/MyInflightRepositoryTest.java
> ----------------------------------------------------------------------
> diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/config/MyInflightRepositoryTest.java b/components/camel-spring/src/test/java/org/apache/camel/spring/config/MyInflightRepositoryTest.java
> new file mode 100644
> index 0000000..53c19e2
> --- /dev/null
> +++ b/components/camel-spring/src/test/java/org/apache/camel/spring/config/MyInflightRepositoryTest.java
> @@ -0,0 +1,39 @@
> +/**
> + * 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.config;
> +
> +import org.apache.camel.impl.DefaultInflightRepository;
> +import org.apache.camel.spring.SpringCamelContext;
> +import org.apache.camel.spring.SpringTestSupport;
> +import org.springframework.context.support.AbstractXmlApplicationContext;
> +import org.springframework.context.support.ClassPathXmlApplicationContext;
> +
> +public class MyInflightRepositoryTest extends SpringTestSupport {
> +    protected AbstractXmlApplicationContext createApplicationContext() {
> +        return new ClassPathXmlApplicationContext("org/apache/camel/spring/config/myInflightRepository.xml");
> +    }
> +
> +    public void testEndpointConfiguration() throws Exception {
> +        SpringCamelContext context = applicationContext.getBeansOfType(SpringCamelContext.class).values().iterator().next();
> +        assertTrue("Get a wrong inflight repository", context.getInflightRepository() instanceof MyInflightRepository);
> +    }
> +
> +    public static class MyInflightRepository extends DefaultInflightRepository {
> +
> +    }
> +
> +}
>
> http://git-wip-us.apache.org/repos/asf/camel/blob/d3d3161b/components/camel-spring/src/test/resources/org/apache/camel/spring/config/myInflightRepository.xml
> ----------------------------------------------------------------------
> diff --git a/components/camel-spring/src/test/resources/org/apache/camel/spring/config/myInflightRepository.xml b/components/camel-spring/src/test/resources/org/apache/camel/spring/config/myInflightRepository.xml
> new file mode 100644
> index 0000000..3536ccf
> --- /dev/null
> +++ b/components/camel-spring/src/test/resources/org/apache/camel/spring/config/myInflightRepository.xml
> @@ -0,0 +1,40 @@
> +<?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 inflightRepositoryRef="myinflightRepository" xmlns="http://camel.apache.org/schema/spring">
> +        <jmxAgent id="agent" disabled="true"/>
> +        <route>
> +            <from uri="seda:a"/>
> +            <to uri="seda:b"/>
> +        </route>
> +        <route>
> +            <from uri="direct:c"/>
> +            <to uri="direct:d"/>
> +        </route>
> +    </camelContext>
> +
> +    <bean id="myinflightRepository" class="org.apache.camel.spring.config.MyInflightRepositoryTest$MyInflightRepository" />
> +
> +</beans>
>



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/

Re: [2/3] camel git commit: CAMEL-8173 Support to set InflightRepository from Camel XML DSL

Posted by Claus Ibsen <cl...@gmail.com>.
On Mon, Dec 29, 2014 at 1:22 PM, Willem Jiang <wi...@gmail.com> wrote:
> Hi Claus,
>
> Thanks for pointing that out. It looks like the Camel Spring already
> support it, but how about the blueprint?
>

They both support the same. They use the same shared code in camel-core-xml.

See this class
https://github.com/apache/camel/blob/master/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java#L147

So if we add other pluggable spi's in the future, its just a matter of
adding a bit of code to that class.

>
> Willem Jiang
>
> Red Hat, Inc.
> FuseSource is now part of Red Hat
> Web: http://www.fusesource.com | http://www.redhat.com
> Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/)
> (English)
>           http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
> Twitter: willemjiang
> Weibo: 姜宁willem
>
> On Sun, Dec 28, 2014 at 10:01 PM, Claus Ibsen <cl...@gmail.com> wrote:
>
>> -1
>>
>> You can already do this. There is no need to have an
>> inflightRepositoryRef option. Just declare the bean and its auto
>> configured which is standard already.
>>
>> See
>>
>> http://camel.apache.org/advanced-configuration-of-camelcontext-using-spring.html
>>
>> On Tue, Dec 23, 2014 at 3:40 PM,  <ni...@apache.org> wrote:
>> > CAMEL-8173 Support to set InflightRepository from Camel XML DSL
>> >
>> >
>> > Project: http://git-wip-us.apache.org/repos/asf/camel/repo
>> > Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/d3d3161b
>> > Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/d3d3161b
>> > Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/d3d3161b
>> >
>> > Branch: refs/heads/master
>> > Commit: d3d3161b408a12349d55a26277590fcafc49c99f
>> > Parents: 524a4e5
>> > Author: Willem Jiang <wi...@gmail.com>
>> > Authored: Tue Dec 23 22:05:49 2014 +0800
>> > Committer: Willem Jiang <wi...@gmail.com>
>> > Committed: Tue Dec 23 22:19:49 2014 +0800
>> >
>> > ----------------------------------------------------------------------
>> >  .../blueprint/CamelContextFactoryBean.java      | 10 +++++
>> >  .../xml/AbstractCamelContextFactoryBean.java    | 11 ++++++
>> >  .../camel/spring/CamelContextFactoryBean.java   | 12 +++++-
>> >  .../spring/config/MyInflightRepositoryTest.java | 39 +++++++++++++++++++
>> >  .../spring/config/myInflightRepository.xml      | 40
>> ++++++++++++++++++++
>> >  5 files changed, 111 insertions(+), 1 deletion(-)
>> > ----------------------------------------------------------------------
>> >
>> >
>> >
>> http://git-wip-us.apache.org/repos/asf/camel/blob/d3d3161b/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java
>> > ----------------------------------------------------------------------
>> > 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 56f1fba..d89f2d8 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
>> > @@ -107,6 +107,8 @@ public class CamelContextFactoryBean extends
>> AbstractCamelContextFactoryBean<Blu
>> >      @XmlAttribute(required = false)
>> >      private String threadNamePattern;
>> >      @XmlAttribute(required = false)
>> > +    private String inflightRepositoryRef;
>> > +    @XmlAttribute(required = false)
>> >      private Boolean useBlueprintPropertyResolver;
>> >      @XmlAttribute(required = false)
>> >      private ShutdownRoute shutdownRoute;
>> > @@ -377,6 +379,14 @@ public class CamelContextFactoryBean extends
>> AbstractCamelContextFactoryBean<Blu
>> >          this.threadNamePattern = threadNamePattern;
>> >      }
>> >
>> > +    public String getInflightRepositoryRef() {
>> > +        return inflightRepositoryRef;
>> > +    }
>> > +
>> > +    public void setInflightRepositoryRef(String inflightRepositoryRef) {
>> > +        this.inflightRepositoryRef = inflightRepositoryRef;
>> > +    }
>> > +
>> >      @Deprecated
>> >      public Boolean getLazyLoadTypeConverters() {
>> >          // use false by default
>> >
>> >
>> http://git-wip-us.apache.org/repos/asf/camel/blob/d3d3161b/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
>> > ----------------------------------------------------------------------
>> > diff --git
>> a/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
>> b/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
>> > index 8aca563..c12ce14 100644
>> > ---
>> a/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
>> > +++
>> b/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
>> > @@ -24,6 +24,7 @@ import java.util.Map;
>> >  import java.util.Map.Entry;
>> >  import java.util.Set;
>> >  import java.util.concurrent.atomic.AtomicBoolean;
>> > +
>> >  import javax.xml.bind.annotation.XmlAccessType;
>> >  import javax.xml.bind.annotation.XmlAccessorType;
>> >  import javax.xml.bind.annotation.XmlTransient;
>> > @@ -672,6 +673,8 @@ public abstract class
>> AbstractCamelContextFactoryBean<T extends ModelCamelContex
>> >      public abstract List<RestContextRefDefinition> getRestRefs();
>> >
>> >      public abstract String getErrorHandlerRef();
>> > +
>> > +    public abstract String getInflightRepositoryRef();
>> >
>> >      public abstract DataFormatsDefinition getDataFormats();
>> >
>> > @@ -715,6 +718,14 @@ public abstract class
>> AbstractCamelContextFactoryBean<T extends ModelCamelContex
>> >          if (getErrorHandlerRef() != null) {
>> >              ctx.setErrorHandlerBuilder(new
>> ErrorHandlerBuilderRef(getErrorHandlerRef()));
>> >          }
>> > +        if (getInflightRepositoryRef() != null) {
>> > +            InflightRepository repository =
>> ctx.getRegistry().lookupByNameAndType(getInflightRepositoryRef(),
>> InflightRepository.class);
>> > +            if (repository == null) {
>> > +                throw new IllegalArgumentException("Cannot not find
>> InflightRepository instance from CamelContext registry with " +
>> getInflightRepositoryRef());
>> > +            }
>> > +            ctx.addService(repository);
>> > +            ctx.setInflightRepository(repository);
>> > +        }
>> >          if (getAutoStartup() != null) {
>> >
>> ctx.setAutoStartup(CamelContextHelper.parseBoolean(getContext(),
>> getAutoStartup()));
>> >          }
>> >
>> >
>> http://git-wip-us.apache.org/repos/asf/camel/blob/d3d3161b/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
>> > ----------------------------------------------------------------------
>> > 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 0a39e2a..859b963 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
>> > @@ -19,6 +19,7 @@ package org.apache.camel.spring;
>> >  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;
>> > @@ -70,7 +71,6 @@ import
>> org.springframework.context.ApplicationContextAware;
>> >  import org.springframework.context.ApplicationEvent;
>> >  import org.springframework.context.ApplicationListener;
>> >  import org.springframework.context.event.ContextRefreshedEvent;
>> > -
>> >  import static
>> org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException;
>> >
>> >  /**
>> > @@ -118,6 +118,8 @@ public class CamelContextFactoryBean extends
>> AbstractCamelContextFactoryBean<Spr
>> >      @XmlAttribute(required = false)
>> >      private String threadNamePattern;
>> >      @XmlAttribute(required = false)
>> > +    private String inflightRepositoryRef;
>> > +    @XmlAttribute(required = false)
>> >      private ShutdownRoute shutdownRoute;
>> >      @XmlAttribute(required = false)
>> >      private ShutdownRunningTask shutdownRunningTask;
>> > @@ -630,6 +632,14 @@ public class CamelContextFactoryBean extends
>> AbstractCamelContextFactoryBean<Spr
>> >          this.threadNamePattern = threadNamePattern;
>> >      }
>> >
>> > +    public String getInflightRepositoryRef() {
>> > +        return inflightRepositoryRef;
>> > +    }
>> > +
>> > +    public void setInflightRepositoryRef(String inflightRepositoryRef) {
>> > +        this.inflightRepositoryRef = inflightRepositoryRef;
>> > +    }
>> > +
>> >      @Deprecated
>> >      public Boolean getLazyLoadTypeConverters() {
>> >          return lazyLoadTypeConverters;
>> >
>> >
>> http://git-wip-us.apache.org/repos/asf/camel/blob/d3d3161b/components/camel-spring/src/test/java/org/apache/camel/spring/config/MyInflightRepositoryTest.java
>> > ----------------------------------------------------------------------
>> > diff --git
>> a/components/camel-spring/src/test/java/org/apache/camel/spring/config/MyInflightRepositoryTest.java
>> b/components/camel-spring/src/test/java/org/apache/camel/spring/config/MyInflightRepositoryTest.java
>> > new file mode 100644
>> > index 0000000..53c19e2
>> > --- /dev/null
>> > +++
>> b/components/camel-spring/src/test/java/org/apache/camel/spring/config/MyInflightRepositoryTest.java
>> > @@ -0,0 +1,39 @@
>> > +/**
>> > + * 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.config;
>> > +
>> > +import org.apache.camel.impl.DefaultInflightRepository;
>> > +import org.apache.camel.spring.SpringCamelContext;
>> > +import org.apache.camel.spring.SpringTestSupport;
>> > +import
>> org.springframework.context.support.AbstractXmlApplicationContext;
>> > +import
>> org.springframework.context.support.ClassPathXmlApplicationContext;
>> > +
>> > +public class MyInflightRepositoryTest extends SpringTestSupport {
>> > +    protected AbstractXmlApplicationContext createApplicationContext() {
>> > +        return new
>> ClassPathXmlApplicationContext("org/apache/camel/spring/config/myInflightRepository.xml");
>> > +    }
>> > +
>> > +    public void testEndpointConfiguration() throws Exception {
>> > +        SpringCamelContext context =
>> applicationContext.getBeansOfType(SpringCamelContext.class).values().iterator().next();
>> > +        assertTrue("Get a wrong inflight repository",
>> context.getInflightRepository() instanceof MyInflightRepository);
>> > +    }
>> > +
>> > +    public static class MyInflightRepository extends
>> DefaultInflightRepository {
>> > +
>> > +    }
>> > +
>> > +}
>> >
>> >
>> http://git-wip-us.apache.org/repos/asf/camel/blob/d3d3161b/components/camel-spring/src/test/resources/org/apache/camel/spring/config/myInflightRepository.xml
>> > ----------------------------------------------------------------------
>> > diff --git
>> a/components/camel-spring/src/test/resources/org/apache/camel/spring/config/myInflightRepository.xml
>> b/components/camel-spring/src/test/resources/org/apache/camel/spring/config/myInflightRepository.xml
>> > new file mode 100644
>> > index 0000000..3536ccf
>> > --- /dev/null
>> > +++
>> b/components/camel-spring/src/test/resources/org/apache/camel/spring/config/myInflightRepository.xml
>> > @@ -0,0 +1,40 @@
>> > +<?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 inflightRepositoryRef="myinflightRepository" xmlns="
>> http://camel.apache.org/schema/spring">
>> > +        <jmxAgent id="agent" disabled="true"/>
>> > +        <route>
>> > +            <from uri="seda:a"/>
>> > +            <to uri="seda:b"/>
>> > +        </route>
>> > +        <route>
>> > +            <from uri="direct:c"/>
>> > +            <to uri="direct:d"/>
>> > +        </route>
>> > +    </camelContext>
>> > +
>> > +    <bean id="myinflightRepository"
>> class="org.apache.camel.spring.config.MyInflightRepositoryTest$MyInflightRepository"
>> />
>> > +
>> > +</beans>
>> >
>>
>>
>>
>> --
>> Claus Ibsen
>> -----------------
>> Red Hat, Inc.
>> Email: cibsen@redhat.com
>> Twitter: davsclaus
>> Blog: http://davsclaus.com
>> Author of Camel in Action: http://www.manning.com/ibsen
>> hawtio: http://hawt.io/
>> fabric8: http://fabric8.io/
>>



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/

Re: [2/3] camel git commit: CAMEL-8173 Support to set InflightRepository from Camel XML DSL

Posted by Willem Jiang <wi...@gmail.com>.
Hi Claus,

Thanks for pointing that out. It looks like the Camel Spring already
support it, but how about the blueprint?


Willem Jiang

Red Hat, Inc.
FuseSource is now part of Red Hat
Web: http://www.fusesource.com | http://www.redhat.com
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/)
(English)
          http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang
Weibo: 姜宁willem

On Sun, Dec 28, 2014 at 10:01 PM, Claus Ibsen <cl...@gmail.com> wrote:

> -1
>
> You can already do this. There is no need to have an
> inflightRepositoryRef option. Just declare the bean and its auto
> configured which is standard already.
>
> See
>
> http://camel.apache.org/advanced-configuration-of-camelcontext-using-spring.html
>
> On Tue, Dec 23, 2014 at 3:40 PM,  <ni...@apache.org> wrote:
> > CAMEL-8173 Support to set InflightRepository from Camel XML DSL
> >
> >
> > Project: http://git-wip-us.apache.org/repos/asf/camel/repo
> > Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/d3d3161b
> > Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/d3d3161b
> > Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/d3d3161b
> >
> > Branch: refs/heads/master
> > Commit: d3d3161b408a12349d55a26277590fcafc49c99f
> > Parents: 524a4e5
> > Author: Willem Jiang <wi...@gmail.com>
> > Authored: Tue Dec 23 22:05:49 2014 +0800
> > Committer: Willem Jiang <wi...@gmail.com>
> > Committed: Tue Dec 23 22:19:49 2014 +0800
> >
> > ----------------------------------------------------------------------
> >  .../blueprint/CamelContextFactoryBean.java      | 10 +++++
> >  .../xml/AbstractCamelContextFactoryBean.java    | 11 ++++++
> >  .../camel/spring/CamelContextFactoryBean.java   | 12 +++++-
> >  .../spring/config/MyInflightRepositoryTest.java | 39 +++++++++++++++++++
> >  .../spring/config/myInflightRepository.xml      | 40
> ++++++++++++++++++++
> >  5 files changed, 111 insertions(+), 1 deletion(-)
> > ----------------------------------------------------------------------
> >
> >
> >
> http://git-wip-us.apache.org/repos/asf/camel/blob/d3d3161b/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java
> > ----------------------------------------------------------------------
> > 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 56f1fba..d89f2d8 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
> > @@ -107,6 +107,8 @@ public class CamelContextFactoryBean extends
> AbstractCamelContextFactoryBean<Blu
> >      @XmlAttribute(required = false)
> >      private String threadNamePattern;
> >      @XmlAttribute(required = false)
> > +    private String inflightRepositoryRef;
> > +    @XmlAttribute(required = false)
> >      private Boolean useBlueprintPropertyResolver;
> >      @XmlAttribute(required = false)
> >      private ShutdownRoute shutdownRoute;
> > @@ -377,6 +379,14 @@ public class CamelContextFactoryBean extends
> AbstractCamelContextFactoryBean<Blu
> >          this.threadNamePattern = threadNamePattern;
> >      }
> >
> > +    public String getInflightRepositoryRef() {
> > +        return inflightRepositoryRef;
> > +    }
> > +
> > +    public void setInflightRepositoryRef(String inflightRepositoryRef) {
> > +        this.inflightRepositoryRef = inflightRepositoryRef;
> > +    }
> > +
> >      @Deprecated
> >      public Boolean getLazyLoadTypeConverters() {
> >          // use false by default
> >
> >
> http://git-wip-us.apache.org/repos/asf/camel/blob/d3d3161b/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
> > ----------------------------------------------------------------------
> > diff --git
> a/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
> b/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
> > index 8aca563..c12ce14 100644
> > ---
> a/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
> > +++
> b/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
> > @@ -24,6 +24,7 @@ import java.util.Map;
> >  import java.util.Map.Entry;
> >  import java.util.Set;
> >  import java.util.concurrent.atomic.AtomicBoolean;
> > +
> >  import javax.xml.bind.annotation.XmlAccessType;
> >  import javax.xml.bind.annotation.XmlAccessorType;
> >  import javax.xml.bind.annotation.XmlTransient;
> > @@ -672,6 +673,8 @@ public abstract class
> AbstractCamelContextFactoryBean<T extends ModelCamelContex
> >      public abstract List<RestContextRefDefinition> getRestRefs();
> >
> >      public abstract String getErrorHandlerRef();
> > +
> > +    public abstract String getInflightRepositoryRef();
> >
> >      public abstract DataFormatsDefinition getDataFormats();
> >
> > @@ -715,6 +718,14 @@ public abstract class
> AbstractCamelContextFactoryBean<T extends ModelCamelContex
> >          if (getErrorHandlerRef() != null) {
> >              ctx.setErrorHandlerBuilder(new
> ErrorHandlerBuilderRef(getErrorHandlerRef()));
> >          }
> > +        if (getInflightRepositoryRef() != null) {
> > +            InflightRepository repository =
> ctx.getRegistry().lookupByNameAndType(getInflightRepositoryRef(),
> InflightRepository.class);
> > +            if (repository == null) {
> > +                throw new IllegalArgumentException("Cannot not find
> InflightRepository instance from CamelContext registry with " +
> getInflightRepositoryRef());
> > +            }
> > +            ctx.addService(repository);
> > +            ctx.setInflightRepository(repository);
> > +        }
> >          if (getAutoStartup() != null) {
> >
> ctx.setAutoStartup(CamelContextHelper.parseBoolean(getContext(),
> getAutoStartup()));
> >          }
> >
> >
> http://git-wip-us.apache.org/repos/asf/camel/blob/d3d3161b/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
> > ----------------------------------------------------------------------
> > 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 0a39e2a..859b963 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
> > @@ -19,6 +19,7 @@ package org.apache.camel.spring;
> >  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;
> > @@ -70,7 +71,6 @@ import
> org.springframework.context.ApplicationContextAware;
> >  import org.springframework.context.ApplicationEvent;
> >  import org.springframework.context.ApplicationListener;
> >  import org.springframework.context.event.ContextRefreshedEvent;
> > -
> >  import static
> org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException;
> >
> >  /**
> > @@ -118,6 +118,8 @@ public class CamelContextFactoryBean extends
> AbstractCamelContextFactoryBean<Spr
> >      @XmlAttribute(required = false)
> >      private String threadNamePattern;
> >      @XmlAttribute(required = false)
> > +    private String inflightRepositoryRef;
> > +    @XmlAttribute(required = false)
> >      private ShutdownRoute shutdownRoute;
> >      @XmlAttribute(required = false)
> >      private ShutdownRunningTask shutdownRunningTask;
> > @@ -630,6 +632,14 @@ public class CamelContextFactoryBean extends
> AbstractCamelContextFactoryBean<Spr
> >          this.threadNamePattern = threadNamePattern;
> >      }
> >
> > +    public String getInflightRepositoryRef() {
> > +        return inflightRepositoryRef;
> > +    }
> > +
> > +    public void setInflightRepositoryRef(String inflightRepositoryRef) {
> > +        this.inflightRepositoryRef = inflightRepositoryRef;
> > +    }
> > +
> >      @Deprecated
> >      public Boolean getLazyLoadTypeConverters() {
> >          return lazyLoadTypeConverters;
> >
> >
> http://git-wip-us.apache.org/repos/asf/camel/blob/d3d3161b/components/camel-spring/src/test/java/org/apache/camel/spring/config/MyInflightRepositoryTest.java
> > ----------------------------------------------------------------------
> > diff --git
> a/components/camel-spring/src/test/java/org/apache/camel/spring/config/MyInflightRepositoryTest.java
> b/components/camel-spring/src/test/java/org/apache/camel/spring/config/MyInflightRepositoryTest.java
> > new file mode 100644
> > index 0000000..53c19e2
> > --- /dev/null
> > +++
> b/components/camel-spring/src/test/java/org/apache/camel/spring/config/MyInflightRepositoryTest.java
> > @@ -0,0 +1,39 @@
> > +/**
> > + * 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.config;
> > +
> > +import org.apache.camel.impl.DefaultInflightRepository;
> > +import org.apache.camel.spring.SpringCamelContext;
> > +import org.apache.camel.spring.SpringTestSupport;
> > +import
> org.springframework.context.support.AbstractXmlApplicationContext;
> > +import
> org.springframework.context.support.ClassPathXmlApplicationContext;
> > +
> > +public class MyInflightRepositoryTest extends SpringTestSupport {
> > +    protected AbstractXmlApplicationContext createApplicationContext() {
> > +        return new
> ClassPathXmlApplicationContext("org/apache/camel/spring/config/myInflightRepository.xml");
> > +    }
> > +
> > +    public void testEndpointConfiguration() throws Exception {
> > +        SpringCamelContext context =
> applicationContext.getBeansOfType(SpringCamelContext.class).values().iterator().next();
> > +        assertTrue("Get a wrong inflight repository",
> context.getInflightRepository() instanceof MyInflightRepository);
> > +    }
> > +
> > +    public static class MyInflightRepository extends
> DefaultInflightRepository {
> > +
> > +    }
> > +
> > +}
> >
> >
> http://git-wip-us.apache.org/repos/asf/camel/blob/d3d3161b/components/camel-spring/src/test/resources/org/apache/camel/spring/config/myInflightRepository.xml
> > ----------------------------------------------------------------------
> > diff --git
> a/components/camel-spring/src/test/resources/org/apache/camel/spring/config/myInflightRepository.xml
> b/components/camel-spring/src/test/resources/org/apache/camel/spring/config/myInflightRepository.xml
> > new file mode 100644
> > index 0000000..3536ccf
> > --- /dev/null
> > +++
> b/components/camel-spring/src/test/resources/org/apache/camel/spring/config/myInflightRepository.xml
> > @@ -0,0 +1,40 @@
> > +<?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 inflightRepositoryRef="myinflightRepository" xmlns="
> http://camel.apache.org/schema/spring">
> > +        <jmxAgent id="agent" disabled="true"/>
> > +        <route>
> > +            <from uri="seda:a"/>
> > +            <to uri="seda:b"/>
> > +        </route>
> > +        <route>
> > +            <from uri="direct:c"/>
> > +            <to uri="direct:d"/>
> > +        </route>
> > +    </camelContext>
> > +
> > +    <bean id="myinflightRepository"
> class="org.apache.camel.spring.config.MyInflightRepositoryTest$MyInflightRepository"
> />
> > +
> > +</beans>
> >
>
>
>
> --
> Claus Ibsen
> -----------------
> Red Hat, Inc.
> Email: cibsen@redhat.com
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen
> hawtio: http://hawt.io/
> fabric8: http://fabric8.io/
>