svn commit: r667533 - in /activemq/camel/trunk/components: camel-osgi/src/main/java/org/apache/camel/osgi/CamelNamespaceHandler.java camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r667533 - in /activemq/camel/trunk/components: camel-osgi/src/main/java/org/apache/camel/osgi/CamelNamespaceHandler.java camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java

gnodet
Author: gnodet
Date: Fri Jun 13 06:36:54 2008
New Revision: 667533

URL: http://svn.apache.org/viewvc?rev=667533&view=rev
Log:
CAMEL-610: camel-spring and camel-context need to import the needed packages for the JAXBContext to work in OSGi

Modified:
    activemq/camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/CamelNamespaceHandler.java
    activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java

Modified: activemq/camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/CamelNamespaceHandler.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/CamelNamespaceHandler.java?rev=667533&r1=667532&r2=667533&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/CamelNamespaceHandler.java (original)
+++ activemq/camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/CamelNamespaceHandler.java Fri Jun 13 06:36:54 2008
@@ -16,6 +16,9 @@
  */
 package org.apache.camel.osgi;
 
+import java.util.HashSet;
+import java.util.Set;
+
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBException;
 
@@ -27,7 +30,27 @@
     }
 
     protected JAXBContext createJaxbContext() throws JAXBException {
-        return JAXBContext.newInstance("org.apache.camel.osgi:" + JAXB_PACKAGES);
+        StringBuilder packages = new StringBuilder();
+        for (Class cl : getJaxbPackages()) {
+            if (packages.length() > 0) {
+                packages.append(":");
+            }
+            packages.append(cl.getName().substring(0, cl.getName().lastIndexOf('.')));
+        }
+        return JAXBContext.newInstance(packages.toString(), getClass().getClassLoader());
+    }
+
+    protected Set<Class> getJaxbPackages() {
+        Set<Class> classes = new HashSet<Class>();
+        classes.add(org.apache.camel.osgi.CamelContextFactoryBean.class);
+        classes.add(org.apache.camel.spring.CamelContextFactoryBean.class);
+        classes.add(org.apache.camel.model.RouteType.class);
+        classes.add(org.apache.camel.model.config.StreamResequencerConfig.class);
+        classes.add(org.apache.camel.model.dataformat.DataFormatType.class);
+        classes.add(org.apache.camel.model.language.ExpressionType.class);
+        classes.add(org.apache.camel.model.loadbalancer.LoadBalancerType.class) ;
+        return classes;
     }
 
+
 }

Modified: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java?rev=667533&r1=667532&r2=667533&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java (original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java Fri Jun 13 06:36:54 2008
@@ -57,11 +57,9 @@
 
 
 public class CamelNamespaceHandler extends NamespaceHandlerSupport {
-    public static final String JAXB_PACKAGES = "org.apache.camel.spring:org.apache.camel.model:org.apache.camel.model.config:"
-                                               + "org.apache.camel.model.dataformat:org.apache.camel.model.language:org.apache.camel.model.loadbalancer";
+
     protected BeanDefinitionParser endpointParser = new BeanDefinitionParser(EndpointFactoryBean.class);
-    protected BeanDefinitionParser beanPostProcessorParser = new BeanDefinitionParser(
-                                                                                      CamelBeanPostProcessor.class);
+    protected BeanDefinitionParser beanPostProcessorParser = new BeanDefinitionParser(CamelBeanPostProcessor.class);
     protected Set<String> parserElementNames = new HashSet<String>();
     private JAXBContext jaxbContext;
     private Map<String, BeanDefinitionParser> parserMap = new HashMap<String, BeanDefinitionParser>();
@@ -149,7 +147,25 @@
     }
 
     protected JAXBContext createJaxbContext() throws JAXBException {
-        return JAXBContext.newInstance(JAXB_PACKAGES);
+        StringBuilder packages = new StringBuilder();
+        for (Class cl : getJaxbPackages()) {
+            if (packages.length() > 0) {
+                packages.append(":");
+            }
+            packages.append(cl.getName().substring(0, cl.getName().lastIndexOf('.')));
+        }
+        return JAXBContext.newInstance(packages.toString(), getClass().getClassLoader());
+    }
+
+    protected Set<Class> getJaxbPackages() {
+        Set<Class> classes = new HashSet<Class>();
+        classes.add(org.apache.camel.spring.CamelContextFactoryBean.class);
+        classes.add(org.apache.camel.model.RouteType.class);
+        classes.add(org.apache.camel.model.config.StreamResequencerConfig.class);
+        classes.add(org.apache.camel.model.dataformat.DataFormatType.class);
+        classes.add(org.apache.camel.model.language.ExpressionType.class);
+        classes.add(org.apache.camel.model.loadbalancer.LoadBalancerType.class) ;
+        return classes;
     }
 
     protected class CamelContextBeanDefinitionParser extends BeanDefinitionParser {