You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by jm...@apache.org on 2006/08/19 22:00:04 UTC

svn commit: r432868 - in /incubator/tuscany/java/sca: bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/ bindings/binding.celtix/src/main/resources/META-INF/ bindings/binding.celtix/src/main/resources/META-INF/sca/ core/src/main/j...

Author: jmarino
Date: Sat Aug 19 13:00:03 2006
New Revision: 432868

URL: http://svn.apache.org/viewvc?rev=432868&view=rev
Log:
commit Jervis' patch for TUSCANY-617 relating to Celtix binding and core directory scanner

Added:
    incubator/tuscany/java/sca/bindings/binding.celtix/src/main/resources/META-INF/
    incubator/tuscany/java/sca/bindings/binding.celtix/src/main/resources/META-INF/sca/
    incubator/tuscany/java/sca/bindings/binding.celtix/src/main/resources/META-INF/sca/default.scdl
Modified:
    incubator/tuscany/java/sca/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/CeltixBindingBuilder.java
    incubator/tuscany/java/sca/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/WebServiceBinding.java
    incubator/tuscany/java/sca/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/WebServiceBindingLoader.java
    incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/services/extension/DirectoryScanExtender.java

Modified: incubator/tuscany/java/sca/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/CeltixBindingBuilder.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/CeltixBindingBuilder.java?rev=432868&r1=432867&r2=432868&view=diff
==============================================================================
--- incubator/tuscany/java/sca/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/CeltixBindingBuilder.java (original)
+++ incubator/tuscany/java/sca/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/CeltixBindingBuilder.java Sat Aug 19 13:00:03 2006
@@ -18,7 +18,10 @@
  */
 package org.apache.tuscany.binding.celtix;
 
-import org.apache.tuscany.spi.annotation.Autowire;
+import java.util.Map;
+import java.util.WeakHashMap;
+
+import org.apache.tuscany.idl.wsdl.WSDLDefinitionRegistry;
 import org.apache.tuscany.spi.component.CompositeComponent;
 import org.apache.tuscany.spi.component.SCAObject;
 import org.apache.tuscany.spi.deployer.DeploymentContext;
@@ -26,6 +29,8 @@
 import org.apache.tuscany.spi.model.BoundReferenceDefinition;
 import org.apache.tuscany.spi.model.BoundServiceDefinition;
 
+import org.objectweb.celtix.Bus;
+
 /**
  * Builds a {@link Service} or {@link org.apache.tuscany.spi.component.Reference} configured 
  * with the Celtix binding
@@ -34,12 +39,7 @@
  */
 public class CeltixBindingBuilder extends BindingBuilderExtension<WebServiceBinding> {
 
-    private BusService busService;
-
-    @Autowire
-    public void setBusService(BusService service) {
-        this.busService = service;
-    }
+    private Bus bus;
 
     public SCAObject build(CompositeComponent parent,
                            BoundServiceDefinition<WebServiceBinding> boundServiceDefinition,
@@ -47,34 +47,48 @@
         //FIXME: CeltixService needs an instance of BusService. How to get BusService wired in 
         //and where BusService is created?
         WebServiceBinding wsBinding = boundServiceDefinition.getBinding();
-        //FIXME get interface
-        Class<?> interfaze = null;
+        if (bus == null) {
+            bus = getBus(wsBinding.getWSDLDefinitionRegistry());
+        }
         return new CeltixService(
             boundServiceDefinition.getName(),
-            interfaze,
+            boundServiceDefinition.getServiceContract().getInterfaceClass(),
             parent,
             wireService,
             wsBinding,
-            busService.getBus());
+            bus);
     }
 
     public SCAObject build(CompositeComponent parent,
                            BoundReferenceDefinition<WebServiceBinding> boundReferenceDefinition,
                            DeploymentContext deploymentContext) {
         WebServiceBinding wsBinding = boundReferenceDefinition.getBinding();
-        //Definition definition = wsBinding.getWSDLDefinition();
-        //Port port = wsBinding.getWSDLPort();
-        //Service service = wsBinding.getWSDLService();
+        if (bus == null) {
+            bus = getBus(wsBinding.getWSDLDefinitionRegistry());
+        }
         return new CeltixReference(
             boundReferenceDefinition.getName(),
             boundReferenceDefinition.getServiceContract().getInterfaceClass(),
             parent,
             wireService,
             wsBinding,
-            busService.getBus());
+            bus);
     }
 
     protected Class<WebServiceBinding> getBindingType() {
         return WebServiceBinding.class;
     }
+    
+    private Bus getBus(WSDLDefinitionRegistry wsdlDefinitionRegistry) {
+        Bus celtixBus = null;
+        try {
+            Map<String, Object> properties = new WeakHashMap<String, Object>();
+            properties.put("celtix.WSDLManager", new TuscanyWSDLManager(wsdlDefinitionRegistry));
+            bus = Bus.init(new String[0], properties);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return celtixBus;
+    }
+
 }

Modified: incubator/tuscany/java/sca/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/WebServiceBinding.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/WebServiceBinding.java?rev=432868&r1=432867&r2=432868&view=diff
==============================================================================
--- incubator/tuscany/java/sca/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/WebServiceBinding.java (original)
+++ incubator/tuscany/java/sca/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/WebServiceBinding.java Sat Aug 19 13:00:03 2006
@@ -22,6 +22,7 @@
 import javax.wsdl.Port;
 import javax.wsdl.Service;
 
