camel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: svn commit: r1043407 - in /camel/trunk: components/camel-blueprint/src/main/java/org/apache/camel/blueprint/ components/camel-blueprint/src/main/java/org/apache/camel/blueprint/handler/ components/camel-core-xml/src/main/java/org/apache/camel/cor
Date Fri, 10 Dec 2010 05:05:39 GMT
On Fri, Dec 10, 2010 at 12:46 AM, Guillaume Nodet <gnodet@gmail.com> wrote:
> I actually did, and it seems to work for me. What kind of errors do you have ?
>

For example fusesource CI :)
http://ci.fusesource.com/hudson/view/Camel/job/camel-trunk-fuse-checkin/68/

Its something about auto assigning camelcontext id. I will take a look
later this morning.
Just that I quickly just revered the blueprint commit and it worked again.

So its the changes in camel-core-xml that affected it.


> On Thu, Dec 9, 2010 at 17:22, Claus Ibsen <claus.ibsen@gmail.com> wrote:
>> This commit broke camel-spring.
>>
>> Please unit test camel-spring also when you do any changes in
>> camel-core-xml or camel-core-osgi. Those are shared between
>> camel-spring and camel-blueprint now.
>>
>> When I undo this change it worked fine in camel-spring on trunk code:
>>
>>  svn merge --change -1043407 .
>>
>>
>>
>> On Wed, Dec 8, 2010 at 2:27 PM,  <gnodet@apache.org> wrote:
>>> Author: gnodet
>>> Date: Wed Dec  8 13:27:44 2010
>>> New Revision: 1043407
>>>
>>> URL: http://svn.apache.org/viewvc?rev=1043407&view=rev
>>> Log:
>>> [CAMEL-3186] @EndpointInject not working in bean created by blueprint
>>>
>>> Added:
>>>    camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelFactoryBean.java
>>>      - copied, changed from r1043385, camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelConsumerTemplateFactoryBean.java
>>>    camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/TestProducer.java
>>>    camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/blueprint/blueprint-10.xml
>>> Modified:
>>>    camel/trunk/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/BlueprintContainerRegistry.java
>>>    camel/trunk/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/handler/CamelNamespaceHandler.java
>>>    camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelConsumerTemplateFactoryBean.java
>>>    camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelEndpointFactoryBean.java
>>>    camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelProducerTemplateFactoryBean.java
>>>    camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelThreadPoolFactoryBean.java
>>>    camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/OSGiBlueprintTestSupport.java
>>>
>>> Modified: camel/trunk/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/BlueprintContainerRegistry.java
>>> URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/BlueprintContainerRegistry.java?rev=1043407&r1=1043406&r2=1043407&view=diff
>>> ==============================================================================
>>> --- camel/trunk/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/BlueprintContainerRegistry.java (original)
>>> +++ camel/trunk/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/BlueprintContainerRegistry.java Wed Dec  8 13:27:44 2010
>>> @@ -16,11 +16,12 @@
>>>  */
>>>  package org.apache.camel.blueprint;
>>>
>>> +import org.apache.aries.blueprint.ExtendedBeanMetadata;
>>> +import org.apache.aries.blueprint.mutable.MutableReferenceMetadata;
>>>  import org.apache.camel.spi.Registry;
>>> +import org.osgi.framework.Bundle;
>>>  import org.osgi.service.blueprint.container.BlueprintContainer;
>>> -import org.osgi.service.blueprint.reflect.BeanMetadata;
>>> -import org.osgi.service.blueprint.reflect.ComponentMetadata;
>>> -import org.osgi.service.blueprint.reflect.ReferenceMetadata;
>>> +import org.osgi.service.blueprint.container.NoSuchComponentException;
>>>
>>>  import java.util.LinkedHashMap;
>>>  import java.util.Map;
>>> @@ -38,7 +39,11 @@ public class BlueprintContainerRegistry
>>>     }
>>>
>>>     public <T> T lookup(String name, Class<T> type) {
>>> -        return type.cast(blueprintContainer.getComponentInstance(name));
>>> +        try {
>>> +            return type.cast(blueprintContainer.getComponentInstance(name));
>>> +        } catch (NoSuchComponentException e) {
>>> +            return null;
>>> +        }
>>>     }
>>>
>>>     public <T> Map<String, T> lookupByType(Class<T> type) {
>>> @@ -47,16 +52,34 @@ public class BlueprintContainerRegistry
>>>
>>>     public static <T> Map<String, T> lookupByType(BlueprintContainer blueprintContainer, Class<T> type) {
>>>         Map<String, T> objects = new LinkedHashMap<String, T>();
>>> -        for (ComponentMetadata metadata : blueprintContainer.getMetadata(ComponentMetadata.class)) {
>>> -            boolean isSingleton = metadata instanceof BeanMetadata
>>> -                        && (BeanMetadata.SCOPE_SINGLETON.equals(((BeanMetadata) metadata).getScope())
>>> -                            || ((BeanMetadata) metadata).getScope() == null);
>>> -            boolean isReference = metadata instanceof ReferenceMetadata;
>>> -            if (isSingleton || isReference) {
>>> -                Object o = blueprintContainer.getComponentInstance( metadata.getId() );
>>> -                if (type.isInstance( o )) {
>>> +        for (ExtendedBeanMetadata metadata : blueprintContainer.getMetadata(ExtendedBeanMetadata.class)) {
>>> +            try {
>>> +                Class cl = metadata.getRuntimeClass();
>>> +                if (cl == null && metadata.getClassName() != null) {
>>> +                    Bundle bundle  = (Bundle) blueprintContainer.getComponentInstance("blueprintBundle");
>>> +                    cl = bundle.loadClass(metadata.getClassName());
>>> +                }
>>> +                if (cl == null || type.isAssignableFrom(cl)) {
>>> +                    Object o = blueprintContainer.getComponentInstance( metadata.getId() );
>>> +                    objects.put( metadata.getId(), type.cast(o) );
>>> +                }
>>> +            } catch (Throwable t) {
>>> +                // ignore
>>> +            }
>>> +        }
>>> +        for (MutableReferenceMetadata metadata : blueprintContainer.getMetadata(MutableReferenceMetadata.class)) {
>>> +            try {
>>> +                Class cl = metadata.getRuntimeInterface();
>>> +                if (cl == null && metadata.getInterface() != null) {
>>> +                    Bundle bundle  = (Bundle) blueprintContainer.getComponentInstance("blueprintBundle");
>>> +                    cl = bundle.loadClass(metadata.getInterface());
>>> +                }
>>> +                if (cl == null || type.isAssignableFrom(cl)) {
>>> +                    Object o = blueprintContainer.getComponentInstance( metadata.getId() );
>>>                     objects.put( metadata.getId(), type.cast(o) );
>>>                 }
>>> +            } catch (Throwable t) {
>>> +                // ignore
>>>             }
>>>         }
>>>         return objects;
>>>
>>> Modified: camel/trunk/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/handler/CamelNamespaceHandler.java
>>> URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/handler/CamelNamespaceHandler.java?rev=1043407&r1=1043406&r2=1043407&view=diff
>>> ==============================================================================
>>> --- camel/trunk/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/handler/CamelNamespaceHandler.java (original)
>>> +++ camel/trunk/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/handler/CamelNamespaceHandler.java Wed Dec  8 13:27:44 2010
>>> @@ -16,50 +16,28 @@
>>>  */
>>>  package org.apache.camel.blueprint.handler;
>>>
>>> -import java.net.URL;
>>> -import java.util.ArrayList;
>>> -import java.util.Arrays;
>>> -import java.util.HashSet;
>>> -import java.util.List;
>>> -import java.util.Set;
>>> -import java.util.concurrent.Callable;
>>> -
>>> -import javax.xml.bind.Binder;
>>> -import javax.xml.bind.JAXBContext;
>>> -import javax.xml.bind.JAXBException;
>>> -
>>> +import org.apache.aries.blueprint.BeanProcessor;
>>>  import org.apache.aries.blueprint.ComponentDefinitionRegistry;
>>>  import org.apache.aries.blueprint.ComponentDefinitionRegistryProcessor;
>>> -import org.w3c.dom.Document;
>>> -import org.w3c.dom.Element;
>>> -import org.w3c.dom.Node;
>>> -import org.w3c.dom.NodeList;
>>> -
>>>  import org.apache.aries.blueprint.NamespaceHandler;
>>>  import org.apache.aries.blueprint.ParserContext;
>>>  import org.apache.aries.blueprint.PassThroughMetadata;
>>>  import org.apache.aries.blueprint.mutable.MutableBeanMetadata;
>>>  import org.apache.aries.blueprint.mutable.MutablePassThroughMetadata;
>>> +import org.apache.aries.blueprint.mutable.MutableRefMetadata;
>>>  import org.apache.aries.blueprint.mutable.MutableReferenceMetadata;
>>> +import org.apache.aries.blueprint.mutable.MutableValueMetadata;
>>> +import org.apache.camel.CamelContext;
>>> +import org.apache.camel.CamelContextAware;
>>> +import org.apache.camel.EndpointInject;
>>> +import org.apache.camel.Produce;
>>>  import org.apache.camel.blueprint.BlueprintCamelContext;
>>>  import org.apache.camel.blueprint.CamelContextFactoryBean;
>>>  import org.apache.camel.core.xml.AbstractCamelContextFactoryBean;
>>> +import org.apache.camel.core.xml.AbstractCamelFactoryBean;
>>> +import org.apache.camel.impl.CamelPostProcessorHelper;
>>>  import org.apache.camel.impl.DefaultCamelContextNameStrategy;
>>> -import org.apache.camel.model.AggregateDefinition;
>>> -import org.apache.camel.model.CatchDefinition;
>>> -import org.apache.camel.model.DataFormatDefinition;
>>> -import org.apache.camel.model.ExpressionNode;
>>> -import org.apache.camel.model.ExpressionSubElementDefinition;
>>> -import org.apache.camel.model.FromDefinition;
>>> -import org.apache.camel.model.MarshalDefinition;
>>> -import org.apache.camel.model.OnExceptionDefinition;
>>> -import org.apache.camel.model.ProcessorDefinition;
>>> -import org.apache.camel.model.ResequenceDefinition;
>>> -import org.apache.camel.model.RouteDefinition;
>>> -import org.apache.camel.model.SendDefinition;
>>> -import org.apache.camel.model.SortDefinition;
>>> -import org.apache.camel.model.UnmarshalDefinition;
>>> -import org.apache.camel.model.WireTapDefinition;
>>> +import org.apache.camel.model.*;
>>>  import org.apache.camel.model.language.ExpressionDefinition;
>>>  import org.apache.camel.spi.CamelContextNameStrategy;
>>>  import org.apache.camel.spi.ComponentResolver;
>>> @@ -68,13 +46,31 @@ import org.apache.camel.spi.LanguageReso
>>>  import org.apache.camel.util.ObjectHelper;
>>>  import org.apache.commons.logging.Log;
>>>  import org.apache.commons.logging.LogFactory;
>>> -
>>>  import org.osgi.framework.Bundle;
>>> -import org.osgi.framework.BundleContext;
>>>  import org.osgi.service.blueprint.container.BlueprintContainer;
>>>  import org.osgi.service.blueprint.container.ComponentDefinitionException;
>>> +import org.osgi.service.blueprint.reflect.BeanMetadata;
>>>  import org.osgi.service.blueprint.reflect.ComponentMetadata;
>>>  import org.osgi.service.blueprint.reflect.Metadata;
>>> +import org.osgi.service.blueprint.reflect.RefMetadata;
>>> +import org.osgi.service.blueprint.reflect.ValueMetadata;
>>> +import org.w3c.dom.Document;
>>> +import org.w3c.dom.Element;
>>> +import org.w3c.dom.Node;
>>> +import org.w3c.dom.NodeList;
>>> +
>>> +import javax.xml.bind.Binder;
>>> +import javax.xml.bind.JAXBContext;
>>> +import javax.xml.bind.JAXBException;
>>> +import java.lang.reflect.Field;
>>> +import java.lang.reflect.Method;
>>> +import java.lang.reflect.Modifier;
>>> +import java.net.URL;
>>> +import java.util.Arrays;
>>> +import java.util.HashSet;
>>> +import java.util.List;
>>> +import java.util.Set;
>>> +import java.util.concurrent.Callable;
>>>
>>>  public class CamelNamespaceHandler implements NamespaceHandler {
>>>
>>> @@ -140,27 +136,7 @@ public class CamelNamespaceHandler imple
>>>             }
>>>
>>>             CamelContextFactoryBean ccfb = (CamelContextFactoryBean) value;
>>> -            try {
>>> -                PassThroughMetadata ptm = (PassThroughMetadata) context.getComponentDefinitionRegistry().getComponentDefinition("blueprintContainer");
>>> -                ccfb.setBlueprintContainer((BlueprintContainer) ptm.getObject());
>>> -                ptm = (PassThroughMetadata) context.getComponentDefinitionRegistry().getComponentDefinition("blueprintBundleContext");
>>> -                ccfb.setBundleContext((BundleContext) ptm.getObject());
>>> -                ccfb.setImplicitId(implicitId);
>>> -            } catch (Exception e) {
>>> -                throw new ComponentDefinitionException("Unable to initialize camel context factory", e);
>>> -            }
>>> -
>>> -            //
>>> -            // gnodet: the initialization of the CamelContextFactoryBean is now done at the end of the blueprint
>>> -            //    container creation through the use of a ComponentDefinitionRegistryProcessor (those are called
>>> -            //    after all the beans have been initialized.  That's why the calls to #afterPropertiesSet and
>>> -            //    #init are commented.
>>> -            //       This mechanism is now required because the #afterPropertiesSet method on the CamelContext
>>> -            //    will search through the blueprint beans for beans implementing known interfaces such as
>>> -            //    LifeCycle strategies, etc... so that they are automatically wired to the CamelContext.
>>> -            //    However, Blueprint does not support real factories, so in order to do so, we need to actually
>>> -            //    access the beans which lead to a circular exception while looking for the CamelContext itself.
>>> -            //
>>> +            ccfb.setImplicitId(implicitId);
>>>
>>>             MutablePassThroughMetadata factory = context.createMetadata(MutablePassThroughMetadata.class);
>>>             factory.setId(".camelBlueprint.passThrough." + contextId);
>>> @@ -170,33 +146,98 @@ public class CamelNamespaceHandler imple
>>>             factory2.setId(".camelBlueprint.factory." + contextId);
>>>             factory2.setFactoryComponent(factory);
>>>             factory2.setFactoryMethod("call");
>>> -//            factory2.setInitMethod("afterPropertiesSet");
>>> +            factory2.setInitMethod("afterPropertiesSet");
>>>             factory2.setDestroyMethod("destroy");
>>> +            factory2.addProperty("blueprintContainer", createRef(context, "blueprintContainer"));
>>> +            factory2.addProperty("bundleContext", createRef(context, "blueprintBundleContext"));
>>>
>>>             MutableBeanMetadata ctx = context.createMetadata(MutableBeanMetadata.class);
>>>             ctx.setId(contextId);
>>> +            ctx.setRuntimeClass(BlueprintCamelContext.class);
>>>             ctx.setFactoryComponent(factory2);
>>>             ctx.setFactoryMethod("getContext");
>>> -//            ctx.setInitMethod("init");
>>> +            ctx.setInitMethod("init");
>>>             ctx.setDestroyMethod("destroy");
>>>
>>> -            MutablePassThroughMetadata processorFactory = context.createMetadata(MutablePassThroughMetadata.class);
>>> -            processorFactory.setId(".camelBlueprint.processor.passThrough." + contextId);
>>> -            processorFactory.setObject(new PassThroughCallable<Object>(new CamelDependenciesFinder(ccfb, context)));
>>> -
>>> -            MutableBeanMetadata processor = context.createMetadata(MutableBeanMetadata.class);
>>> -            processor.setId(".camelBlueprint.processor." + contextId);
>>> -            processor.setRuntimeClass(ComponentDefinitionRegistryProcessor.class);
>>> -            processor.setFactoryComponent(processorFactory);
>>> -            processor.setFactoryMethod("call");
>>> -            processor.setProcessor(true);
>>> -            context.getComponentDefinitionRegistry().registerComponentDefinition( processor );
>>> +            // Register objects
>>> +            registerBeans(context, contextId, ccfb.getEndpoints());
>>> +            registerBeans(context, contextId, ccfb.getThreadPools());
>>> +            registerBeans(context, contextId, ccfb.getBeans());
>>> +
>>> +            // Register processors
>>> +            MutablePassThroughMetadata beanProcessorFactory = context.createMetadata(MutablePassThroughMetadata.class);
>>> +            beanProcessorFactory.setId(".camelBlueprint.processor.bean.passThrough." + contextId);
>>> +            beanProcessorFactory.setObject(new PassThroughCallable<Object>(new CamelInjector(contextId)));
>>> +
>>> +            MutableBeanMetadata beanProcessor = context.createMetadata(MutableBeanMetadata.class);
>>> +            beanProcessor.setId(".camelBlueprint.processor.bean." + contextId);
>>> +            beanProcessor.setRuntimeClass(CamelInjector.class);
>>> +            beanProcessor.setFactoryComponent(beanProcessorFactory);
>>> +            beanProcessor.setFactoryMethod("call");
>>> +            beanProcessor.setProcessor(true);
>>> +            beanProcessor.addProperty("blueprintContainer", createRef(context, "blueprintContainer"));
>>> +            context.getComponentDefinitionRegistry().registerComponentDefinition(beanProcessor);
>>> +
>>> +            MutablePassThroughMetadata regProcessorFactory = context.createMetadata(MutablePassThroughMetadata.class);
>>> +            regProcessorFactory.setId(".camelBlueprint.processor.registry.passThrough." + contextId);
>>> +            regProcessorFactory.setObject(new PassThroughCallable<Object>(new CamelDependenciesFinder(contextId, context)));
>>> +
>>> +            MutableBeanMetadata regProcessor = context.createMetadata(MutableBeanMetadata.class);
>>> +            regProcessor.setId(".camelBlueprint.processor.registry." + contextId);
>>> +            regProcessor.setRuntimeClass(CamelDependenciesFinder.class);
>>> +            regProcessor.setFactoryComponent(regProcessorFactory);
>>> +            regProcessor.setFactoryMethod("call");
>>> +            regProcessor.setProcessor(true);
>>> +            regProcessor.addDependsOn(".camelBlueprint.processor.bean." + contextId);
>>> +            regProcessor.addProperty("blueprintContainer", createRef(context, "blueprintContainer"));
>>> +            context.getComponentDefinitionRegistry().registerComponentDefinition(regProcessor);
>>>
>>>             return ctx;
>>>         }
>>>         return null;
>>>     }
>>>
>>> +    private void registerBeans(ParserContext context, String contextId, List<?> beans) {
>>> +        if (beans != null) {
>>> +            for (Object bean : beans) {
>>> +                if (bean instanceof AbstractCamelFactoryBean) {
>>> +                    registerBean(context, contextId, (AbstractCamelFactoryBean) bean);
>>> +                }
>>> +            }
>>> +        }
>>> +    }
>>> +
>>> +    protected void registerBean(ParserContext context, String contextId, AbstractCamelFactoryBean<?> fact) {
>>> +        String id = fact.getId();
>>> +
>>> +        fact.setCamelContextId(contextId);
>>> +
>>> +        MutablePassThroughMetadata eff = context.createMetadata(MutablePassThroughMetadata.class);
>>> +        eff.setId(".camelBlueprint.bean.factory." + id);
>>> +        eff.setObject(new PassThroughCallable<Object>(fact));
>>> +
>>> +        MutableBeanMetadata ef = context.createMetadata(MutableBeanMetadata.class);
>>> +        ef.setId(".camelBlueprint.bean.factory." + contextId);
>>> +        ef.setFactoryComponent(eff);
>>> +        ef.setFactoryMethod("call");
>>> +        ef.addProperty("blueprintContainer", createRef(context, "blueprintContainer"));
>>> +        ef.setInitMethod("afterPropertiesSet");
>>> +        ef.setDestroyMethod("destroy");
>>> +
>>> +        MutableBeanMetadata e = context.createMetadata(MutableBeanMetadata.class);
>>> +        e.setId(id);
>>> +        e.setRuntimeClass(fact.getObjectType());
>>> +        e.setFactoryComponent(ef);
>>> +        e.setFactoryMethod("getObject");
>>> +
>>> +        context.getComponentDefinitionRegistry().registerComponentDefinition(e);
>>> +    }
>>> +
>>> +    protected BlueprintContainer getBlueprintContainer(ParserContext context) {
>>> +        PassThroughMetadata ptm = (PassThroughMetadata) context.getComponentDefinitionRegistry().getComponentDefinition("blueprintContainer");
>>> +        return (BlueprintContainer) ptm.getObject();
>>> +    }
>>> +
>>>     public ComponentMetadata decorate(Node node, ComponentMetadata component, ParserContext context) {
>>>         return null;
>>>     }
>>> @@ -240,6 +281,18 @@ public class CamelNamespaceHandler imple
>>>         return classes;
>>>     }
>>>
>>> +    private ValueMetadata createValue(ParserContext context, String value) {
>>> +        MutableValueMetadata v = context.createMetadata(MutableValueMetadata.class);
>>> +        v.setStringValue(value);
>>> +        return v;
>>> +    }
>>> +
>>> +    private RefMetadata createRef(ParserContext context, String value) {
>>> +        MutableRefMetadata r = context.createMetadata(MutableRefMetadata.class);
>>> +        r.setComponentId(value);
>>> +        return r;
>>> +    }
>>> +
>>>     public static class PassThroughCallable<T> implements Callable<T> {
>>>
>>>         private T value;
>>> @@ -253,29 +306,152 @@ public class CamelNamespaceHandler imple
>>>         }
>>>     }
>>>
>>> +    public static class CamelInjector extends CamelPostProcessorHelper implements BeanProcessor {
>>> +
>>> +        private final String camelContextName;
>>> +        private BlueprintContainer blueprintContainer;
>>> +
>>> +        public CamelInjector(String camelContextName) {
>>> +            this.camelContextName = camelContextName;
>>> +        }
>>> +
>>> +        public void setBlueprintContainer(BlueprintContainer blueprintContainer) {
>>> +            this.blueprintContainer = blueprintContainer;
>>> +        }
>>> +
>>> +        public Object beforeInit(Object bean, String beanName, BeanCreator beanCreator, BeanMetadata beanMetadata) {
>>> +            injectFields(bean, beanName);
>>> +            injectMethods(bean, beanName);
>>> +            if (bean instanceof CamelContextAware) {
>>> +                ((CamelContextAware) bean).setCamelContext(getCamelContext());
>>> +            }
>>> +            return bean;
>>> +        }
>>> +
>>> +        @Override
>>> +        public CamelContext getCamelContext() {
>>> +            return (CamelContext) blueprintContainer.getComponentInstance(camelContextName);
>>> +        }
>>> +
>>> +        /**
>>> +         * A strategy method to allow implementations to perform some custom JBI
>>> +         * based injection of the POJO
>>> +         *
>>> +         * @param bean the bean to be injected
>>> +         */
>>> +        protected void injectFields(final Object bean, final String beanName) {
>>> +            Class clazz = bean.getClass();
>>> +            do {
>>> +                Field[] fields = clazz.getDeclaredFields();
>>> +                for (Field field : fields) {
>>> +                    EndpointInject endpointInject = field.getAnnotation(EndpointInject.class);
>>> +                    if (endpointInject != null && matchContext(endpointInject.context())) {
>>> +                        injectField(field, endpointInject.uri(), endpointInject.ref(), bean, beanName);
>>> +                    }
>>> +
>>> +                    Produce produce = field.getAnnotation(Produce.class);
>>> +                    if (produce != null && matchContext(produce.context())) {
>>> +                        injectField(field, produce.uri(), produce.ref(), bean, beanName);
>>> +                    }
>>> +                }
>>> +                clazz = clazz.getSuperclass();
>>> +            } while (clazz != null && clazz != Object.class);
>>> +        }
>>> +
>>> +        protected void injectField(Field field, String endpointUri, String endpointRef, Object bean, String beanName) {
>>> +            setField(field, bean, getInjectionValue(field.getType(), endpointUri, endpointRef, field.getName(), bean, beanName));
>>> +        }
>>> +
>>> +        protected static void setField(Field field, Object instance, Object value) {
>>> +            try {
>>> +                boolean oldAccessible = field.isAccessible();
>>> +                boolean shouldSetAccessible = !Modifier.isPublic(field.getModifiers()) && !oldAccessible;
>>> +                if (shouldSetAccessible) {
>>> +                    field.setAccessible(true);
>>> +                }
>>> +                field.set(instance, value);
>>> +                if (shouldSetAccessible) {
>>> +                    field.setAccessible(oldAccessible);
>>> +                }
>>> +            } catch (IllegalArgumentException ex) {
>>> +                throw new UnsupportedOperationException("Cannot inject value of class: " + value.getClass() + " into: " + field);
>>> +            } catch (IllegalAccessException ex) {
>>> +                throw new IllegalStateException("Could not access method: " + ex.getMessage());
>>> +            }
>>> +        }
>>> +
>>> +        protected void injectMethods(final Object bean, final String beanName) {
>>> +            Class clazz = bean.getClass();
>>> +            do {
>>> +                Method[] methods = clazz.getDeclaredMethods();
>>> +                for (Method method : methods) {
>>> +                    setterInjection(method, bean, beanName);
>>> +                    consumerInjection(method, bean, beanName);
>>> +                }
>>> +                clazz = clazz.getSuperclass();
>>> +            } while (clazz != null && clazz != Object.class);
>>> +        }
>>> +
>>> +        protected void setterInjection(Method method, Object bean, String beanName) {
>>> +            EndpointInject endpointInject = method.getAnnotation(EndpointInject.class);
>>> +            if (endpointInject != null && matchContext(endpointInject.context())) {
>>> +                setterInjection(method, bean, beanName, endpointInject.uri(), endpointInject.ref());
>>> +            }
>>> +
>>> +            Produce produce = method.getAnnotation(Produce.class);
>>> +            if (produce != null && matchContext(produce.context())) {
>>> +                setterInjection(method, bean, beanName, produce.uri(), produce.ref());
>>> +            }
>>> +        }
>>> +
>>> +        protected void setterInjection(Method method, Object bean, String beanName, String endpointUri, String endpointRef) {
>>> +            Class<?>[] parameterTypes = method.getParameterTypes();
>>> +            if (parameterTypes != null) {
>>> +                if (parameterTypes.length != 1) {
>>> +                    LOG.warn("Ignoring badly annotated method for injection due to incorrect number of parameters: " + method);
>>> +                } else {
>>> +                    String propertyName = ObjectHelper.getPropertyName(method);
>>> +                    Object value = getInjectionValue(parameterTypes[0], endpointUri, endpointRef, propertyName, bean, beanName);
>>> +                    ObjectHelper.invokeMethod(method, bean, value);
>>> +                }
>>> +            }
>>> +        }
>>> +
>>> +        public Object afterInit(Object o, String s, BeanCreator beanCreator, BeanMetadata beanMetadata) {
>>> +            return o;
>>> +        }
>>> +
>>> +        public void beforeDestroy(Object o, String s) {
>>> +        }
>>> +
>>> +        public void afterDestroy(Object o, String s) {
>>> +        }
>>> +
>>> +    }
>>> +
>>>     public static class CamelDependenciesFinder implements ComponentDefinitionRegistryProcessor {
>>>
>>> -        private final CamelContextFactoryBean ccfb;
>>> +        private final String camelContextName;
>>>         private final ParserContext context;
>>> +        private BlueprintContainer blueprintContainer;
>>>
>>> -        public CamelDependenciesFinder(CamelContextFactoryBean ccfb, ParserContext context) {
>>> -            this.ccfb = ccfb;
>>> +        public CamelDependenciesFinder(String camelContextName, ParserContext context) {
>>> +            this.camelContextName = camelContextName;
>>>             this.context = context;
>>>         }
>>>
>>> +        public void setBlueprintContainer(BlueprintContainer blueprintContainer) {
>>> +            this.blueprintContainer = blueprintContainer;
>>> +        }
>>> +
>>>         public void process(ComponentDefinitionRegistry componentDefinitionRegistry) {
>>> -            try {
>>> -                ccfb.afterPropertiesSet();
>>> -                ccfb.getContext().init();
>>> -            } catch (Exception e) {
>>> -                throw new ComponentDefinitionException("Unable to initialize camel context factory", e);
>>> -            }
>>> +            CamelContext camelContext = (CamelContext) blueprintContainer.getComponentInstance(camelContextName);
>>>
>>>             Set<String> components = new HashSet<String>();
>>>             Set<String> languages = new HashSet<String>();
>>>             Set<String> dataformats = new HashSet<String>();
>>>             Set<String> dependsOn = new HashSet<String>();
>>> -            for (RouteDefinition rd : ccfb.getContext().getRouteDefinitions()) {
>>> +            for (RouteDefinition rd : camelContext.getRouteDefinitions()) {
>>>                 findInputComponents(rd.getInputs(), components, languages, dataformats);
>>>                 findOutputComponents(rd.getOutputs(), components, languages, dataformats);
>>>             }
>>> @@ -365,6 +541,8 @@ public class CamelNamespaceHandler imple
>>>                 languages.clear();
>>>                 dataformats.clear();
>>>             }
>>> +
>>> +
>>>         }
>>>
>>>         public <T extends org.osgi.service.blueprint.reflect.Metadata> T createMetadata(java.lang.Class<T> tClass) {
>>>
>>> Modified: camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelConsumerTemplateFactoryBean.java
>>> URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelConsumerTemplateFactoryBean.java?rev=1043407&r1=1043406&r2=1043407&view=diff
>>> ==============================================================================
>>> --- camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelConsumerTemplateFactoryBean.java (original)
>>> +++ camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelConsumerTemplateFactoryBean.java Wed Dec  8 13:27:44 2010
>>> @@ -37,29 +37,14 @@ import org.apache.camel.util.ServiceHelp
>>>  * @version $Revision: 934375 $
>>>  */
>>>  @XmlAccessorType(XmlAccessType.FIELD)
>>> -public abstract class AbstractCamelConsumerTemplateFactoryBean extends IdentifiedType implements CamelContextAware {
>>> +public abstract class AbstractCamelConsumerTemplateFactoryBean extends AbstractCamelFactoryBean<ConsumerTemplate> {
>>>     @XmlTransient
>>>     private ConsumerTemplate template;
>>>     @XmlAttribute
>>> -    private String camelContextId;
>>> -    @XmlTransient
>>> -    private CamelContext camelContext;
>>> -    @XmlAttribute
>>>     private Integer maximumCacheSize;
>>>
>>> -    public void afterPropertiesSet() throws Exception {
>>> -        if (camelContext == null && camelContextId != null) {
>>> -            camelContext = getCamelContextWithId(camelContextId);
>>> -        }
>>> -        if (camelContext == null) {
>>> -            throw new IllegalArgumentException("A CamelContext or a CamelContextId must be injected!");
>>> -        }
>>> -    }
>>> -
>>> -    protected abstract CamelContext getCamelContextWithId(String camelContextId);
>>> -
>>> -    public Object getObject() throws Exception {
>>> -        template = new DefaultConsumerTemplate(camelContext);
>>> +    public ConsumerTemplate getObject() throws Exception {
>>> +        template = new DefaultConsumerTemplate(getCamelContext());
>>>
>>>         // set custom cache size if provided
>>>         if (maximumCacheSize != null) {
>>> @@ -71,14 +56,10 @@ public abstract class AbstractCamelConsu
>>>         return template;
>>>     }
>>>
>>> -    public Class getObjectType() {
>>> +    public Class<DefaultConsumerTemplate> getObjectType() {
>>>         return DefaultConsumerTemplate.class;
>>>     }
>>>
>>> -    public boolean isSingleton() {
>>> -        return true;
>>> -    }
>>> -
>>>     public void destroy() throws Exception {
>>>         ServiceHelper.stopService(template);
>>>     }
>>> @@ -86,22 +67,6 @@ public abstract class AbstractCamelConsu
>>>     // Properties
>>>     // -------------------------------------------------------------------------
>>>
>>> -    public CamelContext getCamelContext() {
>>> -        return camelContext;
>>> -    }
>>> -
>>> -    public void setCamelContext(CamelContext camelContext) {
>>> -        this.camelContext = camelContext;
>>> -    }
>>> -
>>> -    public String getCamelContextId() {
>>> -        return camelContextId;
>>> -    }
>>> -
>>> -    public void setCamelContextId(String camelContextId) {
>>> -        this.camelContextId = camelContextId;
>>> -    }
>>> -
>>>     public Integer getMaximumCacheSize() {
>>>         return maximumCacheSize;
>>>     }
>>>
>>> Modified: camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelEndpointFactoryBean.java
>>> URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelEndpointFactoryBean.java?rev=1043407&r1=1043406&r2=1043407&view=diff
>>> ==============================================================================
>>> --- camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelEndpointFactoryBean.java (original)
>>> +++ camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelEndpointFactoryBean.java Wed Dec  8 13:27:44 2010
>>> @@ -32,29 +32,19 @@ import static org.apache.camel.util.Obje
>>>
>>>
>>>  @XmlAccessorType(XmlAccessType.FIELD)
>>> -public abstract class AbstractCamelEndpointFactoryBean extends IdentifiedType implements CamelContextAware {
>>> +public abstract class AbstractCamelEndpointFactoryBean extends AbstractCamelFactoryBean<Endpoint> {
>>>     @XmlAttribute
>>>     @Deprecated
>>>     private Boolean singleton = Boolean.FALSE;
>>>     @XmlAttribute
>>>     private String uri;
>>> -    @XmlAttribute
>>> -    private String camelContextId;
>>> -    @XmlTransient
>>> -    private CamelContext context;
>>>     @XmlTransient
>>>     private Endpoint endpoint;
>>>
>>> -    public Object getObject() throws Exception {
>>> +    public Endpoint getObject() throws Exception {
>>>         if (endpoint == null || !endpoint.isSingleton()) {
>>> -            if (context == null && camelContextId != null) {
>>> -                context = getCamelContextWithId(camelContextId);
>>> -            }
>>> -
>>> -            notNull(context, "context");
>>>             notNull(uri, "uri");
>>> -
>>> -            endpoint = context.getEndpoint(uri);
>>> +            endpoint = getCamelContext().getEndpoint(uri);
>>>             if (endpoint == null) {
>>>                 throw new NoSuchEndpointException(uri);
>>>             }
>>> @@ -62,33 +52,10 @@ public abstract class AbstractCamelEndpo
>>>         return endpoint;
>>>     }
>>>
>>> -    protected abstract CamelContext getCamelContextWithId(String camelContextId);
>>> -
>>> -    public Class getObjectType() {
>>> +    public Class<Endpoint> getObjectType() {
>>>         return Endpoint.class;
>>>     }
>>>
>>> -    public boolean isSingleton() {
>>> -        return false;
>>> -    }
>>> -
>>> -    public void setSingleton(boolean singleton) {
>>> -    }
>>> -
>>> -    public CamelContext getCamelContext() {
>>> -        return context;
>>> -    }
>>> -
>>> -
>>> -    /**
>>> -     * Sets the context to use to resolve endpoints
>>> -     *
>>> -     * @param context the context used to resolve endpoints
>>> -     */
>>> -    public void setCamelContext(CamelContext context) {
>>> -        this.context = context;
>>> -    }
>>> -
>>>     public String getUri() {
>>>         return uri;
>>>     }
>>> @@ -102,12 +69,4 @@ public abstract class AbstractCamelEndpo
>>>         this.uri = uri;
>>>     }
>>>
>>> -    public String getCamelContextId() {
>>> -        return camelContextId;
>>> -    }
>>> -
>>> -    public void setCamelContextId(String camelContextId) {
>>> -        this.camelContextId = camelContextId;
>>> -    }
>>> -
>>>  }
>>>
>>> Copied: camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelFactoryBean.java (from r1043385, camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelConsumerTemplateFactoryBean.java)
>>> URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelFactoryBean.java?p2=camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelFactoryBean.java&p1=camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelConsumerTemplateFactoryBean.java&r1=1043385&r2=1043407&rev=1043407&view=diff
>>> ==============================================================================
>>> --- camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelConsumerTemplateFactoryBean.java (original)
>>> +++ camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelFactoryBean.java Wed Dec  8 13:27:44 2010
>>> @@ -16,77 +16,40 @@
>>>  */
>>>  package org.apache.camel.core.xml;
>>>
>>> +import org.apache.camel.CamelContext;
>>> +import org.apache.camel.CamelContextAware;
>>> +import org.apache.camel.model.IdentifiedType;
>>> +
>>>  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 javax.xml.bind.annotation.XmlTransient;
>>> -import javax.xml.bind.annotation.XmlType;
>>>
>>> -import org.apache.camel.CamelContext;
>>> -import org.apache.camel.CamelContextAware;
>>> -import org.apache.camel.ConsumerTemplate;
>>> -import org.apache.camel.impl.DefaultConsumerTemplate;
>>> -import org.apache.camel.model.IdentifiedType;
>>> -import org.apache.camel.util.ServiceHelper;
>>> -
>>> -/**
>>> - * A factory for creating a new {@link org.apache.camel.ConsumerTemplate}
>>> - * instance with a minimum of XML
>>> - *
>>> - * @version $Revision: 934375 $
>>> - */
>>>  @XmlAccessorType(XmlAccessType.FIELD)
>>> -public abstract class AbstractCamelConsumerTemplateFactoryBean extends IdentifiedType implements CamelContextAware {
>>> -    @XmlTransient
>>> -    private ConsumerTemplate template;
>>> +public abstract class AbstractCamelFactoryBean<T> extends IdentifiedType implements CamelContextAware {
>>> +
>>>     @XmlAttribute
>>>     private String camelContextId;
>>>     @XmlTransient
>>>     private CamelContext camelContext;
>>> -    @XmlAttribute
>>> -    private Integer maximumCacheSize;
>>>
>>> -    public void afterPropertiesSet() throws Exception {
>>> -        if (camelContext == null && camelContextId != null) {
>>> -            camelContext = getCamelContextWithId(camelContextId);
>>> -        }
>>> -        if (camelContext == null) {
>>> -            throw new IllegalArgumentException("A CamelContext or a CamelContextId must be injected!");
>>> -        }
>>> -    }
>>> +    public abstract T getObject() throws Exception;
>>>
>>>     protected abstract CamelContext getCamelContextWithId(String camelContextId);
>>>
>>> -    public Object getObject() throws Exception {
>>> -        template = new DefaultConsumerTemplate(camelContext);
>>> -
>>> -        // set custom cache size if provided
>>> -        if (maximumCacheSize != null) {
>>> -            template.setMaximumCacheSize(maximumCacheSize);
>>> -        }
>>> -
>>> -        // must start it so its ready to use
>>> -        ServiceHelper.startService(template);
>>> -        return template;
>>> -    }
>>> -
>>> -    public Class getObjectType() {
>>> -        return DefaultConsumerTemplate.class;
>>> -    }
>>> -
>>> -    public boolean isSingleton() {
>>> -        return true;
>>> +    public void afterPropertiesSet() throws Exception {
>>>     }
>>>
>>>     public void destroy() throws Exception {
>>> -        ServiceHelper.stopService(template);
>>>     }
>>>
>>> -    // Properties
>>> -    // -------------------------------------------------------------------------
>>> -
>>>     public CamelContext getCamelContext() {
>>> +        if (camelContext == null && camelContextId != null) {
>>> +            camelContext = getCamelContextWithId(camelContextId);
>>> +        }
>>> +        if (camelContext == null) {
>>> +            throw new IllegalArgumentException("A CamelContext or a CamelContextId must be injected!");
>>> +        }
>>>         return camelContext;
>>>     }
>>>
>>> @@ -102,11 +65,10 @@ public abstract class AbstractCamelConsu
>>>         this.camelContextId = camelContextId;
>>>     }
>>>
>>> -    public Integer getMaximumCacheSize() {
>>> -        return maximumCacheSize;
>>> +    public boolean isSingleton() {
>>> +        return true;
>>>     }
>>>
>>> -    public void setMaximumCacheSize(Integer maximumCacheSize) {
>>> -        this.maximumCacheSize = maximumCacheSize;
>>> -    }
>>> -}
>>> \ No newline at end of file
>>> +    public abstract Class<? extends T> getObjectType();
>>> +
>>> +}
>>>
>>> Modified: camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelProducerTemplateFactoryBean.java
>>> URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelProducerTemplateFactoryBean.java?rev=1043407&r1=1043406&r2=1043407&view=diff
>>> ==============================================================================
>>> --- camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelProducerTemplateFactoryBean.java (original)
>>> +++ camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelProducerTemplateFactoryBean.java Wed Dec  8 13:27:44 2010
>>> @@ -37,30 +37,15 @@ import org.apache.camel.util.ServiceHelp
>>>  * @version $Revision: 934375 $
>>>  */
>>>  @XmlAccessorType(XmlAccessType.FIELD)
>>> -public abstract class AbstractCamelProducerTemplateFactoryBean extends IdentifiedType implements CamelContextAware {
>>> +public abstract class AbstractCamelProducerTemplateFactoryBean extends AbstractCamelFactoryBean<ProducerTemplate> {
>>>     @XmlTransient
>>>     private ProducerTemplate template;
>>>     @XmlAttribute(required = false)
>>>     private String defaultEndpoint;
>>>     @XmlAttribute
>>> -    private String camelContextId;
>>> -    @XmlTransient
>>> -    private CamelContext camelContext;
>>> -    @XmlAttribute
>>>     private Integer maximumCacheSize;
>>>
>>> -    public void afterPropertiesSet() throws Exception {
>>> -        if (camelContext == null && camelContextId != null) {
>>> -            camelContext = getCamelContextWithId(camelContextId);
>>> -        }
>>> -        if (camelContext == null) {
>>> -            throw new IllegalArgumentException("A CamelContext or a CamelContextId must be injected!");
>>> -        }
>>> -    }
>>> -
>>> -    protected abstract CamelContext getCamelContextWithId(String camelContextId);
>>> -
>>> -    public Object getObject() throws Exception {
>>> +    public ProducerTemplate getObject() throws Exception {
>>>         CamelContext context = getCamelContext();
>>>         if (defaultEndpoint != null) {
>>>             Endpoint endpoint = context.getEndpoint(defaultEndpoint);
>>> @@ -83,28 +68,16 @@ public abstract class AbstractCamelProdu
>>>         return template;
>>>     }
>>>
>>> -    public Class getObjectType() {
>>> +    public Class<DefaultProducerTemplate> getObjectType() {
>>>         return DefaultProducerTemplate.class;
>>>     }
>>>
>>> -    public boolean isSingleton() {
>>> -        return true;
>>> -    }
>>> -
>>>     public void destroy() throws Exception {
>>>         ServiceHelper.stopService(template);
>>>     }
>>>
>>>     // Properties
>>>     // -------------------------------------------------------------------------
>>> -    public CamelContext getCamelContext() {
>>> -        return camelContext;
>>> -    }
>>> -
>>> -    public void setCamelContext(CamelContext camelContext) {
>>> -        this.camelContext = camelContext;
>>> -    }
>>> -
>>>     public String getDefaultEndpoint() {
>>>         return defaultEndpoint;
>>>     }
>>> @@ -116,14 +89,6 @@ public abstract class AbstractCamelProdu
>>>         this.defaultEndpoint = defaultEndpoint;
>>>     }
>>>
>>> -    public String getCamelContextId() {
>>> -        return camelContextId;
>>> -    }
>>> -
>>> -    public void setCamelContextId(String camelContextId) {
>>> -        this.camelContextId = camelContextId;
>>> -    }
>>> -
>>>     public Integer getMaximumCacheSize() {
>>>         return maximumCacheSize;
>>>     }
>>>
>>> Modified: camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelThreadPoolFactoryBean.java
>>> URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelThreadPoolFactoryBean.java?rev=1043407&r1=1043406&r2=1043407&view=diff
>>> ==============================================================================
>>> --- camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelThreadPoolFactoryBean.java (original)
>>> +++ camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelThreadPoolFactoryBean.java Wed Dec  8 13:27:44 2010
>>> @@ -41,7 +41,7 @@ import static org.apache.camel.util.Obje
>>>  * @version $Revision: 925208 $
>>>  */
>>>  @XmlAccessorType(XmlAccessType.FIELD)
>>> -public abstract class AbstractCamelThreadPoolFactoryBean extends IdentifiedType implements CamelContextAware {
>>> +public abstract class AbstractCamelThreadPoolFactoryBean extends AbstractCamelFactoryBean<ExecutorService> {
>>>
>>>     @XmlAttribute(required = true)
>>>     private Integer poolSize;
>>> @@ -60,17 +60,8 @@ public abstract class AbstractCamelThrea
>>>     private String threadName;
>>>     @XmlAttribute
>>>     private Boolean daemon = Boolean.TRUE;
>>> -    @XmlAttribute
>>> -    private String camelContextId;
>>> -    @XmlTransient
>>> -    private CamelContext camelContext;
>>> -
>>> -    public Object getObject() throws Exception {
>>> -        if (camelContext == null && camelContextId != null) {
>>> -            camelContext = getCamelContextWithId(camelContextId);
>>> -        }
>>>
>>> -        notNull(camelContext, "camelContext");
>>> +    public ExecutorService getObject() throws Exception {
>>>         if (poolSize == null || poolSize <= 0) {
>>>             throw new IllegalArgumentException("PoolSize must be a positive number");
>>>         }
>>> @@ -81,21 +72,17 @@ public abstract class AbstractCamelThrea
>>>             rejected = rejectedPolicy.asRejectedExecutionHandler();
>>>         }
>>>
>>> -        ExecutorService answer = camelContext.getExecutorServiceStrategy().newThreadPool(getId(), getThreadName(), getPoolSize(), max,
>>> +        ExecutorService answer = getCamelContext().getExecutorServiceStrategy().newThreadPool(getId(), getThreadName(), getPoolSize(), max,
>>>                     getKeepAliveTime(), getTimeUnit(), getMaxQueueSize(), rejected, isDaemon());
>>>         return answer;
>>>     }
>>>
>>>     protected abstract CamelContext getCamelContextWithId(String camelContextId);
>>>
>>> -    public Class getObjectType() {
>>> +    public Class<ExecutorService> getObjectType() {
>>>         return ExecutorService.class;
>>>     }
>>>
>>> -    public boolean isSingleton() {
>>> -        return true;
>>> -    }
>>> -
>>>     public Integer getPoolSize() {
>>>         return poolSize;
>>>     }
>>> @@ -160,20 +147,4 @@ public abstract class AbstractCamelThrea
>>>         this.daemon = daemon;
>>>     }
>>>
>>> -    public String getCamelContextId() {
>>> -        return camelContextId;
>>> -    }
>>> -
>>> -    public void setCamelContextId(String camelContextId) {
>>> -        this.camelContextId = camelContextId;
>>> -    }
>>> -
>>> -    public CamelContext getCamelContext() {
>>> -        return camelContext;
>>> -    }
>>> -
>>> -    public void setCamelContext(CamelContext camelContext) {
>>> -        this.camelContext = camelContext;
>>> -    }
>>> -
>>>  }
>>> \ No newline at end of file
>>>
>>> Modified: camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/OSGiBlueprintTestSupport.java
>>> URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/OSGiBlueprintTestSupport.java?rev=1043407&r1=1043406&r2=1043407&view=diff
>>> ==============================================================================
>>> --- camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/OSGiBlueprintTestSupport.java (original)
>>> +++ camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/OSGiBlueprintTestSupport.java Wed Dec  8 13:27:44 2010
>>> @@ -20,6 +20,7 @@ import java.io.Closeable;
>>>  import java.io.IOException;
>>>  import java.io.InputStream;
>>>  import java.io.OutputStream;
>>> +import java.lang.reflect.Method;
>>>
>>>  import org.apache.camel.CamelContext;
>>>  import org.apache.camel.component.seda.SedaComponent;
>>> @@ -150,6 +151,18 @@ public class OSGiBlueprintTestSupport ex
>>>         assertEquals(1, ctx.getRoutes().size());
>>>     }
>>>
>>> +    @Test
>>> +    public void testEndpointInjection() throws Exception {
>>> +        getInstalledBundle("CamelBlueprintTestBundle10").start();
>>> +        BlueprintContainer ctn = getOsgiService(BlueprintContainer.class, "(osgi.blueprint.container.symbolicname=CamelBlueprintTestBundle10)", 5000);
>>> +        CamelContext ctx = getOsgiService(CamelContext.class, "(camel.context.symbolicname=CamelBlueprintTestBundle10)", 5000);
>>> +        Object producer = ctn.getComponentInstance("producer");
>>> +        assertNotNull(producer);
>>> +        assertEquals(TestProducer.class.getName(), producer.getClass().getName());
>>> +        Method mth = producer.getClass().getMethod("getTestEndpoint");
>>> +        assertNotNull(mth.invoke(producer));
>>> +    }
>>> +
>>>     @Before
>>>     public void setUp() throws Exception {
>>>     }
>>> @@ -182,39 +195,49 @@ public class OSGiBlueprintTestSupport ex
>>>                         .add("OSGI-INF/blueprint/test.xml", OSGiBlueprintTestSupport.class.getResource("blueprint-4.xml"))
>>>                         .add(TestRouteBuilder.class)
>>>                         .set(Constants.BUNDLE_SYMBOLICNAME, "CamelBlueprintTestBundle4")
>>> -                        .build(withBnd())).noStart(),
>>> +                        .set(Constants.DYNAMICIMPORT_PACKAGE, "*")
>>> +                        .build()).noStart(),
>>>
>>>                 bundle(newBundle()
>>>                         .add("OSGI-INF/blueprint/test.xml", OSGiBlueprintTestSupport.class.getResource("blueprint-5.xml"))
>>>                         .add(TestRouteBuilder.class)
>>>                         .set(Constants.BUNDLE_SYMBOLICNAME, "CamelBlueprintTestBundle5")
>>> -                        .build(withBnd())).noStart(),
>>> +                        .set(Constants.DYNAMICIMPORT_PACKAGE, "*")
>>> +                        .build()).noStart(),
>>>
>>>                 bundle(newBundle()
>>>                         .add("OSGI-INF/blueprint/test.xml", OSGiBlueprintTestSupport.class.getResource("blueprint-6.xml"))
>>> -                        .set(Constants.DYNAMICIMPORT_PACKAGE, "*")
>>>                         .set(Constants.BUNDLE_SYMBOLICNAME, "CamelBlueprintTestBundle6")
>>> -                        .build(withBnd())).noStart(),
>>> +                        .set(Constants.DYNAMICIMPORT_PACKAGE, "*")
>>> +                        .build()).noStart(),
>>>
>>>                 bundle(newBundle()
>>>                         .add("OSGI-INF/blueprint/test.xml", OSGiBlueprintTestSupport.class.getResource("blueprint-7.xml"))
>>>                         .add(TestInterceptStrategy.class)
>>> -                        .set(Constants.DYNAMICIMPORT_PACKAGE, "*")
>>>                         .set(Constants.BUNDLE_SYMBOLICNAME, "CamelBlueprintTestBundle7")
>>> +                        .set(Constants.DYNAMICIMPORT_PACKAGE, "*")
>>>                         .build()).noStart(),
>>>
>>>                 bundle(newBundle()
>>>                         .add("OSGI-INF/blueprint/test.xml", OSGiBlueprintTestSupport.class.getResource("blueprint-8.xml"))
>>>                         .add("org/apache/camel/component/properties/cheese.properties", OSGiBlueprintTestSupport.class.getResource("cheese.properties"))
>>> -                        .set(Constants.DYNAMICIMPORT_PACKAGE, "*")
>>>                         .set(Constants.BUNDLE_SYMBOLICNAME, "CamelBlueprintTestBundle8")
>>> +                        .set(Constants.DYNAMICIMPORT_PACKAGE, "*")
>>>                         .build()).noStart(),
>>>
>>>                 bundle(newBundle()
>>>                         .add("OSGI-INF/blueprint/test.xml", OSGiBlueprintTestSupport.class.getResource("blueprint-9.xml"))
>>>                         .add(TestRouteBuilder.class)
>>>                         .set(Constants.BUNDLE_SYMBOLICNAME, "CamelBlueprintTestBundle9")
>>> -                        .build(withBnd())).noStart(),
>>> +                        .set(Constants.DYNAMICIMPORT_PACKAGE, "*")
>>> +                        .build()).noStart(),
>>> +
>>> +                bundle(newBundle()
>>> +                        .add("OSGI-INF/blueprint/test.xml", OSGiBlueprintTestSupport.class.getResource("blueprint-10.xml"))
>>> +                        .add(TestProducer.class)
>>> +                        .set(Constants.BUNDLE_SYMBOLICNAME, "CamelBlueprintTestBundle10")
>>> +                        .set(Constants.DYNAMICIMPORT_PACKAGE, "*")
>>> +                        .build()).noStart(),
>>>
>>>                 // install the spring dm profile
>>>                 profile("spring.dm").version("1.2.0"),
>>> @@ -234,7 +257,7 @@ public class OSGiBlueprintTestSupport ex
>>>
>>>                 workingDirectory("target/paxrunner/"),
>>>
>>> -//                vmOption("-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"),
>>> +//                vmOption("-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5008"),
>>>
>>>                 //felix(),
>>>                 equinox());
>>>
>>> Added: camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/TestProducer.java
>>> URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/TestProducer.java?rev=1043407&view=auto
>>> ==============================================================================
>>> --- camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/TestProducer.java (added)
>>> +++ camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/TestProducer.java Wed Dec  8 13:27:44 2010
>>> @@ -0,0 +1,30 @@
>>> +/**
>>> + * 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.itest.osgi.blueprint;
>>> +
>>> +import org.apache.camel.EndpointInject;
>>> +import org.apache.camel.ProducerTemplate;
>>> +
>>> +public class TestProducer {
>>> +
>>> +    @EndpointInject(ref = "testEndpoint")
>>> +    private ProducerTemplate testEndpoint;
>>> +
>>> +    public ProducerTemplate getTestEndpoint() {
>>> +        return testEndpoint;
>>> +    }
>>> +}
>>>
>>> Added: camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/blueprint/blueprint-10.xml
>>> URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/blueprint/blueprint-10.xml?rev=1043407&view=auto
>>> ==============================================================================
>>> --- camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/blueprint/blueprint-10.xml (added)
>>> +++ camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/blueprint/blueprint-10.xml Wed Dec  8 13:27:44 2010
>>> @@ -0,0 +1,26 @@
>>> +<?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.
>>> +-->
>>> +<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
>>> +
>>> +    <camelContext xmlns="http://camel.apache.org/schema/blueprint">
>>> +        <endpoint id="testEndpoint" uri="seda:test.queue" />
>>> +    </camelContext>
>>> +
>>> +    <bean id="producer" class="org.apache.camel.itest.osgi.blueprint.TestProducer"/>
>>> +
>>> +</blueprint>
>>>
>>>
>>>
>>
>>
>>
>> --
>> Claus Ibsen
>> -----------------
>> FuseSource
>> Email: cibsen@fusesource.com
>> Web: http://fusesource.com
>> Twitter: davsclaus
>> Blog: http://davsclaus.blogspot.com/
>> Author of Camel in Action: http://www.manning.com/ibsen/
>>
>
>
>
> --
> Cheers,
> Guillaume Nodet
> ------------------------
> Blog: http://gnodet.blogspot.com/
> ------------------------
> Open Source SOA
> http://fusesource.com
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Mime
View raw message