camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r785599 - in /camel/trunk/components: camel-osgi/src/main/java/org/apache/camel/osgi/ camel-osgi/src/main/resources/META-INF/ camel-spring/src/main/java/org/apache/camel/spring/handler/
Date Wed, 17 Jun 2009 13:43:18 GMT
Author: davsclaus
Date: Wed Jun 17 13:43:18 2009
New Revision: 785599

URL: http://svn.apache.org/viewvc?rev=785599&view=rev
Log:
CAMEL-1725: improved logging for camel-osgi and if Camel detects uses OSGi or not.

Modified:
    camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/Activator.java
    camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/CamelContextFactory.java
    camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/CamelContextFactoryBean.java
    camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/CamelNamespaceHandler.java
    camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/OsgiAnnotationTypeConverterLoader.java
    camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/OsgiComponentResolver.java
    camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/OsgiFactoryFinder.java
    camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/OsgiFactoryFinderResolver.java
    camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/OsgiPackageScanClassResolver.java
    camel/trunk/components/camel-osgi/src/main/resources/META-INF/spring.schemas
    camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java

Modified: camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/Activator.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/Activator.java?rev=785599&r1=785598&r2=785599&view=diff
==============================================================================
--- camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/Activator.java (original)
+++ camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/Activator.java Wed
Jun 17 13:43:18 2009
@@ -66,6 +66,10 @@
     }
     
     public void bundleChanged(BundleEvent event) {
+        if (LOG.isTraceEnabled()) {
+            LOG.trace("Bundle changed: " + event);
+        }
+
         try {
             Bundle bundle = event.getBundle();
             if (event.getType() == BundleEvent.RESOLVED) {
@@ -82,9 +86,8 @@
                 mayBeRemoveTypeConverterFor(bundle);
             }
         } catch (Throwable e) {
-            LOG.fatal("Exception handing bundle changed event", e);
+            LOG.fatal("Exception occured during bundleChanged for event: " + event, e);
         }
-        
     }
 
     protected synchronized void addComponentEntry(String entryPath, Bundle bundle, Map<String,
ComponentEntry> entries) {
@@ -163,10 +166,16 @@
     }
 
     public void start(BundleContext context) throws Exception {
-        bundle = context.getBundle();       
+        LOG.info("Camel activator starting");
+
+        bundle = context.getBundle();
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Using bundle: " + bundle);
+        }
         context.addBundleListener(this);
+
         if (LOG.isDebugEnabled()) {
-            LOG.debug("checking existing bundles");
+            LOG.debug("Checking existing bundles for Camel components, languages and type
converters");
         }
         for (Bundle bundle : context.getBundles()) {
             if (bundle.getState() == Bundle.RESOLVED || bundle.getState() == Bundle.STARTING
@@ -175,15 +184,15 @@
                 mayBeAddTypeConverterFor(bundle);
             }
         }
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("actived");
-        }
-        
-    }    
+
+        LOG.info("Camel activator started");
+    }
 
     public void stop(BundleContext context) throws Exception {
+        LOG.info("Camel activator stopping");
+
         if (LOG.isDebugEnabled()) {
-            LOG.debug("removing the components of existing bundles");
+            LOG.debug("Removing Camel bundles");
         }
         for (Bundle bundle : context.getBundles()) {
             if (bundle.getState() == Bundle.RESOLVED || bundle.getState() == Bundle.STARTING

@@ -192,9 +201,8 @@
                 mayBeRemoveTypeConverterFor(bundle);
             }
         }
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("stopped");
-        }
+
+        LOG.info("Camel activator stopped");
     }
     
     protected Set<String> getConverterPackages(URL resource) {
@@ -240,9 +248,13 @@
     }
     
     protected static synchronized String[] findTypeConverterPackageNames() {
+        LOG.trace("Finding TypeConverterPackageNames");
         Set<String> packages = new HashSet<String>();
         for (TypeConverterEntry entry : TYPE_CONVERTERS.values()) {
             for (String packageName : entry.converterPackages) {
+                if (LOG.isTraceEnabled()) {
+                    LOG.trace("Found TypeConverterPackage: " + packageName);
+                }
                 packages.add(packageName);
             }
         }
@@ -250,14 +262,17 @@
     }
         
     public static synchronized Class getComponent(String name) throws Exception {
+        LOG.trace("Finding Component: " + name);
         return getClassFromEntries(name, COMPONENTS);
     }
     
     public static synchronized Class getLanguage(String name) throws Exception {
+        LOG.trace("Finding Language: " + name);
         return getClassFromEntries(name, LANGUAGES);
     }
     
     public static synchronized Class getLanguageResolver(String name) throws Exception {
+        LOG.trace("Finding LanguageResolver: " + name);
         return getClassFromEntries(name, LANGUAGE_RESOLVERS);
     }
     
