Repository: camel
Updated Branches:
  refs/heads/master 440a8fb42 -> 586e13d2e


CAMEL-7999: Fixed camel-mvel to not clash component and language in same 
package with same name.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/586e13d2
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/586e13d2
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/586e13d2

Branch: refs/heads/master
Commit: 586e13d2e7638284eafe6686344695b5036d5f11
Parents: 440a8fb
Author: Claus Ibsen <davscl...@apache.org>
Authored: Wed Jan 28 12:12:23 2015 +0100
Committer: Claus Ibsen <davscl...@apache.org>
Committed: Wed Jan 28 12:12:23 2015 +0100

----------------------------------------------------------------------
 components/camel-mvel/pom.xml                   |   5 +-
 .../camel/component/mvel/MvelComponent.java     |  51 ++++++++
 .../camel/component/mvel/MvelConstants.java     |  31 +++++
 .../camel/component/mvel/MvelEndpoint.java      | 131 +++++++++++++++++++
 .../camel/language/mvel/MvelComponent.java      |  51 --------
 .../camel/language/mvel/MvelEndpoint.java       | 131 -------------------
 .../services/org/apache/camel/component/mvel    |   2 +-
 7 files changed, 218 insertions(+), 184 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/586e13d2/components/camel-mvel/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-mvel/pom.xml b/components/camel-mvel/pom.xml
index c03b701..4ba768e 100644
--- a/components/camel-mvel/pom.xml
+++ b/components/camel-mvel/pom.xml
@@ -32,7 +32,10 @@
   <properties>
     <!-- need to import spi as felix-bundle-plugin has a bug and do not 
include this package despite we use in the source code -->
     
<camel.osgi.import.before.defaults>org.apache.camel.spi;${camel.osgi.import.strict.version}</camel.osgi.import.before.defaults>
-    
<camel.osgi.export.pkg>org.apache.camel.language.mvel.*</camel.osgi.export.pkg>
+    <camel.osgi.export.pkg>
+      org.apache.camel.component.mvel.*,
+      org.apache.camel.language.mvel.*
+    </camel.osgi.export.pkg>
     <camel.osgi.export.service>
       org.apache.camel.spi.ComponentResolver;component=mvel,
       org.apache.camel.spi.LanguageResolver;language=mvel

http://git-wip-us.apache.org/repos/asf/camel/blob/586e13d2/components/camel-mvel/src/main/java/org/apache/camel/component/mvel/MvelComponent.java
----------------------------------------------------------------------
diff --git 
a/components/camel-mvel/src/main/java/org/apache/camel/component/mvel/MvelComponent.java
 
