cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1084817 - in /cxf/sandbox/cxf-blueprint: core/src/main/java/org/apache/cxf/blueprint/core/ jaxws/src/main/java/org/apache/cxf/blueprint/jaxws/ jaxws/src/test/java/org/apache/cxf/blueprint/jaxws/
Date Thu, 24 Mar 2011 00:40:48 GMT
Author: joed
Date: Thu Mar 24 00:40:48 2011
New Revision: 1084817

URL: http://svn.apache.org/viewvc?rev=1084817&view=rev
Log:
Fixed wsdl loading by resorting to a bundle.getEntry and passing that along.
That avoids CXF common trying to use classloading magick to resolve the resources.

Modified:
    cxf/sandbox/cxf-blueprint/core/src/main/java/org/apache/cxf/blueprint/core/NSUtils.java
    cxf/sandbox/cxf-blueprint/jaxws/src/main/java/org/apache/cxf/blueprint/jaxws/EndpointDefinitionParser.java
    cxf/sandbox/cxf-blueprint/jaxws/src/main/java/org/apache/cxf/blueprint/jaxws/MetaDataBeans.java
    cxf/sandbox/cxf-blueprint/jaxws/src/main/java/org/apache/cxf/blueprint/jaxws/ServerDefinitionParser.java
    cxf/sandbox/cxf-blueprint/jaxws/src/test/java/org/apache/cxf/blueprint/jaxws/NsHandlerTest.java

Modified: cxf/sandbox/cxf-blueprint/core/src/main/java/org/apache/cxf/blueprint/core/NSUtils.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/cxf-blueprint/core/src/main/java/org/apache/cxf/blueprint/core/NSUtils.java?rev=1084817&r1=1084816&r2=1084817&view=diff
==============================================================================
--- cxf/sandbox/cxf-blueprint/core/src/main/java/org/apache/cxf/blueprint/core/NSUtils.java
(original)
+++ cxf/sandbox/cxf-blueprint/core/src/main/java/org/apache/cxf/blueprint/core/NSUtils.java
Thu Mar 24 00:40:48 2011
@@ -17,6 +17,8 @@
 
 package org.apache.cxf.blueprint.core;
 
+import java.io.IOException;
+import java.net.URL;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.StringTokenizer;
@@ -33,6 +35,7 @@ import org.apache.aries.blueprint.mutabl
 import org.apache.aries.blueprint.reflect.MapEntryImpl;
 import org.apache.aries.blueprint.reflect.MetadataUtil;
 import org.apache.cxf.helpers.DOMUtils;
+import org.osgi.framework.Bundle;
 import org.osgi.service.blueprint.container.ComponentDefinitionException;
 import org.osgi.service.blueprint.reflect.MapEntry;
 import org.osgi.service.blueprint.reflect.Metadata;
@@ -257,4 +260,17 @@ public class NSUtils {
             return value;
         }
     }
+
+    public static URL location(String location, Bundle bundle) throws IOException {
+        int bangIndex = location.indexOf('!');
+        //No '!', getEntry will do
+        if (bangIndex == -1) {
+            URL url = bundle.getEntry(location);
+
+            if (url != null) {
+                return url;
+            }
+        }
+        return null;
+    }
 }

Modified: cxf/sandbox/cxf-blueprint/jaxws/src/main/java/org/apache/cxf/blueprint/jaxws/EndpointDefinitionParser.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/cxf-blueprint/jaxws/src/main/java/org/apache/cxf/blueprint/jaxws/EndpointDefinitionParser.java?rev=1084817&r1=1084816&r2=1084817&view=diff
==============================================================================
--- cxf/sandbox/cxf-blueprint/jaxws/src/main/java/org/apache/cxf/blueprint/jaxws/EndpointDefinitionParser.java
(original)
+++ cxf/sandbox/cxf-blueprint/jaxws/src/main/java/org/apache/cxf/blueprint/jaxws/EndpointDefinitionParser.java
Thu Mar 24 00:40:48 2011
@@ -53,6 +53,7 @@ class EndpointDefinitionParser extends B
         //Add a blueprintContainer ref
 
         cxfBean.addProperty("blueprintContainer", NSUtils.createRef(context, "blueprintContainer"));
