servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject svn commit: r920352 - in /servicemix/components/engines/servicemix-cxf-se/trunk: ./ src/main/java/org/apache/servicemix/cxfse/ src/main/resources/META-INF/spring/
Date Mon, 08 Mar 2010 15:14:22 GMT
Author: ffang
Date: Mon Mar  8 15:14:22 2010
New Revision: 920352

URL: http://svn.apache.org/viewvc?rev=920352&view=rev
Log:
[SMXCOMP-683]inject ComponentRegistry to servicemix-cxf-se to make cxfse:proxy easy to use
in osgi container

Modified:
    servicemix/components/engines/servicemix-cxf-se/trunk/pom.xml
    servicemix/components/engines/servicemix-cxf-se/trunk/src/main/java/org/apache/servicemix/cxfse/CxfSeComponent.java
    servicemix/components/engines/servicemix-cxf-se/trunk/src/main/java/org/apache/servicemix/cxfse/CxfSeProxyFactoryBean.java
    servicemix/components/engines/servicemix-cxf-se/trunk/src/main/resources/META-INF/spring/servicemix-cxf-se.xml

Modified: servicemix/components/engines/servicemix-cxf-se/trunk/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/components/engines/servicemix-cxf-se/trunk/pom.xml?rev=920352&r1=920351&r2=920352&view=diff
==============================================================================
--- servicemix/components/engines/servicemix-cxf-se/trunk/pom.xml (original)
+++ servicemix/components/engines/servicemix-cxf-se/trunk/pom.xml Mon Mar  8 15:14:22 2010
@@ -50,6 +50,7 @@
         org.apache.servicemix.common.osgi,
         org.apache.servicemix.client*;resolution:=optional,
         org.apache.servicemix.executors.impl,
+        org.apache.servicemix.jbi.runtime,
         org.apache.servicemix.jbi.container*;resolution:=optional,
         org.apache.servicemix.jbi.framework*;resolution:=optional,
         org.apache.xbean.spring.context.v2,

Modified: servicemix/components/engines/servicemix-cxf-se/trunk/src/main/java/org/apache/servicemix/cxfse/CxfSeComponent.java
URL: http://svn.apache.org/viewvc/servicemix/components/engines/servicemix-cxf-se/trunk/src/main/java/org/apache/servicemix/cxfse/CxfSeComponent.java?rev=920352&r1=920351&r2=920352&view=diff
==============================================================================
--- servicemix/components/engines/servicemix-cxf-se/trunk/src/main/java/org/apache/servicemix/cxfse/CxfSeComponent.java
(original)
+++ servicemix/components/engines/servicemix-cxf-se/trunk/src/main/java/org/apache/servicemix/cxfse/CxfSeComponent.java
Mon Mar  8 15:14:22 2010
@@ -42,6 +42,7 @@
     private CxfSeEndpoint[] endpoints;
     private Bus bus;
     private CxfSeConfiguration configuration = new CxfSeConfiguration();
+    private static Object componentRegistry;
     
     public CxfSeComponent() {
         
@@ -96,6 +97,7 @@
         super.doShutDown();
     }
     
+    
     public Bus getBus() {
         return bus;
     }
@@ -107,4 +109,12 @@
    public void setBus(Bus bus) {
         this.bus = bus;
     }
+
+    public void setComponentRegistry(Object componentRegistry) {
+        this.componentRegistry = componentRegistry;
+    }
+
+    public static Object getComponentRegistry() {
+        return componentRegistry;
+    }
 }

Modified: servicemix/components/engines/servicemix-cxf-se/trunk/src/main/java/org/apache/servicemix/cxfse/CxfSeProxyFactoryBean.java
URL: http://svn.apache.org/viewvc/servicemix/components/engines/servicemix-cxf-se/trunk/src/main/java/org/apache/servicemix/cxfse/CxfSeProxyFactoryBean.java?rev=920352&r1=920351&r2=920352&view=diff
==============================================================================
--- servicemix/components/engines/servicemix-cxf-se/trunk/src/main/java/org/apache/servicemix/cxfse/CxfSeProxyFactoryBean.java
(original)
+++ servicemix/components/engines/servicemix-cxf-se/trunk/src/main/java/org/apache/servicemix/cxfse/CxfSeProxyFactoryBean.java
Mon Mar  8 15:14:22 2010
@@ -16,6 +16,7 @@
  */
 package org.apache.servicemix.cxfse;
 
