Author: gnodet
Date: Thu Feb 24 10:25:01 2011
New Revision: 1074097

URL: http://svn.apache.org/viewvc?rev=1074097&view=rev
Log:
[CAMEL-3620] Blueprint container goes 'GracePeriod' if component is defined in 
the same XML file

Added:
    
camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/blueprint/blueprint-15.xml
Modified:
    
camel/trunk/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/handler/CamelNamespaceHandler.java
    
camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/CamelBlueprintTest.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=1074097&r1=1074096&r2=1074097&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 Feb 24 10:25:01 2011
@@ -28,6 +28,8 @@ import java.util.concurrent.Callable;
 import javax.xml.bind.Binder;
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBException;
+
+import org.osgi.service.blueprint.reflect.ServiceReferenceMetadata;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
@@ -87,6 +89,8 @@ import org.osgi.service.blueprint.reflec
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import static org.osgi.service.blueprint.reflect.ServiceReferenceMetadata.*;
+
 public class CamelNamespaceHandler implements NamespaceHandler {
 
     private static final String CAMEL_CONTEXT = "camelContext";
@@ -509,6 +513,7 @@ public class CamelNamespaceHandler imple
                         MutableReferenceMetadata svc = 
createMetadata(MutableReferenceMetadata.class);
                         svc.setId(".camelBlueprint.componentResolver." + 
component);
                         svc.setFilter("(component=" + component + ")");
+                        
svc.setAvailability(componentDefinitionRegistry.containsComponentDefinition(component)
 ? AVAILABILITY_OPTIONAL : AVAILABILITY_MANDATORY);
                         try {
                             // Try to set the runtime interface (only with 
aries blueprint > 0.1
                             svc.getClass().getMethod("setRuntimeInterface", 
Class.class).invoke(svc, ComponentResolver.class);
@@ -535,6 +540,7 @@ public class CamelNamespaceHandler imple
                         MutableReferenceMetadata svc = 
createMetadata(MutableReferenceMetadata.class);
                         svc.setId(".camelBlueprint.languageResolver." + 
language);
                         svc.setFilter("(language=" + language + ")");
+                        
svc.setAvailability(componentDefinitionRegistry.containsComponentDefinition(language)
 ? AVAILABILITY_OPTIONAL : AVAILABILITY_MANDATORY);
                         try {
                             // Try to set the runtime interface (only with 
aries blueprint > 0.1
                             svc.getClass().getMethod("setRuntimeInterface", 
Class.class).invoke(svc, LanguageResolver.class);
@@ -561,6 +567,7 @@ public class CamelNamespaceHandler imple
                         MutableReferenceMetadata svc = 
createMetadata(MutableReferenceMetadata.class);
                         svc.setId(".camelBlueprint.dataformatResolver." + 
dataformat);
                         svc.setFilter("(dataformat=" + dataformat + ")");
+                        
svc.setAvailability(componentDefinitionRegistry.containsComponentDefinition(dataformat)
 ? AVAILABILITY_OPTIONAL : AVAILABILITY_MANDATORY);
                         try {
                             // Try to set the runtime interface (only with 
aries blueprint > 0.1
                             svc.getClass().getMethod("setRuntimeInterface", 
Class.class).invoke(svc, DataFormatResolver.class);

Modified: 
camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/CamelBlueprintTest.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/CamelBlueprintTest.java?rev=1074097&r1=1074096&r2=1074097&view=diff
==============================================================================
--- 
camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/CamelBlueprintTest.java
 (original)
+++ 
camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/CamelBlueprintTest.java
 Thu Feb 24 10:25:01 2011
@@ -193,6 +193,15 @@ public class CamelBlueprintTest extends 
         assertEquals(DeadLetterChannelBuilder.class.getName(), 
eh.getClass().getName());
     }
 
+    @Test
+    public void testRouteWithNonStdComponentFromBlueprint() throws Exception {
+        getInstalledBundle("CamelBlueprintTestBundle15").start();
+        BlueprintContainer ctn = getOsgiService(BlueprintContainer.class, 
"(osgi.blueprint.container.symbolicname=CamelBlueprintTestBundle15)", 10000);
+        CamelContext ctx = getOsgiService(CamelContext.class, 
"(camel.context.symbolicname=CamelBlueprintTestBundle15)", 10000);
+        assertEquals(1, ctx.getRoutes().size());
+        assertSame(ctn.getComponentInstance("mycomp"), 
ctx.getComponent("mycomp"));
+    }
+
     @Configuration
     public static Option[] configure() throws Exception {
 
@@ -280,6 +289,13 @@ public class CamelBlueprintTest extends 
                         .set(Constants.DYNAMICIMPORT_PACKAGE, "*")
                         .build()).noStart(),
 
+                bundle(newBundle()
+                        .add("OSGI-INF/blueprint/test.xml", 
OSGiBlueprintTestSupport.class.getResource("blueprint-15.xml"))
+                        .add(TestProxySender.class)
+                        .set(Constants.BUNDLE_SYMBOLICNAME, 
"CamelBlueprintTestBundle15")
+                        .set(Constants.DYNAMICIMPORT_PACKAGE, "*")
+                        .build()).noStart(),
+
                 // install the spring dm profile
                 profile("spring.dm").version("1.2.0"),
                 // this is how you set the default log level when using pax 
logging (logProfile)

Added: 
camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/blueprint/blueprint-15.xml
URL: 
http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/blueprint/blueprint-15.xml?rev=1074097&view=auto
==============================================================================
--- 
camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/blueprint/blueprint-15.xml
 (added)
+++ 
camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/blueprint/blueprint-15.xml
 Thu Feb 24 10:25:01 2011
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0";>
+
+    <camelContext xmlns="http://camel.apache.org/schema/blueprint";>
+        <route>
+            <from uri="mycomp:queue"/>
+            <to uri="mock:result"/>
+        </route>
+    </camelContext>
+
+    <bean id="mycomp" class="org.apache.camel.component.seda.SedaComponent"/>
+
+</blueprint>


Reply via email to