You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2009/01/13 08:37:33 UTC

svn commit: r734064 - in /activemq/camel/trunk: camel-core/src/main/java/org/apache/camel/util/ components/camel-osgi/src/main/java/org/apache/camel/osgi/ components/camel-osgi/src/test/java/org/apache/camel/osgi/ components/camel-osgi/src/test/java/or...

Author: ningjiang
Date: Mon Jan 12 23:37:28 2009
New Revision: 734064

URL: http://svn.apache.org/viewvc?rev=734064&view=rev
Log:
CAMEL-1240 Moved the ResloverUti OSGI relates code into camel-osgi

Added:
    activemq/camel/trunk/components/camel-osgi/src/test/java/org/apache/camel/osgi/OsgiResolverUtilTest.java   (with props)
    activemq/camel/trunk/components/camel-osgi/src/test/java/org/apache/camel/osgi/test/   (props changed)
      - copied from r734000, activemq/camel/trunk/components/camel-osgi/src/test/java/org/apache/camel/osgi/converter/
    activemq/camel/trunk/components/camel-osgi/src/test/java/org/apache/camel/osgi/test/MyRouteBuilder.java   (with props)
Removed:
    activemq/camel/trunk/components/camel-osgi/src/test/java/org/apache/camel/osgi/converter/
Modified:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ResolverUtil.java
    activemq/camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/CamelContextFactoryBean.java
    activemq/camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/OsgiResolverUtil.java
    activemq/camel/trunk/components/camel-osgi/src/test/java/org/apache/camel/osgi/ActivatorTest.java
    activemq/camel/trunk/components/camel-osgi/src/test/java/org/apache/camel/osgi/CamelMockBundle.java
    activemq/camel/trunk/components/camel-osgi/src/test/java/org/apache/camel/osgi/test/MyTypeConverter.java
    activemq/camel/trunk/components/camel-osgi/src/test/resources/META-INF/services/org/apache/camel/TypeConverter
    activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
    activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/RouteBuilderFinder.java

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ResolverUtil.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ResolverUtil.java?rev=734064&r1=734063&r2=734064&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ResolverUtil.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ResolverUtil.java Mon Jan 12 23:37:28 2009
@@ -285,48 +285,13 @@
 
         Set<ClassLoader> set = getClassLoaders();
 
