From ac1b197298975b185c90ab02f28a2666861f977c Mon Sep 17 00:00:00 2001 From: rfeng Date: Wed, 30 Jul 2008 22:11:46 +0000 Subject: Apply the patch for TUSCANY-2469 from Wojtek. (sca-binding-sdo-problem-jira-2469-30-july.patch) git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@681221 13f79535-47bb-0310-9956-ffa450edef68 --- java/sca/itest/corba/pom.xml | 215 +++++++++++++++------ .../sca/test/corba/ScenarioFourTestCase.java | 49 ++++- .../tuscany/sca/test/corba/types/ScenarioFour.java | 5 + .../test/corba/types/ScenarioFourException.java | 37 ++++ .../sca/test/corba/types/ScenarioFourImpl.java | 12 ++ .../corba/src/test/resources/scenariofour.xsd | 31 +++ .../corba/impl/CorbaServiceBindingProvider.java | 8 +- .../corba/impl/service/DynaCorbaServant.java | 132 ++----------- .../corba/impl/service/InvocationProxy.java | 45 +++++ .../corba/testing/CorbaServantTestCase.java | 52 +++-- java/sca/modules/binding-sca-corba/pom.xml | 187 +++++++++++------- .../corba/impl/CorbaSCABindingProviderFactory.java | 10 +- .../sca/corba/impl/CorbaSCAInvocationProxy.java | 113 +++++++++++ .../impl/CorbaSCAReferenceBindingProvider.java | 31 +-- .../corba/impl/CorbaSCAServiceBindingProvider.java | 39 +++- 15 files changed, 670 insertions(+), 296 deletions(-) create mode 100644 java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFourException.java create mode 100644 java/sca/itest/corba/src/test/resources/scenariofour.xsd create mode 100644 java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/service/InvocationProxy.java create mode 100644 java/sca/modules/binding-sca-corba/src/main/java/org/apache/tuscany/sca/binding/sca/corba/impl/CorbaSCAInvocationProxy.java diff --git a/java/sca/itest/corba/pom.xml b/java/sca/itest/corba/pom.xml index b1d45f7c32..c79e84b660 100644 --- a/java/sca/itest/corba/pom.xml +++ b/java/sca/itest/corba/pom.xml @@ -1,73 +1,162 @@ - 4.0.0 - - org.apache.tuscany.sca - tuscany-itest - 1.4-SNAPSHOT - ../pom.xml - - itest-corba-binding - Apache Tuscany SCA CORBA Binding Integration Tests - + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 1.4-SNAPSHOT + ../pom.xml + + itest-corba-binding + Apache Tuscany SCA CORBA Binding Integration Tests + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-corba-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-host-corba-jdk + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-sca + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-sca-corba + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca - tuscany-host-embedded - 1.4-SNAPSHOT - - - org.apache.tuscany.sca - tuscany-implementation-java-runtime - 1.4-SNAPSHOT - runtime - - - org.apache.tuscany.sca - tuscany-binding-corba-runtime - 1.4-SNAPSHOT - runtime - - - org.apache.tuscany.sca - tuscany-host-corba-jdk + tuscany-databinding-axiom 1.4-SNAPSHOT runtime - - org.apache.tuscany.sca - tuscany-binding-sca - 1.4-SNAPSHOT - runtime - - - org.apache.tuscany.sca - tuscany-binding-sca-corba - 1.4-SNAPSHOT - runtime - - - junit - junit - 4.2 - compile - - + + + org.apache.tuscany.sca + tuscany-databinding-sdo + 1.4-SNAPSHOT + compile + + + + junit + junit + 4.2 + compile + + + + + + + org.codehaus.mojo + build-helper-maven-plugin + 1.0 + + + add-source + generate-sources + + add-test-source + + + + target/sdo-source + + + + + + + org.apache.tuscany.sdo + tuscany-sdo-plugin + 1.1-incubating + + + generate-scenariofour-sdo + generate-sources + + + ${basedir}/src/test/resources/scenariofour.xsd + + + org.apache.tuscany.sca.test.corba.scenariofour + + ScenarioFour + true + true + true + + + generate + + + + + + diff --git a/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/ScenarioFourTestCase.java b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/ScenarioFourTestCase.java index f47792c5f2..7ab5ca1e14 100644 --- a/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/ScenarioFourTestCase.java +++ b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/ScenarioFourTestCase.java @@ -26,13 +26,17 @@ import junit.framework.Assert; import org.apache.tuscany.sca.host.corba.naming.TransientNameServer; import org.apache.tuscany.sca.host.corba.naming.TransientNameService; import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.apache.tuscany.sca.test.corba.scenariofour.ScenarioFourFactory; +import org.apache.tuscany.sca.test.corba.scenariofour.ScenarioFourSdo; import org.apache.tuscany.sca.test.corba.types.ScenarioFour; import org.apache.tuscany.sca.test.corba.types.ScenarioFourComponent; +import org.apache.tuscany.sca.test.corba.types.ScenarioFourException; import org.apache.tuscany.sca.test.corba.types.ScenarioFourStruct; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; + /** * Tests SCA default binding over CORBA binding */ @@ -42,6 +46,8 @@ public class ScenarioFourTestCase { private static int ORB_INITIAL_PORT = 5060; private static SCADomain domain; private static TransientNameServer server; + private static ScenarioFourComponent scenarioFourComponent; + private static ScenarioFour scenarioFour; /** * Sets up name service, creates and registers traditional CORBA service, @@ -63,6 +69,8 @@ public class ScenarioFourTestCase { } // obtain domain domain = SCADomain.newInstance("ScenarioFour.composite"); + scenarioFourComponent = domain.getService(ScenarioFourComponent.class, "ScenarioFour"); + scenarioFour = scenarioFourComponent.getScenarioFour(); } catch (Exception e) { e.printStackTrace(); } @@ -76,16 +84,17 @@ public class ScenarioFourTestCase { server.stop(); } + /** + * General tests for passing JAXB objects + */ @Test - public void test_generalTest() { + public void test_generalJAXB() { try { - ScenarioFourComponent soc = domain.getService(ScenarioFourComponent.class, "ScenarioFour"); - ScenarioFour so = soc.getScenarioFour(); ScenarioFourStruct input = new ScenarioFourStruct(); input.field1 = "Test"; input.field2 = 1; input.field3 = new double[1]; - ScenarioFourStruct output = so.setStruct(input); + ScenarioFourStruct output = scenarioFour.setStruct(input); assertTrue(input.equals(output)); } catch (Exception e) { e.printStackTrace(); @@ -93,4 +102,36 @@ public class ScenarioFourTestCase { } } + /** + * Test for JAXB exceptions + */ + @Test + public void test_exceptionsJAXB() { + try { + scenarioFour.exceptionTest(); + fail(); + } catch (ScenarioFourException e) { + assertTrue(ScenarioFourException.DEFAULT_CONTENT.equals(e.getContent())); + } catch (Exception e) { + e.printStackTrace(); + fail(); + } + } + + /** + * General test for passing SDO objects + */ + @Test + public void test_generalSDO() { + try { + ScenarioFourSdo scenarioFourSdo = ScenarioFourFactory.INSTANCE.createScenarioFourSdo(); + scenarioFourSdo.setMessage("Test1"); + scenarioFourSdo.setSymbol("Test2"); + ScenarioFourSdo result = scenarioFour.passScenarioFourStruct(scenarioFourSdo); + assertTrue(scenarioFourSdo.getMessage().equals(result.getMessage()) && scenarioFourSdo.getSymbol().equals(result.getSymbol())); + } catch (Exception e) { + e.printStackTrace(); + fail(); + } + } } diff --git a/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFour.java b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFour.java index d1492f85e5..936021719e 100644 --- a/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFour.java +++ b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFour.java @@ -19,6 +19,7 @@ package org.apache.tuscany.sca.test.corba.types; +import org.apache.tuscany.sca.test.corba.scenariofour.ScenarioFourSdo; import org.osoa.sca.annotations.Remotable; /** @@ -29,4 +30,8 @@ public interface ScenarioFour { ScenarioFourStruct setStruct(ScenarioFourStruct struct); + void exceptionTest() throws ScenarioFourException; + + ScenarioFourSdo passScenarioFourStruct(ScenarioFourSdo scenarioFourSdo); + } diff --git a/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFourException.java b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFourException.java new file mode 100644 index 0000000000..1afda33e35 --- /dev/null +++ b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFourException.java @@ -0,0 +1,37 @@ +/* + * 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. + */ + +package org.apache.tuscany.sca.test.corba.types; + +public class ScenarioFourException extends Exception { + + public static final String DEFAULT_CONTENT = "Test"; + + private static final long serialVersionUID = 1L; + private String content; + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + +} diff --git a/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFourImpl.java b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFourImpl.java index c047fafca4..35c3109ef4 100644 --- a/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFourImpl.java +++ b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFourImpl.java @@ -19,6 +19,8 @@ package org.apache.tuscany.sca.test.corba.types; +import org.apache.tuscany.sca.test.corba.scenariofour.ScenarioFourSdo; + /** * Implementation of ScenarioFour service */ @@ -28,4 +30,14 @@ public class ScenarioFourImpl implements ScenarioFour { return struct; } + public void exceptionTest() throws ScenarioFourException { + ScenarioFourException exception = new ScenarioFourException(); + exception.setContent(ScenarioFourException.DEFAULT_CONTENT); + throw exception; + } + + public ScenarioFourSdo passScenarioFourStruct(ScenarioFourSdo scenarioFourSdo) { + return scenarioFourSdo; + } + } diff --git a/java/sca/itest/corba/src/test/resources/scenariofour.xsd b/java/sca/itest/corba/src/test/resources/scenariofour.xsd new file mode 100644 index 0000000000..2669b54be3 --- /dev/null +++ b/java/sca/itest/corba/src/test/resources/scenariofour.xsd @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + diff --git a/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaServiceBindingProvider.java b/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaServiceBindingProvider.java index a7cc210470..fe4fabc293 100644 --- a/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaServiceBindingProvider.java +++ b/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaServiceBindingProvider.java @@ -20,9 +20,13 @@ package org.apache.tuscany.sca.binding.corba.impl; import org.apache.tuscany.sca.binding.corba.CorbaBinding; +import org.apache.tuscany.sca.binding.corba.impl.service.ComponentInvocationProxy; import org.apache.tuscany.sca.binding.corba.impl.service.DynaCorbaServant; +import org.apache.tuscany.sca.binding.corba.impl.service.InvocationProxy; +import org.apache.tuscany.sca.binding.corba.impl.types.util.Utils; import org.apache.tuscany.sca.host.corba.CorbaHost; import org.apache.tuscany.sca.interfacedef.InterfaceContract; +import org.apache.tuscany.sca.interfacedef.java.JavaInterface; import org.apache.tuscany.sca.provider.ServiceBindingProvider; import org.apache.tuscany.sca.runtime.RuntimeComponentService; import org.osoa.sca.ServiceRuntimeException; @@ -55,7 +59,9 @@ public class CorbaServiceBindingProvider implements ServiceBindingProvider { */ public void start() { try { - servant = new DynaCorbaServant(service, binding); + Class javaClass = ((JavaInterface)service.getInterfaceContract().getInterface()).getJavaClass(); + InvocationProxy proxy = new ComponentInvocationProxy(service, service.getRuntimeWire(binding), javaClass); + servant = new DynaCorbaServant(proxy, Utils.getTypeId(javaClass)); servant.setIds(new String[] {binding.getId()}); host.registerServant(binding.getCorbaname(), servant); } catch (Exception e) { diff --git a/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/service/DynaCorbaServant.java b/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/service/DynaCorbaServant.java index 0d9d33b198..26f006242e 100644 --- a/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/service/DynaCorbaServant.java +++ b/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/service/DynaCorbaServant.java @@ -19,24 +19,14 @@ package org.apache.tuscany.sca.binding.corba.impl.service; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -import java.util.Map; -import org.apache.tuscany.sca.assembly.Binding; import org.apache.tuscany.sca.binding.corba.impl.exceptions.RequestConfigurationException; import org.apache.tuscany.sca.binding.corba.impl.types.TypeTree; import org.apache.tuscany.sca.binding.corba.impl.types.TypeTreeCreator; import org.apache.tuscany.sca.binding.corba.impl.types.util.TypeHelpersProxy; import org.apache.tuscany.sca.binding.corba.impl.types.util.Utils; -import org.apache.tuscany.sca.binding.corba.impl.util.OperationMapper; -import org.apache.tuscany.sca.interfacedef.DataType; -import org.apache.tuscany.sca.interfacedef.Operation; -import org.apache.tuscany.sca.interfacedef.java.JavaInterface; -import org.apache.tuscany.sca.runtime.RuntimeComponentService; import org.omg.CORBA.MARSHAL; import org.omg.CORBA.portable.InputStream; import org.omg.CORBA.portable.InvokeHandler; @@ -49,113 +39,22 @@ import org.omg.CORBA.portable.ResponseHandler; */ public class DynaCorbaServant extends ObjectImpl implements InvokeHandler { - private RuntimeComponentService service; - private Binding binding; private String[] ids; - private Map operationsCache = new HashMap(); - private Class javaClass; - private Map operationsMap; - private Map methodOperationMapping; - private boolean scaBindingRules; - - /** - * Creates servant with CORBA binding mapping rules in default - * - * @param service backed service - * @param binding binding object - * @throws RequestConfigurationException - */ - public DynaCorbaServant(RuntimeComponentService service, Binding binding) throws RequestConfigurationException { - // use CORBA binding rules by default - this(service, binding, false); - } + private InvocationProxy invocationProxy; + private String typeId; /** * Creates servant object - * - * @param service backed service - * @param binding binding object - * @param scaBindingRules apply SCA default binding mapping rules + * @param invocationProxy + * @param typeId * @throws RequestConfigurationException */ - public DynaCorbaServant(RuntimeComponentService service, Binding binding, boolean scaBindingRules) throws RequestConfigurationException { - this.scaBindingRules = scaBindingRules; - this.service = service; - this.binding = binding; - this.javaClass = ((JavaInterface)service.getInterfaceContract().getInterface()).getJavaClass(); - this.operationsMap = OperationMapper.mapOperationToMethod(javaClass); - cacheOperationTypes(service.getInterfaceContract().getInterface().getOperations()); - createMethod2OperationMapping(); + public DynaCorbaServant(InvocationProxy invocationProxy, String typeId) throws RequestConfigurationException { + this.invocationProxy = invocationProxy; + this.typeId = typeId; setDefaultIds(); } - /** - * Maps Java methods to Tuscany operations - */ - private void createMethod2OperationMapping() { - // for every operation find all methods with the same name, then - // compare operations and methods parameters - this.methodOperationMapping = new HashMap(); - for (Operation operation : service.getInterfaceContract().getInterface().getOperations()) { - List inputTypes = operation.getInputType().getLogical(); - Method[] methods = javaClass.getMethods(); - for (int i = 0; i < methods.length; i++) { - if (methods[i].getName().equals(operation.getName()) && inputTypes.size() == methods[i] - .getParameterTypes().length) { - Class[] parameterTypes = methods[i].getParameterTypes(); - int j = 0; - boolean parameterMatch = true; - for (DataType dataType : inputTypes) { - if (!dataType.getPhysical().equals(parameterTypes[j])) { - parameterMatch = false; - break; - } - j++; - } - if (parameterMatch) { - // match found - methodOperationMapping.put(methods[i], operation); - break; - } - } - } - - } - } - - /** - * Caches TypeTree for every operation in backed component - * @param operations - * @throws RequestConfigurationException - */ - private void cacheOperationTypes(List operations) throws RequestConfigurationException { - for (Operation operation : operations) { - try { - OperationTypes operationTypes = new OperationTypes(); - List inputInstances = new ArrayList(); - // cache output type tree - if (operation.getOutputType() != null && operation.getOutputType().getPhysical() != null - && !operation.getOutputType().getPhysical().equals(void.class)) { - TypeTree outputType = TypeTreeCreator.createTypeTree(operation.getOutputType().getPhysical(), scaBindingRules); - operationTypes.setOutputType(outputType); - } - // cache input types trees - if (operation.getInputType() != null) { - for (DataType> type : operation.getInputType().getLogical()) { - Class forClass = type.getPhysical(); - TypeTree inputType = TypeTreeCreator.createTypeTree(forClass, scaBindingRules); - inputInstances.add(inputType); - } - - } - operationTypes.setInputType(inputInstances); - operationsCache.put(operation, operationTypes); - } catch (RequestConfigurationException e) { - throw e; - } - } - } - /** * Sets CORBA object ID * @param ids @@ -172,16 +71,12 @@ public class DynaCorbaServant extends ObjectImpl implements InvokeHandler { } public OutputStream _invoke(String operationName, InputStream in, ResponseHandler rh) { - Operation operation = null; - Method method = operationsMap.get(operationName); - // searching for proper operation - operation = methodOperationMapping.get(method); - if (operation == null) { + OperationTypes types = invocationProxy.getOperationTypes(operationName); + if (types == null) { // operation wasn't found throw new org.omg.CORBA.BAD_OPERATION(0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE); } else { List inputInstances = new ArrayList(); - OperationTypes types = operationsCache.get(operation); try { // retrieving in arguments for (TypeTree tree : types.getInputType()) { @@ -195,19 +90,19 @@ public class DynaCorbaServant extends ObjectImpl implements InvokeHandler { } try { // invocation and sending result - Object result = service.getRuntimeWire(binding).invoke(operation, inputInstances.toArray()); + Object result = invocationProxy.invoke(operationName, inputInstances); OutputStream out = rh.createReply(); if (types.getOutputType() != null) { TypeTree tree = types.getOutputType(); TypeHelpersProxy.write(tree.getRootNode(), out, result); } return out; - } catch (InvocationTargetException ie) { + } catch (InvocationException ie) { // handling user exception try { OutputStream out = rh.createExceptionReply(); Class exceptionClass = ie.getTargetException().getClass(); - TypeTree tree = TypeTreeCreator.createTypeTree(exceptionClass, scaBindingRules); + TypeTree tree = TypeTreeCreator.createTypeTree(exceptionClass, false); String exceptionId = Utils.getTypeId(exceptionClass); out.write_string(exceptionId); TypeHelpersProxy.write(tree.getRootNode(), out, ie.getTargetException()); @@ -234,8 +129,7 @@ public class DynaCorbaServant extends ObjectImpl implements InvokeHandler { * Sets servant ID to default, based on Java class name */ private void setDefaultIds() { - String id = Utils.getTypeId(javaClass); - this.ids = new String[] {id}; + this.ids = new String[] {typeId}; } } diff --git a/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/service/InvocationProxy.java b/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/service/InvocationProxy.java new file mode 100644 index 0000000000..f732e142b2 --- /dev/null +++ b/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/service/InvocationProxy.java @@ -0,0 +1,45 @@ +/* + * 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. + */ + +package org.apache.tuscany.sca.binding.corba.impl.service; + +import java.util.List; + +/** + * Target proxy interface for service bindings + */ +public interface InvocationProxy { + + /** + * Gets operations types for target + * @param operationName + * @return + */ + public OperationTypes getOperationTypes(String operationName); + + /** + * Invokes target operation + * @param operationName + * @param arguments + * @return + * @throws InvocationException + */ + public Object invoke(String operationName, List arguments) throws InvocationException; + +} diff --git a/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/CorbaServantTestCase.java b/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/CorbaServantTestCase.java index 74642f1984..1ccf22140b 100644 --- a/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/CorbaServantTestCase.java +++ b/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/CorbaServantTestCase.java @@ -30,7 +30,10 @@ import org.apache.tuscany.sca.binding.corba.impl.exceptions.CorbaException; import org.apache.tuscany.sca.binding.corba.impl.exceptions.RequestConfigurationException; import org.apache.tuscany.sca.binding.corba.impl.reference.DynaCorbaRequest; import org.apache.tuscany.sca.binding.corba.impl.reference.DynaCorbaResponse; +import org.apache.tuscany.sca.binding.corba.impl.service.ComponentInvocationProxy; import org.apache.tuscany.sca.binding.corba.impl.service.DynaCorbaServant; +import org.apache.tuscany.sca.binding.corba.impl.service.InvocationProxy; +import org.apache.tuscany.sca.binding.corba.impl.types.util.Utils; import org.apache.tuscany.sca.binding.corba.testing.enums.Color; import org.apache.tuscany.sca.binding.corba.testing.enums.EnumManager; import org.apache.tuscany.sca.binding.corba.testing.enums.EnumManagerHelper; @@ -58,6 +61,7 @@ import org.apache.tuscany.sca.binding.corba.testing.servants.TestObjectServant; import org.apache.tuscany.sca.binding.corba.testing.service.mocks.TestRuntimeComponentService; import org.apache.tuscany.sca.host.corba.naming.TransientNameServer; import org.apache.tuscany.sca.host.corba.naming.TransientNameService; +import org.apache.tuscany.sca.interfacedef.java.JavaInterface; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; @@ -138,7 +142,9 @@ public class CorbaServantTestCase { try { PrimitivesSetter primitivesSetter = new PrimitivesSetterServant(); TestRuntimeComponentService service = new TestRuntimeComponentService(primitivesSetter); - DynaCorbaServant servant = new DynaCorbaServant(service, null); + Class javaClass = ((JavaInterface)service.getInterfaceContract().getInterface()).getJavaClass(); + InvocationProxy proxy = new ComponentInvocationProxy(service, service.getRuntimeWire(null), javaClass); + DynaCorbaServant servant = new DynaCorbaServant(proxy, Utils.getTypeId(javaClass)); String[] ids = new String[] {"IDL:org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetter:1.0"}; servant.setIds(ids); @@ -187,7 +193,9 @@ public class CorbaServantTestCase { try { ArraysSetter arraysSetter = new ArraysSetterServant(); TestRuntimeComponentService service = new TestRuntimeComponentService(arraysSetter); - DynaCorbaServant servant = new DynaCorbaServant(service, null); + Class javaClass = ((JavaInterface)service.getInterfaceContract().getInterface()).getJavaClass(); + InvocationProxy proxy = new ComponentInvocationProxy(service, service.getRuntimeWire(null), javaClass); + DynaCorbaServant servant = new DynaCorbaServant(proxy, Utils.getTypeId(javaClass)); String[] ids = new String[] {"IDL:org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetter:1.0"}; servant.setIds(ids); java.lang.Object result = null; @@ -244,7 +252,9 @@ public class CorbaServantTestCase { try { TestObject to = new TestObjectServant(); TestRuntimeComponentService service = new TestRuntimeComponentService(to); - DynaCorbaServant servant = new DynaCorbaServant(service, null); + Class javaClass = ((JavaInterface)service.getInterfaceContract().getInterface()).getJavaClass(); + InvocationProxy proxy = new ComponentInvocationProxy(service, service.getRuntimeWire(null), javaClass); + DynaCorbaServant servant = new DynaCorbaServant(proxy, Utils.getTypeId(javaClass)); String[] ids = new String[] {"IDL:org/apache/tuscany/sca/binding/corba/testing/generated/TestObject:1.0"}; servant.setIds(ids); bindServant(servant, "TestObject"); @@ -279,7 +289,9 @@ public class CorbaServantTestCase { try { TestObjectServant tos = new TestObjectServant(); TestRuntimeComponentService service = new TestRuntimeComponentService(tos); - DynaCorbaServant servant = new DynaCorbaServant(service, null); + Class javaClass = ((JavaInterface)service.getInterfaceContract().getInterface()).getJavaClass(); + InvocationProxy proxy = new ComponentInvocationProxy(service, service.getRuntimeWire(null), javaClass); + DynaCorbaServant servant = new DynaCorbaServant(proxy, Utils.getTypeId(javaClass)); String[] ids = new String[] {"IDL:org/apache/tuscany/sca/binding/corba/testing/generated/TestObject:1.0"}; servant.setIds(ids); bindServant(servant, "TestObject"); @@ -298,7 +310,9 @@ public class CorbaServantTestCase { try { InvalidTestObjectServant tos = new InvalidTestObjectServant(); TestRuntimeComponentService service = new TestRuntimeComponentService(tos); - DynaCorbaServant servant = new DynaCorbaServant(service, null); + Class javaClass = ((JavaInterface)service.getInterfaceContract().getInterface()).getJavaClass(); + InvocationProxy proxy = new ComponentInvocationProxy(service, service.getRuntimeWire(null), javaClass); + DynaCorbaServant servant = new DynaCorbaServant(proxy, Utils.getTypeId(javaClass)); String[] ids = new String[] {"IDL:org/apache/tuscany/sca/binding/corba/testing/generated/TestObject:1.0"}; servant.setIds(ids); bindServant(servant, "InvalidTestObject"); @@ -328,7 +342,9 @@ public class CorbaServantTestCase { try { CalcServant calc = new CalcServant(); TestRuntimeComponentService service = new TestRuntimeComponentService(calc); - DynaCorbaServant servant = new DynaCorbaServant(service, null); + Class javaClass = ((JavaInterface)service.getInterfaceContract().getInterface()).getJavaClass(); + InvocationProxy proxy = new ComponentInvocationProxy(service, service.getRuntimeWire(null), javaClass); + DynaCorbaServant servant = new DynaCorbaServant(proxy, Utils.getTypeId(javaClass)); String[] ids = {"IDL:org/apache/tuscany/sca/binding/corba/testing/exceptions/Calc:1.0"}; servant.setIds(ids); bindServant(servant, "Calc"); @@ -347,7 +363,9 @@ public class CorbaServantTestCase { try { CalcServant calc = new CalcServant(); TestRuntimeComponentService service = new TestRuntimeComponentService(calc); - DynaCorbaServant servant = new DynaCorbaServant(service, null); + Class javaClass = ((JavaInterface)service.getInterfaceContract().getInterface()).getJavaClass(); + InvocationProxy proxy = new ComponentInvocationProxy(service, service.getRuntimeWire(null), javaClass); + DynaCorbaServant servant = new DynaCorbaServant(proxy, Utils.getTypeId(javaClass)); String[] ids = {"IDL:org/apache/tuscany/sca/binding/corba/testing/exceptions/Calc:1.0"}; servant.setIds(ids); bindServant(servant, "Calc"); @@ -372,7 +390,9 @@ public class CorbaServantTestCase { try { EnumManagerServant ems = new EnumManagerServant(); TestRuntimeComponentService service = new TestRuntimeComponentService(ems); - DynaCorbaServant servant = new DynaCorbaServant(service, null); + Class javaClass = ((JavaInterface)service.getInterfaceContract().getInterface()).getJavaClass(); + InvocationProxy proxy = new ComponentInvocationProxy(service, service.getRuntimeWire(null), javaClass); + DynaCorbaServant servant = new DynaCorbaServant(proxy, Utils.getTypeId(javaClass)); String[] ids = {"IDL:org/apache/tuscany/sca/binding/corba/testing/enums/EnumManager:1.0"}; servant.setIds(ids); bindServant(servant, "Enum"); @@ -390,7 +410,9 @@ public class CorbaServantTestCase { try { NonCorbaServant ncs = new NonCorbaServant(); TestRuntimeComponentService service = new TestRuntimeComponentService(ncs); - DynaCorbaServant servant = new DynaCorbaServant(service, null); + Class javaClass = ((JavaInterface)service.getInterfaceContract().getInterface()).getJavaClass(); + InvocationProxy proxy = new ComponentInvocationProxy(service, service.getRuntimeWire(null), javaClass); + DynaCorbaServant servant = new DynaCorbaServant(proxy, Utils.getTypeId(javaClass)); bindServant(servant, "NonCorbaServant"); // it's non corba servant so we don't have stubs to test them DynaCorbaRequest request = new DynaCorbaRequest(bindReference("NonCorbaServant"), "setString"); @@ -406,7 +428,9 @@ public class CorbaServantTestCase { try { NonCorbaServant ncs = new NonCorbaServant(); TestRuntimeComponentService service = new TestRuntimeComponentService(ncs); - DynaCorbaServant servant = new DynaCorbaServant(service, null); + Class javaClass = ((JavaInterface)service.getInterfaceContract().getInterface()).getJavaClass(); + InvocationProxy proxy = new ComponentInvocationProxy(service, service.getRuntimeWire(null), javaClass); + DynaCorbaServant servant = new DynaCorbaServant(proxy, Utils.getTypeId(javaClass)); bindServant(servant, "NonCorbaServant"); // it's non corba servant so we don't have stubs to test them DynaCorbaRequest request = new DynaCorbaRequest(bindReference("NonCorbaServant"), "throwException"); @@ -431,7 +455,9 @@ public class CorbaServantTestCase { try { CalcServant calc = new CalcServant(); TestRuntimeComponentService service = new TestRuntimeComponentService(calc); - DynaCorbaServant servant = new DynaCorbaServant(service, null); + Class javaClass = ((JavaInterface)service.getInterfaceContract().getInterface()).getJavaClass(); + InvocationProxy proxy = new ComponentInvocationProxy(service, service.getRuntimeWire(null), javaClass); + DynaCorbaServant servant = new DynaCorbaServant(proxy, Utils.getTypeId(javaClass)); String[] ids = new String[] {"IDL:org/apache/tuscany/sca/binding/corba/testing/generated/TestObject:1.0"}; servant.setIds(ids); bindServant(servant, "Calc"); @@ -459,7 +485,9 @@ public class CorbaServantTestCase { InvalidTypesServant its = new InvalidTypesServant(); TestRuntimeComponentService service = new TestRuntimeComponentService(its); //expecting exception... - new DynaCorbaServant(service, null); + Class javaClass = ((JavaInterface)service.getInterfaceContract().getInterface()).getJavaClass(); + InvocationProxy proxy = new ComponentInvocationProxy(service, service.getRuntimeWire(null), javaClass); + DynaCorbaServant servant = new DynaCorbaServant(proxy, Utils.getTypeId(javaClass)); fail(); } catch (Exception e) { if (e instanceof RequestConfigurationException) { diff --git a/java/sca/modules/binding-sca-corba/pom.xml b/java/sca/modules/binding-sca-corba/pom.xml index 9ff1ae1003..37e7914254 100644 --- a/java/sca/modules/binding-sca-corba/pom.xml +++ b/java/sca/modules/binding-sca-corba/pom.xml @@ -1,87 +1,132 @@ - 4.0.0 - - org.apache.tuscany.sca - tuscany-modules - 1.4-SNAPSHOT - ../pom.xml - + 4.0.0 + + org.apache.tuscany.sca + tuscany-modules + 1.4-SNAPSHOT + ../pom.xml + - tuscany-binding-sca-corba - Apache Tuscany SCA CORBA-based Default Binding Extension + tuscany-binding-sca-corba + + Apache Tuscany SCA CORBA-based Default Binding Extension + - + - - org.apache.tuscany.sca - tuscany-binding-sca - 1.4-SNAPSHOT - + + org.apache.tuscany.sca + tuscany-binding-sca + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-binding-corba + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-binding-corba-runtime + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-host-corba + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-host-corba-jdk + 1.4-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-interface-wsdl + 1.4-SNAPSHOT + - - org.apache.tuscany.sca - tuscany-binding-corba - 1.4-SNAPSHOT - - org.apache.tuscany.sca - tuscany-binding-corba-runtime + tuscany-databinding-axiom 1.4-SNAPSHOT - - org.apache.tuscany.sca - tuscany-host-corba - 1.4-SNAPSHOT - - - - org.apache.tuscany.sca - tuscany-host-corba-jdk - 1.4-SNAPSHOT - test - - - - - - - - - org.apache.felix - maven-bundle-plugin - - - - ${tuscany.version} - org.apache.tuscany.sca.binding.sca.corba - ${pom.name} - org.apache.tuscany.sca.binding.sca.corba* - - - - - + + + + org.apache.tuscany.sca + tuscany-binding-ws-wsdlgen + 1.4-SNAPSHOT + + + + + + + + org.apache.felix + maven-bundle-plugin + + + + + ${tuscany.version} + + + org.apache.tuscany.sca.binding.sca.corba + + + ${pom.name} + + + org.apache.tuscany.sca.binding.sca.corba* + + + + + + diff --git a/java/sca/modules/binding-sca-corba/src/main/java/org/apache/tuscany/sca/binding/sca/corba/impl/CorbaSCABindingProviderFactory.java b/java/sca/modules/binding-sca-corba/src/main/java/org/apache/tuscany/sca/binding/sca/corba/impl/CorbaSCABindingProviderFactory.java index a8a9a3d5eb..2eee714de6 100644 --- a/java/sca/modules/binding-sca-corba/src/main/java/org/apache/tuscany/sca/binding/sca/corba/impl/CorbaSCABindingProviderFactory.java +++ b/java/sca/modules/binding-sca-corba/src/main/java/org/apache/tuscany/sca/binding/sca/corba/impl/CorbaSCABindingProviderFactory.java @@ -38,22 +38,24 @@ public class CorbaSCABindingProviderFactory implements BindingProviderFactory getModelType() { diff --git a/java/sca/modules/binding-sca-corba/src/main/java/org/apache/tuscany/sca/binding/sca/corba/impl/CorbaSCAInvocationProxy.java b/java/sca/modules/binding-sca-corba/src/main/java/org/apache/tuscany/sca/binding/sca/corba/impl/CorbaSCAInvocationProxy.java new file mode 100644 index 0000000000..f20b027644 --- /dev/null +++ b/java/sca/modules/binding-sca-corba/src/main/java/org/apache/tuscany/sca/binding/sca/corba/impl/CorbaSCAInvocationProxy.java @@ -0,0 +1,113 @@ +/* + * 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. + */ + +package org.apache.tuscany.sca.binding.sca.corba.impl; + +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.List; + +import javax.xml.stream.XMLStreamException; + +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.impl.llom.util.AXIOMUtil; +import org.apache.tuscany.sca.binding.corba.impl.exceptions.RequestConfigurationException; +import org.apache.tuscany.sca.binding.corba.impl.service.InvocationException; +import org.apache.tuscany.sca.binding.corba.impl.service.InvocationProxy; +import org.apache.tuscany.sca.binding.corba.impl.service.OperationTypes; +import org.apache.tuscany.sca.binding.corba.impl.types.TypeTree; +import org.apache.tuscany.sca.binding.corba.impl.types.TypeTreeCreator; +import org.apache.tuscany.sca.interfacedef.Interface; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.interfacedef.util.FaultException; +import org.apache.tuscany.sca.invocation.Message; +import org.apache.tuscany.sca.invocation.MessageFactory; +import org.apache.tuscany.sca.runtime.RuntimeWire; + +/** + * Invocation proxy for SCA default binding over CORBA binding + */ +public class CorbaSCAInvocationProxy implements InvocationProxy { + + private RuntimeWire wire; + private Interface componentInterface; + private OperationTypes types = new OperationTypes(); + private MessageFactory messageFactory; + + public CorbaSCAInvocationProxy(RuntimeWire wire, Interface componentInterface, MessageFactory messageFactory) { + this.wire = wire; + this.componentInterface = componentInterface; + this.messageFactory = messageFactory; + try { + List inputType = new ArrayList(); + inputType.add(TypeTreeCreator.createTypeTree(String.class, false)); + types.setInputType(inputType); + types.setOutputType(TypeTreeCreator.createTypeTree(String.class, false)); + } catch (RequestConfigurationException e) { + // ignore - string type should not cause this exception + } + } + + public Object invoke(String operationName, List arguments) throws InvocationException { + try { + OMElement omContent = AXIOMUtil.stringToOM((String)arguments.get(0)); + String componentOperationName = omContent.getQName().getLocalPart(); + Operation componentOperation = null; + for (Operation operation : componentInterface.getOperations()) { + if (operation.getName().equals(componentOperationName)) { + componentOperation = operation; + break; + } + } + if (componentOperation == null) { + // TODO: throw an exception - no such operation + } else { + Message msg = messageFactory.createMessage(); + msg.setOperation(componentOperation); + Object[] args = new Object[1]; + args[0] = omContent; + msg.setBody(args); + OMElement omResult = (OMElement)wire.invoke(componentOperation, msg); + return omResult.toStringWithConsume(); + } + } catch (XMLStreamException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (InvocationTargetException e) { + OMElement omException = (OMElement)((FaultException)e.getCause()).getFaultInfo(); + try { + WrappedSCAException wrappedException = new WrappedSCAException(omException.toStringWithConsume()); + InvocationException exception = new InvocationException(wrappedException); + throw exception; + } catch (XMLStreamException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + } + + return null; + } + + public OperationTypes getOperationTypes(String operationName) { + // ignoring operationName - only one operation for this proxy is allowed + return types; + } + +} diff --git a/java/sca/modules/binding-sca-corba/src/main/java/org/apache/tuscany/sca/binding/sca/corba/impl/CorbaSCAReferenceBindingProvider.java b/java/sca/modules/binding-sca-corba/src/main/java/org/apache/tuscany/sca/binding/sca/corba/impl/CorbaSCAReferenceBindingProvider.java index f20a0b1a02..c578f8bdf4 100644 --- a/java/sca/modules/binding-sca-corba/src/main/java/org/apache/tuscany/sca/binding/sca/corba/impl/CorbaSCAReferenceBindingProvider.java +++ b/java/sca/modules/binding-sca-corba/src/main/java/org/apache/tuscany/sca/binding/sca/corba/impl/CorbaSCAReferenceBindingProvider.java @@ -19,19 +19,20 @@ package org.apache.tuscany.sca.binding.sca.corba.impl; -import java.lang.reflect.Method; -import java.util.Map; import java.util.logging.Logger; +import org.apache.axiom.om.OMElement; import org.apache.tuscany.sca.assembly.SCABinding; -import org.apache.tuscany.sca.binding.corba.impl.CorbaInvoker; -import org.apache.tuscany.sca.binding.corba.impl.util.OperationMapper; +import org.apache.tuscany.sca.binding.ws.WebServiceBinding; +import org.apache.tuscany.sca.binding.ws.WebServiceBindingFactory; +import org.apache.tuscany.sca.binding.ws.wsdlgen.BindingWSDLGenerator; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.host.corba.CorbaHost; import org.apache.tuscany.sca.interfacedef.InterfaceContract; import org.apache.tuscany.sca.interfacedef.Operation; -import org.apache.tuscany.sca.interfacedef.java.JavaInterface; import org.apache.tuscany.sca.invocation.Invoker; import org.apache.tuscany.sca.provider.ReferenceBindingProvider; +import org.apache.tuscany.sca.runtime.RuntimeComponent; import org.apache.tuscany.sca.runtime.RuntimeComponentReference; import org.omg.CORBA.Object; @@ -44,23 +45,27 @@ public class CorbaSCAReferenceBindingProvider implements ReferenceBindingProvide private SCABinding binding; private CorbaHost host; - private RuntimeComponentReference reference; private Object remoteObject; private Class referenceClass; - private Map operationsMap = null; + private InterfaceContract wsdlInterfaceContract; public CorbaSCAReferenceBindingProvider(SCABinding binding, CorbaHost host, - RuntimeComponentReference reference) { + RuntimeComponent component, + RuntimeComponentReference reference, + ExtensionPointRegistry extensions) { this.binding = binding; this.host = host; - this.reference = reference; - this.referenceClass = ((JavaInterface)reference.getInterfaceContract().getInterface()).getJavaClass(); - operationsMap = OperationMapper.mapMethodToOperation(referenceClass); + + WebServiceBindingFactory wsFactory = extensions.getExtensionPoint(WebServiceBindingFactory.class); + WebServiceBinding wsBinding = wsFactory.createWebServiceBinding(); + BindingWSDLGenerator.generateWSDL(component, reference, wsBinding, extensions, null); + wsdlInterfaceContract = wsBinding.getBindingInterfaceContract(); + wsdlInterfaceContract.getInterface().resetDataBinding(OMElement.class.getName()); } public InterfaceContract getBindingInterfaceContract() { - return reference.getInterfaceContract(); + return wsdlInterfaceContract; } public boolean supportsOneWayInvocation() { @@ -72,7 +77,7 @@ public class CorbaSCAReferenceBindingProvider implements ReferenceBindingProvide if (remoteObject == null) { remoteObject = host.lookup(binding.getURI()); } - return new CorbaInvoker(remoteObject, referenceClass, operationsMap, true); + return new CorbaSCAInvoker(remoteObject, referenceClass, null, true); } catch (Exception e) { logger.warning(e.getMessage()); } diff --git a/java/sca/modules/binding-sca-corba/src/main/java/org/apache/tuscany/sca/binding/sca/corba/impl/CorbaSCAServiceBindingProvider.java b/java/sca/modules/binding-sca-corba/src/main/java/org/apache/tuscany/sca/binding/sca/corba/impl/CorbaSCAServiceBindingProvider.java index 88e785bd42..1dabefc9f7 100644 --- a/java/sca/modules/binding-sca-corba/src/main/java/org/apache/tuscany/sca/binding/sca/corba/impl/CorbaSCAServiceBindingProvider.java +++ b/java/sca/modules/binding-sca-corba/src/main/java/org/apache/tuscany/sca/binding/sca/corba/impl/CorbaSCAServiceBindingProvider.java @@ -19,35 +19,55 @@ package org.apache.tuscany.sca.binding.sca.corba.impl; +import org.apache.axiom.om.OMElement; import org.apache.tuscany.sca.assembly.SCABinding; import org.apache.tuscany.sca.binding.corba.impl.service.DynaCorbaServant; +import org.apache.tuscany.sca.binding.corba.impl.service.InvocationProxy; +import org.apache.tuscany.sca.binding.ws.WebServiceBinding; +import org.apache.tuscany.sca.binding.ws.WebServiceBindingFactory; +import org.apache.tuscany.sca.binding.ws.wsdlgen.BindingWSDLGenerator; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.host.corba.CorbaHost; import org.apache.tuscany.sca.interfacedef.InterfaceContract; +import org.apache.tuscany.sca.invocation.MessageFactory; import org.apache.tuscany.sca.provider.ServiceBindingProvider; +import org.apache.tuscany.sca.runtime.RuntimeComponent; import org.apache.tuscany.sca.runtime.RuntimeComponentService; import org.osoa.sca.ServiceRuntimeException; + /** * Service binding provider for SCA default binding over CORBA binding */ public class CorbaSCAServiceBindingProvider implements ServiceBindingProvider { - + private SCABinding binding; private CorbaHost host; private RuntimeComponentService service; private DynaCorbaServant servant; - + private MessageFactory messageFactory; + private InterfaceContract wsdlInterfaceContract; public CorbaSCAServiceBindingProvider(SCABinding binding, CorbaHost host, - RuntimeComponentService service) { + RuntimeComponent component, + RuntimeComponentService service, + ExtensionPointRegistry extensions) { this.binding = binding; this.host = host; this.service = service; + + messageFactory = extensions.getExtensionPoint(MessageFactory.class); + + WebServiceBindingFactory wsFactory = extensions.getExtensionPoint(WebServiceBindingFactory.class); + WebServiceBinding wsBinding = wsFactory.createWebServiceBinding(); + BindingWSDLGenerator.generateWSDL(component, service, wsBinding, extensions, null); + wsdlInterfaceContract = wsBinding.getBindingInterfaceContract(); + wsdlInterfaceContract.getInterface().resetDataBinding(OMElement.class.getName()); } public InterfaceContract getBindingInterfaceContract() { - return service.getInterfaceContract(); + return wsdlInterfaceContract; } public boolean supportsOneWayInvocation() { @@ -56,19 +76,20 @@ public class CorbaSCAServiceBindingProvider implements ServiceBindingProvider { public void start() { try { - servant = new DynaCorbaServant(service, binding, true); + InvocationProxy proxy = new CorbaSCAInvocationProxy(service.getRuntimeWire(binding), service.getInterfaceContract().getInterface(), messageFactory); + servant = new DynaCorbaServant(proxy, "IDL:org/apache/tuscany/sca/binding/sca/corba/Service:1.0"); host.registerServant(binding.getURI(), servant); } catch (Exception e) { throw new ServiceRuntimeException(e); - } + } } public void stop() { try { host.unregisterServant(binding.getURI()); - } catch (Exception e) { - throw new ServiceRuntimeException(e); - } + } catch (Exception e) { + throw new ServiceRuntimeException(e); + } } -- cgit v1.2.3