b/components/camel-mvel/src/main/java/org/apache/camel/component/mvel/MvelComponent.java
new file mode 100644
index 0000000..5ac1cb6
--- /dev/null
+++ 
b/components/camel-mvel/src/main/java/org/apache/camel/component/mvel/MvelComponent.java
@@ -0,0 +1,51 @@
+/**
+ * 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.component.mvel;
+
+import java.util.Map;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.impl.UriEndpointComponent;
+import org.apache.camel.util.ResourceHelper;
+
+/**
+ * An <a href="http://camel.apache.org/mvel.html";>Mvel Component</a>
+ * for performing transforming messages
+ */
+public class MvelComponent extends UriEndpointComponent {
+
+    public MvelComponent() {
+        super(MvelEndpoint.class);
+    }
+
+    protected Endpoint createEndpoint(String uri, String remaining, 
Map<String, Object> parameters) throws Exception {
+        boolean cache = getAndRemoveParameter(parameters, "contentCache", 
Boolean.class, Boolean.TRUE);
+
+        MvelEndpoint answer = new MvelEndpoint(uri, this, remaining);
+        setProperties(answer, parameters);
+        answer.setContentCache(cache);
+
+        // if its a http resource then append any remaining parameters and 
update the resource uri
+        if (ResourceHelper.isHttpUri(remaining)) {
+            remaining = ResourceHelper.appendParameters(remaining, parameters);
+            answer.setResourceUri(remaining);
+        }
+
+        return answer;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/586e13d2/components/camel-mvel/src/main/java/org/apache/camel/component/mvel/MvelConstants.java
----------------------------------------------------------------------
diff --git 
a/components/camel-mvel/src/main/java/org/apache/camel/component/mvel/MvelConstants.java
 
b/components/camel-mvel/src/main/java/org/apache/camel/component/mvel/MvelConstants.java
new file mode 100644
index 0000000..473b8d4
--- /dev/null
+++ 
b/components/camel-mvel/src/main/java/org/apache/camel/component/mvel/MvelConstants.java
@@ -0,0 +1,31 @@
+/**
+ * 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.component.mvel;
+
+/**
+ * Mvel constants
+ */
+public final class MvelConstants {
+
+    public static final String MVEL_RESOURCE_URI = "CamelMvelResourceUri";
+
+    public static final String MVEL_TEMPLATE = "CamelMvelTemplate";
+
+    private MvelConstants() {
+        // Utility class
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/586e13d2/components/camel-mvel/src/main/java/org/apache/camel/component/mvel/MvelEndpoint.java
----------------------------------------------------------------------
diff --git 
a/components/camel-mvel/src/main/java/org/apache/camel/component/mvel/MvelEndpoint.java
 
b/components/camel-mvel/src/main/java/org/apache/camel/component/mvel/MvelEndpoint.java
new file mode 100644
index 0000000..06204d3
--- /dev/null
+++ 
b/components/camel-mvel/src/main/java/org/apache/camel/component/mvel/MvelEndpoint.java
@@ -0,0 +1,131 @@
+/**
+ * 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.component.mvel;
+
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.util.Map;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.ExchangePattern;
+import org.apache.camel.Message;
+import org.apache.camel.component.ResourceEndpoint;
+import org.apache.camel.converter.IOConverter;
+import org.apache.camel.spi.UriEndpoint;
+import org.apache.camel.spi.UriParam;
+import org.apache.camel.util.ExchangeHelper;
+import org.apache.camel.util.ObjectHelper;
+import org.mvel2.ParserContext;
+import org.mvel2.templates.CompiledTemplate;
+import org.mvel2.templates.TemplateCompiler;
+import org.mvel2.templates.TemplateRuntime;
+
+@UriEndpoint(scheme = "mvel", label = "transformation,script")
+public class MvelEndpoint extends ResourceEndpoint {
+
+    @UriParam
+    private String encoding;
+    private volatile String template;
+    private volatile CompiledTemplate compiled;
+
+    public MvelEndpoint(String uri, MvelComponent component, String 
resourceUri) {
+        super(uri, component, resourceUri);
+    }
+
+    @Override
+    public boolean isSingleton() {
+        return true;
+    }
+
+    @Override
+    public ExchangePattern getExchangePattern() {
+        return ExchangePattern.InOut;
+    }
+
+    @Override
+    protected String createEndpointUri() {
+        return "mvel:" + getResourceUri();
+    }
+
+    public String getEncoding() {
+        return encoding;
+    }
+
+    public void setEncoding(String encoding) {
+        this.encoding = encoding;
+    }
+
+    @Override
+    protected void onExchange(Exchange exchange) throws Exception {
+        String path = getResourceUri();
+        ObjectHelper.notNull(path, "resourceUri");
+
+        String newResourceUri = 
exchange.getIn().getHeader(MvelConstants.MVEL_RESOURCE_URI, String.class);
+        if (newResourceUri != null) {
+            exchange.getIn().removeHeader(MvelConstants.MVEL_RESOURCE_URI);
+
+            log.debug("{} set to {} creating new endpoint to handle exchange", 
MvelConstants.MVEL_RESOURCE_URI, newResourceUri);
+            MvelEndpoint newEndpoint = findOrCreateEndpoint(getEndpointUri(), 
newResourceUri);
+            newEndpoint.onExchange(exchange);
+            return;
+        }
+
+        CompiledTemplate compiled;
+        ParserContext mvelContext = ParserContext.create();
+        Map<String, Object> variableMap = 
ExchangeHelper.createVariableMap(exchange);
+
+        String content = 
exchange.getIn().getHeader(MvelConstants.MVEL_TEMPLATE, String.class);
+        if (content != null) {
+            // use content from header
+            if (log.isDebugEnabled()) {
+                log.debug("Mvel content read from header {} for endpoint {}", 
MvelConstants.MVEL_TEMPLATE, getEndpointUri());
+            }
+            // remove the header to avoid it being propagated in the routing
+            exchange.getIn().removeHeader(MvelConstants.MVEL_TEMPLATE);
+            compiled = TemplateCompiler.compileTemplate(content, mvelContext);
+        } else {
+            if (log.isDebugEnabled()) {
+                log.debug("Mvel content read from resource {} with 
resourceUri: {} for endpoint {}", new Object[]{getResourceUri(), path, 
getEndpointUri()});
+            }
+            // getResourceAsInputStream also considers the content cache
+            Reader reader = getEncoding() != null ? new 
InputStreamReader(getResourceAsInputStream(), getEncoding()) : new 
InputStreamReader(getResourceAsInputStream());
+            String template = IOConverter.toString(reader);
+            if (!template.equals(this.template)) {
+                this.template = template;
+                this.compiled = TemplateCompiler.compileTemplate(template, 
mvelContext);
+            }
+            compiled = this.compiled;
+        }
+
+        // let mvel parse and execute the template
+        log.debug("Mvel is evaluating using mvel context: {}", variableMap);
+        Object result = TemplateRuntime.execute(compiled, mvelContext, 
variableMap);
+
+        // now lets output the results to the exchange
+        Message out = exchange.getOut();
+        out.setBody(result.toString());
+        out.setHeaders(exchange.getIn().getHeaders());
+        out.setAttachments(exchange.getIn().getAttachments());
+    }
+
+    public MvelEndpoint findOrCreateEndpoint(String uri, String 
newResourceUri) {
+        String newUri = uri.replace(getResourceUri(), newResourceUri);
+        log.debug("Getting endpoint with URI: {}", newUri);
+        return getCamelContext().getEndpoint(newUri, MvelEndpoint.class);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/586e13d2/components/camel-mvel/src/main/java/org/apache/camel/language/mvel/MvelComponent.java
----------------------------------------------------------------------
diff --git 
a/components/camel-mvel/src/main/java/org/apache/camel/language/mvel/MvelComponent.java
 
b/components/camel-mvel/src/main/java/org/apache/camel/language/mvel/MvelComponent.java
deleted file mode 100644
index 1fe03f3a..0000000
--- 
a/components/camel-mvel/src/main/java/org/apache/camel/language/mvel/MvelComponent.java
+++ /dev/null
@@ -1,51 +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.language.mvel;
-
-import java.util.Map;
-
-import org.apache.camel.Endpoint;
-import org.apache.camel.impl.UriEndpointComponent;
-import org.apache.camel.util.ResourceHelper;
-
-/**
- * An <a href="http://camel.apache.org/mvel.html";>Mvel Component</a>
- * for performing transforming messages
- */
-public class MvelComponent extends UriEndpointComponent {
-
-    public MvelComponent() {
-        super(MvelEndpoint.class);
-    }
-
-    protected Endpoint createEndpoint(String uri, String remaining, 
Map<String, Object> parameters) throws Exception {
-        boolean cache = getAndRemoveParameter(parameters, "contentCache", 
Boolean.class, Boolean.TRUE);
-
-        MvelEndpoint answer = new MvelEndpoint(uri, this, remaining);
-        setProperties(answer, parameters);
-        answer.setContentCache(cache);
-
-        // if its a http resource then append any remaining parameters and 
update the resource uri
-        if (ResourceHelper.isHttpUri(remaining)) {
-            remaining = ResourceHelper.appendParameters(remaining, parameters);
-            answer.setResourceUri(remaining);
-        }
-
-        return answer;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/586e13d2/components/camel-mvel/src/main/java/org/apache/camel/language/mvel/MvelEndpoint.java
----------------------------------------------------------------------
diff --git 
a/components/camel-mvel/src/main/java/org/apache/camel/language/mvel/MvelEndpoint.java
 
b/components/camel-mvel/src/main/java/org/apache/camel/language/mvel/MvelEndpoint.java
deleted file mode 100644
index 61b5f2d..0000000
--- 
a/components/camel-mvel/src/main/java/org/apache/camel/language/mvel/MvelEndpoint.java
+++ /dev/null
@@ -1,131 +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.language.mvel;
-
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.util.Map;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.ExchangePattern;
-import org.apache.camel.Message;
-import org.apache.camel.component.ResourceEndpoint;
-import org.apache.camel.converter.IOConverter;
-import org.apache.camel.spi.UriEndpoint;
-import org.apache.camel.spi.UriParam;
-import org.apache.camel.util.ExchangeHelper;
-import org.apache.camel.util.ObjectHelper;
-import org.mvel2.ParserContext;
-import org.mvel2.templates.CompiledTemplate;
-import org.mvel2.templates.TemplateCompiler;
-import org.mvel2.templates.TemplateRuntime;
-
-@UriEndpoint(scheme = "mvel", label = "transformation,script")
-public class MvelEndpoint extends ResourceEndpoint {
-
-    @UriParam
-    private String encoding;
-    private volatile String template;
-    private volatile CompiledTemplate compiled;
-
-    public MvelEndpoint(String uri, MvelComponent component, String 
resourceUri) {
-        super(uri, component, resourceUri);
-    }
-
-    @Override
-    public boolean isSingleton() {
-        return true;
-    }
-
-    @Override
-    public ExchangePattern getExchangePattern() {
-        return ExchangePattern.InOut;
-    }
-
-    @Override
-    protected String createEndpointUri() {
-        return "mvel:" + getResourceUri();
-    }
-
-    public String getEncoding() {
-        return encoding;
-    }
-
-    public void setEncoding(String encoding) {
-        this.encoding = encoding;
-    }
-
-    @Override
-    protected void onExchange(Exchange exchange) throws Exception {
-        String path = getResourceUri();
-        ObjectHelper.notNull(path, "resourceUri");
-
-        String newResourceUri = 
exchange.getIn().getHeader(MvelConstants.MVEL_RESOURCE_URI, String.class);
-        if (newResourceUri != null) {
-            exchange.getIn().removeHeader(MvelConstants.MVEL_RESOURCE_URI);
-
-            log.debug("{} set to {} creating new endpoint to handle exchange", 
MvelConstants.MVEL_RESOURCE_URI, newResourceUri);
-            MvelEndpoint newEndpoint = findOrCreateEndpoint(getEndpointUri(), 
newResourceUri);
-            newEndpoint.onExchange(exchange);
-            return;
-        }
-
-        CompiledTemplate compiled;
-        ParserContext mvelContext = ParserContext.create();
-        Map<String, Object> variableMap = 
ExchangeHelper.createVariableMap(exchange);
-
-        String content = 
exchange.getIn().getHeader(MvelConstants.MVEL_TEMPLATE, String.class);
-        if (content != null) {
-            // use content from header
-            if (log.isDebugEnabled()) {
-                log.debug("Mvel content read from header {} for endpoint {}", 
MvelConstants.MVEL_TEMPLATE, getEndpointUri());
-            }
-            // remove the header to avoid it being propagated in the routing
-            exchange.getIn().removeHeader(MvelConstants.MVEL_TEMPLATE);
-            compiled = TemplateCompiler.compileTemplate(content, mvelContext);
-        } else {
-            if (log.isDebugEnabled()) {
-                log.debug("Mvel content read from resource {} with 
resourceUri: {} for endpoint {}", new Object[]{getResourceUri(), path, 
getEndpointUri()});
-            }
-            // getResourceAsInputStream also considers the content cache
-            Reader reader = getEncoding() != null ? new 
InputStreamReader(getResourceAsInputStream(), getEncoding()) : new 
InputStreamReader(getResourceAsInputStream());
-            String template = IOConverter.toString(reader);
-            if (!template.equals(this.template)) {
-                this.template = template;
-                this.compiled = TemplateCompiler.compileTemplate(template, 
mvelContext);
-            }
-            compiled = this.compiled;
-        }
-
-        // let mvel parse and execute the template
-        log.debug("Mvel is evaluating using mvel context: {}", variableMap);
-        Object result = TemplateRuntime.execute(compiled, mvelContext, 
variableMap);
-
-        // now lets output the results to the exchange
-        Message out = exchange.getOut();
-        out.setBody(result.toString());
-        out.setHeaders(exchange.getIn().getHeaders());
-        out.setAttachments(exchange.getIn().getAttachments());
-    }
-
-    public MvelEndpoint findOrCreateEndpoint(String uri, String 
newResourceUri) {
-        String newUri = uri.replace(getResourceUri(), newResourceUri);
-        log.debug("Getting endpoint with URI: {}", newUri);
-        return getCamelContext().getEndpoint(newUri, MvelEndpoint.class);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/586e13d2/components/camel-mvel/src/main/resources/META-INF/services/org/apache/camel/component/mvel
----------------------------------------------------------------------
diff --git 
a/components/camel-mvel/src/main/resources/META-INF/services/org/apache/camel/component/mvel
 
b/components/camel-mvel/src/main/resources/META-INF/services/org/apache/camel/component/mvel
index 027426c..74cbd4a9 100644
--- 
a/components/camel-mvel/src/main/resources/META-INF/services/org/apache/camel/component/mvel
+++ 
b/components/camel-mvel/src/main/resources/META-INF/services/org/apache/camel/component/mvel
@@ -15,4 +15,4 @@
 # limitations under the License.
 #
 
-class=org.apache.camel.language.mvel.MvelComponent
\ No newline at end of file
+class=org.apache.camel.component.mvel.MvelComponent
\ No newline at end of file

Reply via email to