camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r1380252 - in /camel/trunk: camel-core/src/main/java/org/apache/camel/impl/ components/camel-cdi/ components/camel-cdi/src/main/java/org/apache/camel/cdi/ components/camel-cdi/src/main/java/org/apache/camel/component/cdi/ components/camel-c...
Date Mon, 03 Sep 2012 14:39:43 GMT
Author: jstrachan
Date: Mon Sep  3 14:39:42 2012
New Revision: 1380252

URL: http://svn.apache.org/viewvc?rev=1380252&view=rev
Log:
simplified the code to reuse more existing camel code & ensure more consistent error messages
and allowed injection via @Inject @Uri("someURI") on Endpoint / ProducerTemplate injections
for more CDI-like injection. also moved the Uri and Mock annotations into org.apache.camel.cdi
as they are the (optional) public programming API for working with CDI

Added:
    camel/trunk/components/camel-cdi/src/main/java/org/apache/camel/cdi/
    camel/trunk/components/camel-cdi/src/main/java/org/apache/camel/cdi/Mock.java   (with
props)
    camel/trunk/components/camel-cdi/src/main/java/org/apache/camel/cdi/Uri.java   (with props)
    camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/EndpointPropertyInjectTest.java
  (with props)
    camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/EndpointUriInjectTest.java
  (with props)
    camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/EndpointUriInjectedBean.java
  (with props)
    camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/EndpointUriPropertyInjectedBean.java
  (with props)
Removed:
    camel/trunk/components/camel-cdi/src/main/java/org/apache/camel/component/cdi/Mock.java
    camel/trunk/components/camel-cdi/src/main/java/org/apache/camel/component/cdi/util/
Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/impl/CamelPostProcessorHelper.java
    camel/trunk/components/camel-cdi/pom.xml
    camel/trunk/components/camel-cdi/src/main/java/org/apache/camel/component/cdi/internal/CamelFactory.java
    camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/ConsumeTest.java
    camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/ProduceInjectTest.java
    camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/MockEndpointInjectedBean.java
    camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/ProduceInjectedBean.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/CamelPostProcessorHelper.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/CamelPostProcessorHelper.java?rev=1380252&r1=1380251&r2=1380252&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/CamelPostProcessorHelper.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/CamelPostProcessorHelper.java
Mon Sep  3 14:39:42 2012
@@ -132,7 +132,7 @@ public class CamelPostProcessorHelper im
         return new UnitOfWorkProcessor(answer);
     }
 
-    protected Endpoint getEndpointInjection(Object bean, String uri, String name, String
propertyName,
+    public Endpoint getEndpointInjection(Object bean, String uri, String name, String propertyName,
                                             String injectionPointName, boolean mandatory)
{
         if (ObjectHelper.isEmpty(uri) && ObjectHelper.isEmpty(name)) {
             // if no uri or ref, then fallback and try the endpoint property

Modified: camel/trunk/components/camel-cdi/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cdi/pom.xml?rev=1380252&r1=1380251&r2=1380252&view=diff
==============================================================================
--- camel/trunk/components/camel-cdi/pom.xml (original)
+++ camel/trunk/components/camel-cdi/pom.xml Mon Sep  3 14:39:42 2012
@@ -43,6 +43,7 @@
           *
       </camel.osgi.import>
       <camel.osgi.export.pkg>
+          org.apache.camel.cdi.*;${camel.osgi.version},
           org.apache.camel.component.cdi.*;${camel.osgi.version}
       </camel.osgi.export.pkg>
   </properties>

Added: camel/trunk/components/camel-cdi/src/main/java/org/apache/camel/cdi/Mock.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cdi/src/main/java/org/apache/camel/cdi/Mock.java?rev=1380252&view=auto
==============================================================================
--- camel/trunk/components/camel-cdi/src/main/java/org/apache/camel/cdi/Mock.java (added)
+++ camel/trunk/components/camel-cdi/src/main/java/org/apache/camel/cdi/Mock.java Mon Sep
 3 14:39:42 2012
@@ -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.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+/**
+ * A qualifier for injecting instances of {@link org.apache.camel.component.mock.MockEndpoint}
into a bean.
+ */
+@Qualifier
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER})
+public @interface Mock {
+}

Propchange: camel/trunk/components/camel-cdi/src/main/java/org/apache/camel/cdi/Mock.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-cdi/src/main/java/org/apache/camel/cdi/Uri.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cdi/src/main/java/org/apache/camel/cdi/Uri.java?rev=1380252&view=auto
==============================================================================
--- camel/trunk/components/camel-cdi/src/main/java/org/apache/camel/cdi/Uri.java (added)
+++ camel/trunk/components/camel-cdi/src/main/java/org/apache/camel/cdi/Uri.java Mon Sep 
3 14:39:42 2012
@@ -0,0 +1,36 @@
+/**
+ * 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.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * 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>
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER})
+public @interface Uri {
+
+    /**
+     * Returns the <a href="http://camel.apache.org/uris.html">Camel URI</a>
of the endpoint
+     */
+    String value();
+}

