camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r905585 - /camel/trunk/components/camel-freemarker/src/main/java/org/apache/camel/component/freemarker/FreemarkerComponent.java
Date Tue, 02 Feb 2010 11:35:07 GMT
Author: davsclaus
Date: Tue Feb  2 11:35:06 2010
New Revision: 905585

URL: http://svn.apache.org/viewvc?rev=905585&view=rev
Log:
CAMEL-2423: Applied 2nd patch. Thanks to Frank Schwartz.

Modified:
    camel/trunk/components/camel-freemarker/src/main/java/org/apache/camel/component/freemarker/FreemarkerComponent.java

Modified: camel/trunk/components/camel-freemarker/src/main/java/org/apache/camel/component/freemarker/FreemarkerComponent.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-freemarker/src/main/java/org/apache/camel/component/freemarker/FreemarkerComponent.java?rev=905585&r1=905584&r2=905585&view=diff
==============================================================================
--- camel/trunk/components/camel-freemarker/src/main/java/org/apache/camel/component/freemarker/FreemarkerComponent.java
(original)
+++ camel/trunk/components/camel-freemarker/src/main/java/org/apache/camel/component/freemarker/FreemarkerComponent.java
Tue Feb  2 11:35:06 2010
@@ -21,30 +21,18 @@
 
 import freemarker.cache.URLTemplateLoader;
 import freemarker.template.Configuration;
-
 import org.apache.camel.Endpoint;
-import org.apache.camel.impl.DefaultComponent;
+import org.apache.camel.component.ResourceBasedComponent;
 import org.apache.camel.util.ObjectHelper;
-import org.springframework.beans.factory.BeanClassLoaderAware;
 
 /**
  * Freemarker component.
  */
-public class FreemarkerComponent extends DefaultComponent implements BeanClassLoaderAware
{
+public class FreemarkerComponent extends ResourceBasedComponent {
 
     private Configuration configuration;
     private Configuration noCacheConfiguration;
 
-    private ClassLoader beanClassLoader; 
-
-    public void setBeanClassLoader(ClassLoader classLoader) {
-        this.beanClassLoader = classLoader;
-    }
-
-    public ClassLoader getBeanClassLoader() {
-        return beanClassLoader;
-    }
-
     protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object>
parameters) throws Exception {
         FreemarkerEndpoint endpoint = new FreemarkerEndpoint(uri, this, remaining);
 
@@ -56,7 +44,7 @@
         }
         boolean cache = getAndRemoveParameter(parameters, "contentCache", Boolean.class,
Boolean.TRUE);
         if (cache) {
-            config = getConfiguraiton();
+            config = getConfiguration();
         } else {
             config = getNoCacheConfiguration();
         }
@@ -65,40 +53,27 @@
         return endpoint;
     }
 
-    public synchronized Configuration getConfiguraiton() {
+    public synchronized Configuration getConfiguration() {
         if (configuration == null) {
             configuration = new Configuration();
             configuration.setTemplateLoader(new URLTemplateLoader() {
                 @Override
                 protected URL getURL(String name) {
-                    ClassLoader[] loaders = {
-                        beanClassLoader, 
-                        Thread.currentThread().getContextClassLoader(), 
-                        this.getClass().getClassLoader()
-                    };
-                    for (ClassLoader classLoader : loaders) {
-                        if (classLoader != null) {
-                            URL resource = classLoader.getResource(name);
-                            if (resource != null) {
-                                return resource;
-                            }
-                        }
-                    }
-                    return null;
+                    return getResourceLoader().getClassLoader().getResource(name);
                 }
             });
         }
         return (Configuration) configuration.clone();
     }
 
-    public void setConfiguraiton(Configuration configuration) {
+    public void setConfiguration(Configuration configuration) {
         this.configuration = configuration;
     }
 
     private synchronized Configuration getNoCacheConfiguration() {
         if (noCacheConfiguration == null) {
             // create a clone of the regular configuration
-            noCacheConfiguration = (Configuration) getConfiguraiton().clone();
+            noCacheConfiguration = (Configuration) getConfiguration().clone();
             // set this one to not use cache
             noCacheConfiguration.setCacheStorage(new NoCacheStorage());
         }



Mime
View raw message