+import java.lang.reflect.Method;
 import java.util.List;
 
 import javax.jbi.component.ComponentContext;
@@ -25,6 +26,7 @@
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
+import org.apache.cxf.bus.spring.SpringBusFactory;
 import org.apache.cxf.frontend.ClientProxy;
 import org.apache.cxf.interceptor.Interceptor;
 import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
@@ -49,6 +51,13 @@
  */
 public class CxfSeProxyFactoryBean implements FactoryBean, InitializingBean,
         DisposableBean {
+    
+    private static final String[] CXF_CONFIG = new String[] {
+        "META-INF/cxf/cxf.xml",
+        "META-INF/cxf/cxf-extension-soap.xml",
+        "META-INF/cxf/transport/jbi/cxf-transport-jbi.xml",
+        "META-INF/cxf/binding/jbi/cxf-binding-jbi.xml"
+    };
 
     private String name = ClientFactory.DEFAULT_JNDI_NAME;
 
@@ -96,16 +105,19 @@
         if (isUseJBIWrapper()) {
             cf.setBindingId(org.apache.cxf.binding.jbi.JBIConstants.NS_JBI_BINDING);
         }
-        Bus bus = BusFactory.getDefaultBus();
+        ComponentContext internalContext = getInternalContext();
+       
+        Bus bus = new SpringBusFactory().createBus(CXF_CONFIG);;
         JBITransportFactory jbiTransportFactory = (JBITransportFactory) bus
                 .getExtension(ConduitInitiatorManager.class)
                 .getConduitInitiator(JBITransportFactory.TRANSPORT_ID);
-        if (getInternalContext() != null) { 
-            DeliveryChannel dc = getInternalContext().getDeliveryChannel();
+        if (internalContext != null) { 
+            DeliveryChannel dc = internalContext.getDeliveryChannel();
             if (dc != null) {
                 jbiTransportFactory.setDeliveryChannel(dc);
             }
         }
+        cf.setBus(bus);
         Object proxy = cf.create();
         if (!isUseJBIWrapper() && !isUseSOAPEnvelope()) {
         	removeInterceptor(ClientProxy.getClient(proxy).getEndpoint().getBinding().getInInterceptors(),

@@ -145,6 +157,15 @@
     }
 
     protected ComponentContext getInternalContext() throws Exception {
+        if (CxfSeComponent.getComponentRegistry() != null) {
+            //in osgi container
+            Object componentRegistry = CxfSeComponent.getComponentRegistry();
+            //use reflection to avoid nmr project dependency
+            Method mth = componentRegistry.getClass().getMethod("createComponentContext");
+            if (mth != null) {
+                context = (ComponentContext) mth.invoke(componentRegistry);
+            }
+        }
         if (context == null) {
             if (factory == null) {
                 if (container != null) {

Modified: servicemix/components/engines/servicemix-cxf-se/trunk/src/main/resources/META-INF/spring/servicemix-cxf-se.xml
URL: http://svn.apache.org/viewvc/servicemix/components/engines/servicemix-cxf-se/trunk/src/main/resources/META-INF/spring/servicemix-cxf-se.xml?rev=920352&r1=920351&r2=920352&view=diff
==============================================================================
--- servicemix/components/engines/servicemix-cxf-se/trunk/src/main/resources/META-INF/spring/servicemix-cxf-se.xml
(original)
+++ servicemix/components/engines/servicemix-cxf-se/trunk/src/main/resources/META-INF/spring/servicemix-cxf-se.xml
Mon Mar  8 15:14:22 2010
@@ -40,9 +40,14 @@
     <import resource="classpath:META-INF/cxf/transport/jbi/cxf-transport-jbi.xml" />
     <import resource="classpath:META-INF/cxf/binding/jbi/cxf-binding-jbi.xml" />
 
+    <osgi:reference id="componentRegistry"
+                    interface="org.apache.servicemix.jbi.runtime.ComponentRegistry"
+                    cardinality="1..1" />
+
     <bean id="servicemix-cxf-se" class="org.apache.servicemix.cxfse.CxfSeComponent">
         <property name="bus" ref="cxf" />
         <property name="executorFactory" ref="executorFactory" />
+        <property name="componentRegistry" ref="componentRegistry"/>
     </bean>
 
     <bean id="executorFactory" class="org.apache.servicemix.executors.impl.ExecutorFactoryImpl">



Mime
View raw message