Propchange: camel/trunk/components/camel-cdi/src/main/java/org/apache/camel/cdi/Uri.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: camel/trunk/components/camel-cdi/src/main/java/org/apache/camel/component/cdi/internal/CamelFactory.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cdi/src/main/java/org/apache/camel/component/cdi/internal/CamelFactory.java?rev=1380252&r1=1380251&r2=1380252&view=diff
==============================================================================
--- camel/trunk/components/camel-cdi/src/main/java/org/apache/camel/component/cdi/internal/CamelFactory.java
(original)
+++ camel/trunk/components/camel-cdi/src/main/java/org/apache/camel/component/cdi/internal/CamelFactory.java
Mon Sep  3 14:39:42 2012
@@ -16,8 +16,10 @@
  */
 package org.apache.camel.component.cdi.internal;
 
-import java.lang.reflect.Type;
 import javax.enterprise.inject.Produces;
+import javax.enterprise.inject.spi.Annotated;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
 import javax.enterprise.inject.spi.InjectionPoint;
 import javax.inject.Inject;
 
@@ -26,9 +28,13 @@ import org.apache.camel.Endpoint;
 import org.apache.camel.EndpointInject;
 import org.apache.camel.Produce;
 import org.apache.camel.ProducerTemplate;
-import org.apache.camel.component.cdi.Mock;
+import org.apache.camel.cdi.Mock;
+import org.apache.camel.cdi.Uri;
 import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.impl.CamelPostProcessorHelper;
+import org.apache.camel.util.CamelContextHelper;
 import org.apache.camel.util.ObjectHelper;
