camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r732209 - in /activemq/camel/branches/camel-1.x: ./ camel-core/src/main/java/org/apache/camel/ camel-core/src/main/java/org/apache/camel/component/file/ camel-core/src/main/java/org/apache/camel/impl/ camel-core/src/main/java/org/apache/cam...
Date Wed, 07 Jan 2009 03:17:19 GMT
Author: ningjiang
Date: Tue Jan  6 19:17:19 2009
New Revision: 732209

URL: http://svn.apache.org/viewvc?rev=732209&view=rev
Log:
Merged revisions 732207 via svnmerge from 
https://svn.apache.org/repos/asf/activemq/camel/trunk

........
  r732207 | ningjiang | 2009-01-07 11:09:24 +0800 (Wed, 07 Jan 2009) | 1 line
  
  CAMEL-1223 FactoryFinder should support OSGI as well
........

Added:
    activemq/camel/branches/camel-1.x/components/camel-osgi/src/main/java/org/apache/camel/osgi/OsgiFactoryFinder.java
      - copied unchanged from r732207, activemq/camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/OsgiFactoryFinder.java
Modified:
    activemq/camel/branches/camel-1.x/   (props changed)
    activemq/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/CamelContext.java
    activemq/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/component/file/FileEndpoint.java
    activemq/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
    activemq/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/util/FactoryFinder.java
    activemq/camel/branches/camel-1.x/components/camel-osgi/src/main/java/org/apache/camel/osgi/CamelContextFactoryBean.java
    activemq/camel/branches/camel-1.x/components/camel-spring/src/main/java/org/apache/camel/spring/SpringCamelContext.java

Propchange: activemq/camel/branches/camel-1.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jan  6 19:17:19 2009
@@ -1 +1 @@
-/activemq/camel/trunk:709850,711200,711206,711219-711220,711523,711531,711756,711784,711859,711874,711962,711971,712064,712119,712148,712662,712692,712925,713013,713107,713136,713273,713290,713292,713295,713314,713475,713625,713932,713944,714032,717965,717989,718242,718273,718312-718515,719163-719184,719334,719339,719524,719662,719848,719851,719855,719864,719978-719979,720207,720435-720437,720806,721272,721331,721333-721334,721360,721669,721764,721813,721985,722005,722070,722110,722415,722438,722726,722845,722878,723264,723314,723325-723327,723409,723835,723966,724122,724619,724681,725040,725309-725320,725340,725351,725569-725572,725612,725652-725660,725715,725883,726339,726640-726645,726932,727113,727375,727377,727624,727713,727946,729401,729892,730069,730132,730154,730157,730275,730299,730504-730505,730508,730571,730599,730759,730903,730916,730923,730936,730992,731126,731168-731169,731488,731492,731799,731824,731836,731844,731860
+/activemq/camel/trunk:709850,711200,711206,711219-711220,711523,711531,711756,711784,711859,711874,711962,711971,712064,712119,712148,712662,712692,712925,713013,713107,713136,713273,713290,713292,713295,713314,713475,713625,713932,713944,714032,717965,717989,718242,718273,718312-718515,719163-719184,719334,719339,719524,719662,719848,719851,719855,719864,719978-719979,720207,720435-720437,720806,721272,721331,721333-721334,721360,721669,721764,721813,721985,722005,722070,722110,722415,722438,722726,722845,722878,723264,723314,723325-723327,723409,723835,723966,724122,724619,724681,725040,725309-725320,725340,725351,725569-725572,725612,725652-725660,725715,725883,726339,726640-726645,726932,727113,727375,727377,727624,727713,727946,729401,729892,730069,730132,730154,730157,730275,730299,730504-730505,730508,730571,730599,730759,730903,730916,730923,730936,730992,731126,731168-731169,731488,731492,731799,731824,731836,731844,731860,732207

Propchange: activemq/camel/branches/camel-1.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: activemq/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/CamelContext.java
URL: http://svn.apache.org/viewvc/activemq/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/CamelContext.java?rev=732209&r1=732208&r2=732209&view=diff
==============================================================================
--- activemq/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/CamelContext.java
(original)
+++ activemq/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/CamelContext.java
Tue Jan  6 19:17:19 2009
@@ -30,6 +30,7 @@
 import org.apache.camel.spi.Language;
 import org.apache.camel.spi.LifecycleStrategy;
 import org.apache.camel.spi.Registry;