+        cxfBean.addProperty("bundleContext", NSUtils.createRef(context, "blueprintBundleContext"));
         if (!StringUtils.isEmpty(NSUtils.getIdOrName(element))) {
             cxfBean.setId(NSUtils.getIdOrName(element));
         } else {

Modified: cxf/sandbox/cxf-blueprint/jaxws/src/main/java/org/apache/cxf/blueprint/jaxws/MetaDataBeans.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/cxf-blueprint/jaxws/src/main/java/org/apache/cxf/blueprint/jaxws/MetaDataBeans.java?rev=1084817&r1=1084816&r2=1084817&view=diff
==============================================================================
--- cxf/sandbox/cxf-blueprint/jaxws/src/main/java/org/apache/cxf/blueprint/jaxws/MetaDataBeans.java
(original)
+++ cxf/sandbox/cxf-blueprint/jaxws/src/main/java/org/apache/cxf/blueprint/jaxws/MetaDataBeans.java
Thu Mar 24 00:40:48 2011
@@ -17,20 +17,27 @@
 
 package org.apache.cxf.blueprint.jaxws;
 
+import java.io.IOException;
+import java.net.URL;
 import java.util.List;
 
 import org.apache.cxf.Bus;
+import org.apache.cxf.blueprint.core.NSUtils;
 import org.apache.cxf.frontend.ServerFactoryBean;
 import org.apache.cxf.interceptor.Interceptor;
 import org.apache.cxf.jaxws.EndpointImpl;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.service.factory.ReflectionServiceFactoryBean;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
 import org.osgi.service.blueprint.container.BlueprintContainer;
 
 class MetaDataBeans {
 
     public static class CxfBlueprintServer extends ServerFactoryBean {
 
+        private BundleContext bundleContext;
+
         private BlueprintContainer blueprintContainer;
 
         public CxfBlueprintServer() {
@@ -41,7 +48,25 @@ class MetaDataBeans {
             super(fact);
         }
 
+        private void setWsdl(String wsdl) {
+            super.setWsdlLocation(wsdl);
+        }
+
         public void init() {
+
+            if (!getWsdlLocation().startsWith("file:") || !getWsdlLocation().startsWith("jar:")
|| !getWsdlLocation().startsWith("wsjar:")) {
+                try {
+                    String wsdlLocation;
+                    if (getWsdlLocation().startsWith("classpath:")) {
+                        wsdlLocation = NSUtils.location(getWsdlLocation().split(":")[1],
bundleContext.getBundle()).toString();
+                    } else {
+                        wsdlLocation = NSUtils.location(getWsdlLocation(), bundleContext.getBundle()).toString();
+                    }
+                    setWsdl(wsdlLocation);
+                } catch (IOException e) {
+                    throw new RuntimeException("WSDL " + getWsdlLocation() + "  not found.");
+                }
+            }
             super.create();
         }
 
@@ -104,6 +129,7 @@ class MetaDataBeans {
 
     public static class CxfBlueprintEndpoint extends EndpointImpl {
 
+        private BundleContext bundleContext;
         private BlueprintContainer blueprintContainer;
 
         public CxfBlueprintEndpoint(Object implementor) {
@@ -115,6 +141,30 @@ class MetaDataBeans {
             setBus(bus);
         }
 
+        private void setWsdl(String wsdl) {
+            super.setWsdlLocation(wsdl);
+        }
+
+        @Override
+        public void publish() {
+
+            if (!getWsdlLocation().startsWith("file:") || !getWsdlLocation().startsWith("jar:")
|| !getWsdlLocation().startsWith("wsjar:")) {
+                try {
+                    String wsdlLocation;
+                    if (getWsdlLocation().startsWith("classpath:")) {
+                        wsdlLocation = NSUtils.location(getWsdlLocation().split(":")[1],
bundleContext.getBundle()).toString();
+                    } else {
+                        wsdlLocation = NSUtils.location(getWsdlLocation(), bundleContext.getBundle()).toString();
+                    }
+                    setWsdl(wsdlLocation);
+                } catch (IOException e) {
+                    throw new RuntimeException("WSDL " + getWsdlLocation() + "  not found.");
+                }
+            }
+
+            super.publish();
+        }
+
         @Override
         public void stop() {
             super.stop();
@@ -129,6 +179,14 @@ class MetaDataBeans {
             this.blueprintContainer = blueprintContainer;
         }
 
+        public BundleContext getBundleContext() {
+            return bundleContext;
+        }
+
+        public void setBundleContext(BundleContext bundleContext) {
+            this.bundleContext = bundleContext;
+        }
+
         public List getInInterceptors() {
             return super.getInInterceptors();
         }
@@ -153,6 +211,19 @@ class MetaDataBeans {
             return super.getOutInterceptors();
         }
 
+        private URL location(String location, Bundle bundle) throws IOException {
+            int bangIndex = location.indexOf('!');
+            //No '!', getEntry will do
+            if (bangIndex == -1) {
+                URL url = bundle.getEntry(location);
+
+                if (url != null) {
+                    return url;
+                }
+            }
+            return null;
+        }
+
         public void setOutInterceptors(List interceptors) {
             for (Object o : interceptors) {
                 super.getOutInterceptors().add((Interceptor<? extends Message>) o);

Modified: cxf/sandbox/cxf-blueprint/jaxws/src/main/java/org/apache/cxf/blueprint/jaxws/ServerDefinitionParser.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/cxf-blueprint/jaxws/src/main/java/org/apache/cxf/blueprint/jaxws/ServerDefinitionParser.java?rev=1084817&r1=1084816&r2=1084817&view=diff
==============================================================================
--- cxf/sandbox/cxf-blueprint/jaxws/src/main/java/org/apache/cxf/blueprint/jaxws/ServerDefinitionParser.java
(original)
+++ cxf/sandbox/cxf-blueprint/jaxws/src/main/java/org/apache/cxf/blueprint/jaxws/ServerDefinitionParser.java
Thu Mar 24 00:40:48 2011
@@ -40,6 +40,7 @@ class ServerDefinitionParser extends Bas
 
         //Add a blueprintContainer ref
 
+        cxfBean.addProperty("bundleContext", NSUtils.createRef(context, "blueprintBundleContext"));
         cxfBean.addProperty("blueprintContainer", NSUtils.createRef(context, "blueprintContainer"));
 
         if (!StringUtils.isEmpty(NSUtils.getIdOrName(element))) {

Modified: cxf/sandbox/cxf-blueprint/jaxws/src/test/java/org/apache/cxf/blueprint/jaxws/NsHandlerTest.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/cxf-blueprint/jaxws/src/test/java/org/apache/cxf/blueprint/jaxws/NsHandlerTest.java?rev=1084817&r1=1084816&r2=1084817&view=diff
==============================================================================
--- cxf/sandbox/cxf-blueprint/jaxws/src/test/java/org/apache/cxf/blueprint/jaxws/NsHandlerTest.java
(original)
+++ cxf/sandbox/cxf-blueprint/jaxws/src/test/java/org/apache/cxf/blueprint/jaxws/NsHandlerTest.java
Thu Mar 24 00:40:48 2011
@@ -36,7 +36,7 @@ public class NsHandlerTest extends BaseN
 
         BeanMetadata comp = (BeanMetadata) cdr.getComponentDefinition("bob");
 
-        BeanProperty bp = (BeanProperty) comp.getProperties().get(1);
+        BeanProperty bp = (BeanProperty) comp.getProperties().get(2);
         RefMetadata anon = (RefMetadata) bp.getValue();
 
         assertTrue("cxf.bus.threaded.default".equals(anon.getComponentId()));
@@ -48,7 +48,9 @@ public class NsHandlerTest extends BaseN
 
         BeanMetadata comp = (BeanMetadata) cdr.getComponentDefinition("bob");
 
-        BeanProperty bp = (BeanProperty) comp.getProperties().get(3);
+        System.out.println(comp.getProperties());
+
+        BeanProperty bp = (BeanProperty) comp.getProperties().get(4);
         CollectionMetadata anon = (CollectionMetadata) bp.getValue();
 
         RefMetadata interceptor = (RefMetadata) anon.getValues().get(0);



Mime
View raw message