You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2016/05/05 10:18:34 UTC
[1/4] camel git commit: CAMEL-9921: Setup dozer to ensure it loads
the EL engine so it works as expected when it performs mapping such as using
variables.
Repository: camel
Updated Branches:
refs/heads/camel-2.16.x d5197cc7d -> 5475d83f5
refs/heads/camel-2.17.x b35a74052 -> 6d8182719
CAMEL-9921: Setup dozer to ensure it loads the EL engine so it works as expected when it performs mapping such as using variables.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/b47ecc8d
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/b47ecc8d
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/b47ecc8d
Branch: refs/heads/camel-2.17.x
Commit: b47ecc8d6f87da490cf8c1feda7246754a258f29
Parents: b35a740
Author: Claus Ibsen <da...@apache.org>
Authored: Thu May 5 12:01:31 2016 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu May 5 12:02:44 2016 +0200
----------------------------------------------------------------------
components/camel-dozer/pom.xml | 126 ++++++++++---------
.../camel/component/dozer/DozerEndpoint.java | 46 ++++++-
2 files changed, 105 insertions(+), 67 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/b47ecc8d/components/camel-dozer/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-dozer/pom.xml b/components/camel-dozer/pom.xml
index 93154a4..2b82150 100644
--- a/components/camel-dozer/pom.xml
+++ b/components/camel-dozer/pom.xml
@@ -15,71 +15,73 @@
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>
+<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>
- <artifactId>components</artifactId>
- <groupId>org.apache.camel</groupId>
- <version>2.17.2-SNAPSHOT</version>
- </parent>
+ <parent>
+ <artifactId>components</artifactId>
+ <groupId>org.apache.camel</groupId>
+ <version>2.17.2-SNAPSHOT</version>
+ </parent>
- <artifactId>camel-dozer</artifactId>
- <packaging>bundle</packaging>
- <name>Camel :: Dozer</name>
- <description>Camel Support for the Dozer type conversion framework</description>
+ <artifactId>camel-dozer</artifactId>
+ <packaging>jar</packaging>
+ <name>Camel :: Dozer</name>
+ <description>Camel Support for the Dozer type conversion framework</description>
- <properties>
- <camel.osgi.export.pkg>
- org.apache.camel.converter.dozer.*,
- org.apache.camel.component.dozer.*
- </camel.osgi.export.pkg>
- </properties>
+ <properties>
+ <camel.osgi.export.pkg>
+ org.apache.camel.converter.dozer.*,
+ org.apache.camel.component.dozer.*
+ </camel.osgi.export.pkg>
+ </properties>
- <dependencies>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-core</artifactId>
- </dependency>
- <dependency>
- <groupId>net.sf.dozer</groupId>
- <artifactId>dozer</artifactId>
- </dependency>
- <dependency>
- <groupId>javax.el</groupId>
- <artifactId>javax.el-api</artifactId>
- <version>${javax.el-api-version}</version>
- </dependency>
- <dependency>
- <groupId>org.glassfish.web</groupId>
- <artifactId>javax.el</artifactId>
- <version>${javax.el-version}</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-test-spring</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-jaxb</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-jackson</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>net.sf.dozer</groupId>
+ <artifactId>dozer</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javax.el</groupId>
+ <artifactId>javax.el-api</artifactId>
+ <version>${javax.el-api-version}</version>
+ </dependency>
+ <!-- must use this glassfish EL implementation -->
+ <dependency>
+ <groupId>org.glassfish.web</groupId>
+ <artifactId>javax.el</artifactId>
+ <version>${javax.el-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test-spring</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-jaxb</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-jackson</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
</project>
http://git-wip-us.apache.org/repos/asf/camel/blob/b47ecc8d/components/camel-dozer/src/main/java/org/apache/camel/component/dozer/DozerEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-dozer/src/main/java/org/apache/camel/component/dozer/DozerEndpoint.java b/components/camel-dozer/src/main/java/org/apache/camel/component/dozer/DozerEndpoint.java
index 9e056b1..8c0f3db 100644
--- a/components/camel-dozer/src/main/java/org/apache/camel/component/dozer/DozerEndpoint.java
+++ b/components/camel-dozer/src/main/java/org/apache/camel/component/dozer/DozerEndpoint.java
@@ -21,6 +21,8 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
+import com.sun.el.ExpressionFactoryImpl;
+
import org.apache.camel.Component;
import org.apache.camel.Consumer;
import org.apache.camel.Processor;
@@ -33,6 +35,10 @@ import org.apache.camel.util.IOHelper;
import org.apache.camel.util.ResourceHelper;
import org.dozer.CustomConverter;
import org.dozer.DozerBeanMapper;
+import org.dozer.config.BeanContainer;
+import org.dozer.loader.xml.ELEngine;
+import org.dozer.loader.xml.ElementReader;
+import org.dozer.loader.xml.ExpressionElementReader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -107,6 +113,41 @@ public class DozerEndpoint extends DefaultEndpoint {
protected void doStart() throws Exception {
super.doStart();
+ initDozerBeanContainerAndMapper();
+ }
+
+ @Override
+ protected void doStop() throws Exception {
+ super.doStop();
+ // noop
+ }
+
+ protected void initDozerBeanContainerAndMapper() throws Exception {
+ LOG.info("Configuring DozerBeanContainer and DozerBeanMapper");
+
+ // must setup dozer to be able to load the EL factory we are using which is from glashfish
+ ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
+
+ ExpressionFactoryImpl factory = new ExpressionFactoryImpl();
+ ClassLoader cl = factory.getClass().getClassLoader();
+ Thread.currentThread().setContextClassLoader(cl);
+
+ System.setProperty("javax.el.ExpressionFactory", "com.sun.el.ExpressionFactoryImpl");
+ try {
+ ELEngine engine = new ELEngine();
+ engine.init();
+ BeanContainer.getInstance().setElEngine(engine);
+ ElementReader reader = new ExpressionElementReader(engine);
+ BeanContainer.getInstance().setElementReader(reader);
+
+ } catch (Throwable e) {
+ throw new IllegalStateException("Error configuring DozerBeanContainer/DozerBeanMapper due " + e.getMessage(), e);
+ } finally {
+ System.clearProperty("javax.el.ExpressionFactory");
+ Thread.currentThread().setContextClassLoader(oldCl);
+ }
+
+ // configure mapper as well
if (mapper == null) {
if (configuration.getMappingConfiguration() != null) {
mapper = DozerTypeConverterLoader.createDozerBeanMapper(
@@ -116,12 +157,7 @@ public class DozerEndpoint extends DefaultEndpoint {
}
configureMapper(mapper);
}
- }
- @Override
- protected void doStop() throws Exception {
- super.doStop();
- // noop
}
private DozerBeanMapper createDozerBeanMapper() throws Exception {
[3/4] camel git commit: CAMEL-9921: Setup dozer to ensure it loads
the EL engine so it works as expected when it performs mapping such as using
variables.
Posted by da...@apache.org.
CAMEL-9921: Setup dozer to ensure it loads the EL engine so it works as expected when it performs mapping such as using variables.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/5475d83f
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/5475d83f
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/5475d83f
Branch: refs/heads/camel-2.16.x
Commit: 5475d83f593495393ba2fe2faecb3d6006a82707
Parents: 32b2cd5
Author: Claus Ibsen <da...@apache.org>
Authored: Thu May 5 12:18:06 2016 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu May 5 12:18:06 2016 +0200
----------------------------------------------------------------------
components/camel-dozer/pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/5475d83f/components/camel-dozer/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-dozer/pom.xml b/components/camel-dozer/pom.xml
index 0f789aa..5a69e8d 100644
--- a/components/camel-dozer/pom.xml
+++ b/components/camel-dozer/pom.xml
@@ -26,7 +26,7 @@
</parent>
<artifactId>camel-dozer</artifactId>
- <packaging>jar</packaging>
+ <packaging>bundle</packaging>
<name>Camel :: Dozer</name>
<description>Camel Support for the Dozer type conversion framework</description>
[4/4] camel git commit: CAMEL-9921: Setup dozer to ensure it loads
the EL engine so it works as expected when it performs mapping such as using
variables.
Posted by da...@apache.org.
CAMEL-9921: Setup dozer to ensure it loads the EL engine so it works as expected when it performs mapping such as using variables.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/6d818271
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/6d818271
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/6d818271
Branch: refs/heads/camel-2.17.x
Commit: 6d8182719d974d82941951cbcf11b09e49cd66cb
Parents: b47ecc8
Author: Claus Ibsen <da...@apache.org>
Authored: Thu May 5 12:18:06 2016 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu May 5 12:18:24 2016 +0200
----------------------------------------------------------------------
components/camel-dozer/pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/6d818271/components/camel-dozer/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-dozer/pom.xml b/components/camel-dozer/pom.xml
index 2b82150..03ca8c8 100644
--- a/components/camel-dozer/pom.xml
+++ b/components/camel-dozer/pom.xml
@@ -26,7 +26,7 @@
</parent>
<artifactId>camel-dozer</artifactId>
- <packaging>jar</packaging>
+ <packaging>bundle</packaging>
<name>Camel :: Dozer</name>
<description>Camel Support for the Dozer type conversion framework</description>
[2/4] camel git commit: CAMEL-9921: Setup dozer to ensure it loads
the EL engine so it works as expected when it performs mapping such as using
variables.
Posted by da...@apache.org.
CAMEL-9921: Setup dozer to ensure it loads the EL engine so it works as expected when it performs mapping such as using variables.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/32b2cd56
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/32b2cd56
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/32b2cd56
Branch: refs/heads/camel-2.16.x
Commit: 32b2cd56d160b679c09a252a9d9e0c4863b70feb
Parents: d5197cc
Author: Claus Ibsen <da...@apache.org>
Authored: Thu May 5 12:01:31 2016 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu May 5 12:13:45 2016 +0200
----------------------------------------------------------------------
components/camel-dozer/pom.xml | 126 ++++++++++---------
.../camel/component/dozer/DozerEndpoint.java | 46 ++++++-
2 files changed, 105 insertions(+), 67 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/32b2cd56/components/camel-dozer/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-dozer/pom.xml b/components/camel-dozer/pom.xml
index 9ca2ae6..0f789aa 100644
--- a/components/camel-dozer/pom.xml
+++ b/components/camel-dozer/pom.xml
@@ -15,71 +15,73 @@
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>
+<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>
- <artifactId>components</artifactId>
- <groupId>org.apache.camel</groupId>
- <version>2.16.4-SNAPSHOT</version>
- </parent>
+ <parent>
+ <artifactId>components</artifactId>
+ <groupId>org.apache.camel</groupId>
+ <version>2.16.4-SNAPSHOT</version>
+ </parent>
- <artifactId>camel-dozer</artifactId>
- <packaging>bundle</packaging>
- <name>Camel :: Dozer</name>
- <description>Camel Support for the Dozer type conversion framework</description>
+ <artifactId>camel-dozer</artifactId>
+ <packaging>jar</packaging>
+ <name>Camel :: Dozer</name>
+ <description>Camel Support for the Dozer type conversion framework</description>
- <properties>
- <camel.osgi.export.pkg>
- org.apache.camel.converter.dozer.*,
- org.apache.camel.component.dozer.*
- </camel.osgi.export.pkg>
- </properties>
+ <properties>
+ <camel.osgi.export.pkg>
+ org.apache.camel.converter.dozer.*,
+ org.apache.camel.component.dozer.*
+ </camel.osgi.export.pkg>
+ </properties>
- <dependencies>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-core</artifactId>
- </dependency>
- <dependency>
- <groupId>net.sf.dozer</groupId>
- <artifactId>dozer</artifactId>
- </dependency>
- <dependency>
- <groupId>javax.el</groupId>
- <artifactId>javax.el-api</artifactId>
- <version>${javax.el-api-version}</version>
- </dependency>
- <dependency>
- <groupId>org.glassfish.web</groupId>
- <artifactId>javax.el</artifactId>
- <version>${javax.el-version}</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-test-spring</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-jaxb</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-jackson</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>net.sf.dozer</groupId>
+ <artifactId>dozer</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javax.el</groupId>
+ <artifactId>javax.el-api</artifactId>
+ <version>${javax.el-api-version}</version>
+ </dependency>
+ <!-- must use this glassfish EL implementation -->
+ <dependency>
+ <groupId>org.glassfish.web</groupId>
+ <artifactId>javax.el</artifactId>
+ <version>${javax.el-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test-spring</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-jaxb</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-jackson</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
</project>
http://git-wip-us.apache.org/repos/asf/camel/blob/32b2cd56/components/camel-dozer/src/main/java/org/apache/camel/component/dozer/DozerEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-dozer/src/main/java/org/apache/camel/component/dozer/DozerEndpoint.java b/components/camel-dozer/src/main/java/org/apache/camel/component/dozer/DozerEndpoint.java
index f315bfb..996ac7a 100644
--- a/components/camel-dozer/src/main/java/org/apache/camel/component/dozer/DozerEndpoint.java
+++ b/components/camel-dozer/src/main/java/org/apache/camel/component/dozer/DozerEndpoint.java
@@ -21,6 +21,8 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
+import com.sun.el.ExpressionFactoryImpl;
+
import org.apache.camel.Component;
import org.apache.camel.Consumer;
import org.apache.camel.Processor;
@@ -33,6 +35,10 @@ import org.apache.camel.util.IOHelper;
import org.apache.camel.util.ResourceHelper;
import org.dozer.CustomConverter;
import org.dozer.DozerBeanMapper;
+import org.dozer.config.BeanContainer;
+import org.dozer.loader.xml.ELEngine;
+import org.dozer.loader.xml.ElementReader;
+import org.dozer.loader.xml.ExpressionElementReader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -104,6 +110,41 @@ public class DozerEndpoint extends DefaultEndpoint {
protected void doStart() throws Exception {
super.doStart();
+ initDozerBeanContainerAndMapper();
+ }
+
+ @Override
+ protected void doStop() throws Exception {
+ super.doStop();
+ // noop
+ }
+
+ protected void initDozerBeanContainerAndMapper() throws Exception {
+ LOG.info("Configuring DozerBeanContainer and DozerBeanMapper");
+
+ // must setup dozer to be able to load the EL factory we are using which is from glashfish
+ ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
+
+ ExpressionFactoryImpl factory = new ExpressionFactoryImpl();
+ ClassLoader cl = factory.getClass().getClassLoader();
+ Thread.currentThread().setContextClassLoader(cl);
+
+ System.setProperty("javax.el.ExpressionFactory", "com.sun.el.ExpressionFactoryImpl");
+ try {
+ ELEngine engine = new ELEngine();
+ engine.init();
+ BeanContainer.getInstance().setElEngine(engine);
+ ElementReader reader = new ExpressionElementReader(engine);
+ BeanContainer.getInstance().setElementReader(reader);
+
+ } catch (Throwable e) {
+ throw new IllegalStateException("Error configuring DozerBeanContainer/DozerBeanMapper due " + e.getMessage(), e);
+ } finally {
+ System.clearProperty("javax.el.ExpressionFactory");
+ Thread.currentThread().setContextClassLoader(oldCl);
+ }
+
+ // configure mapper as well
if (mapper == null) {
if (configuration.getMappingConfiguration() != null) {
mapper = DozerTypeConverterLoader.createDozerBeanMapper(
@@ -113,12 +154,7 @@ public class DozerEndpoint extends DefaultEndpoint {
}
configureMapper(mapper);
}
- }
- @Override
- protected void doStop() throws Exception {
- super.doStop();
- // noop
}
private DozerBeanMapper createDozerBeanMapper() throws Exception {