@@ -294,6 +309,5 @@
         }
         return entry.type;
     }
-    
 
 }

Modified: camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/CamelContextFactory.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/CamelContextFactory.java?rev=785599&r1=785598&r2=785599&view=diff
==============================================================================
--- camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/CamelContextFactory.java
(original)
+++ camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/CamelContextFactory.java
Wed Jun 17 13:43:18 2009
@@ -14,14 +14,9 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.camel.osgi;
 
 import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.xml.bind.annotation.XmlTransient;
 
 import org.apache.camel.impl.DefaultCamelContext;
 import org.apache.camel.impl.converter.AnnotationTypeConverterLoader;
@@ -45,28 +40,42 @@
     }
 
     public void setBundleContext(BundleContext bundleContext) {
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Using BundleContext: " + bundleContext);
+        }
         this.bundleContext = bundleContext;
     }
     
     public DefaultCamelContext createContext() {
+        LOG.debug("Creating DefaultCamelContext");
+
         DefaultCamelContext context = new DefaultCamelContext();
         if (bundleContext != null) {
             if (LOG.isDebugEnabled()) {
-                LOG.debug("The bundle context is not be null, let's setup the Osgi resolvers");
+                LOG.debug("Using OSGI resolvers");
             }
+            LOG.debug("Using OsgiFactoryFinderResolver");
             context.setFactoryFinderResolver(new OsgiFactoryFinderResolver());
+            LOG.debug("Using OsgiPackageScanClassResolver");
             context.setPackageScanClassResolver(new OsgiPackageScanClassResolver(bundleContext));
+            LOG.debug("Using OsgiComponentResolver");
             context.setComponentResolver(new OsgiComponentResolver());
+            LOG.debug("Using OsgiLanguageResolver");
             context.setLanguageResolver(new OsgiLanguageResolver());
             addOsgiAnnotationTypeConverterLoader(context, bundleContext);            
+        } else {
+            // TODO: should we not thrown an excpetion to not allow it to startup
+            LOG.warn("BundleContext not set, cannot run in OSGI container");
         }
         
         return context;
     }
     
     protected void addOsgiAnnotationTypeConverterLoader(DefaultCamelContext context, BundleContext
bundleContext) {
+        LOG.debug("Using OsgiAnnotationTypeConverterLoader");
         DefaultTypeConverter typeConverter = (DefaultTypeConverter) context.getTypeConverter();
         List<TypeConverterLoader> typeConverterLoaders = typeConverter.getTypeConverterLoaders();
+
         // Remove the AnnotationTypeConverterLoader
         TypeConverterLoader atLoader = null; 
         for (TypeConverterLoader loader : typeConverterLoaders) {
@@ -79,6 +88,6 @@
             typeConverterLoaders.remove(atLoader);
         }
         typeConverterLoaders.add(new OsgiAnnotationTypeConverterLoader(context.getPackageScanClassResolver()));
-        LOG.debug("added the OsgiAnnotationTypeConverterLoader");
-    }    
+    }
+
 }

Modified: camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/CamelContextFactoryBean.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/CamelContextFactoryBean.java?rev=785599&r1=785598&r2=785599&view=diff
==============================================================================
--- camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/CamelContextFactoryBean.java
(original)
+++ camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/CamelContextFactoryBean.java
Wed Jun 17 13:43:18 2009
@@ -44,6 +44,9 @@
     }
 
     public void setBundleContext(BundleContext bundleContext) {
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Using BundleContext: " + bundleContext);
+        }
         this.bundleContext = bundleContext;
     }
     
