camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hadr...@apache.org
Subject svn commit: r1329531 - in /camel/trunk/components/camel-cdi: ./ src/main/java/org/apache/camel/component/cdi/ src/main/java/org/apache/camel/component/cdi/util/ src/main/resources/META-INF/services/ src/test/java/org/apache/camel/cdi/ src/test/java/org...
Date Tue, 24 Apr 2012 02:30:44 GMT
Author: hadrian
Date: Tue Apr 24 02:30:44 2012
New Revision: 1329531

URL: http://svn.apache.org/viewvc?rev=1329531&view=rev
Log:
CAMEL-5145. Patches applied with thanks to Lukasz

Removed:
    camel/trunk/components/camel-cdi/src/main/java/org/apache/camel/component/cdi/util/AnyLiteral.java
    camel/trunk/components/camel-cdi/src/main/java/org/apache/camel/component/cdi/util/BeanManagerProvider.java
    camel/trunk/components/camel-cdi/src/main/java/org/apache/camel/component/cdi/util/BeanProvider.java
    camel/trunk/components/camel-cdi/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension
    camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/CdiContainerBeanManagerTest.java
Modified:
    camel/trunk/components/camel-cdi/pom.xml
    camel/trunk/components/camel-cdi/src/main/java/org/apache/camel/component/cdi/CdiBeanRegistry.java
    camel/trunk/components/camel-cdi/src/main/java/org/apache/camel/component/cdi/CdiCamelContext.java
    camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/store/Item.java