+import org.apache.deltaspike.core.api.provider.BeanProvider;
 
 /**
  * produces {@link Endpoint} and {@link org.apache.camel.ProducerTemplate} instances for
injection into beans
@@ -40,66 +46,80 @@ public class CamelFactory {
     @Produces
     @Mock
     public MockEndpoint createMockEndpoint(InjectionPoint point) {
-        String url = "";
-        String name = "";
+        String uri = "";
+        String ref = "";
         EndpointInject annotation = point.getAnnotated().getAnnotation(EndpointInject.class);
         if (annotation != null) {
-            url = annotation.uri();
-            name = annotation.ref();
+            uri = annotation.uri();
+            ref = annotation.ref();
         }
-        if (ObjectHelper.isEmpty(name)) {
-            name = point.getMember().getName();
+        if (ObjectHelper.isEmpty(ref)) {
+            ref = point.getMember().getName();
         }
-        if (ObjectHelper.isEmpty(url)) {
-            url = "mock:" + name;
+        if (ObjectHelper.isEmpty(uri)) {
+            uri = "mock:" + ref;
         }
-        return camelContext.getEndpoint(url, MockEndpoint.class);
+        return CamelContextHelper.getMandatoryEndpoint(camelContext, uri, MockEndpoint.class);
     }
 
     @SuppressWarnings("unchecked")
     @Produces
-    public Endpoint createEndpoint(InjectionPoint point) {
-        Class<? extends Endpoint> endpointType = Endpoint.class;
-        Type pointType = point.getType();
-        if (pointType instanceof Class<?>) {
-            endpointType = (Class<? extends Endpoint>)pointType;
-        }
-        EndpointInject annotation = point.getAnnotated().getAnnotation(EndpointInject.class);
-        if (annotation != null) {
-            String uri = annotation.uri();
-            if (ObjectHelper.isEmpty(uri)) {
-                String ref = annotation.ref();
-                if (ObjectHelper.isNotEmpty(ref)) {
-                    uri = "ref:" + ref;
-                } else {
-
-                }
-            }
-            return camelContext.getEndpoint(uri, endpointType);
-        }
-        throw new IllegalArgumentException(
-                "Could not create instance of Endpoint for the given injection point " +
point);
+    public Endpoint createEndpoint(InjectionPoint point, BeanManager beanManager) {
+        Annotated annotated = point.getAnnotated();
+        Uri uri = annotated.getAnnotation(Uri.class);
+        if (uri != null) {
+            return CamelContextHelper.getMandatoryEndpoint(camelContext, uri.value());
+        }
+        EndpointInject annotation = annotated.getAnnotation(EndpointInject.class);
+        ObjectHelper.notNull(annotation, "Must be annotated with @EndpointInject");
+        return getEndpoint(point, annotation.uri(), annotation.ref(), annotation.property());
     }
 
     @Produces
     public ProducerTemplate createProducerTemplate(InjectionPoint point) {
         ProducerTemplate producerTemplate = camelContext.createProducerTemplate();
-        Produce annotation = point.getAnnotated().getAnnotation(Produce.class);
-        if (annotation != null) {
-            String uri = annotation.uri();
-            String ref = annotation.ref();
-            String property = annotation.property();
-            if (ObjectHelper.isEmpty(uri)) {
-                if (ObjectHelper.isNotEmpty(ref)) {
-                    uri = "ref:" + ref;
-                } else {
-                    ObjectHelper.notEmpty(property, "uri, ref or property", annotation);
-                    // now lets get the property value
-                    throw new UnsupportedOperationException("property not yet supported");
-                }
+        Annotated annotated = point.getAnnotated();
+        Uri uri = annotated.getAnnotation(Uri.class);
+        Endpoint endpoint = null;
+        if (uri != null) {
+            endpoint = CamelContextHelper.getMandatoryEndpoint(camelContext, uri.value());
+        } else {
+            Produce annotation = annotated.getAnnotation(Produce.class);
+            if (annotation != null) {
+                endpoint = getEndpoint(point, annotation.uri(), annotation.ref(), annotation.property());
             }
-            producerTemplate.setDefaultEndpointUri(uri);
+        }
+        if (endpoint != null) {
+            producerTemplate.setDefaultEndpoint(endpoint);
         }
         return producerTemplate;
     }
+
+    protected Endpoint getEndpoint(InjectionPoint point, String uri, String ref, String property)
{
+        String injectName = getInjectionPointName(point);
+        if (ObjectHelper.isEmpty(property)) {
+            return resolveEndpoint(uri, ref, injectName);
+        } else {
+            throw new UnsupportedOperationException();
+/*
+            TODO this code won't work in CDI as we've not yet created the bean being injected
yet
+            so cannot evaluate the property yet!
+
+            CamelPostProcessorHelper helper = new CamelPostProcessorHelper(camelContext);
+            Bean<?> bean = point.getBean();
+            Class<?> beanClass = bean.getBeanClass();
+            Object instance = BeanProvider.getContextualReference((Class)beanClass, bean);
+            return helper.getEndpointInjection(instance, uri, ref, property, injectName,
true);
+*/
+        }
+    }
+
+    private Endpoint resolveEndpoint(String uri, String ref, String injectionName) {
+        return CamelContextHelper.getEndpointInjection(camelContext, uri, ref, injectionName,
true);
+    }
+
+    private String getInjectionPointName(InjectionPoint point) {
+        // TODO is there a better name?
+        return point.toString();
+    }
 }

