cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1165737 - in /cxf/branches/2.4.x-fixes: ./ rt/core/src/main/java/org/apache/cxf/bus/spring/SpringBeanLocator.java rt/transports/http/src/main/resources/META-INF/cxf/osgi/cxf-extension-osgi.xml
Date Tue, 06 Sep 2011 16:05:17 GMT
Author: dkulp
Date: Tue Sep  6 16:05:17 2011
New Revision: 1165737

URL: http://svn.apache.org/viewvc?rev=1165737&view=rev
Log:
Merged revisions 1165725 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1165725 | dkulp | 2011-09-06 11:54:23 -0400 (Tue, 06 Sep 2011) | 2 lines
  
  Remove requirment of importing cxf-extension-osgi to make it match how
  blueprint works.
........

Modified:
    cxf/branches/2.4.x-fixes/   (props changed)
    cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/spring/SpringBeanLocator.java
    cxf/branches/2.4.x-fixes/rt/transports/http/src/main/resources/META-INF/cxf/osgi/cxf-extension-osgi.xml

Propchange: cxf/branches/2.4.x-fixes/
            ('svn:mergeinfo' removed)

Propchange: cxf/branches/2.4.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/spring/SpringBeanLocator.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/spring/SpringBeanLocator.java?rev=1165737&r1=1165736&r2=1165737&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/spring/SpringBeanLocator.java
(original)
+++ cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/spring/SpringBeanLocator.java
Tue Sep  6 16:05:17 2011
@@ -33,6 +33,7 @@ import java.util.Set;
 import org.apache.cxf.Bus;
 import org.apache.cxf.bus.extension.ExtensionManagerImpl;
 import org.apache.cxf.configuration.ConfiguredBeanLocator;
+import org.osgi.framework.ServiceReference;
 import org.springframework.beans.Mergeable;
 import org.springframework.beans.PropertyValue;
 import org.springframework.beans.factory.config.BeanDefinition;
@@ -47,6 +48,7 @@ public class SpringBeanLocator implement
     ApplicationContext context;
     ConfiguredBeanLocator orig;
     Set<String> passThroughs = new HashSet<String>();
+    boolean osgi = true;
     
     public SpringBeanLocator(ApplicationContext ctx, Bus bus) {
         context = ctx;
@@ -95,8 +97,33 @@ public class SpringBeanLocator implement
             lst.add(context.getBean(n, type));
         }
         lst.addAll(orig.getBeansOfType(type));
+        if (lst.isEmpty()) {
+            tryOSGI(lst, type);
+        }
         return lst;
     }
+    private <T> void tryOSGI(Collection<T> lst, Class<T> type) {
+        if (!osgi) {
+            return;
+        }
+        try {
+            //use a little reflection to allow this to work without the spring-dm jars
+            //for the non-osgi cases
+            Object bc = context.getClass().getMethod("getBundleContext").invoke(context);
+            Object o = bc.getClass()
+                .getMethod("getServiceReference", String.class).invoke(bc, type.getName());
+            if (o != null) {
+                o = bc.getClass().getMethod("getService", ServiceReference.class).invoke(bc,
o);
+                lst.add(type.cast(o));
+            }
+        } catch (NoSuchMethodException e) {
+            osgi = false;
+            //not using OSGi
+        } catch (Throwable e) {
+            //ignore
+        }
+    }
+    
 
     public <T> boolean loadBeansOfType(Class<T> type,
                                        BeanLoaderListener<T> listener) {

Modified: cxf/branches/2.4.x-fixes/rt/transports/http/src/main/resources/META-INF/cxf/osgi/cxf-extension-osgi.xml
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/transports/http/src/main/resources/META-INF/cxf/osgi/cxf-extension-osgi.xml?rev=1165737&r1=1165736&r2=1165737&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/rt/transports/http/src/main/resources/META-INF/cxf/osgi/cxf-extension-osgi.xml
(original)
+++ cxf/branches/2.4.x-fixes/rt/transports/http/src/main/resources/META-INF/cxf/osgi/cxf-extension-osgi.xml
Tue Sep  6 16:05:17 2011
@@ -24,10 +24,8 @@
 http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
 http://www.springframework.org/schema/osgi  http://www.springframework.org/schema/osgi/spring-osgi.xsd">
 
-    <osgi:reference id="osgiDestinationRegistry"
-                    interface="org.apache.cxf.transport.http.DestinationRegistry" />
-
-	<bean id="org.apache.cxf.transport.http.HTTPTransportFactory" class="org.apache.cxf.transport.http.HTTPTransportFactory">
-		<constructor-arg ref="osgiDestinationRegistry"/>
-	</bean>
+    <bean id="osgiDestinationRegistry-import-not-needed"
+      class="org.apache.cxf.bus.spring.OldSpringSupport" lazy-init="false">
+        <constructor-arg value="cxf-extension-osgi.xml"/>
+    </bean>
 </beans>



Mime
View raw message