Modified: camel/trunk/components/camel-cdi/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cdi/pom.xml?rev=1329531&r1=1329530&r2=1329531&view=diff
==============================================================================
--- camel/trunk/components/camel-cdi/pom.xml (original)
+++ camel/trunk/components/camel-cdi/pom.xml Tue Apr 24 02:30:44 2012
@@ -1,133 +1,145 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  Licensed to the Apache Software Foundation (ASF) under one or more
-  contributor license agreements.  See the NOTICE file distributed with
-  this work for additional information regarding copyright ownership.
-  The ASF licenses this file to You under the Apache License, Version 2.0
-  (the "License"); you may not use this file except in compliance with
-  the License.  You may obtain a copy of the License at
-
-  http://www.apache.org/licenses/LICENSE-2.0
-
-  Unless required by applicable law or agreed to in writing, software
-  distributed under the License is distributed on an "AS IS" BASIS,
-  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  See the License for the specific language governing permissions and
-  limitations under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-
-  <modelVersion>4.0.0</modelVersion>
-
-  <parent>
-    <groupId>org.apache.camel</groupId>
-    <artifactId>camel-parent</artifactId>
-    <version>2.10-SNAPSHOT</version>
-    <relativePath>../../parent</relativePath>
-  </parent>
-
-  <artifactId>camel-cdi</artifactId>
-  <packaging>bundle</packaging>
-  <name>Camel :: CDI</name>
-  <description>Camel CDI</description>
-
-  <properties>
-    <camel.osgi.export.pkg>org.apache.camel.component.cdi.*</camel.osgi.export.pkg>
-  </properties>
-
-  <dependencies>
-
-    <dependency>
-      <groupId>org.apache.camel</groupId>
-      <artifactId>camel-core</artifactId>
-    </dependency>
-
-    <!-- SPI API -->
-    <dependency>
-      <groupId>org.apache.openwebbeans</groupId>
-      <artifactId>openwebbeans-spi</artifactId>
-      <version>${openwebbeans-version}</version>
-    </dependency>
-
-    <!-- EL Plugin -->
-    <dependency>
-      <groupId>org.apache.openwebbeans</groupId>
-      <artifactId>openwebbeans-el10</artifactId>
-      <version>${openwebbeans-version}</version>
-    </dependency>
-
-    <!-- Interceptor API -->
-    <dependency>
-      <groupId>org.apache.geronimo.specs</groupId>
-      <artifactId>geronimo-interceptor_1.1_spec</artifactId>
-      <version>1.0</version>
-    </dependency>
-
-    <!-- JSR-299 API -->
-    <dependency>
-      <groupId>org.apache.geronimo.specs</groupId>
-      <artifactId>geronimo-jcdi_1.0_spec</artifactId>
-      <version>1.0</version>
-      <scope>provided</scope>
-    </dependency>
-
-    <!-- JSR-330 API -->
-    <dependency>
-      <groupId>org.apache.geronimo.specs</groupId>
-      <artifactId>geronimo-atinject_1.0_spec</artifactId>
-      <version>1.0</version>
-      <scope>provided</scope>
-    </dependency>
-
-    <!-- logging -->
-    <dependency>
-      <groupId>org.slf4j</groupId>
-      <artifactId>slf4j-log4j12</artifactId>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>log4j</groupId>
-      <artifactId>log4j</artifactId>
-      <scope>test</scope>
-    </dependency>
-
-    <!-- JSR-299 Impl -->
-    <dependency>
-      <groupId>org.apache.openwebbeans</groupId>
-      <artifactId>openwebbeans-impl</artifactId>
-      <version>${openwebbeans-version}</version>
-      <scope>test</scope>
-    </dependency>
-    <!-- Test -->
-    <dependency>
-      <groupId>org.apache.openwebbeans.test</groupId>
-      <artifactId>cditest</artifactId>
-      <version>${openwebbeans-version}</version>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.openwebbeans.test</groupId>
-      <artifactId>cditest-owb</artifactId>
-      <version>${openwebbeans-version}</version>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.camel</groupId>
-      <artifactId>camel-test</artifactId>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.geronimo.specs</groupId>
-      <artifactId>geronimo-servlet_2.5_spec</artifactId>
-      <scope>test</scope>
-    </dependency>
-
-  </dependencies>
-
-</project>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.camel</groupId>
+    <artifactId>camel-parent</artifactId>
+    <version>2.10-SNAPSHOT</version>
+    <relativePath>../../parent</relativePath>
+  </parent>
+
+  <artifactId>camel-cdi</artifactId>
+  <packaging>bundle</packaging>
+  <name>Camel :: CDI</name>
+  <description>Camel CDI</description>
+
+  <properties>
+    <camel.osgi.export.pkg>org.apache.camel.component.cdi.*</camel.osgi.export.pkg>
+    <deltaspike-version>0.2-incubating</deltaspike-version>
+    <!-- these properties should be in-sync with deltaspike -->
+    <owb-version>1.1.4</owb-version>
+    <weld-version>1.1.5.Final</weld-version>
+  </properties>
+
+  <dependencies>
+
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-core</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.deltaspike.core</groupId>
+      <artifactId>deltaspike-core-api</artifactId>
+      <version>${deltaspike-version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.geronimo.specs</groupId>
+      <artifactId>geronimo-jcdi_1.0_spec</artifactId>
+      <version>1.0</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.geronimo.specs</groupId>
+      <artifactId>geronimo-atinject_1.0_spec</artifactId>
+      <version>1.0</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.geronimo.specs</groupId>
+      <artifactId>geronimo-interceptor_1.1_spec</artifactId>
+      <version>1.0</version>
+    </dependency>
+
+    <!-- logging -->
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-log4j12</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-test</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.deltaspike.cdictrl</groupId>
+      <artifactId>deltaspike-cdictrl-api</artifactId>
+      <version>${deltaspike-version}</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+  <profiles>
+    <profile>
+      <id>owb</id>
+      <activation>
+        <activeByDefault>true</activeByDefault>
+      </activation>
+      <dependencies>
+        <dependency>
+          <groupId>org.apache.geronimo.specs</groupId>
+          <artifactId>geronimo-servlet_2.5_spec</artifactId>
+          <scope>test</scope>
+        </dependency>
+        <dependency>
+          <groupId>org.apache.deltaspike.cdictrl</groupId>
+          <artifactId>deltaspike-cdictrl-owb</artifactId>
+          <version>${deltaspike-version}</version>
+          <scope>test</scope>
+        </dependency>
+        <dependency>
+          <groupId>org.apache.openwebbeans</groupId>
+          <artifactId>openwebbeans-impl</artifactId>
+          <version>${owb-version}</version>
+          <scope>test</scope>
+        </dependency>
+        <dependency>
+          <groupId>org.apache.openwebbeans</groupId>
+          <artifactId>openwebbeans-spi</artifactId>
+          <version>${owb-version}</version>
+          <scope>test</scope>
+        </dependency>
+      </dependencies>
+    </profile>
+
+    <profile>
+      <id>weld</id>
+      <dependencies>
+        <dependency>
+          <groupId>org.apache.deltaspike.cdictrl</groupId>
+          <artifactId>deltaspike-cdictrl-weld</artifactId>
+          <version>${deltaspike-version}</version>
+          <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.jboss.weld.se</groupId>
+            <artifactId>weld-se</artifactId>
+            <version>${weld-version}</version>
+            <scope>provided</scope>
+        </dependency>
+      </dependencies>
+    </profile>
+  </profiles>
+
+</project>

Modified: camel/trunk/components/camel-cdi/src/main/java/org/apache/camel/component/cdi/CdiBeanRegistry.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cdi/src/main/java/org/apache/camel/component/cdi/CdiBeanRegistry.java?rev=1329531&r1=1329530&r2=1329531&view=diff
==============================================================================
--- camel/trunk/components/camel-cdi/src/main/java/org/apache/camel/component/cdi/CdiBeanRegistry.java
(original)
+++ camel/trunk/components/camel-cdi/src/main/java/org/apache/camel/component/cdi/CdiBeanRegistry.java
Tue Apr 24 02:30:44 2012
@@ -16,11 +16,15 @@
  */
 package org.apache.camel.component.cdi;
 
+import java.util.HashMap;
 import java.util.Map;
+import java.util.Set;
+
+import javax.enterprise.inject.spi.Bean;
 
-import org.apache.camel.component.cdi.util.BeanProvider;
 import org.apache.camel.spi.Registry;
 import org.apache.camel.util.ObjectHelper;
+import org.apache.deltaspike.core.api.provider.BeanProvider;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -33,7 +37,7 @@ public class CdiBeanRegistry implements 
     @Override
     public Object lookup(final String name) {
         ObjectHelper.notEmpty(name, "name");
-        LOG.trace("Looking up bean {}", name);
+        LOG.trace("Looking up bean with name {}", name);
 
         return BeanProvider.getContextualReference(name, true);
     }
@@ -43,15 +47,27 @@ public class CdiBeanRegistry implements 
         ObjectHelper.notEmpty(name, "name");
         ObjectHelper.notNull(type, "type");
 
-        LOG.trace("Looking up bean {} of type {}", name, type);
+        LOG.trace("Looking up bean with name {} of type {}", name, type);
         return BeanProvider.getContextualReference(name, true, type);
     }
 
     @Override
     public <T> Map<String, T> lookupByType(final Class<T> type) {
         ObjectHelper.notNull(type, "type");
-        LOG.trace("Looking up beans of type {}", type);
-        return BeanProvider.getContextualNamesReferences(type, true, true);
+
+        LOG.trace("Lookups based of type {}", type);
+        Map<String, T> beans = new HashMap<String, T>();
+        Set<Bean<T>> definitions = BeanProvider.getBeanDefinitions(type, true,
true);
+
+        if (definitions == null) {
+            return beans;
+        }
+        for (Bean<T> bean : definitions) {
+            if (bean.getName() != null) {
+                beans.put(bean.getName(), BeanProvider.getContextualReference(type, bean));
+            }
+        }
+        return beans;
     }
 
     @Override