-        ClassLoader osgiClassLoader = getOsgiClassLoader(set);
-
-        if (osgiClassLoader != null) {
-            // if we have an osgi bundle loader use this one only
-            LOG.debug("Using only osgi bundle classloader");
-            find(test, packageName, osgiClassLoader, true);
-        } else {
-            LOG.debug("Using only regular classloaders");
-            for (ClassLoader classLoader : set) {
-                if (!isOsgiClassloader(classLoader)) {
-                    find(test, packageName, classLoader, false);
-                }
-            }
-        }
-    }
-
-    /**
-     * Gets the osgi classloader if any in the given set
-     */
-    private static ClassLoader getOsgiClassLoader(Set<ClassLoader> set) {
-        for (ClassLoader loader : set) {
-            if (isOsgiClassloader(loader)) {
-                return loader;
-            }
+        LOG.debug("Using only regular classloaders");
+        for (ClassLoader classLoader : set) {            
+            find(test, packageName, classLoader);            
         }
-        return null;
     }
 
-    /**
-     * Is it an osgi classloader
-     */
-    private static boolean isOsgiClassloader(ClassLoader loader) {
-        try {
-            Method mth = loader.getClass().getMethod("getBundle", new Class[]{});
-            if (mth != null) {
-                return true;
-            }
-        } catch (NoSuchMethodException e) {
-            // ignore its not an osgi loader
-        }
-        return false;
-    }
+    
 
     /**
      * Tries to find the reosurce in the package using the class loader.
@@ -335,30 +300,13 @@
      *
      * @param test what to find
      * @param packageName the package to search in
-     * @param loader the class loader
-     * @param osgi true if its a osgi bundle loader, false if regular classloader
+     * @param loader the class loader     
      */
-    protected void find(Test test, String packageName, ClassLoader loader, boolean osgi) {
+    protected void find(Test test, String packageName, ClassLoader loader) {
         if (LOG.isTraceEnabled()) {
             LOG.trace("Searching for: " + test + " in package: " + packageName + " using classloader: "
-                    + loader.getClass().getName() + " osgi bundle classloader: " + osgi);
-        }
-
-        if (osgi) {
-            try {
-                Method mth = loader.getClass().getMethod("getBundle", new Class[]{});
-                if (mth != null) {
-                    if (LOG.isDebugEnabled()) {
-                        LOG.debug("Loading from osgi buindle using classloader: " + loader);
-                    }
-                    loadImplementationsInBundle(test, packageName, loader, mth);
-                    return;
-                }
-            } catch (NoSuchMethodException e) {
-                LOG.warn("It's not an osgi bundle classloader: " + loader);
-                return;
-            }
-        }
+                    + loader.getClass().getName());
+        }        
 
         Enumeration<URL> urls;
         try {
@@ -454,44 +402,7 @@
         return loader.getResources(packageName);
     }
 
-    private void loadImplementationsInBundle(Test test, String packageName, ClassLoader loader, Method mth) {
-        // Use an inner class to avoid a NoClassDefFoundError when used in a non-osgi env
-        Set<String> urls = OsgiUtil.getImplementationsInBundle(test, packageName, loader, mth);
-        if (urls != null) {
-            for (String url : urls) {
-                // substring to avoid leading slashes
-                addIfMatching(test, url);
-            }
-        }
-    }
-
-    private static final class OsgiUtil {
-        private OsgiUtil() {
-            // Helper class
-        }
-        static Set<String> getImplementationsInBundle(Test test, String packageName, ClassLoader loader, Method mth) {
-            try {
-                org.osgi.framework.Bundle bundle = (org.osgi.framework.Bundle) mth.invoke(loader);
-                org.osgi.framework.Bundle[] bundles = bundle.getBundleContext().getBundles();
-                Set<String> urls = new HashSet<String>();
-                for (org.osgi.framework.Bundle bd : bundles) {
-                    if (LOG.isTraceEnabled()) {
-                        LOG.trace("Searching in bundle:" + bd);
-                    }
-                    Enumeration<URL> paths = bd.findEntries("/" + packageName, "*.class", true);
-                    while (paths != null && paths.hasMoreElements()) {
-                        URL path = paths.nextElement();                        
-                        urls.add(path.getPath().substring(1));
-                    }
-                }
-                return urls;
-            } catch (Throwable t) {
-                LOG.error("Could not search osgi bundles for classes matching criteria: " + test
-                          + "due to an Exception: " + t.getMessage());
-                return null;
-            }
-        }
-    }
+    
 
 
     /**

Modified: activemq/camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/CamelContextFactoryBean.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/CamelContextFactoryBean.java?rev=734064&r1=734063&r2=734064&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/CamelContextFactoryBean.java (original)
+++ activemq/camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/CamelContextFactoryBean.java Mon Jan 12 23:37:28 2009
@@ -26,8 +26,10 @@
 import org.apache.camel.impl.converter.AnnotationTypeConverterLoader;
 import org.apache.camel.impl.converter.DefaultTypeConverter;
 import org.apache.camel.impl.converter.TypeConverterLoader;
+import org.apache.camel.spring.RouteBuilderFinder;
 import org.apache.camel.spring.SpringCamelContext;
 import org.apache.camel.util.FactoryFinder;
+import org.apache.camel.util.ResolverUtil;
 import org.osgi.framework.BundleContext;
 import org.springframework.osgi.context.BundleContextAware;
 
@@ -56,6 +58,18 @@
         }
         
         return context;
+    }    
+    
+    /**
+     * The factory method for create the ResolverUtil
+     * @return a new instance of ResolverUtil
+     */
+    protected ResolverUtil createResolverUtil() {
+        if (bundleContext != null) {
+            return new OsgiResolverUtil(bundleContext);
+        } else {
+            return new ResolverUtil();
+        }
     }
     
     protected void addOsgiAnnotationTypeConverterLoader(SpringCamelContext context, BundleContext bundleContext) {

Modified: activemq/camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/OsgiResolverUtil.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/OsgiResolverUtil.java?rev=734064&r1=734063&r2=734064&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/OsgiResolverUtil.java (original)
+++ activemq/camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/OsgiResolverUtil.java Mon Jan 12 23:37:28 2009
@@ -16,9 +16,14 @@
  */
 package org.apache.camel.osgi;
 
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.HashSet;
 import java.util.Set;
 
 import org.apache.camel.util.ResolverUtil;
+import org.apache.camel.util.ResolverUtil.Test;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.springframework.osgi.util.BundleDelegatingClassLoader;
@@ -43,5 +48,123 @@
         classLoaders.add(osgiLoader);
         return classLoaders;
     }
+    
+    /**
+     * Scans for classes starting at the package provided and descending into
+     * subpackages. Each class is offered up to the Test as it is discovered,
+     * and if the Test returns true the class is retained. Accumulated classes
+     * can be fetched by calling {@link #getClasses()}.
+     *
+     * @param test        an instance of {@link Test} that will be used to filter
+     *                    classes
+     * @param packageName the name of the package from which to start scanning
+     *                    for classes, e.g. {@code net.sourceforge.stripes}
+     */
+    public void find(Test test, String packageName) {
+        packageName = packageName.replace('.', '/');
+
+        Set<ClassLoader> set = getClassLoaders();
+
+        ClassLoader osgiClassLoader = getOsgiClassLoader(set);
+
+        if (osgiClassLoader != null) {
+            // if we have an osgi bundle loader use this one only
+            LOG.debug("Using only osgi bundle classloader");
+            findInOsgiClassLoader(test, packageName, osgiClassLoader);
+        } else {
+            LOG.debug("Using only regular classloaders");
+            for (ClassLoader classLoader : set) {
+                if (!isOsgiClassloader(classLoader)) {
+                    find(test, packageName, classLoader);
+                }
+            }
+        }
+    }
+
+    
+    private void findInOsgiClassLoader(Test test, String packageName, ClassLoader osgiClassLoader) {
+        try {
+            Method mth = osgiClassLoader.getClass().getMethod("getBundle", new Class[]{});
+            if (mth != null) {
+                if (LOG.isDebugEnabled()) {
+                    LOG.debug("Loading from osgi buindle using classloader: " + osgiClassLoader);
+                }
+                loadImplementationsInBundle(test, packageName, osgiClassLoader, mth);
+                return;
+            }
+        } catch (NoSuchMethodException e) {
+            LOG.warn("It's not an osgi bundle classloader: " + osgiClassLoader);
+            return;
+        }
+        
+    }
+
+    /**
+     * Gets the osgi classloader if any in the given set
+     */
+    private static ClassLoader getOsgiClassLoader(Set<ClassLoader> set) {
+        for (ClassLoader loader : set) {
+            if (isOsgiClassloader(loader)) {
+                return loader;
+            }
+        }
+        return null;
+    }
+
+    /**
+     * Is it an osgi classloader
+     */
+    private static boolean isOsgiClassloader(ClassLoader loader) {
+        try {
+            Method mth = loader.getClass().getMethod("getBundle", new Class[]{});
+            if (mth != null) {
+                return true;
+            }
+        } catch (NoSuchMethodException e) {
+            // ignore its not an osgi loader
+        }
+        return false;
+    }
+    
+    private void loadImplementationsInBundle(Test test, String packageName, ClassLoader loader, Method mth) {
+        // Use an inner class to avoid a NoClassDefFoundError when used in a non-osgi env
+        Set<String> urls = OsgiUtil.getImplementationsInBundle(test, packageName, loader, mth);
+        if (urls != null) {
+            for (String url : urls) {
+                // substring to avoid leading slashes
+                addIfMatching(test, url);
+            }
+        }
+    }
+
+    private static final class OsgiUtil {
+        private OsgiUtil() {
+            // Helper class
+        }
+        static Set<String> getImplementationsInBundle(Test test, String packageName, ClassLoader loader, Method mth) {
+            try {
+                org.osgi.framework.Bundle bundle = (org.osgi.framework.Bundle) mth.invoke(loader);
+                org.osgi.framework.Bundle[] bundles = bundle.getBundleContext().getBundles();
+                Set<String> urls = new HashSet<String>();
+                for (org.osgi.framework.Bundle bd : bundles) {
+                    if (LOG.isTraceEnabled()) {
+                        LOG.trace("Searching in bundle:" + bd);
+                    }
+                    Enumeration<URL> paths = bd.findEntries("/" + packageName, "*.class", true);
+                    while (paths != null && paths.hasMoreElements()) {
+                        URL path = paths.nextElement();
+                        String pathString = path.getPath();
+                        pathString.indexOf(packageName);
+                        urls.add(pathString.substring(pathString.indexOf(packageName)));
+                    }
+                }
+                return urls;
+            } catch (Throwable t) {
+                LOG.error("Could not search osgi bundles for classes matching criteria: " + test
+                          + "due to an Exception: " + t.getMessage());
+                return null;
+            }
+        }
+    }
 
 }