Modified: camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/ConsumeTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/ConsumeTest.java?rev=1380252&r1=1380251&r2=1380252&view=diff
==============================================================================
--- camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/ConsumeTest.java (original)
+++ camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/ConsumeTest.java Mon
Sep  3 14:39:42 2012
@@ -21,8 +21,6 @@ import javax.inject.Inject;
 import org.apache.camel.Consume;
 import org.apache.camel.Produce;
 import org.apache.camel.ProducerTemplate;
-import org.apache.camel.cdi.support.MockEndpointInjectedBean;
-import org.apache.camel.component.cdi.Mock;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.junit.Test;
 

Added: camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/EndpointPropertyInjectTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/EndpointPropertyInjectTest.java?rev=1380252&view=auto
==============================================================================
--- camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/EndpointPropertyInjectTest.java
(added)
+++ camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/EndpointPropertyInjectTest.java
Mon Sep  3 14:39:42 2012
@@ -0,0 +1,45 @@
+/**
+ * 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.EndpointUriPropertyInjectedBean;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * Test endpoint injection using a dynamic property expression
+ */
+public class EndpointPropertyInjectTest extends CdiTestSupport {
+
+    @Inject
+    private EndpointUriPropertyInjectedBean bean;
+
+    // TODO not supported yet!
+    @Ignore
+    public void shouldInjectEndpointByProperty() {
+        assertNotNull(bean);
+        Endpoint endpoint = bean.getEndpoint();
+        assertNotNull("Could not find injected endpoint!", endpoint);
+        assertTrue("Endpoint should be a MockEndpoint but was " + endpoint, endpoint instanceof
MockEndpoint);
+        assertEquals("Endpoint URI", "mock://injectedByProperty", endpoint.getEndpointUri());
+    }
+
+}

Propchange: camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/EndpointPropertyInjectTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/EndpointUriInjectTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/EndpointUriInjectTest.java?rev=1380252&view=auto
==============================================================================
--- camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/EndpointUriInjectTest.java
(added)
+++ camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/EndpointUriInjectTest.java
Mon Sep  3 14:39:42 2012
@@ -0,0 +1,44 @@
+/**
+ * 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.EndpointInjectedBean;
+import org.apache.camel.cdi.support.EndpointUriInjectedBean;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.Test;
+
+/**
+ * Test endpoint injection
+ */
+public class EndpointUriInjectTest extends CdiTestSupport {
+
+    @Inject
+    private EndpointUriInjectedBean bean;
+
+    @Test
+    public void shouldInjectEndpoint() {
+        assertNotNull(bean);
+        Endpoint endpoint = bean.getEndpoint();
+        assertNotNull("Could not find injected endpoint!", endpoint);
+        assertTrue("Endpoint should be a MockEndpoint but was " + endpoint, endpoint instanceof
MockEndpoint);
+        assertEquals("Endpoint URI", "mock://uriInjected", endpoint.getEndpointUri());
+    }
+
+}

Propchange: camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/EndpointUriInjectTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/ProduceInjectTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/ProduceInjectTest.java?rev=1380252&r1=1380251&r2=1380252&view=diff
==============================================================================
--- camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/ProduceInjectTest.java
(original)
+++ camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/ProduceInjectTest.java
Mon Sep  3 14:39:42 2012
@@ -36,6 +36,10 @@ public class ProduceInjectTest extends C
         ProducerTemplate producer = bean.getProducer();
         assertNotNull("Could not find injected producer!", producer);
         assertEquals("producer default URI", "mock://foo", producer.getDefaultEndpoint().getEndpointUri());