Modified: camel/trunk/components/camel-cdi/src/main/java/org/apache/camel/component/cdi/CdiCamelContext.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cdi/src/main/java/org/apache/camel/component/cdi/CdiCamelContext.java?rev=1329531&r1=1329530&r2=1329531&view=diff
==============================================================================
--- camel/trunk/components/camel-cdi/src/main/java/org/apache/camel/component/cdi/CdiCamelContext.java
(original)
+++ camel/trunk/components/camel-cdi/src/main/java/org/apache/camel/component/cdi/CdiCamelContext.java
Tue Apr 24 02:30:44 2012
@@ -24,8 +24,8 @@ import org.apache.camel.impl.DefaultCame
 public class CdiCamelContext extends DefaultCamelContext {
 
     public CdiCamelContext() {
-        super.setRegistry(new CdiBeanRegistry());
+        setRegistry(new CdiBeanRegistry());
+        setInjector(new CdiInjector(getInjector()));
     }
 
-
 }
\ No newline at end of file

Modified: camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/store/Item.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/store/Item.java?rev=1329531&r1=1329530&r2=1329531&view=diff
==============================================================================
--- camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/store/Item.java (original)
+++ camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/store/Item.java Tue
Apr 24 02:30:44 2012
@@ -62,5 +62,24 @@ public class Item implements Serializabl
         this.price = price;
     }
 
+    // Simple equals implementation
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        Item other = (Item) obj;
+        if (name == null) {
+            if (other.name != null)
+                return false;
+        } else if (!name.equals(other.name))
+            return false;
+        if (price != other.price)
+            return false;
+        return true;
+    }
 
 }



Mime
View raw message