http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/java/org/apache/camel/cdi/Mock.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/Mock.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/Mock.java index 27e9650..bcc4500 100644 --- a/components/camel-cdi/src/main/java/org/apache/camel/cdi/Mock.java +++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/Mock.java @@ -25,21 +25,31 @@ import javax.inject.Qualifier; /** * A qualifier for injecting instances of {@link org.apache.camel.component.mock.MockEndpoint} into a bean. + * + * @deprecated Use {@link org.apache.camel.cdi.Uri} instead: + * + * <pre><code> + * {@literal @}Inject + * {@literal @}Uri("mock:outbound") + * MockEndpoint mock; + * </code></pre> */ +@Deprecated @Qualifier @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER}) public @interface Mock { /** - * Returns an optional URI used to create the MockEndpoint + * Returns an optional URI used to create the {@code MockEndpoint}. */ @Nonbinding String value() default ""; /** - * Returns the name of the CamelContext to use to resolve the endpoint for this URI + * Returns the name of the Camel context to use to resolve the {@code MockEndpoint}. */ @Nonbinding String context() default ""; + }
http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/java/org/apache/camel/cdi/RoutesXml.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/RoutesXml.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/RoutesXml.java index 48f6377..aa83263 100644 --- a/components/camel-cdi/src/main/java/org/apache/camel/cdi/RoutesXml.java +++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/RoutesXml.java @@ -85,4 +85,4 @@ public final class RoutesXml { return loadRoutesFromFile(camelContext, new File(fileName)); } -} +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/java/org/apache/camel/cdi/Uri.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/Uri.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/Uri.java old mode 100644 new mode 100755 index 0d320f1..0fff3d1 --- a/components/camel-cdi/src/main/java/org/apache/camel/cdi/Uri.java +++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/Uri.java @@ -24,20 +24,18 @@ import javax.enterprise.util.Nonbinding; import javax.inject.Qualifier; /** - * An injection annotation to define the <a href="http://camel.apache.org/uris.html">Camel URI</a> used - * to reference the underlying <a href="http://camel.apache.org/endpoint.html">Camel Endpoint</a>. + * A CDI qualifier to define the <a href="http://camel.apache.org/uris.html">Camel URI</a> associated to + * the annotated resource. This annotation can be used to annotate an {@code @Inject} injection point for + * values of type {@link org.apache.camel.Endpoint} or {@link org.apache.camel.ProducerTemplate}. For example: + * <pre><code> + * {@literal @}Inject + * {@literal @}Uri("mock:foo") + * Endpoint endpoint; * - * This annotation can be used to annotate an @Inject injection point for values of type - * {@link org.apache.camel.Endpoint} or {@link org.apache.camel.ProducerTemplate} with a String URI. - * - * For example: - * <code> - * public class Foo { - * @Inject @Uri("mock:foo") Endpoint endpoint; - * - * @Inject @Uri("seda:bar") ProducerTemplate producer; - * } - * </code> + * {@literal @}Inject + * {@literal @}Uri("seda:bar") + * ProducerTemplate producer; + * </code></pre> */ @Qualifier @Retention(RetentionPolicy.RUNTIME) @@ -45,14 +43,21 @@ import javax.inject.Qualifier; public @interface Uri { /** - * Returns the <a href="http://camel.apache.org/uris.html">Camel URI</a> of the endpoint + * Returns the <a href="http://camel.apache.org/uris.html">Camel URI</a> of the resource. */ - @Nonbinding - String value(); + @Nonbinding String value(); /** - * Returns the name of the CamelContext to use to resolve the endpoint for this URI + * Returns the name of the {@code CamelContext} to use to resolve the Camel resource for this URI. + * + * @deprecated Use the {@link ContextName} qualifier to specify the name of the {@code CamelContext} instead: + * <pre><code> + * {@literal @}Inject + * {@literal @}ContextName("foo") + * {@literal @}Uri("seda:bar") + * Endpoint endpoint; + * </code></pre> */ - @Nonbinding - String context() default ""; + @Deprecated + @Nonbinding String context() default ""; } http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/java/org/apache/camel/cdi/Vetoed.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/Vetoed.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/Vetoed.java new file mode 100644 index 0000000..b6bd5cb --- /dev/null +++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/Vetoed.java @@ -0,0 +1,32 @@ +/** + * 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.cdi; + +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +/** + * Annotation to veto an {@code AnnotatedType} for CDI 1.1+ backward compatibility. + */ +@Documented +@Target(value = { TYPE }) +@Retention(value = RUNTIME) +@interface Vetoed { +} http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/java/org/apache/camel/cdi/component/properties/CdiPropertiesComponent.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/component/properties/CdiPropertiesComponent.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/component/properties/CdiPropertiesComponent.java deleted file mode 100644 index 921f6a1..0000000 --- a/components/camel-cdi/src/main/java/org/apache/camel/cdi/component/properties/CdiPropertiesComponent.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * 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.cdi.component.properties; - -import javax.inject.Named; - -import org.apache.camel.component.properties.PropertiesComponent; - -/** - * Simple extension for properties component which uses custom property resolver. - */ -@Named("properties") -public class CdiPropertiesComponent extends PropertiesComponent { - - public CdiPropertiesComponent() { - setPropertiesParser(new CdiPropertiesParser(this)); - } - -} http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/java/org/apache/camel/cdi/component/properties/CdiPropertiesParser.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/component/properties/CdiPropertiesParser.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/component/properties/CdiPropertiesParser.java deleted file mode 100644 index e9cde59..0000000 --- a/components/camel-cdi/src/main/java/org/apache/camel/cdi/component/properties/CdiPropertiesParser.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * 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.cdi.component.properties; - -import java.util.Properties; - -import org.apache.camel.component.properties.DefaultPropertiesParser; -import org.apache.camel.component.properties.PropertiesComponent; -import org.apache.deltaspike.core.api.config.ConfigResolver; - -/** - * Properties parser which uses {@link ConfigResolver} from deltaspike to obtain - * configuration properties. If property is not recognized by deltaspike execution - * will be delegated to parent implementation. - */ -public class CdiPropertiesParser extends DefaultPropertiesParser { - - public CdiPropertiesParser(PropertiesComponent propertiesComponent) { - super(propertiesComponent); - } - - @Override - public String parseProperty(String key, String value, Properties properties) { - String answer = ConfigResolver.getPropertyValue(key); - - if (answer != null) { - return answer; - } - - return super.parseProperty(key, value, properties); - } - -} http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/BeanAdapter.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/BeanAdapter.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/BeanAdapter.java deleted file mode 100644 index 3bab39a..0000000 --- a/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/BeanAdapter.java +++ /dev/null @@ -1,133 +0,0 @@ -/** - * 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.cdi.internal; - -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.List; - -import org.apache.camel.Consume; -import org.apache.camel.EndpointInject; -import org.apache.camel.Produce; -import org.apache.camel.cdi.ContextName; -import org.apache.camel.impl.DefaultCamelBeanPostProcessor; - -/** - * Contains the bean and the consume methods - */ -public class BeanAdapter { - - private final List<Method> consumeMethods = new ArrayList<Method>(); - private final List<Method> produceMethods = new ArrayList<Method>(); - private final List<Method> endpointMethods = new ArrayList<Method>(); - private final List<Field> produceFields = new ArrayList<Field>(); - private final List<Field> endpointFields = new ArrayList<Field>(); - private final ContextName startup; - - public BeanAdapter(ContextName startup) { - this.startup = startup; - } - - /** - * Returns true if this adapter is empty (i.e. has no custom adapter code) - */ - public boolean isEmpty() { - return consumeMethods.isEmpty() && produceMethods.isEmpty() && produceFields.isEmpty() - && endpointMethods.isEmpty() && endpointFields.isEmpty(); - } - - public void addConsumeMethod(Method method) { - consumeMethods.add(method); - } - - public void addProduceMethod(Method method) { - produceMethods.add(method); - } - - public void addProduceField(Field field) { - produceFields.add(field); - } - - public void addEndpointField(Field field) { - endpointFields.add(field); - } - - public void addEndpointMethod(Method method) { - endpointMethods.add(method); - } - - /** - * Perform injections - */ - public void inject(CamelExtension camelExtension, Object reference, String beanName) { - for (Method method : consumeMethods) { - Consume annotation = method.getAnnotation(Consume.class); - if (annotation != null) { - String contextName = CamelExtension.getCamelContextName(annotation.context(), startup); - DefaultCamelBeanPostProcessor postProcessor = camelExtension.getPostProcessor(contextName, null); - if (postProcessor != null) { - postProcessor.getPostProcessorHelper().consumerInjection(method, reference, beanName); - } - } - } - for (Method method : produceMethods) { - Produce annotation = method.getAnnotation(Produce.class); - if (annotation != null) { - String contextName = CamelExtension.getCamelContextName(annotation.context(), startup); - DefaultCamelBeanPostProcessor postProcessor = camelExtension.getPostProcessor(contextName, null); - if (postProcessor != null && postProcessor.getPostProcessorHelper().matchContext(contextName)) { - postProcessor.setterInjection(method, reference, beanName, annotation.uri(), annotation.ref(), - annotation.property()); - } - } - } - for (Method method : endpointMethods) { - EndpointInject annotation = method.getAnnotation(EndpointInject.class); - if (annotation != null) { - String contextName = CamelExtension.getCamelContextName(annotation.context(), startup); - DefaultCamelBeanPostProcessor postProcessor = camelExtension.getPostProcessor(contextName, null); - if (postProcessor != null && postProcessor.getPostProcessorHelper().matchContext(contextName)) { - postProcessor.setterInjection(method, reference, beanName, annotation.uri(), annotation.ref(), - annotation.property()); - - } - } - } - for (Field field : produceFields) { - Produce annotation = field.getAnnotation(Produce.class); - if (annotation != null) { - String contextName = CamelExtension.getCamelContextName(annotation.context(), startup); - DefaultCamelBeanPostProcessor postProcessor = camelExtension.getPostProcessor(contextName, null); - if (postProcessor != null && postProcessor.getPostProcessorHelper().matchContext(contextName)) { - postProcessor.injectField(field, annotation.uri(), annotation.ref(), - annotation.property(), reference, beanName); - } - } - } - for (Field field : endpointFields) { - EndpointInject annotation = field.getAnnotation(EndpointInject.class); - String contextName = CamelExtension.getCamelContextName(annotation.context(), startup); - DefaultCamelBeanPostProcessor postProcessor = camelExtension.getPostProcessor(contextName, null); - if (postProcessor != null && postProcessor.getPostProcessorHelper().matchContext(contextName)) { - postProcessor.injectField(field, annotation.uri(), annotation.ref(), - annotation.property(), reference, beanName); - } - } - } - -} http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/CamelContextBean.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/CamelContextBean.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/CamelContextBean.java deleted file mode 100644 index 1ea5159..0000000 --- a/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/CamelContextBean.java +++ /dev/null @@ -1,138 +0,0 @@ -/** - * 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.cdi.internal; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Type; -import java.util.Arrays; -import java.util.HashSet; -import java.util.Set; -import javax.enterprise.context.ApplicationScoped; -import javax.enterprise.context.spi.CreationalContext; -import javax.enterprise.inject.spi.Bean; -import javax.enterprise.inject.spi.BeanManager; -import javax.enterprise.inject.spi.InjectionPoint; -import javax.enterprise.inject.spi.InjectionTarget; - -import org.apache.camel.CamelContext; -import org.apache.camel.cdi.CdiCamelContext; -import org.apache.camel.util.ObjectHelper; -import org.apache.deltaspike.core.api.literal.AnyLiteral; -import org.apache.deltaspike.core.api.literal.DefaultLiteral; - -/** - * Description of camel context bean. - */ -public class CamelContextBean implements Bean<CdiCamelContext> { - - private final BeanManager beanManager; - private final String name; - private final String camelContextName; - private final InjectionTarget<CdiCamelContext> target; - private final CamelContextConfig config; - - public CamelContextBean(BeanManager beanManager) { - this(beanManager, "CamelContext", "", new CamelContextConfig()); - } - - public CamelContextBean(BeanManager beanManager, String name, String camelContextName, - CamelContextConfig config) { - this.beanManager = beanManager; - this.name = name; - this.camelContextName = camelContextName; - this.config = config; - this.target = beanManager.createInjectionTarget(beanManager.createAnnotatedType(CdiCamelContext.class)); - } - - @Override - public CdiCamelContext create(CreationalContext<CdiCamelContext> context) { - // create CdiCamelContext and set its name - CdiCamelContext camelContext = target.produce(context); - if (ObjectHelper.isNotEmpty(camelContextName)) { - camelContext.setName(camelContextName); - } - - // then do dependency injection - target.inject(camelContext, context); - - // and post construct which will start Camel - target.postConstruct(camelContext); - - context.push(camelContext); - return camelContext; - } - - @Override - public void destroy(CdiCamelContext instance, CreationalContext<CdiCamelContext> context) { - target.preDestroy(instance); - target.dispose(instance); - context.release(); - } - - @Override - public Set<Type> getTypes() { - return new HashSet<Type>(Arrays.asList(Object.class, CamelContext.class, CdiCamelContext.class)); - } - - @Override - public Set<Annotation> getQualifiers() { - return new HashSet<Annotation>(Arrays.asList(new DefaultLiteral(), new AnyLiteral())); - } - - @Override - public Class<? extends Annotation> getScope() { - return ApplicationScoped.class; - } - - @Override - public String getName() { - return name; - } - - @Override - public boolean isNullable() { - return false; - } - - @Override - public Set<InjectionPoint> getInjectionPoints() { - return target.getInjectionPoints(); - } - - @Override - public Class<?> getBeanClass() { - return CdiCamelContext.class; - } - - @Override - public Set<Class<? extends Annotation>> getStereotypes() { - return new HashSet<Class<? extends Annotation>>(); - } - - @Override - public boolean isAlternative() { - return false; - } - - public String getCamelContextName() { - return camelContextName; - } - - public void configureCamelContext(CdiCamelContext camelContext) { - config.configure(camelContext, beanManager); - } -} http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/CamelContextConfig.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/CamelContextConfig.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/CamelContextConfig.java deleted file mode 100644 index 65c92ac..0000000 --- a/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/CamelContextConfig.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * 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.cdi.internal; - -import java.lang.reflect.Type; -import java.util.LinkedHashSet; -import java.util.Set; - -import javax.enterprise.context.spi.CreationalContext; -import javax.enterprise.inject.spi.AnnotatedType; -import javax.enterprise.inject.spi.Bean; -import javax.enterprise.inject.spi.BeanManager; - -import org.apache.camel.RoutesBuilder; -import org.apache.camel.RuntimeCamelException; -import org.apache.camel.cdi.CdiCamelContext; -import org.apache.camel.model.RouteContainer; -import org.apache.camel.util.ObjectHelper; - -/** - * Configuration options to be applied to a {@link org.apache.camel.CamelContext} by a {@link CamelContextBean} - */ -public class CamelContextConfig { - // use a set to avoid duplicates - private final Set<Bean<?>> routeBuilderBeans = new LinkedHashSet<Bean<?>>(); - private final Set<AnnotatedType<?>> patRouteBuilders = new LinkedHashSet<AnnotatedType<?>>(); - - public void addRouteBuilderBean(Bean<?> bean) { - routeBuilderBeans.add(bean); - } - - public void configure(CdiCamelContext camelContext, BeanManager beanManager) { - for (AnnotatedType<?> pat : patRouteBuilders) { - final Set<Bean<?>> beans = beanManager.getBeans(pat.getJavaClass()); - final Bean<?> bean = beanManager.resolve(beans); - routeBuilderBeans.add(bean); - } - patRouteBuilders.clear(); - - for (Bean<?> bean : routeBuilderBeans) { - CreationalContext<?> createContext = beanManager.createCreationalContext(bean); - Class<?> beanClass = bean.getBeanClass(); - Set<Type> types = bean.getTypes(); - for (Type type : types) { - // lets use the first type for producer methods - if (type instanceof Class<?>) { - beanClass = (Class<?>) type; - break; - } - } - Object reference = beanManager.getReference(bean, beanClass, createContext); - ObjectHelper.notNull(reference, "Could not instantiate bean of type: " + beanClass.getName() + " for " + bean); - try { - // we should not toString reference instance as in CDI it may be proxied - if (reference instanceof RoutesBuilder) { - RoutesBuilder routeBuilder = (RoutesBuilder)reference; - camelContext.addRoutes(routeBuilder); - } else if (reference instanceof RouteContainer) { - RouteContainer routeContainer = (RouteContainer)reference; - camelContext.addRouteDefinitions(routeContainer.getRoutes()); - } else { - throw new IllegalArgumentException("Invalid route builder of type: " + beanClass.getName() - + ". Should be RoutesBuilder or RoutesContainer"); - } - } catch (Exception e) { - throw new RuntimeCamelException("Error adding route builder of type: " + beanClass.getName() - + " to CamelContext: " + camelContext.getName() + " due " + e.getMessage(), e); - } - } - } - - public void addRouteBuilderBean(final AnnotatedType<?> process) { - patRouteBuilders.add(process); - } -} http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/CamelContextMap.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/CamelContextMap.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/CamelContextMap.java deleted file mode 100644 index b2d5487..0000000 --- a/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/CamelContextMap.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * 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.cdi.internal; - -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -import javax.annotation.PostConstruct; -import javax.enterprise.context.ApplicationScoped; -import javax.enterprise.inject.Instance; -import javax.inject.Inject; - -import org.apache.camel.CamelContext; -import org.apache.camel.util.ObjectHelper; - -/** - * A helper class to be able to resolve CamelContext instances by their name - */ -@ApplicationScoped -public class CamelContextMap { - @Inject - private Instance<CamelContext> camelContexts; - - private Map<String, CamelContext> camelContextMap = new HashMap<String, CamelContext>(); - - @PostConstruct - public void start() { - ObjectHelper.notNull(camelContexts, "camelContexts"); - - Iterator<CamelContext> iterator = camelContexts.iterator(); - while (iterator.hasNext()) { - CamelContext camelContext = iterator.next(); - camelContextMap.put(camelContext.getName(), camelContext); - } - } - - /** - * Returns the {@link CamelContext} for the given context name - */ - public CamelContext getCamelContext(String name) { - CamelContext answer = camelContextMap.get(name); - if (answer == null && ObjectHelper.isEmpty(name)) { - // lets return the first one for the default context? - Collection<CamelContext> values = camelContextMap.values(); - for (CamelContext value : values) { - answer = value; - break; - } - } - return answer; - - } - - /** - * Returns the CamelContext for the given name or throw an exception - */ - public CamelContext getMandatoryCamelContext(String contextName) { - CamelContext camelContext = getCamelContext(contextName); - ObjectHelper.notNull(camelContext, "No CamelContext found for name '" + contextName + "' when available names are " + camelContextMap.keySet()); - return camelContext; - } - - public Map<String, CamelContext> getCamelContextMap() { - return camelContextMap; - } -} http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/CamelExtension.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/CamelExtension.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/CamelExtension.java deleted file mode 100644 index a9c715b..0000000 --- a/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/CamelExtension.java +++ /dev/null @@ -1,342 +0,0 @@ -/** - * 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.cdi.internal; - -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import javax.enterprise.context.spi.CreationalContext; -import javax.enterprise.event.Observes; -import javax.enterprise.inject.spi.AfterBeanDiscovery; -import javax.enterprise.inject.spi.AfterDeploymentValidation; -import javax.enterprise.inject.spi.Annotated; -import javax.enterprise.inject.spi.AnnotatedType; -import javax.enterprise.inject.spi.Bean; -import javax.enterprise.inject.spi.BeanManager; -import javax.enterprise.inject.spi.Extension; -import javax.enterprise.inject.spi.InjectionTarget; -import javax.enterprise.inject.spi.ProcessAnnotatedType; -import javax.enterprise.inject.spi.ProcessBean; -import javax.enterprise.inject.spi.ProcessInjectionTarget; -import javax.enterprise.inject.spi.ProcessProducerMethod; -import javax.enterprise.util.AnnotationLiteral; -import javax.inject.Inject; - -import org.apache.camel.CamelContext; -import org.apache.camel.CamelContextAware; -import org.apache.camel.Consume; -import org.apache.camel.EndpointInject; -import org.apache.camel.Produce; -import org.apache.camel.RoutesBuilder; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.cdi.CdiBeanManagerHelper; -import org.apache.camel.cdi.CdiCamelContext; -import org.apache.camel.cdi.ContextName; -import org.apache.camel.impl.DefaultCamelBeanPostProcessor; -import org.apache.camel.model.RouteContainer; -import org.apache.camel.util.ObjectHelper; -import org.apache.camel.util.ReflectionHelper; -import org.apache.deltaspike.core.util.metadata.builder.AnnotatedTypeBuilder; - -/** - * Set of camel specific hooks for CDI. - */ -public class CamelExtension implements Extension { - - private static class InjectLiteral extends AnnotationLiteral<Inject> { - private static final long serialVersionUID = 1L; - } - - @Inject - BeanManager beanManager; - - private CamelContextMap camelContextMap; - private final Set<Bean<?>> eagerBeans = new HashSet<Bean<?>>(); - private final Map<String, CamelContextConfig> camelContextConfigMap = new HashMap<String, CamelContextConfig>(); - private final List<CamelContextBean> camelContextBeans = new ArrayList<CamelContextBean>(); - - public CamelExtension() { - } - - /** - * If no context name is specified then default it to the value from - * the {@link org.apache.camel.cdi.ContextName} annotation - */ - public static String getCamelContextName(String context, ContextName annotation) { - if (ObjectHelper.isEmpty(context) && annotation != null) { - return annotation.value(); - } - return context; - } - - /** - * Process camel context aware bean definitions. - * - * @param process Annotated type. - * @throws Exception In case of exceptions. - */ - protected void contextAwareness(@Observes ProcessAnnotatedType<CamelContextAware> process) throws Exception { - AnnotatedType<CamelContextAware> at = process.getAnnotatedType(); - - Method method = at.getJavaClass().getMethod("setCamelContext", CamelContext.class); - AnnotatedTypeBuilder<CamelContextAware> builder = new AnnotatedTypeBuilder<CamelContextAware>() - .readFromType(at) - .addToMethod(method, new InjectLiteral()); - process.setAnnotatedType(builder.create()); - } - - protected void detectRouteBuilders(@Observes ProcessAnnotatedType<?> process) throws Exception { - AnnotatedType<?> annotatedType = process.getAnnotatedType(); - ContextName annotation = annotatedType.getAnnotation(ContextName.class); - Class<?> javaClass = annotatedType.getJavaClass(); - if (annotation != null && isRoutesBean(javaClass)) { - addRouteBuilderBean(annotatedType, annotation); - } - } - - private void addRouteBuilderBean(final AnnotatedType<?> process, ContextName annotation) { - final CamelContextConfig config = getCamelConfig(annotation.value()); - config.addRouteBuilderBean(process); - } - - /** - * Disable creation of default CamelContext bean and rely on context created - * and managed by extension. - * - * @param process Annotated type. - */ - protected void disableDefaultContext(@Observes ProcessAnnotatedType<? extends CamelContext> process) { - process.veto(); - } - - /** - * Registers managed camel bean. - * - * @param abd After bean discovery event. - * @param manager Bean manager. - */ - protected void registerManagedCamelContext(@Observes AfterBeanDiscovery abd, BeanManager manager) { - // lets ensure we have at least one camel context - if (camelContextConfigMap.isEmpty()) { - abd.addBean(new CamelContextBean(manager)); - } else { - Set<Map.Entry<String, CamelContextConfig>> entries = camelContextConfigMap.entrySet(); - for (Map.Entry<String, CamelContextConfig> entry : entries) { - String name = entry.getKey(); - CamelContextConfig config = entry.getValue(); - CamelContextBean camelContextBean = new CamelContextBean(manager, "CamelContext:" + name, name, config); - camelContextBeans.add(camelContextBean); - abd.addBean(camelContextBean); - } - } - } - - /** - * Lets detect all beans annotated with @Consume so they can be auto-registered - */ - public void detectConsumeBeans(@Observes ProcessBean<?> event) { - final Bean<?> bean = event.getBean(); - Class<?> beanClass = bean.getBeanClass(); - ReflectionHelper.doWithMethods(beanClass, new ReflectionHelper.MethodCallback() { - @Override - public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException { - Consume consume = method.getAnnotation(Consume.class); - if (consume != null) { - eagerBeans.add(bean); - } - } - }); - } - - /** - * Lets detect all beans annotated of type {@link RouteBuilder} - * which are annotated with {@link org.apache.camel.cdi.ContextName} - * so they can be auto-registered - */ - public void detectRouteBuilderBeans(@Observes ProcessBean<?> event) { - final Bean<?> bean = event.getBean(); - Class<?> beanClass = bean.getBeanClass(); - if (isRoutesBean(beanClass)) { - addRouteBuilderBean(bean, beanClass.getAnnotation(ContextName.class)); - } - } - - private void addRouteBuilderBean(Bean<?> bean, ContextName annotation) { - if (annotation != null) { - String contextName = annotation.value(); - CamelContextConfig config = getCamelConfig(contextName); - config.addRouteBuilderBean(bean); - } - } - - private CamelContextConfig getCamelConfig(final String contextName) { - CamelContextConfig config = camelContextConfigMap.get(contextName); - if (config == null) { - config = new CamelContextConfig(); - camelContextConfigMap.put(contextName, config); - } - return config; - } - - /** - * Lets detect all producer methods creating instances of {@link RouteBuilder} which are annotated with - * {@link org.apache.camel.cdi.ContextName} so they can be auto-registered - */ - public void detectProducerRoutes(@Observes ProcessProducerMethod<?, ?> event) { - Annotated annotated = event.getAnnotated(); - ContextName annotation = annotated.getAnnotation(ContextName.class); - Class<?> returnType = event.getAnnotatedProducerMethod().getJavaMember().getReturnType(); - if (isRoutesBean(returnType)) { - addRouteBuilderBean(event.getBean(), annotation); - } - } - - /** - * Lets force the CDI container to create all beans annotated with @Consume so that the consumer becomes active - */ - public void startConsumeBeans(@Observes AfterDeploymentValidation event, BeanManager beanManager) throws Exception { - for (CamelContextBean bean : camelContextBeans) { - String name = bean.getCamelContextName(); - CamelContext context = getCamelContext(name, beanManager); - if (context == null) { - throw new IllegalStateException( - "CamelContext '" + name + "' has not been injected into the CamelContextMap"); - } - bean.configureCamelContext((CdiCamelContext) context); - } - - for (Bean<?> bean : eagerBeans) { - // force lazy creation to start the consumer - CreationalContext<?> creationalContext = beanManager.createCreationalContext(bean); - beanManager.getReference(bean, bean.getBeanClass(), creationalContext); - } - } - - /** - * Lets perform injection of all beans which use Camel annotations - */ - @SuppressWarnings("unchecked") - public void onInjectionTarget(@Observes ProcessInjectionTarget<?> event) { - final InjectionTarget injectionTarget = event.getInjectionTarget(); - AnnotatedType annotatedType = event.getAnnotatedType(); - final Class<Object> beanClass = annotatedType.getJavaClass(); - // TODO this is a bit of a hack - what should the bean name be? - final String beanName = injectionTarget.toString(); - ContextName contextName = annotatedType.getAnnotation(ContextName.class); - final BeanAdapter adapter = createBeanAdapter(beanClass, contextName); - if (!adapter.isEmpty()) { - DelegateInjectionTarget newTarget = new DelegateInjectionTarget(injectionTarget) { - @Override - public void inject(Object instance, CreationalContext ctx) { - super.inject(instance, ctx); - - // now lets inject our Camel injections to the bean instance - adapter.inject(CamelExtension.this, instance, beanName); - } - }; - event.setInjectionTarget(newTarget); - } - } - - /** - * Perform injection on an existing bean such as a test case which is created directly by a testing framework. - * <p/> - * This is because BeanProvider.injectFields() does not invoke the onInjectionTarget() method so the injection - * of @Produce / @EndpointInject and processing of the @Consume annotations are not performed. - */ - public void inject(Object bean) { - Class<?> beanClass = bean.getClass(); - ContextName contextName = beanClass.getAnnotation(ContextName.class); - final BeanAdapter adapter = createBeanAdapter(beanClass, contextName); - if (!adapter.isEmpty()) { - // TODO this is a bit of a hack - what should the bean name be? - final String beanName = bean.toString(); - adapter.inject(this, bean, beanName); - } - } - - private BeanAdapter createBeanAdapter(Class<?> beanClass, ContextName contextName) { - final BeanAdapter adapter = new BeanAdapter(contextName); - ReflectionHelper.doWithFields(beanClass, new ReflectionHelper.FieldCallback() { - @Override - public void doWith(Field field) throws IllegalArgumentException, IllegalAccessException { - Produce produce = field.getAnnotation(Produce.class); - if (produce != null && !injectAnnotatedField(field)) { - adapter.addProduceField(field); - } - EndpointInject endpointInject = field.getAnnotation(EndpointInject.class); - if (endpointInject != null) { - adapter.addEndpointField(field); - } - } - }); - ReflectionHelper.doWithMethods(beanClass, new ReflectionHelper.MethodCallback() { - @Override - public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException { - Consume consume = method.getAnnotation(Consume.class); - if (consume != null) { - adapter.addConsumeMethod(method); - } - Produce produce = method.getAnnotation(Produce.class); - if (produce != null) { - adapter.addProduceMethod(method); - } - EndpointInject endpointInject = method.getAnnotation(EndpointInject.class); - if (endpointInject != null) { - adapter.addEndpointMethod(method); - } - } - }); - return adapter; - } - - protected DefaultCamelBeanPostProcessor getPostProcessor(String context, BeanManager beanManager) { - CamelContext camelContext = getCamelContext(context, beanManager); - if (camelContext != null) { - return new DefaultCamelBeanPostProcessor(camelContext); - } else { - throw new IllegalArgumentException("No such CamelContext '" + context + "' available!"); - } - } - - protected CamelContext getCamelContext(String context, BeanManager beanManager) { - BeanManager manager = this.beanManager != null ? this.beanManager : beanManager; - if (camelContextMap == null && manager != null) { - camelContextMap = CdiBeanManagerHelper.lookupBeanByType(manager, CamelContextMap.class); - } - ObjectHelper.notNull(camelContextMap, "Could not resolve CamelContextMap"); - return camelContextMap.getCamelContext(context); - } - - /** - * Returns true if this field is annotated with @Inject - */ - protected static boolean injectAnnotatedField(Field field) { - return field.getAnnotation(Inject.class) != null; - } - - protected boolean isRoutesBean(Class<?> returnType) { - return (RoutesBuilder.class.isAssignableFrom(returnType) || RouteContainer.class.isAssignableFrom(returnType)) - && !Modifier.isAbstract(returnType.getModifiers()); - } -} http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/CamelFactory.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/CamelFactory.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/CamelFactory.java deleted file mode 100644 index d79dd6c..0000000 --- a/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/CamelFactory.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * 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.cdi.internal; - -import javax.enterprise.inject.Produces; -import javax.enterprise.inject.spi.Annotated; -import javax.enterprise.inject.spi.Bean; -import javax.enterprise.inject.spi.InjectionPoint; -import javax.inject.Inject; - -import org.apache.camel.CamelContext; -import org.apache.camel.Endpoint; -import org.apache.camel.ProducerTemplate; -import org.apache.camel.cdi.ContextName; -import org.apache.camel.cdi.Mock; -import org.apache.camel.cdi.Uri; -import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.util.CamelContextHelper; -import org.apache.camel.util.ObjectHelper; - -/** - * Produces {@link Endpoint} and {@link org.apache.camel.ProducerTemplate} instances for injection into beans - */ -public class CamelFactory { - @Inject CamelContextMap camelContextMap; - - @Produces - @Mock - public MockEndpoint createMockEndpoint(InjectionPoint point) { - Mock annotation = point.getAnnotated().getAnnotation(Mock.class); - ObjectHelper.notNull(annotation, "Should be annotated with @Mock"); - String uri = annotation.value(); - if (ObjectHelper.isEmpty(uri)) { - uri = "mock:" + point.getMember().getName(); - } - return CamelContextHelper.getMandatoryEndpoint(getCamelContext(point, annotation.context()), uri, MockEndpoint.class); - } - - @Produces - @Uri("") - public Endpoint createEndpoint(InjectionPoint point) { - Annotated annotated = point.getAnnotated(); - Uri uri = annotated.getAnnotation(Uri.class); - ObjectHelper.notNull(uri, "Should be annotated with @Uri"); - return CamelContextHelper.getMandatoryEndpoint(getCamelContext(point, uri.context()), uri.value()); - } - - @Produces - @Uri("") - public ProducerTemplate createProducerTemplate(InjectionPoint point) { - Annotated annotated = point.getAnnotated(); - Uri uri = annotated.getAnnotation(Uri.class); - CamelContext camelContext = getCamelContext(point, uri.context()); - ProducerTemplate producerTemplate = camelContext.createProducerTemplate(); - ObjectHelper.notNull(uri, "Should be annotated with @Uri"); - Endpoint endpoint = CamelContextHelper.getMandatoryEndpoint(camelContext, uri.value()); - producerTemplate.setDefaultEndpoint(endpoint); - return producerTemplate; - } - - protected CamelContext getCamelContext(InjectionPoint point, String contextName) { - ContextName startup = point.getAnnotated().getAnnotation(ContextName.class); - if (startup == null) { - Bean<?> bean = point.getBean(); - if (bean != null) { - startup = bean.getBeanClass().getAnnotation(ContextName.class); - } - } - String name = CamelExtension.getCamelContextName(contextName, startup); - return camelContextMap.getMandatoryCamelContext(name); - } -} http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/DelegateInjectionTarget.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/DelegateInjectionTarget.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/DelegateInjectionTarget.java deleted file mode 100644 index dc6a4dc..0000000 --- a/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/DelegateInjectionTarget.java +++ /dev/null @@ -1,63 +0,0 @@ -/** - * 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.cdi.internal; - -import java.util.Set; -import javax.enterprise.context.spi.CreationalContext; -import javax.enterprise.inject.spi.InjectionPoint; -import javax.enterprise.inject.spi.InjectionTarget; - -/** - * A helper class for creating delegate implementations of {@link InjectionTarget} - */ -public abstract class DelegateInjectionTarget implements InjectionTarget { - private final InjectionTarget delegate; - - public DelegateInjectionTarget(InjectionTarget<Object> delegate) { - this.delegate = delegate; - } - - @Override - public void dispose(Object instance) { - delegate.dispose(instance); - } - - @Override - public Set<InjectionPoint> getInjectionPoints() { - return delegate.getInjectionPoints(); - } - - @Override - public void inject(Object instance, CreationalContext ctx) { - delegate.inject(instance, ctx); - } - - @Override - public void postConstruct(Object instance) { - delegate.postConstruct(instance); - } - - @Override - public void preDestroy(Object instance) { - delegate.preDestroy(instance); - } - - @Override - public Object produce(CreationalContext creationalContext) { - return delegate.produce(creationalContext); - } -} http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/resources/META-INF/LICENSE.txt ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/main/resources/META-INF/LICENSE.txt b/components/camel-cdi/src/main/resources/META-INF/LICENSE.txt deleted file mode 100644 index 6b0b127..0000000 --- a/components/camel-cdi/src/main/resources/META-INF/LICENSE.txt +++ /dev/null @@ -1,203 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed 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. - http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/resources/META-INF/NOTICE.txt ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/main/resources/META-INF/NOTICE.txt b/components/camel-cdi/src/main/resources/META-INF/NOTICE.txt deleted file mode 100644 index 2e215bf..0000000 --- a/components/camel-cdi/src/main/resources/META-INF/NOTICE.txt +++ /dev/null @@ -1,11 +0,0 @@ - ========================================================================= - == NOTICE file corresponding to the section 4 d of == - == the Apache License, Version 2.0, == - == in this case for the Apache Camel distribution. == - ========================================================================= - - This product includes software developed by - The Apache Software Foundation (http://www.apache.org/). - - Please read the different LICENSE files present in the licenses directory of - this distribution. http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/resources/META-INF/beans.xml ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/main/resources/META-INF/beans.xml b/components/camel-cdi/src/main/resources/META-INF/beans.xml index 112d56d..dd78a5d 100644 --- a/components/camel-cdi/src/main/resources/META-INF/beans.xml +++ b/components/camel-cdi/src/main/resources/META-INF/beans.xml @@ -1,18 +1,24 @@ <?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 + 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 + 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. + 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/> \ No newline at end of file +<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee + http://xmlns.jcp.org/xml/ns/javaee/beans_1_0.xsd" + version="1.0" bean-discovery-mode="all"> + +</beans> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension b/components/camel-cdi/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension index fecef7b..7f78ef9 100644 --- a/components/camel-cdi/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension +++ b/components/camel-cdi/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension @@ -14,4 +14,5 @@ # See the License for the specific language governing permissions and # limitations under the License. # -org.apache.camel.cdi.internal.CamelExtension \ No newline at end of file + +org.apache.camel.cdi.CdiCamelExtension \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/CamelContextAwareTest.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/CamelContextAwareTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/CamelContextAwareTest.java deleted file mode 100644 index 79716c3..0000000 --- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/CamelContextAwareTest.java +++ /dev/null @@ -1,38 +0,0 @@ -/** - * 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.cdi; - -import javax.inject.Inject; - -import org.apache.camel.cdi.support.ContextAwareBean; -import org.junit.Test; - -/** - * Test context awareness. - */ -public class CamelContextAwareTest extends CdiContextTestSupport { - - @Inject - private ContextAwareBean bean; - - @Test - public void shouldInjectCamelContextToBean() throws InterruptedException { - assertNotNull(bean.getCamelContext()); - assertSame(context, bean.getCamelContext()); - } - -} http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/CamelEndpointInjectTest.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/CamelEndpointInjectTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/CamelEndpointInjectTest.java deleted file mode 100644 index 9884b5c..0000000 --- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/CamelEndpointInjectTest.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * 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.cdi; - -import javax.inject.Inject; - -import org.apache.camel.Endpoint; -import org.apache.camel.cdi.support.CamelEndpointInjectedBean; -import org.apache.camel.component.mock.MockEndpoint; -import org.junit.Test; - -/** - * Test endpoint injection using vanilla camel annotations without the use of @Inject - */ -public class CamelEndpointInjectTest extends CdiTestSupport { - - @Inject - private CamelEndpointInjectedBean bean; - - @Test - public void shouldInjectEndpoint() { - assertNotNull(bean); - Endpoint endpoint = bean.getEndpoint(); - assertNotNull("Could not find injected endpoint!", endpoint); - assertEquals("endpoint URI", "direct://inject", endpoint.getEndpointUri()); - - MockEndpoint mockEndpoint = bean.getMockEndpoint(); - assertNotNull("Could not find injected mock endpoint!", mockEndpoint); - assertEquals("mock endpoint URI", "mock://result", mockEndpoint.getEndpointUri()); - } - -} http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/CamelExtensionTest.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/CamelExtensionTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/CamelExtensionTest.java deleted file mode 100644 index f7a83fc..0000000 --- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/CamelExtensionTest.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * 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.cdi; - -import javax.inject.Inject; - -import org.apache.camel.CamelContext; -import org.junit.Test; - -/** - * Test camel extension. - */ -public class CamelExtensionTest extends CdiTestSupport { - - @Inject - private CamelContext context; - - @Test - public void shouldBeStartedByTestFramework() { - assertTrue(context.getStatus().isStarted()); - assertFalse(context.getStatus().isStopped()); - assertFalse(context.getStatus().isStopping()); - } - -} http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/CdiContextTestSupport.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/CdiContextTestSupport.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/CdiContextTestSupport.java deleted file mode 100644 index c82530b..0000000 --- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/CdiContextTestSupport.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * 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.cdi; - -import java.util.logging.LogManager; - -import org.apache.camel.CamelContext; -import org.apache.camel.cdi.internal.CamelExtension; -import org.apache.camel.test.junit4.CamelTestSupport; -import org.apache.deltaspike.cdise.api.CdiContainer; -import org.apache.deltaspike.cdise.api.CdiContainerLoader; -import org.apache.deltaspike.core.api.provider.BeanProvider; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; - -/** - * Base class for cdi tests. - */ -public abstract class CdiContextTestSupport extends CamelTestSupport { - - private CdiContainer cdiContainer; - - /** - * Reset configuration of java util logging and forward it to slf4j. - * - * @throws Exception In case of failures. - */ - @BeforeClass - public static void before() throws Exception { - LogManager.getLogManager().reset(); - org.slf4j.bridge.SLF4JBridgeHandler.install(); - } - - @Before - public void setUp() throws Exception { - // set up CDI container before camel context start up - cdiContainer = CdiContainerLoader.getCdiContainer(); - cdiContainer.boot(); - - // inject fields inside child classes - BeanProvider.injectFields(this); - - super.setUp(); - } - - @After - public void tearDown() throws Exception { - super.tearDown(); - cdiContainer.shutdown(); - } - - @Override - protected CamelContext createCamelContext() throws Exception { - return BeanProvider.getContextualReference(CdiCamelContext.class); - } - - @Override - protected void applyCamelPostProcessor() throws Exception { - // lets perform any custom camel injection on the test case object - CamelExtension camelExtension = BeanProvider.getContextualReference(CamelExtension.class); - camelExtension.inject(this); - } -} - http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/CdiTestSupport.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/CdiTestSupport.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/CdiTestSupport.java deleted file mode 100644 index 0a002ff..0000000 --- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/CdiTestSupport.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * 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.cdi; - -import java.util.logging.LogManager; - -import org.apache.camel.test.junit4.TestSupport; -import org.apache.deltaspike.cdise.api.CdiContainer; -import org.apache.deltaspike.cdise.api.CdiContainerLoader; -import org.apache.deltaspike.core.api.provider.BeanProvider; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; - -/** - * Base class for cdi tests. - */ -public abstract class CdiTestSupport extends TestSupport { - - private CdiContainer cdiContainer; - - /** - * Reset configuration of java util logging and forward it to slf4j. - * - * @throws Exception In case of failures. - */ - @BeforeClass - public static void before() throws Exception { - LogManager.getLogManager().reset(); - org.slf4j.bridge.SLF4JBridgeHandler.install(); - } - - @Before - public void setUp() throws Exception { - // set up CDI container before camel context start up - cdiContainer = CdiContainerLoader.getCdiContainer(); - cdiContainer.boot(); - - BeanProvider.injectFields(this); - } - - @After - public void tearDown() throws Exception { - cdiContainer.shutdown(); - } - -} - http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/ConsumeStubbedEndpointTest.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/ConsumeStubbedEndpointTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/ConsumeStubbedEndpointTest.java deleted file mode 100644 index bee7627..0000000 --- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/ConsumeStubbedEndpointTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * 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.cdi; - -import javax.inject.Inject; - -import org.apache.camel.Consume; -import org.apache.camel.ProducerTemplate; -import org.apache.camel.component.mock.MockEndpoint; -import org.junit.Test; - -/** - * Tests sending & consuming to a stubbed out component called 'cheese' which is created - * via the {@link org.apache.camel.cdi.support.CheeseComponentFactory} class - */ -public class ConsumeStubbedEndpointTest extends CdiTestSupport { - - @Inject @Mock - private MockEndpoint result; - - @Inject @Uri("cheese:start") - private ProducerTemplate producer; - - @Consume(uri = "cheese:start") - public void onStart(String body) { - producer.sendBody("mock:result", "Hello " + body + "!"); - } - - @Test - public void consumeAnnotation() throws Exception { - assertNotNull("Could not inject producer", producer); - assertNotNull("Could not inject mock endpoint", result); - - result.expectedBodiesReceived("Hello world!"); - - producer.sendBody("world"); - - result.assertIsSatisfied(); - } - -} http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/ConsumeTest.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/ConsumeTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/ConsumeTest.java deleted file mode 100644 index ee78313..0000000 --- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/ConsumeTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * 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.cdi; - -import javax.inject.Inject; - -import org.apache.camel.Consume; -import org.apache.camel.ProducerTemplate; -import org.apache.camel.component.mock.MockEndpoint; -import org.junit.Test; - -/** - * Test consume annotation - */ -public class ConsumeTest extends CdiTestSupport { - - @Inject @Mock - private MockEndpoint result; - - @Inject @Uri("seda:start") - private ProducerTemplate producer; - - @Consume(uri = "seda:start") - public void onStart(String body) { - producer.sendBody("mock:result", "Hello " + body + "!"); - } - - @Test - public void consumeAnnotation() throws Exception { - assertNotNull("Could not inject producer", producer); - assertNotNull("Could not inject mock endpoint", result); - - result.expectedBodiesReceived("Hello world!"); - - producer.sendBody("world"); - - result.assertIsSatisfied(); - } - -}