+import org.apache.camel.util.FactoryFinder;
 
 /**
  * Interface used to represent the context used to configure routes and the
@@ -326,4 +327,17 @@
      * @return the data formats available
      */
     Map<String, DataFormatType> getDataFormats();
+    
+    /**
+     * Create a FactoryFinder which will be used for the loading the factory class from META-INF
+     * @return the factory finder
+     */
+    FactoryFinder createFactoryFinder();
+    
+    /**
+     * Create a FactoryFinder which will be used for the loading the factory class from META-INF
+     * @param path the META-INF path
+     * @return the factory finder
+     */
+    FactoryFinder createFactoryFinder(String path);
 }

Modified: activemq/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/component/file/FileEndpoint.java
URL: http://svn.apache.org/viewvc/activemq/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/component/file/FileEndpoint.java?rev=732209&r1=732208&r2=732209&view=diff
==============================================================================
--- activemq/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/component/file/FileEndpoint.java
(original)
+++ activemq/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/component/file/FileEndpoint.java
Tue Jan  6 19:17:19 2009
@@ -378,7 +378,7 @@
     protected FileProcessStrategy createFileStrategy() {
         Class<?> factory = null;
         try {
-            FactoryFinder finder = new FactoryFinder("META-INF/services/org/apache/camel/component/");
+            FactoryFinder finder = getCamelContext().createFactoryFinder("META-INF/services/org/apache/camel/component/");
             factory = finder.findClass("file", "strategy.factory.");
         } catch (ClassNotFoundException e) {
             LOG.debug("'strategy.factory.class' not found", e);

Modified: activemq/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
URL: http://svn.apache.org/viewvc/activemq/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java?rev=732209&r1=732208&r2=732209&view=diff
==============================================================================
--- activemq/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
(original)
+++ activemq/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
Tue Jan  6 19:17:19 2009
@@ -17,6 +17,7 @@
 package org.apache.camel.impl;
 
 import java.io.IOException;
+import java.lang.reflect.Constructor;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
@@ -67,7 +68,6 @@
 import static org.apache.camel.util.ServiceHelper.startServices;
 import static org.apache.camel.util.ServiceHelper.stopServices;
 
-
 /**
  * Represents the context used to configure routes and the policies to use.
  *
@@ -97,6 +97,7 @@
     private Long delay;
     private ErrorHandlerBuilder errorHandlerBuilder;
     private Map<String, DataFormatType> dataFormats = new HashMap<String, DataFormatType>();
+    private Class<? extends FactoryFinder> factoryFinderClass = FactoryFinder.class;
 
     public DefaultCamelContext() {
         name = NAME_PREFIX + ++nameSuffix;
@@ -695,7 +696,7 @@
      * Lazily create a default implementation
      */
     protected Injector createInjector() {
-        FactoryFinder finder = new FactoryFinder();
+        FactoryFinder finder = createFactoryFinder();
         try {
             return (Injector) finder.newInstance("Injector");
         } catch (NoFactoryAvailableException e) {
@@ -773,4 +774,27 @@
     public Map<String, DataFormatType> getDataFormats() {
         return dataFormats;
     }
+    
+    public void setFactoryFinderClass(Class<? extends FactoryFinder> finderClass) {
+        factoryFinderClass = finderClass;
+    }
+
+    public FactoryFinder createFactoryFinder() {
+        try {
+            return factoryFinderClass.newInstance();
+        } catch (Exception e) {
+            throw new RuntimeCamelException(e);
+        }
+    }
+
+    public FactoryFinder createFactoryFinder(String path) {
+        try {
+            Constructor<? extends FactoryFinder> constructor;
+            constructor = factoryFinderClass.getConstructor(String.class);
+            return constructor.newInstance(path);
+        } catch (Exception e) {
+            throw new RuntimeCamelException(e);
+        }
+        
+    }
 }

Modified: activemq/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/util/FactoryFinder.java
URL: http://svn.apache.org/viewvc/activemq/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/util/FactoryFinder.java?rev=732209&r1=732208&r2=732209&view=diff
==============================================================================
--- activemq/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/util/FactoryFinder.java
(original)
+++ activemq/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/util/FactoryFinder.java
Tue Jan  6 19:17:19 2009
@@ -32,7 +32,7 @@
  */
 public class FactoryFinder {
     private final String path;
-    private final ConcurrentHashMap classMap = new ConcurrentHashMap();
+    protected final ConcurrentHashMap<String, Class> classMap = new ConcurrentHashMap<String,
Class>();
 
     public FactoryFinder() {
         this("META-INF/services/org/apache/camel/");
@@ -66,7 +66,7 @@
 
     public Object newInstance(String key, Injector injector, String propertyPrefix) throws
IOException,
         ClassNotFoundException {
-        Class type = findClass(key, propertyPrefix);
+        Class<?> type = findClass(key, propertyPrefix);
         return injector.newInstance(type);
     }
 
@@ -77,7 +77,7 @@
 
     public <T> T newInstance(String key, Injector injector, String propertyPrefix,
Class<T> expectedType)
         throws IOException, ClassNotFoundException {
-        Class type = findClass(key, propertyPrefix);
+        Class<?> type = findClass(key, propertyPrefix);
         Object value = injector.newInstance(type);
         if (expectedType.isInstance(value)) {
             return expectedType.cast(value);

Modified: activemq/camel/branches/camel-1.x/components/camel-osgi/src/main/java/org/apache/camel/osgi/CamelContextFactoryBean.java
URL: http://svn.apache.org/viewvc/activemq/camel/branches/camel-1.x/components/camel-osgi/src/main/java/org/apache/camel/osgi/CamelContextFactoryBean.java?rev=732209&r1=732208&r2=732209&view=diff
==============================================================================
--- activemq/camel/branches/camel-1.x/components/camel-osgi/src/main/java/org/apache/camel/osgi/CamelContextFactoryBean.java
(original)
+++ activemq/camel/branches/camel-1.x/components/camel-osgi/src/main/java/org/apache/camel/osgi/CamelContextFactoryBean.java
Tue Jan  6 19:17:19 2009
@@ -27,6 +27,7 @@
 import org.apache.camel.impl.converter.DefaultTypeConverter;
 import org.apache.camel.impl.converter.TypeConverterLoader;
 import org.apache.camel.spring.SpringCamelContext;
+import org.apache.camel.util.FactoryFinder;
 import org.osgi.framework.BundleContext;
 import org.springframework.osgi.context.BundleContextAware;
 
@@ -44,14 +45,14 @@
     public void setBundleContext(BundleContext bundleContext) {
         this.bundleContext = bundleContext;
     }
-
-
+    
     protected SpringCamelContext createContext() {
         SpringCamelContext context = super.createContext();
         if (bundleContext != null) {
             context.setComponentResolver(new OsgiComponentResolver());
             context.setLanguageResolver(new OsgiLanguageResolver());
-            addOsgiAnnotationTypeConverterLoader(context, bundleContext);            
+            addOsgiAnnotationTypeConverterLoader(context, bundleContext);
+            context.setFactoryFinderClass(OsgiFactoryFinder.class);
         }
         
         return context;
@@ -72,6 +73,6 @@
             typeConverterLoaders.remove(atLoader);
         }
         typeConverterLoaders.add(new OsgiAnnotationTypeConverterLoader(bundleContext));
-    }
-
+    }    
+    
 }

Modified: activemq/camel/branches/camel-1.x/components/camel-spring/src/main/java/org/apache/camel/spring/SpringCamelContext.java
URL: http://svn.apache.org/viewvc/activemq/camel/branches/camel-1.x/components/camel-spring/src/main/java/org/apache/camel/spring/SpringCamelContext.java?rev=732209&r1=732208&r2=732209&view=diff
==============================================================================
--- activemq/camel/branches/camel-1.x/components/camel-spring/src/main/java/org/apache/camel/spring/SpringCamelContext.java
(original)
+++ activemq/camel/branches/camel-1.x/components/camel-spring/src/main/java/org/apache/camel/spring/SpringCamelContext.java
Tue Jan  6 19:17:19 2009
@@ -18,7 +18,6 @@
 
 import org.apache.camel.Endpoint;
 import org.apache.camel.NoTypeConversionAvailableException;
-import org.apache.camel.Processor;
 import org.apache.camel.component.bean.BeanProcessor;
 import org.apache.camel.component.event.EventComponent;
 import org.apache.camel.component.event.EventEndpoint;
@@ -213,5 +212,6 @@
 
     public boolean getShouldStartContext() {
         return shouldStartContext;
-    }
+    }    
+    
 }



Mime
View raw message