camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1342313 - in /camel/trunk: components/camel-blueprint/src/main/java/org/apache/camel/blueprint/handler/ components/camel-core-xml/src/main/java/org/apache/camel/core/xml/ tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blu...
Date Thu, 24 May 2012 16:18:42 GMT
Author: davsclaus
Date: Thu May 24 16:18:42 2012
New Revision: 1342313

URL: http://svn.apache.org/viewvc?rev=1342313&view=rev
Log:
Blueprint namespace should lookup default blueprint camelcontext if not explict configured
in the namespace.

Modified:
    camel/trunk/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/handler/CamelNamespaceHandler.java
    camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelFactoryBean.java
    camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/CamelBlueprint8Test.java

Modified: camel/trunk/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/handler/CamelNamespaceHandler.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/handler/CamelNamespaceHandler.java?rev=1342313&r1=1342312&r2=1342313&view=diff
==============================================================================
--- camel/trunk/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/handler/CamelNamespaceHandler.java
(original)
+++ camel/trunk/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/handler/CamelNamespaceHandler.java
Thu May 24 16:18:42 2012
@@ -526,9 +526,17 @@ public class CamelNamespaceHandler imple
             this.blueprintContainer = blueprintContainer;
         }
 
+        @Override
+        public CamelContext getCamelContext() {
+            if (blueprintContainer != null) {
+                CamelContext answer = (CamelContext) blueprintContainer.getComponentInstance(camelContextName);
+                return answer;
+            }
+            return null;
+        }
+
         public Object beforeInit(Object bean, String beanName, BeanCreator beanCreator, BeanMetadata
beanMetadata) {
-            injectFields(bean, beanName);
-            injectMethods(bean, beanName);
+            // prefer to inject later in afterInit
             return bean;
         }
 
@@ -618,6 +626,8 @@ public class CamelNamespaceHandler imple
 
         public Object afterInit(Object bean, String beanName, BeanCreator beanCreator, BeanMetadata
beanMetadata) {
             // we cannot inject CamelContextAware beans as the CamelContext may not be ready
+            injectFields(bean, beanName);
+            injectMethods(bean, beanName);
             return bean;
         }
 

Modified: camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelFactoryBean.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelFactoryBean.java?rev=1342313&r1=1342312&r2=1342313&view=diff
==============================================================================
--- camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelFactoryBean.java
(original)
+++ camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelFactoryBean.java
Thu May 24 16:18:42 2012
@@ -23,6 +23,7 @@ import javax.xml.bind.annotation.XmlTran
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.CamelContextAware;
+import org.apache.camel.NoSuchBeanException;
 import org.apache.camel.model.IdentifiedType;
 
 @XmlAccessorType(XmlAccessType.FIELD)
@@ -52,8 +53,13 @@ public abstract class AbstractCamelFacto
     }
 
     public CamelContext getCamelContext() {
+        // when getting CamelContext then we assume it must exists
+
         if (camelContext == null && camelContextId != null) {
             camelContext = getCamelContextWithId(camelContextId);
+            if (camelContext == null) {
+                throw new IllegalStateException("Cannot find CamelContext with id: " + camelContextId);
+            }
         }
         if (camelContext == null) {
             camelContext = discoverDefaultCamelContext();

Modified: camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/CamelBlueprint8Test.java
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/CamelBlueprint8Test.java?rev=1342313&r1=1342312&r2=1342313&view=diff
==============================================================================
--- camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/CamelBlueprint8Test.java
(original)
+++ camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/CamelBlueprint8Test.java
Thu May 24 16:18:42 2012
@@ -19,7 +19,6 @@ package org.apache.camel.itest.osgi.blue
 import java.lang.reflect.Method;
 
 import org.apache.camel.util.jsse.SSLContextParameters;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.ops4j.pax.exam.Option;
@@ -39,7 +38,6 @@ import static org.ops4j.pax.swissbox.tin
 public class CamelBlueprint8Test extends OSGiBlueprintTestSupport {
 
     @Test
-    @Ignore("Fix me")
     public void testEndpointInjection() throws Exception {
         getInstalledBundle("CamelBlueprintTestBundle10").start();
         BlueprintContainer ctn = getOsgiService(BlueprintContainer.class, "(osgi.blueprint.container.symbolicname=CamelBlueprintTestBundle10)",
10000);
@@ -91,12 +89,12 @@ public class CamelBlueprint8Test extends
         Option[] options = combine(
                 getDefaultCamelKarafOptions(),
 
-//                bundle(newBundle()
-//                        .add("OSGI-INF/blueprint/test.xml", OSGiBlueprintTestSupport.class.getResource("blueprint-10.xml"))
-//                        .add(TestProducer.class)
-//                        .set(Constants.BUNDLE_SYMBOLICNAME, "CamelBlueprintTestBundle10")
-//                        .set(Constants.DYNAMICIMPORT_PACKAGE, "*")
-//                        .build()).noStart(),
+                bundle(newBundle()
+                        .add("OSGI-INF/blueprint/test.xml", OSGiBlueprintTestSupport.class.getResource("blueprint-10.xml"))
+                        .add(TestProducer.class)
+                        .set(Constants.BUNDLE_SYMBOLICNAME, "CamelBlueprintTestBundle10")
+                        .set(Constants.DYNAMICIMPORT_PACKAGE, "*")
+                        .build()).noStart(),
 
 
                 bundle(newBundle()



Mime
View raw message