Modified: activemq/camel/trunk/components/camel-osgi/src/test/java/org/apache/camel/osgi/ActivatorTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-osgi/src/test/java/org/apache/camel/osgi/ActivatorTest.java?rev=734064&r1=734063&r2=734064&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-osgi/src/test/java/org/apache/camel/osgi/ActivatorTest.java (original)
+++ activemq/camel/trunk/components/camel-osgi/src/test/java/org/apache/camel/osgi/ActivatorTest.java Mon Jan 12 23:37:28 2009
@@ -51,7 +51,7 @@
         String[] packages = Activator.findTypeConverterPackageNames();
         assertEquals("We should find three converter package here", 3, packages.length);
         
-        assertTrue("Here should contains org.apache.camel.osgi.coverter", containsPackageName("org.apache.camel.osgi.coverter", packages));
+        assertTrue("Here should contains org.apache.camel.osgi.test", containsPackageName("org.apache.camel.osgi.test", packages));
     }
 
 }

Modified: activemq/camel/trunk/components/camel-osgi/src/test/java/org/apache/camel/osgi/CamelMockBundle.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-osgi/src/test/java/org/apache/camel/osgi/CamelMockBundle.java?rev=734064&r1=734063&r2=734064&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-osgi/src/test/java/org/apache/camel/osgi/CamelMockBundle.java (original)
+++ activemq/camel/trunk/components/camel-osgi/src/test/java/org/apache/camel/osgi/CamelMockBundle.java Mon Jan 12 23:37:28 2009
@@ -74,6 +74,18 @@
         }
 
         return result;