+import org.apache.tuscany.idl.wsdl.WSDLDefinitionRegistry;
 import org.apache.tuscany.spi.model.Binding;
 
 /**
@@ -36,6 +37,8 @@
     private Service service;
     //private String portURI;
     private String uri;
+    //We have to use WebServiceBinding to pass WSDLDefinitionRegistry to BindingBuilder
+    private WSDLDefinitionRegistry wsdlDefinitionRegistry;
 
     public WebServiceBinding(Definition definition, Port port, String uri, String portURI, Service service) {
         this.definition = definition;
@@ -63,6 +66,14 @@
 
     public void setWSDLDefinition(Definition def) {
         definition = def;
+    }
+    
+    public WSDLDefinitionRegistry getWSDLDefinitionRegistry() {
+        return wsdlDefinitionRegistry;
+    }
+
+    public void setWSDLDefinitionRegistry(WSDLDefinitionRegistry theWsdlDefinitionRegistry) {
+        wsdlDefinitionRegistry = theWsdlDefinitionRegistry;
     }
 
 //    public void setPortURI(String uri) {

Modified: incubator/tuscany/java/sca/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/WebServiceBindingLoader.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/WebServiceBindingLoader.java?rev=432868&r1=432867&r2=432868&view=diff
==============================================================================
--- incubator/tuscany/java/sca/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/WebServiceBindingLoader.java (original)
+++ incubator/tuscany/java/sca/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/WebServiceBindingLoader.java Sat Aug 19 13:00:03 2006
@@ -27,14 +27,13 @@
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
 
-
+import org.apache.tuscany.idl.wsdl.WSDLDefinitionRegistry;
 import org.apache.tuscany.spi.annotation.Autowire;
 import org.apache.tuscany.spi.component.CompositeComponent;
 import org.apache.tuscany.spi.deployer.DeploymentContext;
 import org.apache.tuscany.spi.extension.LoaderExtension;
 import org.apache.tuscany.spi.loader.LoaderException;
 import org.apache.tuscany.spi.loader.LoaderRegistry;
-import org.apache.tuscany.idl.wsdl.WSDLDefinitionRegistry;
 
 import org.osoa.sca.annotations.Constructor;
 import org.osoa.sca.annotations.Scope;

Added: incubator/tuscany/java/sca/bindings/binding.celtix/src/main/resources/META-INF/sca/default.scdl
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/bindings/binding.celtix/src/main/resources/META-INF/sca/default.scdl?rev=432868&view=auto
==============================================================================
--- incubator/tuscany/java/sca/bindings/binding.celtix/src/main/resources/META-INF/sca/default.scdl (added)
+++ incubator/tuscany/java/sca/bindings/binding.celtix/src/main/resources/META-INF/sca/default.scdl Sat Aug 19 13:00:03 2006
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ *  Copyright (c) 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed 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.
+ -->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+           xmlns:system="http://tuscany.apache.org/xmlns/system/1.0-SNAPSHOT"
+
+           name="org.apache.tuscany.binding.celtix.WebServiceBinding">
+
+    <component name="ws.implementationLoader">
+        <system:implementation.system class="org.apache.tuscany.binding.celtix.WebServiceBindingLoader"/>
+    </component>
+
+ <component name="ws.componentBuilder">
+    <system:implementation.system class="org.apache.tuscany.binding.celtix.CeltixBindingBuilder"/>
+ </component>
+
+
+
+</composite>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ *  Copyright (c) 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed 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.
+ -->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+           xmlns:system="http://tuscany.apache.org/xmlns/system/1.0-SNAPSHOT"
+
+           name="org.apache.tuscany.binding.celtix.WebServiceBinding">
+
+    <component name="ws.implementationLoader">
+        <system:implementation.system class="org.apache.tuscany.binding.celtix.WebServiceBindingLoader"/>
+    </component>
+
+ <component name="ws.componentBuilder">
+    <system:implementation.system class="org.apache.tuscany.binding.celtix.CeltixBindingBuilder"/>
+ </component>
+
+
+
+</composite>

Modified: incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/services/extension/DirectoryScanExtender.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/services/extension/DirectoryScanExtender.java?rev=432868&r1=432867&r2=432868&view=diff
==============================================================================
--- incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/services/extension/DirectoryScanExtender.java (original)
+++ incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/services/extension/DirectoryScanExtender.java Sat Aug 19 13:00:03 2006
@@ -6,15 +6,15 @@
  * 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.    
+ * under the License.
  */
 package org.apache.tuscany.core.services.extension;
 
@@ -99,9 +99,14 @@
         try {
             extensionURL = new URL("jar:" + file.toURI().toURL() + "!/");
             scdl = new URL(extensionURL, "META-INF/sca/default.scdl");
+            //test if the scdl file exists
+        	scdl.openStream();
         } catch (MalformedURLException e) {
             // file may not be a JAR file
             return;
+        } catch (java.io.IOException e) {
+        	//The jar file is ignored as it does not contain a valid scdl
+        	return;
         }
 
         // assume this class's ClassLoader is the Tuscany system classloader



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org