+
+        ProducerTemplate producer2 = bean.getProducer2();
+        assertNotNull("Could not find injected producer2!", producer2);
+        assertEquals("producer2 default URI", "mock://bar", producer2.getDefaultEndpoint().getEndpointUri());
     }
 
 }

Added: camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/EndpointUriInjectedBean.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/EndpointUriInjectedBean.java?rev=1380252&view=auto
==============================================================================
--- camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/EndpointUriInjectedBean.java
(added)
+++ camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/EndpointUriInjectedBean.java
Mon Sep  3 14:39:42 2012
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.cdi.support;
+
+import javax.inject.Inject;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.cdi.Uri;
+
+/**
+ */
+public class EndpointUriInjectedBean {
+
+    @Inject @Uri("mock:uriInjected")
+    private Endpoint endpoint;
+
+    public Endpoint getEndpoint() {
+        return endpoint;
+    }
+
+    public void setEndpoint(Endpoint endpoint) {
+        this.endpoint = endpoint;
+    }
+}

Propchange: camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/EndpointUriInjectedBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/EndpointUriPropertyInjectedBean.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/EndpointUriPropertyInjectedBean.java?rev=1380252&view=auto
==============================================================================
--- camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/EndpointUriPropertyInjectedBean.java
(added)
+++ camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/EndpointUriPropertyInjectedBean.java
Mon Sep  3 14:39:42 2012
@@ -0,0 +1,43 @@
+/**
+ * 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.support;
+
+import javax.inject.Inject;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.cdi.Uri;
+
+/**
+ */
+public class EndpointUriPropertyInjectedBean {
+
+    @Inject @EndpointInject(property = "injectUri")
+    private Endpoint endpoint;
+
+    public Endpoint getEndpoint() {
+        return endpoint;
+    }
+
+    public void setEndpoint(Endpoint endpoint) {
+        this.endpoint = endpoint;
+    }
+
+    public String getInjectUri() {
+        return "mock:injectedByProperty";
+    }
+}

Propchange: camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/EndpointUriPropertyInjectedBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/MockEndpointInjectedBean.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/MockEndpointInjectedBean.java?rev=1380252&r1=1380251&r2=1380252&view=diff
==============================================================================
--- camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/MockEndpointInjectedBean.java
(original)
+++ camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/MockEndpointInjectedBean.java
Mon Sep  3 14:39:42 2012
@@ -19,7 +19,7 @@ package org.apache.camel.cdi.support;
 import javax.inject.Inject;
 
 import org.apache.camel.EndpointInject;
-import org.apache.camel.component.cdi.Mock;
+import org.apache.camel.cdi.Mock;
 import org.apache.camel.component.mock.MockEndpoint;
 
 public class MockEndpointInjectedBean {

Modified: camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/ProduceInjectedBean.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/ProduceInjectedBean.java?rev=1380252&r1=1380251&r2=1380252&view=diff
==============================================================================
--- camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/ProduceInjectedBean.java
(original)
+++ camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/ProduceInjectedBean.java
Mon Sep  3 14:39:42 2012
@@ -18,18 +18,23 @@ package org.apache.camel.cdi.support;
 
 import javax.inject.Inject;
 
-import org.apache.camel.EndpointInject;
 import org.apache.camel.Produce;
 import org.apache.camel.ProducerTemplate;
-import org.apache.camel.component.cdi.Mock;
-import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.cdi.Uri;
 
 public class ProduceInjectedBean {
 
     @Produce(uri = "mock:foo")
     private ProducerTemplate producer;
 
+    @Inject @Uri("mock:bar")
+    private ProducerTemplate producer2;
+
     public ProducerTemplate getProducer() {
         return producer;
     }
+
+    public ProducerTemplate getProducer2() {
+        return producer2;
+    }
 }



Mime
View raw message