-
+    }
+    
+    public Enumeration findEntries(String path, String filePattern, boolean recurse) {
+        if (path.equals("/org/apache/camel/osgi/test") && filePattern.equals("*.class")) {
+            List<URL> urls = new ArrayList<URL>();
+            URL url = getClass().getClassLoader().getResource("org/apache/camel/osgi/test/MyTypeConverter.class");
+            urls.add(url);
+            url = getClass().getClassLoader().getResource("org/apache/camel/osgi/test/MyRouteBuilder.class");
+            urls.add(url);
+            return new ListEnumeration(urls);
+        } else {
+            return super.findEntries(path, filePattern, recurse);
+        }
     }
 }

Added: activemq/camel/trunk/components/camel-osgi/src/test/java/org/apache/camel/osgi/OsgiResolverUtilTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-osgi/src/test/java/org/apache/camel/osgi/OsgiResolverUtilTest.java?rev=734064&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-osgi/src/test/java/org/apache/camel/osgi/OsgiResolverUtilTest.java (added)
+++ activemq/camel/trunk/components/camel-osgi/src/test/java/org/apache/camel/osgi/OsgiResolverUtilTest.java Mon Jan 12 23:37:28 2009
@@ -0,0 +1,52 @@
+/**
+ * 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.osgi;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.Set;
+
+import org.apache.camel.Converter;
+import org.apache.camel.Routes;
+import org.apache.camel.osgi.test.MyRouteBuilder;
+import org.apache.camel.osgi.test.MyTypeConverter;
+import org.osgi.framework.BundleContext;
+
+public class OsgiResolverUtilTest extends CamelOsgiTestSupport {
+    public void testOsgiResolverFindAnnotatedTest() throws IOException {
+        BundleContext  context = getActivator().getBundle().getBundleContext();
+        OsgiResolverUtil resolver  = new OsgiResolverUtil(context);
+             
+        String[] packageNames = {"org.apache.camel.osgi.test"};
+        resolver.findAnnotated(Converter.class, packageNames);
+        Set<Class> classes = resolver.getClasses();
+        assertEquals("There should find a class", classes.size(), 1);
+        assertTrue("Find a wrong class", classes.contains(MyTypeConverter.class));
+    }
+    
+    public void testOsgiResolverFindImplementationTest() {
+        BundleContext  context = getActivator().getBundle().getBundleContext();
+        OsgiResolverUtil resolver  = new OsgiResolverUtil(context);
+        String[] packageNames = {"org.apache.camel.osgi.test"};
+        resolver.findImplementations(Routes.class, packageNames);
+        Set<Class> classes = resolver.getClasses();
+        assertEquals("There should find a class", classes.size(), 1);
+        assertTrue("Find a wrong class", classes.contains(MyRouteBuilder.class));
+    }
+
+}

Propchange: activemq/camel/trunk/components/camel-osgi/src/test/java/org/apache/camel/osgi/OsgiResolverUtilTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/camel/trunk/components/camel-osgi/src/test/java/org/apache/camel/osgi/OsgiResolverUtilTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: activemq/camel/trunk/components/camel-osgi/src/test/java/org/apache/camel/osgi/test/
------------------------------------------------------------------------------
    svn:mergeinfo = 

Added: activemq/camel/trunk/components/camel-osgi/src/test/java/org/apache/camel/osgi/test/MyRouteBuilder.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-osgi/src/test/java/org/apache/camel/osgi/test/MyRouteBuilder.java?rev=734064&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-osgi/src/test/java/org/apache/camel/osgi/test/MyRouteBuilder.java (added)
+++ activemq/camel/trunk/components/camel-osgi/src/test/java/org/apache/camel/osgi/test/MyRouteBuilder.java Mon Jan 12 23:37:28 2009
@@ -0,0 +1,29 @@
+/**
+ * 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.osgi.test;
+
+import org.apache.camel.builder.RouteBuilder;
+
+public class MyRouteBuilder extends RouteBuilder {
+
+    @Override
+    public void configure() throws Exception {
+        // Do nothing here
+        
+    }
+
+}

Propchange: activemq/camel/trunk/components/camel-osgi/src/test/java/org/apache/camel/osgi/test/MyRouteBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/camel/trunk/components/camel-osgi/src/test/java/org/apache/camel/osgi/test/MyRouteBuilder.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: activemq/camel/trunk/components/camel-osgi/src/test/java/org/apache/camel/osgi/test/MyTypeConverter.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-osgi/src/test/java/org/apache/camel/osgi/test/MyTypeConverter.java?rev=734064&r1=734000&r2=734064&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-osgi/src/test/java/org/apache/camel/osgi/test/MyTypeConverter.java (original)
+++ activemq/camel/trunk/components/camel-osgi/src/test/java/org/apache/camel/osgi/test/MyTypeConverter.java Mon Jan 12 23:37:28 2009
@@ -14,13 +14,14 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.camel.osgi.converter;
+package org.apache.camel.osgi.test;
 
 import java.util.Collection;
 
 import org.apache.camel.Converter;
 import org.apache.camel.util.ObjectHelper;
 
+@Converter
 public final class MyTypeConverter {
 
     /**
@@ -36,22 +37,18 @@
      */
     @Converter
     public static boolean toBool(Object value) {
-        Boolean answer = toBoolean(value);
+        Boolean answer = null;    
+        if (value instanceof String) {
+            answer = Boolean.valueOf((String)value);
+        } 
+        if (value instanceof Boolean) {
+            answer = (Boolean) value;
+        }
         if (answer != null) {
             return answer.booleanValue();
         }
         return false;
-    }
+    }    
     
