camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [4/9] camel git commit: Fixed resource loading in chunk component.
Date Mon, 02 Mar 2015 07:17:11 GMT
Fixed resource loading in chunk component.


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

Branch: refs/heads/master
Commit: 3101074c98d18502e17632af8cbfb6edcaed764d
Parents: 101554b
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Sun Mar 1 15:08:57 2015 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Mon Mar 2 08:18:03 2015 +0100

----------------------------------------------------------------------
 .../camel/component/chunk/ChunkEndpoint.java    | 28 +++++++++++++-------
 1 file changed, 19 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/3101074c/components/camel-chunk/src/main/java/org/apache/camel/component/chunk/ChunkEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-chunk/src/main/java/org/apache/camel/component/chunk/ChunkEndpoint.java
b/components/camel-chunk/src/main/java/org/apache/camel/component/chunk/ChunkEndpoint.java
index 1623e21..dbb791f 100644
--- a/components/camel-chunk/src/main/java/org/apache/camel/component/chunk/ChunkEndpoint.java
+++ b/components/camel-chunk/src/main/java/org/apache/camel/component/chunk/ChunkEndpoint.java
@@ -25,7 +25,6 @@ import java.util.Map;
 
 import com.x5.template.Chunk;
 import com.x5.template.Theme;
-
 import org.apache.camel.Component;
 import org.apache.camel.Exchange;
 import org.apache.camel.ExchangePattern;
@@ -92,11 +91,8 @@ public class ChunkEndpoint extends ResourceEndpoint {
 
     @Override
     protected void onExchange(Exchange exchange) throws Exception {
-        boolean fromTemplate = false;
+        boolean fromTemplate;
         String newResourceUri = exchange.getIn().getHeader(CHUNK_RESOURCE_URI, String.class);
-        if (theme == null) {
-            theme = getOrCreateTheme();
-        }
         if (newResourceUri == null) {
             String newTemplate = exchange.getIn().getHeader(CHUNK_TEMPLATE, String.class);
             Chunk newChunk;
@@ -172,12 +168,10 @@ public class ChunkEndpoint extends ResourceEndpoint {
             if (themeFolder == null && themeSubfolder == null) {
                 theme = new Theme(); 
             } else if (themeFolder != null && themeSubfolder == null) {
-                ClassLoader apcl = getCamelContext().getApplicationContextClassLoader();
-                URL url = apcl.getResource(themeFolder);
+                URL url = getCamelContext().getClassResolver().loadResourceAsURL(themeFolder);
                 theme = new Theme(url.getPath(), "");
             } else {
-                ClassLoader apcl = getCamelContext().getApplicationContextClassLoader();
-                URL url = apcl.getResource(themeFolder);
+                URL url = getCamelContext().getClassResolver().loadResourceAsURL(themeFolder);
                 theme = new Theme(url.getPath(), themeSubfolder);
             }
             if (encoding != null) {
@@ -242,4 +236,20 @@ public class ChunkEndpoint extends ResourceEndpoint {
     public void setExtension(String extension) {
         this.extension = extension;
     }
+
+    @Override
+    protected void doStart() throws Exception {
+        super.doStart();
+
+        if (theme == null) {
+            theme = getOrCreateTheme();
+        }
+    }
+
+    @Override
+    protected void doStop() throws Exception {
+        super.doStop();
+
+        // noop
+    }
 }


Mime
View raw message