@@ -51,21 +54,31 @@
         SpringCamelContext context = super.createContext();
         if (bundleContext != null) {
             if (LOG.isDebugEnabled()) {
-                LOG.debug("The bundle context is not be null, let's setup the Osgi resolvers");
+                LOG.debug("Using OSGI resolvers");
             }
+            LOG.debug("Using OsgiFactoryFinderResolver");
             context.setFactoryFinderResolver(new OsgiFactoryFinderResolver());
+            LOG.debug("Using OsgiPackageScanClassResolver");
             context.setPackageScanClassResolver(new OsgiPackageScanClassResolver(bundleContext));
+            LOG.debug("Using OsgiComponentResolver");
             context.setComponentResolver(new OsgiComponentResolver());
-            context.setLanguageResolver(new OsgiLanguageResolver());            
+            LOG.debug("Using OsgiLanguageResolver");
+            context.setLanguageResolver(new OsgiLanguageResolver());
             addOsgiAnnotationTypeConverterLoader(context);
+        } else {
+            // TODO: should we not thrown an excpetion to not allow it to startup
+            LOG.warn("BundleContext not set, cannot run in OSGI container");
         }
         
         return context;
     }    
     
     protected void addOsgiAnnotationTypeConverterLoader(SpringCamelContext context) {
+        LOG.debug("Using OsgiAnnotationTypeConverterLoader");
+
         DefaultTypeConverter typeConverter = (DefaultTypeConverter) context.getTypeConverter();
         List<TypeConverterLoader> typeConverterLoaders = typeConverter.getTypeConverterLoaders();
+
         // Remove the AnnotationTypeConverterLoader
         TypeConverterLoader atLoader = null; 
         for (TypeConverterLoader loader : typeConverterLoaders) {
@@ -80,7 +93,6 @@
 
         // add our osgi annotation loader
         typeConverterLoaders.add(new OsgiAnnotationTypeConverterLoader(context.getPackageScanClassResolver()));
-        LOG.debug("added the OsgiAnnotationTypeConverterLoader");
-    }    
+    }
     
 }

Modified: camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/CamelNamespaceHandler.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/CamelNamespaceHandler.java?rev=785599&r1=785598&r2=785599&view=diff
==============================================================================
--- camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/CamelNamespaceHandler.java
(original)
+++ camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/CamelNamespaceHandler.java
Wed Jun 17 13:43:18 2009
@@ -28,6 +28,8 @@
         super.init();
         registerParser("camelContext", new CamelContextBeanDefinitionParser(CamelContextFactoryBean.class));
     }