-    /**
-     * Converts the given value to a Boolean, handling strings or Boolean
-     * objects; otherwise returning null if the value cannot be converted to a
-     * boolean
-     */
-    @Converter
-    public static Boolean toBoolean(Object value) {
-        return ObjectHelper.toBoolean(value);
-    }
-
 
 }

Modified: activemq/camel/trunk/components/camel-osgi/src/test/resources/META-INF/services/org/apache/camel/TypeConverter
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-osgi/src/test/resources/META-INF/services/org/apache/camel/TypeConverter?rev=734064&r1=734063&r2=734064&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-osgi/src/test/resources/META-INF/services/org/apache/camel/TypeConverter (original)
+++ activemq/camel/trunk/components/camel-osgi/src/test/resources/META-INF/services/org/apache/camel/TypeConverter Mon Jan 12 23:37:28 2009
@@ -15,4 +15,4 @@
 # limitations under the License.
 #
 
-org.apache.camel.osgi.coverter
\ No newline at end of file
+org.apache.camel.osgi.test
\ No newline at end of file

Modified: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java?rev=734064&r1=734063&r2=734064&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java (original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java Mon Jan 12 23:37:28 2009
@@ -49,6 +49,7 @@
 import org.apache.camel.processor.interceptor.Tracer;
 import org.apache.camel.spi.LifecycleStrategy;
 import org.apache.camel.spi.Registry;
+import org.apache.camel.util.ResolverUtil;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.springframework.beans.factory.DisposableBean;
@@ -138,6 +139,14 @@
     public boolean isSingleton() {
         return true;
     }
+    
+    public ClassLoader getContextClassLoaderOnStart() {
+        return contextClassLoaderOnStart;
+    }
+    
+    public List<Routes> getAdditionalBuilders() {
+        return additionalBuilders;
+    }
 
     public void afterPropertiesSet() throws Exception {
         // TODO there should be a neater way to do this!
@@ -256,7 +265,7 @@
         if (LOG.isDebugEnabled()) {
             LOG.debug("Found JAXB created routes: " + getRoutes());
         }
-        findRouteBuiders();
+        findRouteBuilders();
         installRoutes();
     }
 
@@ -512,12 +521,20 @@
      * Strategy method to try find {@link RouteBuilder} instances on the
      * classpath
      */
-    protected void findRouteBuiders() throws Exception, InstantiationException {
-        if (packages != null && packages.length > 0) {
-            RouteBuilderFinder finder = new RouteBuilderFinder(getContext(), packages, contextClassLoaderOnStart, getBeanPostProcessor());
-            finder.appendBuilders(additionalBuilders);
+    protected void findRouteBuilders() throws Exception, InstantiationException {
+        if (getPackages() != null && getPackages().length > 0) {
+            RouteBuilderFinder finder = new RouteBuilderFinder(getContext(), getPackages(), getContextClassLoaderOnStart(), getBeanPostProcessor(), createResolverUtil());
+            finder.appendBuilders(getAdditionalBuilders());
         }
     }
+    
+    /**
+     * The factory method for create the ResolverUtil
+     * @return a new instance of ResolverUtil
+     */
+    protected ResolverUtil createResolverUtil() {
+        return new ResolverUtil();
+    }
 
     public void setDataFormats(DataFormatsType dataFormats) {
         this.dataFormats = dataFormats;

Modified: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/RouteBuilderFinder.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/RouteBuilderFinder.java?rev=734064&r1=734063&r2=734064&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/RouteBuilderFinder.java (original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/RouteBuilderFinder.java Mon Jan 12 23:37:28 2009
@@ -38,16 +38,16 @@
     private static final transient Log LOG = LogFactory.getLog(RouteBuilderFinder.class);
     private final SpringCamelContext camelContext;
     private final String[] packages;
-    private ApplicationContext applicationContext;
-    private ResolverUtil resolver = new ResolverUtil();
+    private ResolverUtil resolver;
+    private ApplicationContext applicationContext;    
     private BeanPostProcessor beanPostProcessor;
 
-    public RouteBuilderFinder(SpringCamelContext camelContext, String[] packages, ClassLoader classLoader, BeanPostProcessor postProcessor) {
+    public RouteBuilderFinder(SpringCamelContext camelContext, String[] packages, ClassLoader classLoader, BeanPostProcessor postProcessor, ResolverUtil resolverUtil) {
         this.camelContext = camelContext;
         this.applicationContext = camelContext.getApplicationContext();
         this.packages = packages;
         this.beanPostProcessor = postProcessor;
-
+        this.resolver = resolverUtil;
         // lets add all the available class loaders just in case of weirdness
         // we could make this more strict once we've worked out all the gremlins
         // in servicemix-camel
@@ -60,8 +60,7 @@
         set.add(getClass().getClassLoader());
 */
     }
-
-
+  
     public String[] getPackages() {
         return packages;
     }