+
+    // TODO: This does not look correct with the code below, why are the so few jaxb packages?
     
     protected Set<Class> getJaxbPackages() {
         Set<Class> classes = new HashSet<Class>();

Modified: camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/OsgiAnnotationTypeConverterLoader.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/OsgiAnnotationTypeConverterLoader.java?rev=785599&r1=785598&r2=785599&view=diff
==============================================================================
--- camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/OsgiAnnotationTypeConverterLoader.java
(original)
+++ camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/OsgiAnnotationTypeConverterLoader.java
Wed Jun 17 13:43:18 2009
@@ -18,12 +18,8 @@
 
 import org.apache.camel.impl.converter.AnnotationTypeConverterLoader;
 import org.apache.camel.spi.PackageScanClassResolver;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.osgi.framework.BundleContext;
 
 public class OsgiAnnotationTypeConverterLoader extends AnnotationTypeConverterLoader {
-    private static final transient Log LOG = LogFactory.getLog(OsgiAnnotationTypeConverterLoader.class);
 
     public OsgiAnnotationTypeConverterLoader(PackageScanClassResolver packageScanClassResolver)
{
         super(packageScanClassResolver);

Modified: camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/OsgiComponentResolver.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/OsgiComponentResolver.java?rev=785599&r1=785598&r2=785599&view=diff
==============================================================================
--- camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/OsgiComponentResolver.java
(original)
+++ camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/OsgiComponentResolver.java
Wed Jun 17 13:43:18 2009
@@ -16,23 +16,11 @@
  */
 package org.apache.camel.osgi;
 
-import java.io.BufferedInputStream;
-import java.net.URL;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
 import org.apache.camel.CamelContext;
 import org.apache.camel.Component;
 import org.apache.camel.spi.ComponentResolver;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleEvent;
-import org.osgi.framework.SynchronousBundleListener;
-import org.springframework.osgi.util.BundleDelegatingClassLoader;
 
 public class OsgiComponentResolver implements ComponentResolver {
     

Modified: camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/OsgiFactoryFinder.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/OsgiFactoryFinder.java?rev=785599&r1=785598&r2=785599&view=diff
==============================================================================
--- camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/OsgiFactoryFinder.java
(original)
+++ camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/OsgiFactoryFinder.java
Wed Jun 17 13:43:18 2009
@@ -79,7 +79,7 @@
        
     public BundleEntry getResource(String name) {
         BundleEntry entry = null;
-        BundleContext bundleContext =  Activator.getBundle().getBundleContext();
+        BundleContext bundleContext = Activator.getBundle().getBundleContext();
 
         URL url;
         for (Bundle bundle : bundleContext.getBundles()) {

Modified: camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/OsgiFactoryFinderResolver.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/OsgiFactoryFinderResolver.java?rev=785599&r1=785598&r2=785599&view=diff
==============================================================================
--- camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/OsgiFactoryFinderResolver.java
(original)
+++ camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/OsgiFactoryFinderResolver.java
Wed Jun 17 13:43:18 2009
@@ -16,18 +16,14 @@
  */
 package org.apache.camel.osgi;
 
-
 import org.apache.camel.spi.ClassResolver;
 import org.apache.camel.spi.FactoryFinder;
 import org.apache.camel.spi.FactoryFinderResolver;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 
 /**
  * @version $Revision$
  */
 public class OsgiFactoryFinderResolver implements FactoryFinderResolver {
-    private static final transient Log LOG = LogFactory.getLog(OsgiFactoryFinderResolver.class);
 
     public FactoryFinder resolveDefaultFactoryFinder(ClassResolver classResolver) {     
  
         return resolveFactoryFinder(classResolver, "META-INF/services/org/apache/camel/");

Modified: camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/OsgiPackageScanClassResolver.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/OsgiPackageScanClassResolver.java?rev=785599&r1=785598&r2=785599&view=diff
==============================================================================
--- camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/OsgiPackageScanClassResolver.java
(original)
+++ camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/OsgiPackageScanClassResolver.java
Wed Jun 17 13:43:18 2009
@@ -138,7 +138,7 @@
                         String urlString = pathString.substring(pathString.indexOf(packageName));
                         urls.add(urlString);
                         if (LOG.isTraceEnabled()) {
-                            LOG.trace("added url " + urlString);
+                            LOG.trace("Added url: " + urlString);
                         }
                     }
                 }

Modified: camel/trunk/components/camel-osgi/src/main/resources/META-INF/spring.schemas
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-osgi/src/main/resources/META-INF/spring.schemas?rev=785599&r1=785598&r2=785599&view=diff
==============================================================================
--- camel/trunk/components/camel-osgi/src/main/resources/META-INF/spring.schemas (original)
+++ camel/trunk/components/camel-osgi/src/main/resources/META-INF/spring.schemas Wed Jun 17
13:43:18 2009
@@ -20,4 +20,6 @@
 http\://activemq.apache.org/camel/schema/osgi/camel-osgi-1.3.0.xsd=camel-osgi.xsd
 http\://activemq.apache.org/camel/schema/osgi/camel-osgi-1.4.0.xsd=camel-osgi.xsd
 http\://activemq.apache.org/camel/schema/osgi/camel-osgi-1.5.0.xsd=camel-osgi.xsd
+http\://activemq.apache.org/camel/schema/osgi/camel-osgi-1.6.0.xsd=camel-osgi.xsd
+http\://activemq.apache.org/camel/schema/osgi/camel-osgi-1.6.1.xsd=camel-osgi.xsd
 http\://camel.apache.org/schema/osgi/camel-osgi-${pom.version}.xsd=camel-osgi.xsd
\ No newline at end of file

Modified: camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java?rev=785599&r1=785598&r2=785599&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java
(original)
+++ camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java
Wed Jun 17 13:43:18 2009
@@ -42,6 +42,8 @@
 import org.apache.camel.spring.remoting.CamelServiceExporter;
 import org.apache.camel.util.ObjectHelper;
 import org.apache.camel.view.ModelFileGenerator;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.springframework.beans.factory.BeanDefinitionStoreException;
 import org.springframework.beans.factory.config.BeanDefinition;
 import org.springframework.beans.factory.config.RuntimeBeanReference;
@@ -55,6 +57,7 @@
  */
 public class CamelNamespaceHandler extends NamespaceHandlerSupport {
 
+    private static final Log LOG = LogFactory.getLog(CamelNamespaceHandler.class);
     protected BeanDefinitionParser endpointParser = new BeanDefinitionParser(CamelEndpointFactoryBean.class);
     protected BeanDefinitionParser beanPostProcessorParser = new BeanDefinitionParser(CamelBeanPostProcessor.class);
     protected Set<String> parserElementNames = new HashSet<String>();
@@ -80,11 +83,24 @@
         addBeanDefinitionParser("endpoint", CamelEndpointFactoryBean.class);
 
         // camel context
+        boolean osgi = false;
         Class cl = CamelContextFactoryBean.class;
         try {
             cl = Class.forName("org.apache.camel.osgi.CamelContextFactoryBean");
+            osgi = true;
         } catch (Throwable t) {
             // not running with camel-osgi so we fallback to the regular factory bean
+            LOG.trace("Cannot find class so assuming not running in OSGI container: " + t.getMessage());
+        }
+
+        if (osgi) {
+            LOG.info("camel-osgi.jar detected in classpath");
+        } else {
+            LOG.info("camel-osgi.jar not detected in classpath");
+        }
+
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Using " + cl.getCanonicalName() + " as CamelContextBeanDefinitionParser");
         }
         registerParser("camelContext", new CamelContextBeanDefinitionParser(cl));
     }



Mime
View raw message