Added support for CORBA arrays

git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@686519 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
wjaniszewski 2008-08-16 16:18:00 +00:00
parent 51709cd9fd
commit acb232a116
32 changed files with 1296 additions and 169 deletions

View file

@ -19,15 +19,19 @@
package org.apache.tuscany.sca.binding.corba.impl;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.Map;
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.util.OperationMapper;
import org.apache.tuscany.sca.interfacedef.DataType;
import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.invocation.Invoker;
import org.apache.tuscany.sca.invocation.Message;
import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
import org.omg.CORBA.Object;
import org.osoa.sca.ServiceRuntimeException;
@ -39,11 +43,13 @@ public class CorbaInvoker implements Invoker {
private Object remoteObject;
private Class<?> referenceClass;
private Map<Method, String> operationsMap;
private Map<Operation, Method> operationMethodMapping;
public CorbaInvoker(Object remoteObject, Class<?> referenceClass, Map<Method, String> operationsMap) {
public CorbaInvoker(RuntimeComponentReference reference, Object remoteObject, Class<?> referenceClass, Map<Method, String> operationsMap) {
this.remoteObject = remoteObject;
this.referenceClass = referenceClass;
this.operationsMap = operationsMap;
this.operationMethodMapping = OperationMapper.mapOperationToMethod(reference.getInterfaceContract().getInterface().getOperations(), referenceClass);
}
/**
@ -55,12 +61,14 @@ public class CorbaInvoker implements Invoker {
request.setReferenceClass(referenceClass);
request.setOperationsMap(operationsMap);
if (msg.getOperation().getOutputType() != null) {
request.setOutputType(msg.getOperation().getOutputType().getPhysical());
Annotation[] notes = operationMethodMapping.get(msg.getOperation()).getAnnotations();
request.setOutputType(msg.getOperation().getOutputType().getPhysical(), notes);
}
java.lang.Object[] args = msg.getBody();
if (args != null) {
Annotation[][] notes = operationMethodMapping.get(msg.getOperation()).getParameterAnnotations();
for (int i = 0; i < args.length; i++) {
request.addArgument(args[i]);
request.addArgument(args[i], notes[i]);
}
}
if (msg.getOperation().getFaultTypes() != null) {

View file

@ -50,7 +50,7 @@ public class CorbaReferenceBindingProvider implements ReferenceBindingProvider {
this.host = host;
this.reference = reference;
this.referenceClass = ((JavaInterface)reference.getInterfaceContract().getInterface()).getJavaClass();
operationsMap = OperationMapper.mapMethodToOperation(referenceClass);
operationsMap = OperationMapper.mapMethodToOperationName(referenceClass);
}
/**
@ -61,7 +61,7 @@ public class CorbaReferenceBindingProvider implements ReferenceBindingProvider {
if (remoteObject == null) {
remoteObject = host.lookup(binding.getCorbaname());
}
return new CorbaInvoker(remoteObject, referenceClass, operationsMap);
return new CorbaInvoker(reference, remoteObject, referenceClass, operationsMap);
} catch (Exception e) {
}
return null;

View file

@ -19,6 +19,7 @@
package org.apache.tuscany.sca.binding.corba.impl.reference;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
@ -85,12 +86,21 @@ public class DynaCorbaRequest {
}
/**
* Adds operation argument - stores arguments and caches its TypeTree
* Adds operation argument - stores arguments and caches its TypeTree. Annotations will be set to null by default.
*
* @param argument
*/
public void addArgument(java.lang.Object argument) throws RequestConfigurationException {
TypeTree tree = TypeTreeCreator.createTypeTree(argument.getClass());
addArgument(argument, null);
}
/**
* Adds operation argument - stores arguments and caches its TypeTree
*
* @param argument
*/
public void addArgument(java.lang.Object argument, Annotation[] notes) throws RequestConfigurationException {
TypeTree tree = TypeTreeCreator.createTypeTree(argument.getClass(), notes);
argumentsTypes.add(tree);
arguments.add(argument);
}
@ -109,12 +119,21 @@ public class DynaCorbaRequest {
}
/**
* Sets return type for operation
* Sets return type for operation. Annotations will be set to null by default.
*
* @param forClass
*/
public void setOutputType(Class<?> forClass) throws RequestConfigurationException {
returnTree = TypeTreeCreator.createTypeTree(forClass);
setOutputType(forClass, null);
}
/**
* Sets return type for operation
*
* @param forClass
*/
public void setOutputType(Class<?> forClass, Annotation[] notes) throws RequestConfigurationException {
returnTree = TypeTreeCreator.createTypeTree(forClass, notes);
}
/**
@ -123,7 +142,7 @@ public class DynaCorbaRequest {
* @param forClass
*/
public void addExceptionType(Class<?> forClass) throws RequestConfigurationException {
TypeTree tree = TypeTreeCreator.createTypeTree(forClass);
TypeTree tree = TypeTreeCreator.createTypeTree(forClass, null);
String exceptionId = Utils.getTypeId(forClass);
exceptions.put(exceptionId, tree);
}

View file

@ -19,6 +19,7 @@
package org.apache.tuscany.sca.binding.corba.impl.service;
import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
@ -42,57 +43,20 @@ import org.apache.tuscany.sca.runtime.RuntimeWire;
public class ComponentInvocationProxy implements InvocationProxy {
private RuntimeWire wire;
private RuntimeComponentService service;
private Map<Method, Operation> methodOperationMapping;
private Map<Operation, Method> operationMethodMapping;
private Map<String, Method> operationsMap;
private Map<Operation, OperationTypes> operationsCache = new HashMap<Operation, OperationTypes>();
private Class<?> javaClass;
public ComponentInvocationProxy(RuntimeComponentService service, RuntimeWire wire, Class<?> javaClass)
throws RequestConfigurationException {
this.wire = wire;
this.service = service;
this.javaClass = javaClass;
operationsMap = OperationMapper.mapOperationToMethod(javaClass);
createMethod2OperationMapping();
operationsMap = OperationMapper.mapOperationNameToMethod(javaClass);
operationMethodMapping = OperationMapper.mapOperationToMethod(service.getInterfaceContract().getInterface().getOperations(), javaClass);
methodOperationMapping = OperationMapper.mapMethodToOperation(service.getInterfaceContract().getInterface().getOperations(), javaClass);
cacheOperationTypes(service.getInterfaceContract().getInterface().getOperations());
}
/**
* Maps Java methods to Tuscany operations
*/
@SuppressWarnings("unchecked")
private void createMethod2OperationMapping() {
// for every operation find all methods with the same name, then
// compare operations and methods parameters
this.methodOperationMapping = new HashMap<Method, Operation>();
for (Operation operation : service.getInterfaceContract().getInterface().getOperations()) {
List<DataType> 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
*
@ -107,16 +71,21 @@ public class ComponentInvocationProxy implements InvocationProxy {
// cache output type tree
if (operation.getOutputType() != null && operation.getOutputType().getPhysical() != null
&& !operation.getOutputType().getPhysical().equals(void.class)) {
Annotation[] notes = operationMethodMapping.get(operation).getAnnotations();
TypeTree outputType =
TypeTreeCreator.createTypeTree(operation.getOutputType().getPhysical());
TypeTreeCreator.createTypeTree(operation.getOutputType().getPhysical(), notes);
operationTypes.setOutputType(outputType);
}
// cache input types trees
if (operation.getInputType() != null) {
Method method = operationMethodMapping.get(operation);
Annotation[][] notes = method.getParameterAnnotations();
int i = 0;
for (DataType<List<DataType<?>>> type : operation.getInputType().getLogical()) {
Class<?> forClass = type.getPhysical();
TypeTree inputType = TypeTreeCreator.createTypeTree(forClass);
TypeTree inputType = TypeTreeCreator.createTypeTree(forClass, notes[i]);
inputInstances.add(inputType);
i++;
}
}

View file

@ -103,7 +103,7 @@ public class DynaCorbaServant extends ObjectImpl implements InvokeHandler {
try {
OutputStream out = rh.createExceptionReply();
Class<?> exceptionClass = ie.getTargetException().getClass();
TypeTree tree = TypeTreeCreator.createTypeTree(exceptionClass);
TypeTree tree = TypeTreeCreator.createTypeTree(exceptionClass, null);
String exceptionId = Utils.getTypeId(exceptionClass);
out.write_string(exceptionId);
TypeHelpersProxy.write(tree.getRootNode(), out, ie.getTargetException());

View file

@ -0,0 +1,46 @@
/*
* 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.types;
/**
* Holds information retrieved from objects annotations
*/
public class AnnotationAttributes {
private boolean corbaArray;
private int[] corbaArrayLength;
public boolean isCorbaArray() {
return corbaArray;
}
public void setCorbaArray(boolean isCorbaArray) {
this.corbaArray = isCorbaArray;
}
public int[] getCorbaArrayLength() {
return corbaArrayLength;
}
public void setCorbaArrayLength(int[] corbaArrayLength) {
this.corbaArrayLength = corbaArrayLength;
}
}

View file

@ -19,6 +19,7 @@
package org.apache.tuscany.sca.binding.corba.impl.types;
import java.lang.annotation.Annotation;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
@ -30,6 +31,7 @@ import java.util.List;
import java.util.Set;
import org.apache.tuscany.sca.binding.corba.impl.exceptions.RequestConfigurationException;
import org.apache.tuscany.sca.binding.corba.meta.CorbaArray;
/**
* @version $Rev$ $Date$
@ -133,17 +135,44 @@ public class TypeTreeCreator {
return null;
}
/**
* Return given array without first element
* @param array
* @return
*/
private static int[] removeFirstElement(int[] array) {
int[] result = new int[array.length - 1];
System.arraycopy(array, 1, result, 0, result.length);
return result;
}
/**
* Converts objects annotations to structure which will be used by this class
* @param notes
* @return
*/
private static AnnotationAttributes createAnnotationAttributes(Annotation[] notes) {
AnnotationAttributes attrs = new AnnotationAttributes();
for (int i = 0; notes != null && i < notes.length; i++) {
if (notes[i].annotationType().equals(CorbaArray.class)) {
attrs.setCorbaArray(true);
attrs.setCorbaArrayLength(((CorbaArray)notes[i]).value());
}
}
return attrs;
}
/**
* Creates tree for given type.
*
* @param forClass
* @return type tree
*/
public static TypeTree createTypeTree(Class<?> forClass)
throws RequestConfigurationException {
public static TypeTree createTypeTree(Class<?> forClass, Annotation[] notes) throws RequestConfigurationException {
TypeTree tree = new TypeTree();
TypeTreeNode rootNode = null;
rootNode = inspectClassHierarchy(forClass, tree);
AnnotationAttributes attrs = createAnnotationAttributes(notes);
rootNode = inspectClassHierarchy(forClass, attrs, tree);
tree.setRootNode(rootNode);
return tree;
@ -156,11 +185,11 @@ public class TypeTreeCreator {
* @param tree
* @return
*/
private static TypeTreeNode inspectClassHierarchy(Class<?> forClass, TypeTree tree)
private static TypeTreeNode inspectClassHierarchy(Class<?> forClass, AnnotationAttributes attributes, TypeTree tree)
throws RequestConfigurationException {
TypeTreeNode node = null;
node = createTypeNode(forClass);
node = createTypeNode(forClass, attributes);
NodeType nodeType = node.getNodeType();
TypeTreeNode[] children = null;
@ -168,20 +197,25 @@ public class TypeTreeCreator {
if (nodeType.equals(NodeType.primitive)) {
// stop condition for recurrent method
} else if (nodeType.equals(NodeType.array)) {
// similar to sequence, but with fixed array length
// TODO: determine how array length will be declared
Class<?> reduced = reduceArrayDimension(node.getJavaClass());
children = new TypeTreeNode[1];
int[] newLengths = removeFirstElement(attributes.getCorbaArrayLength());
attributes.setCorbaArrayLength(newLengths);
children[0] = inspectClassHierarchy(reduced, attributes, tree);
} else if (nodeType.equals(NodeType.sequence)) {
// reducing sequence dimension
Class<?> reduced = reduceArrayDimension(node.getJavaClass());
children = new TypeTreeNode[1];
children[0] = inspectClassHierarchy(reduced, tree);
children[0] = inspectClassHierarchy(reduced, attributes, tree);
// System.arraycopy(src, srcPos, dest, destPos, length)
} else if (nodeType.equals(NodeType.struct) || nodeType.equals(NodeType.exception)) {
// inspect types for every structure member
Field[] fields = node.getJavaClass().getFields();
children = new TypeTreeNode[fields.length];
for (int i = 0; i < fields.length; i++) {
Class<?> field = fields[i].getType();
TypeTreeNode child = inspectClassHierarchy(field, tree);
AnnotationAttributes fAttrs = createAnnotationAttributes(fields[i].getAnnotations());
TypeTreeNode child = inspectClassHierarchy(field, fAttrs, tree);
child.setName(fields[i].getName());
children[i] = child;
}
@ -204,11 +238,24 @@ public class TypeTreeCreator {
* @return node
* @throws RequestConfigurationException
*/
private static TypeTreeNode createTypeNode(Class<?> forClass) throws RequestConfigurationException {
private static TypeTreeNode createTypeNode(Class<?> forClass, AnnotationAttributes attributes)
throws RequestConfigurationException {
TypeTreeNode node = new TypeTreeNode();
if (forClass.isArray()) {
if (forClass.isArray() && !attributes.isCorbaArray()) {
node.setNodeType(NodeType.sequence);
node.setJavaClass(forClass);
} else if (forClass.isArray() && attributes.isCorbaArray()) {
node.setNodeType(NodeType.array);
node.setJavaClass(forClass);
try {
// set the actual array size for further use by ArrayTypeHelper
node.setAttributes(attributes.getCorbaArrayLength()[0]);
} catch (ArrayIndexOutOfBoundsException e) {
RequestConfigurationException exc =
new RequestConfigurationException("Annotated array size doesn't match declared arrays size");
throw exc;
}
} else if (primitives.contains(forClass)) {
node.setNodeType(NodeType.primitive);
node.setJavaClass(forClass);
@ -350,4 +397,5 @@ public class TypeTreeCreator {
} while (forClass != null && !forClass.equals(Object.class));
return false;
}
}

View file

@ -30,6 +30,7 @@ public class TypeTreeNode {
private TypeTreeNode[] children;
private Class<?> javaClass;
private String name;
private Object attributes;
public String getName() {
return name;
@ -63,4 +64,12 @@ public class TypeTreeNode {
this.javaClass = javaClass;
}
public Object getAttributes() {
return attributes;
}
public void setAttributes(Object attributes) {
this.attributes = attributes;
}
}

View file

@ -19,6 +19,8 @@
package org.apache.tuscany.sca.binding.corba.impl.types.util;
import java.lang.reflect.Array;
import org.apache.tuscany.sca.binding.corba.impl.types.TypeTreeNode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
@ -29,13 +31,23 @@ import org.omg.CORBA.portable.OutputStream;
public class ArrayTypeHelper implements TypeHelper {
public Object read(TypeTreeNode node, InputStream is) {
// TODO Auto-generated method stub
return null;
Object array = null;
try {
int size = (Integer)node.getAttributes();
array = Array.newInstance(node.getChildren()[0].getJavaClass(), size);
for (int i = 0; i < size; i++) {
Array.set(array, i, TypeHelpersProxy.read(node.getChildren()[0], is));
}
} catch (Exception e) {
e.printStackTrace();
}
return array;
}
public void write(TypeTreeNode node, OutputStream os, Object data) {
// TODO Auto-generated method stub
for (int i = 0; i < (Integer)node.getAttributes(); i++) {
TypeHelpersProxy.write(node.getChildren()[0], os, Array.get(data, i));
}
}
}

View file

@ -30,6 +30,8 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.tuscany.sca.interfacedef.DataType;
import org.apache.tuscany.sca.interfacedef.Operation;
import org.omg.CORBA.portable.IDLEntity;
/**
@ -60,7 +62,7 @@ public final class OperationMapper {
* @return
*/
@SuppressWarnings("unchecked")
public static Map<Method, String> mapMethodToOperation(Class<?> intfClass) {
public static Map<Method, String> mapMethodToOperationName(Class<?> intfClass) {
return iiopMap(intfClass, false);
}
@ -70,7 +72,7 @@ public final class OperationMapper {
* @return
*/
@SuppressWarnings("unchecked")
public static Map<String, Method> mapOperationToMethod(Class<?> intfClass) {
public static Map<String, Method> mapOperationNameToMethod(Class<?> intfClass) {
return iiopMap(intfClass, true);
}
@ -524,4 +526,53 @@ public final class OperationMapper {
keywords.add("wstring");
}
@SuppressWarnings("unchecked")
public static Map<Operation, Method> mapOperationToMethod(List<Operation> operations, Class<?> forClass) {
return (Map<Operation, Method>)createMethod2OperationMapping(operations, forClass, false);
}
@SuppressWarnings("unchecked")
public static Map<Method, Operation> mapMethodToOperation(List<Operation> operations, Class<?> forClass) {
return (Map<Method, Operation>)createMethod2OperationMapping(operations, forClass, true);
}
/**
* Maps Java methods to Tuscany operations
*/
@SuppressWarnings("unchecked")
private static Map createMethod2OperationMapping(List<Operation> operations, Class<?> forClass, boolean method2operation) {
// for every operation find all methods with the same name, then
// compare operations and methods parameters
Map mapping = new HashMap();
for (Operation operation : operations) {
List<DataType> inputTypes = operation.getInputType().getLogical();
Method[] methods = forClass.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
if (method2operation) {
mapping.put(methods[i], operation);
} else {
mapping.put(operation, methods[i]);
}
break;
}
}
}
}
return mapping;
}
}

View file

@ -0,0 +1,34 @@
/*
* 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.meta;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/**
* @version $Rev$ $Date$
* Declares CORBA arrays lengths
*/
@Retention(RetentionPolicy.RUNTIME)
public @interface CorbaArray {
int[] value();
}

View file

@ -20,6 +20,7 @@
package org.apache.tuscany.sca.binding.corba.testing;
import static junit.framework.Assert.fail;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.lang.reflect.Array;
@ -34,6 +35,9 @@ import org.apache.tuscany.sca.binding.corba.impl.service.ComponentInvocationProx
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.arrays_unions.ArraysUnionsTests;
import org.apache.tuscany.sca.binding.corba.testing.arrays_unions.ArraysUnionsTestsHelper;
import org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStruct;
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;
@ -51,6 +55,7 @@ import org.apache.tuscany.sca.binding.corba.testing.generated.TestObject;
import org.apache.tuscany.sca.binding.corba.testing.generated.TestObjectHelper;
import org.apache.tuscany.sca.binding.corba.testing.hierarchy.NonCorbaException;
import org.apache.tuscany.sca.binding.corba.testing.servants.ArraysSetterServant;
import org.apache.tuscany.sca.binding.corba.testing.servants.ArraysUnionsTuscanyServant;
import org.apache.tuscany.sca.binding.corba.testing.servants.CalcServant;
import org.apache.tuscany.sca.binding.corba.testing.servants.EnumManagerServant;
import org.apache.tuscany.sca.binding.corba.testing.servants.InvalidTestObjectServant;
@ -503,4 +508,54 @@ public class CorbaServantTestCase {
}
}
@Test
public void test_arraysPassing() {
try {
ArraysUnionsTuscanyServant arraysUnions = new ArraysUnionsTuscanyServant();
TestRuntimeComponentService service = new TestRuntimeComponentService(arraysUnions);
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/arrays_unions/ArraysUnionsTests:1.0"};
servant.setIds(ids);
bindServant(servant, "ArraysUnions");
Object reference = bindReference("ArraysUnions");
ArraysUnionsTests objRef = ArraysUnionsTestsHelper.narrow(reference);
String[][] stringArray = {{"Hello", "World"}, {"Hi", "Again"}};
String[][] result = objRef.passStringArray(stringArray);
for (int i = 0; i < stringArray.length; i++) {
for (int j = 0; j < stringArray[i].length; j++) {
assertEquals(stringArray[i][j], result[i][j]);
}
}
TestStruct struct = new TestStruct();
String[] field1 = {"Hello", "World"};
int[][] field2 = { {4, 2, 2, 5}, {6, 12, 5, 8}};
float[][][] field3 = { { {2, 6}, {2, 7}, {9, 3}, {4, 6}}, { {3, 7}, {6, 6}, {3, 5}, {6, 2}}};
struct.oneDimArray = field1;
struct.twoDimArray = field2;
struct.threeDimArray = field3;
TestStruct structResult = objRef.passTestStruct(struct);
for (int i = 0; i < struct.oneDimArray.length; i++) {
assertEquals(struct.oneDimArray[i], structResult.oneDimArray[i]);
}
for (int i = 0; i < struct.twoDimArray.length; i++) {
for (int j = 0; j < struct.twoDimArray[i].length; j++) {
assertEquals(struct.twoDimArray[i][j], structResult.twoDimArray[i][j]);
}
}
for (int i = 0; i < struct.threeDimArray.length; i++) {
for (int j = 0; j < struct.threeDimArray[i].length; j++) {
for (int k = 0; k < struct.threeDimArray[i][j].length; k++) {
assertEquals(struct.threeDimArray[i][j][k], structResult.threeDimArray[i][j][k]);
}
}
}
} catch (Exception e) {
e.printStackTrace();
fail();
}
}
}

View file

@ -24,6 +24,7 @@ import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.lang.annotation.Annotation;
import java.lang.reflect.Array;
import junit.framework.Assert;
@ -37,7 +38,9 @@ import org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.DivBy
import org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.NotSupported;
import org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStruct;
import org.apache.tuscany.sca.binding.corba.testing.generated.SomeStruct;
import org.apache.tuscany.sca.binding.corba.testing.hierarchy.ArraysTestStruct;
import org.apache.tuscany.sca.binding.corba.testing.hierarchy.DummyObject;
import org.apache.tuscany.sca.binding.corba.testing.hierarchy.InvalidCorbaArray;
import org.apache.tuscany.sca.binding.corba.testing.hierarchy.InvalidEnum1;
import org.apache.tuscany.sca.binding.corba.testing.hierarchy.InvalidEnum2;
import org.apache.tuscany.sca.binding.corba.testing.hierarchy.InvalidEnum3;
@ -45,6 +48,8 @@ import org.apache.tuscany.sca.binding.corba.testing.hierarchy.InvalidStruct1;
import org.apache.tuscany.sca.binding.corba.testing.hierarchy.InvalidStruct2;
import org.apache.tuscany.sca.binding.corba.testing.hierarchy.InvalidStruct3;
import org.apache.tuscany.sca.binding.corba.testing.servants.ArraysSetterServant;
import org.apache.tuscany.sca.binding.corba.testing.servants.ArraysUnionsServant;
import org.apache.tuscany.sca.binding.corba.testing.servants.ArraysUnionsTuscanyServant;
import org.apache.tuscany.sca.binding.corba.testing.servants.CalcServant;
import org.apache.tuscany.sca.binding.corba.testing.servants.EnumManagerServant;
import org.apache.tuscany.sca.binding.corba.testing.servants.ObjectManagerServant;
@ -66,7 +71,8 @@ import org.omg.CosNaming.NamingContextHelper;
/**
* @version $Rev$ $Date$
* Tests API for dynamic CORBA requests. Tests handling various Java types.
* Tests API for dynamic CORBA requests. Tests handling various Java
* types.
*/
public class CorbaTypesTestCase {
private static TransientNameServer server;
@ -78,6 +84,7 @@ public class CorbaTypesTestCase {
private static Object refCalcObject;
private static Object refObjectManager;
private static Object refEnumManager;
private static Object refArraysUnions;
/**
* Spawns tnameserv process (must be in PATH). Initializes test servants and
@ -109,6 +116,7 @@ public class CorbaTypesTestCase {
CalcServant calcObject = new CalcServant();
ObjectManagerServant objectManager = new ObjectManagerServant();
EnumManagerServant enumManager = new EnumManagerServant();
ArraysUnionsServant arraysUnions = new ArraysUnionsServant();
orb.connect(singleSetter);
orb.connect(arraysSetter);
@ -140,6 +148,10 @@ public class CorbaTypesTestCase {
path = new NameComponent[] {nc};
namingContext.rebind(path, enumManager);
nc = new NameComponent("ArraysUnions", "");
path = new NameComponent[] {nc};
namingContext.rebind(path, arraysUnions);
NamingContextExt nce = NamingContextExtHelper.narrow(orb.resolve_initial_references("NameService"));
refArraysSetter = nce.resolve(nce.to_name("ArraysSetter"));
@ -148,6 +160,7 @@ public class CorbaTypesTestCase {
refCalcObject = nce.resolve(nce.to_name("CalcObject"));
refObjectManager = nce.resolve(nce.to_name("ObjectManager"));
refEnumManager = nce.resolve(nce.to_name("EnumManager"));
refArraysUnions = nce.resolve(nce.to_name("ArraysUnions"));
} catch (Exception e) {
e.printStackTrace();
@ -624,7 +637,7 @@ public class CorbaTypesTestCase {
}
/**
* Tests hanlding passing wrong params
* Tests handling passing wrong params
*/
@Test
public void test_systemException_BAD_PARAM() {
@ -644,4 +657,106 @@ public class CorbaTypesTestCase {
}
}
/**
* Tests passing CORBA arrays
*/
@Test
public void test_arraysPassing() {
try {
DynaCorbaRequest request = new DynaCorbaRequest(refArraysUnions, "passStringArray");
Annotation[] notes =
ArraysUnionsTuscanyServant.class.getMethod("passStringArray", new Class<?>[] {String[][].class})
.getAnnotations();
request.setOutputType(String[][].class, notes);
String[][] argument = { {"Hello", "World"}, {"Hi", "again"}};
request.addArgument(argument, notes);
DynaCorbaResponse response = request.invoke();
String[][] result = (String[][])response.getContent();
for (int i = 0; i < argument.length; i++) {
for (int j = 0; j < argument[i].length; j++) {
assertEquals(argument[i][j], result[i][j]);
}
}
} catch (Exception e) {
e.printStackTrace();
fail();
}
try {
DynaCorbaRequest request = new DynaCorbaRequest(refArraysUnions, "passTestStruct");
ArraysTestStruct arg = new ArraysTestStruct();
String[] field1 = {"Hello", "World"};
arg.field1 = field1;
int[][] field2 = { {4, 2, 2, 5}, {6, 12, 5, 8}};
arg.field2 = field2;
float[][][] field3 = { { {2, 6}, {2, 7}, {9, 3}, {4, 6}}, { {3, 7}, {6, 6}, {3, 5}, {6, 2}}};
arg.field3 = field3;
request.addArgument(arg);
request.setOutputType(ArraysTestStruct.class);
DynaCorbaResponse response = request.invoke();
ArraysTestStruct result = (ArraysTestStruct)response.getContent();
for (int i = 0; i < arg.field1.length; i++) {
assertEquals(arg.field1[i], result.field1[i]);
}
for (int i = 0; i < arg.field2.length; i++) {
for (int j = 0; j < arg.field2[i].length; j++) {
assertEquals(arg.field2[i][j], result.field2[i][j]);
}
}
for (int i = 0; i < arg.field2.length; i++) {
for (int j = 0; j < arg.field2[i].length; j++) {
for (int k = 0; k < arg.field3[i][j].length; k++) {
assertEquals(arg.field3[i][j][k], result.field3[i][j][k]);
}
}
}
} catch (Exception e) {
e.printStackTrace();
fail();
}
}
/**
* Tests situation when CORBA array dimension size doesn't match
* CORBA array annotation arguments (which sets dimension lengths)
*/
@Test
public void test_invalidArrayAnnotationSize() {
try {
DynaCorbaRequest request = new DynaCorbaRequest(refArraysUnions, "passStringArray");
Annotation[] notes =
ArraysUnionsTuscanyServant.class.getMethod("passStringArray", new Class<?>[] {String[][].class})
.getAnnotations();
request.setOutputType(String[][][].class, notes);
fail();
} catch (RequestConfigurationException e) {
// expected
} catch (Exception e) {
e.printStackTrace();
fail();
}
try {
DynaCorbaRequest request = new DynaCorbaRequest(refArraysUnions, "passStringArray");
Annotation[] notes =
ArraysUnionsTuscanyServant.class.getMethod("passStringArray", new Class<?>[] {String[][].class})
.getAnnotations();
request.addArgument(new String[0][0][0], notes);
fail();
} catch (RequestConfigurationException e) {
// expected
} catch (Exception e) {
e.printStackTrace();
fail();
}
try {
DynaCorbaRequest request = new DynaCorbaRequest(refArraysUnions, "passStringArray");
request.addArgument(new InvalidCorbaArray(), null);
fail();
} catch (RequestConfigurationException e) {
// expected
} catch (Exception e) {
e.printStackTrace();
fail();
}
}
}

View file

@ -38,7 +38,7 @@ public class OperationMappingTestCase {
*/
@Test
public void test_mappingRules() {
Map<Method, String> met2op = OperationMapper.mapMethodToOperation(MappingTestInterface.class);
Map<Method, String> met2op = OperationMapper.mapMethodToOperationName(MappingTestInterface.class);
for (Method method : met2op.keySet()) {
String name = method.getName();
String translatedName = met2op.get(method);

View file

@ -0,0 +1,13 @@
package org.apache.tuscany.sca.binding.corba.testing.arrays_unions;
/**
* org/apache/tuscany/sca/binding/corba/testing/arrays_unions/ArraysUnionsTests.java .
* Generated by the IDL-to-Java compiler (portable), version "3.2"
* from arrays_unions.idl
* sobota, 16 sierpieñ 2008 00:51:16 CEST
*/
public interface ArraysUnionsTests extends ArraysUnionsTestsOperations, org.omg.CORBA.Object, org.omg.CORBA.portable.IDLEntity
{
} // interface ArraysUnionsTests

View file

@ -0,0 +1,85 @@
package org.apache.tuscany.sca.binding.corba.testing.arrays_unions;
/**
* org/apache/tuscany/sca/binding/corba/testing/arrays_unions/ArraysUnionsTestsHelper.java .
* Generated by the IDL-to-Java compiler (portable), version "3.2"
* from arrays_unions.idl
* sobota, 16 sierpieñ 2008 00:51:16 CEST
*/
abstract public class ArraysUnionsTestsHelper
{
private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/arrays_unions/ArraysUnionsTests:1.0";
public static void insert (org.omg.CORBA.Any a, org.apache.tuscany.sca.binding.corba.testing.arrays_unions.ArraysUnionsTests that)
{
org.omg.CORBA.portable.OutputStream out = a.create_output_stream ();
a.type (type ());
write (out, that);
a.read_value (out.create_input_stream (), type ());
}
public static org.apache.tuscany.sca.binding.corba.testing.arrays_unions.ArraysUnionsTests extract (org.omg.CORBA.Any a)
{
return read (a.create_input_stream ());
}
private static org.omg.CORBA.TypeCode __typeCode = null;
synchronized public static org.omg.CORBA.TypeCode type ()
{
if (__typeCode == null)
{
__typeCode = org.omg.CORBA.ORB.init ().create_interface_tc (org.apache.tuscany.sca.binding.corba.testing.arrays_unions.ArraysUnionsTestsHelper.id (), "ArraysUnionsTests");
}
return __typeCode;
}
public static String id ()
{
return _id;
}
public static org.apache.tuscany.sca.binding.corba.testing.arrays_unions.ArraysUnionsTests read (org.omg.CORBA.portable.InputStream istream)
{
return narrow (istream.read_Object (_ArraysUnionsTestsStub.class));
}
public static void write (org.omg.CORBA.portable.OutputStream ostream, org.apache.tuscany.sca.binding.corba.testing.arrays_unions.ArraysUnionsTests value)
{
ostream.write_Object ((org.omg.CORBA.Object) value);
}
public static org.apache.tuscany.sca.binding.corba.testing.arrays_unions.ArraysUnionsTests narrow (org.omg.CORBA.Object obj)
{
if (obj == null)
return null;
else if (obj instanceof org.apache.tuscany.sca.binding.corba.testing.arrays_unions.ArraysUnionsTests)
return (org.apache.tuscany.sca.binding.corba.testing.arrays_unions.ArraysUnionsTests)obj;
else if (!obj._is_a (id ()))
throw new org.omg.CORBA.BAD_PARAM ();
else
{
org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate ();
org.apache.tuscany.sca.binding.corba.testing.arrays_unions._ArraysUnionsTestsStub stub = new org.apache.tuscany.sca.binding.corba.testing.arrays_unions._ArraysUnionsTestsStub ();
stub._set_delegate(delegate);
return stub;
}
}
public static org.apache.tuscany.sca.binding.corba.testing.arrays_unions.ArraysUnionsTests unchecked_narrow (org.omg.CORBA.Object obj)
{
if (obj == null)
return null;
else if (obj instanceof org.apache.tuscany.sca.binding.corba.testing.arrays_unions.ArraysUnionsTests)
return (org.apache.tuscany.sca.binding.corba.testing.arrays_unions.ArraysUnionsTests)obj;
else
{
org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate ();
org.apache.tuscany.sca.binding.corba.testing.arrays_unions._ArraysUnionsTestsStub stub = new org.apache.tuscany.sca.binding.corba.testing.arrays_unions._ArraysUnionsTestsStub ();
stub._set_delegate(delegate);
return stub;
}
}
}

View file

@ -0,0 +1,38 @@
package org.apache.tuscany.sca.binding.corba.testing.arrays_unions;
/**
* org/apache/tuscany/sca/binding/corba/testing/arrays_unions/ArraysUnionsTestsHolder.java .
* Generated by the IDL-to-Java compiler (portable), version "3.2"
* from arrays_unions.idl
* sobota, 16 sierpieñ 2008 00:51:16 CEST
*/
public final class ArraysUnionsTestsHolder implements org.omg.CORBA.portable.Streamable
{
public org.apache.tuscany.sca.binding.corba.testing.arrays_unions.ArraysUnionsTests value = null;
public ArraysUnionsTestsHolder ()
{
}
public ArraysUnionsTestsHolder (org.apache.tuscany.sca.binding.corba.testing.arrays_unions.ArraysUnionsTests initialValue)
{
value = initialValue;
}
public void _read (org.omg.CORBA.portable.InputStream i)
{
value = org.apache.tuscany.sca.binding.corba.testing.arrays_unions.ArraysUnionsTestsHelper.read (i);
}
public void _write (org.omg.CORBA.portable.OutputStream o)
{
org.apache.tuscany.sca.binding.corba.testing.arrays_unions.ArraysUnionsTestsHelper.write (o, value);
}
public org.omg.CORBA.TypeCode _type ()
{
return org.apache.tuscany.sca.binding.corba.testing.arrays_unions.ArraysUnionsTestsHelper.type ();
}
}

View file

@ -0,0 +1,15 @@
package org.apache.tuscany.sca.binding.corba.testing.arrays_unions;
/**
* org/apache/tuscany/sca/binding/corba/testing/arrays_unions/ArraysUnionsTestsOperations.java .
* Generated by the IDL-to-Java compiler (portable), version "3.2"
* from arrays_unions.idl
* sobota, 16 sierpieñ 2008 00:51:16 CEST
*/
public interface ArraysUnionsTestsOperations
{
org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStruct passTestStruct (org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStruct arg);
String[][] passStringArray (String[][] arg);
} // interface ArraysUnionsTestsOperations

View file

@ -0,0 +1,76 @@
package org.apache.tuscany.sca.binding.corba.testing.arrays_unions;
/**
* org/apache/tuscany/sca/binding/corba/testing/arrays_unions/StringArrayHelper.java .
* Generated by the IDL-to-Java compiler (portable), version "3.2"
* from arrays_unions.idl
* sobota, 16 sierpieñ 2008 00:51:16 CEST
*/
abstract public class StringArrayHelper
{
private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/arrays_unions/StringArray:1.0";
public static void insert (org.omg.CORBA.Any a, String[][] that)
{
org.omg.CORBA.portable.OutputStream out = a.create_output_stream ();
a.type (type ());
write (out, that);
a.read_value (out.create_input_stream (), type ());
}
public static String[][] extract (org.omg.CORBA.Any a)
{
return read (a.create_input_stream ());
}
private static org.omg.CORBA.TypeCode __typeCode = null;
synchronized public static org.omg.CORBA.TypeCode type ()
{
if (__typeCode == null)
{
__typeCode = org.omg.CORBA.ORB.init ().create_string_tc (0);
__typeCode = org.omg.CORBA.ORB.init ().create_array_tc (2, __typeCode );
__typeCode = org.omg.CORBA.ORB.init ().create_array_tc (2, __typeCode );
__typeCode = org.omg.CORBA.ORB.init ().create_alias_tc (org.apache.tuscany.sca.binding.corba.testing.arrays_unions.StringArrayHelper.id (), "StringArray", __typeCode);
}
return __typeCode;
}
public static String id ()
{
return _id;
}
public static String[][] read (org.omg.CORBA.portable.InputStream istream)
{
String value[][] = null;
value = new String[2][];
for (int _o0 = 0;_o0 < (2); ++_o0)
{
value[_o0] = new String[2];
for (int _o1 = 0;_o1 < (2); ++_o1)
{
value[_o0][_o1] = istream.read_string ();
}
}
return value;
}
public static void write (org.omg.CORBA.portable.OutputStream ostream, String[][] value)
{
if (value.length != (2))
throw new org.omg.CORBA.MARSHAL (0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE);
for (int _i0 = 0;_i0 < (2); ++_i0)
{
if (value[_i0].length != (2))
throw new org.omg.CORBA.MARSHAL (0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE);
for (int _i1 = 0;_i1 < (2); ++_i1)
{
ostream.write_string (value[_i0][_i1]);
}
}
}
}

View file

@ -0,0 +1,39 @@
package org.apache.tuscany.sca.binding.corba.testing.arrays_unions;
/**
* org/apache/tuscany/sca/binding/corba/testing/arrays_unions/StringArrayHolder.java .
* Generated by the IDL-to-Java compiler (portable), version "3.2"
* from arrays_unions.idl
* sobota, 16 sierpieñ 2008 00:51:16 CEST
*/
public final class StringArrayHolder implements org.omg.CORBA.portable.Streamable
{
public String value[][] = null;
public StringArrayHolder ()
{
}
public StringArrayHolder (String[][] initialValue)
{
value = initialValue;
}
public void _read (org.omg.CORBA.portable.InputStream i)
{
value = org.apache.tuscany.sca.binding.corba.testing.arrays_unions.StringArrayHelper.read (i);
}
public void _write (org.omg.CORBA.portable.OutputStream o)
{
org.apache.tuscany.sca.binding.corba.testing.arrays_unions.StringArrayHelper.write (o, value);
}
public org.omg.CORBA.TypeCode _type ()
{
return org.apache.tuscany.sca.binding.corba.testing.arrays_unions.StringArrayHelper.type ();
}
}

View file

@ -0,0 +1,28 @@
package org.apache.tuscany.sca.binding.corba.testing.arrays_unions;
/**
* org/apache/tuscany/sca/binding/corba/testing/arrays_unions/TestStruct.java .
* Generated by the IDL-to-Java compiler (portable), version "3.2"
* from arrays_unions.idl
* sobota, 16 sierpieñ 2008 00:51:16 CEST
*/
public final class TestStruct implements org.omg.CORBA.portable.IDLEntity
{
public String oneDimArray[] = null;
public int twoDimArray[][] = null;
public float threeDimArray[][][] = null;
public TestStruct ()
{
} // ctor
public TestStruct (String[] _oneDimArray, int[][] _twoDimArray, float[][][] _threeDimArray)
{
oneDimArray = _oneDimArray;
twoDimArray = _twoDimArray;
threeDimArray = _threeDimArray;
} // ctor
} // class TestStruct

View file

@ -0,0 +1,149 @@
package org.apache.tuscany.sca.binding.corba.testing.arrays_unions;
/**
* org/apache/tuscany/sca/binding/corba/testing/arrays_unions/TestStructHelper.java .
* Generated by the IDL-to-Java compiler (portable), version "3.2"
* from arrays_unions.idl
* sobota, 16 sierpieñ 2008 00:51:16 CEST
*/
abstract public class TestStructHelper
{
private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/arrays_unions/TestStruct/TestStruct:1.0";
public static void insert (org.omg.CORBA.Any a, org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStruct that)
{
org.omg.CORBA.portable.OutputStream out = a.create_output_stream ();
a.type (type ());
write (out, that);
a.read_value (out.create_input_stream (), type ());
}
public static org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStruct extract (org.omg.CORBA.Any a)
{
return read (a.create_input_stream ());
}
private static org.omg.CORBA.TypeCode __typeCode = null;
private static boolean __active = false;
synchronized public static org.omg.CORBA.TypeCode type ()
{
if (__typeCode == null)
{
synchronized (org.omg.CORBA.TypeCode.class)
{
if (__typeCode == null)
{
if (__active)
{
return org.omg.CORBA.ORB.init().create_recursive_tc ( _id );
}
__active = true;
org.omg.CORBA.StructMember[] _members0 = new org.omg.CORBA.StructMember [3];
org.omg.CORBA.TypeCode _tcOf_members0 = null;
_tcOf_members0 = org.omg.CORBA.ORB.init ().create_string_tc (0);
_tcOf_members0 = org.omg.CORBA.ORB.init ().create_array_tc (2, _tcOf_members0 );
_members0[0] = new org.omg.CORBA.StructMember (
"oneDimArray",
_tcOf_members0,
null);
_tcOf_members0 = org.omg.CORBA.ORB.init ().get_primitive_tc (org.omg.CORBA.TCKind.tk_long);
_tcOf_members0 = org.omg.CORBA.ORB.init ().create_array_tc (2, _tcOf_members0 );
_tcOf_members0 = org.omg.CORBA.ORB.init ().create_array_tc (4, _tcOf_members0 );
_members0[1] = new org.omg.CORBA.StructMember (
"twoDimArray",
_tcOf_members0,
null);
_tcOf_members0 = org.omg.CORBA.ORB.init ().get_primitive_tc (org.omg.CORBA.TCKind.tk_float);
_tcOf_members0 = org.omg.CORBA.ORB.init ().create_array_tc (2, _tcOf_members0 );
_tcOf_members0 = org.omg.CORBA.ORB.init ().create_array_tc (4, _tcOf_members0 );
_tcOf_members0 = org.omg.CORBA.ORB.init ().create_array_tc (2, _tcOf_members0 );
_members0[2] = new org.omg.CORBA.StructMember (
"threeDimArray",
_tcOf_members0,
null);
__typeCode = org.omg.CORBA.ORB.init ().create_struct_tc (org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStructHelper.id (), "TestStruct", _members0);
__active = false;
}
}
}
return __typeCode;
}
public static String id ()
{
return _id;
}
public static org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStruct read (org.omg.CORBA.portable.InputStream istream)
{
org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStruct value = new org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStruct ();
value.oneDimArray = new String[2];
for (int _o0 = 0;_o0 < (2); ++_o0)
{
value.oneDimArray[_o0] = istream.read_string ();
}
value.twoDimArray = new int[2][];
for (int _o1 = 0;_o1 < (2); ++_o1)
{
value.twoDimArray[_o1] = new int[4];
for (int _o2 = 0;_o2 < (4); ++_o2)
{
value.twoDimArray[_o1][_o2] = istream.read_long ();
}
}
value.threeDimArray = new float[2][][];
for (int _o3 = 0;_o3 < (2); ++_o3)
{
value.threeDimArray[_o3] = new float[4][];
for (int _o4 = 0;_o4 < (4); ++_o4)
{
value.threeDimArray[_o3][_o4] = new float[2];
for (int _o5 = 0;_o5 < (2); ++_o5)
{
value.threeDimArray[_o3][_o4][_o5] = istream.read_float ();
}
}
}
return value;
}
public static void write (org.omg.CORBA.portable.OutputStream ostream, org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStruct value)
{
if (value.oneDimArray.length != (2))
throw new org.omg.CORBA.MARSHAL (0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE);
for (int _i0 = 0;_i0 < (2); ++_i0)
{
ostream.write_string (value.oneDimArray[_i0]);
}
if (value.twoDimArray.length != (2))
throw new org.omg.CORBA.MARSHAL (0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE);
for (int _i1 = 0;_i1 < (2); ++_i1)
{
if (value.twoDimArray[_i1].length != (4))
throw new org.omg.CORBA.MARSHAL (0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE);
for (int _i2 = 0;_i2 < (4); ++_i2)
{
ostream.write_long (value.twoDimArray[_i1][_i2]);
}
}
if (value.threeDimArray.length != (2))
throw new org.omg.CORBA.MARSHAL (0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE);
for (int _i3 = 0;_i3 < (2); ++_i3)
{
if (value.threeDimArray[_i3].length != (4))
throw new org.omg.CORBA.MARSHAL (0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE);
for (int _i4 = 0;_i4 < (4); ++_i4)
{
if (value.threeDimArray[_i3][_i4].length != (2))
throw new org.omg.CORBA.MARSHAL (0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE);
for (int _i5 = 0;_i5 < (2); ++_i5)
{
ostream.write_float (value.threeDimArray[_i3][_i4][_i5]);
}
}
}
}
}

View file

@ -0,0 +1,38 @@
package org.apache.tuscany.sca.binding.corba.testing.arrays_unions;
/**
* org/apache/tuscany/sca/binding/corba/testing/arrays_unions/TestStructHolder.java .
* Generated by the IDL-to-Java compiler (portable), version "3.2"
* from arrays_unions.idl
* sobota, 16 sierpieñ 2008 00:51:16 CEST
*/
public final class TestStructHolder implements org.omg.CORBA.portable.Streamable
{
public org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStruct value = null;
public TestStructHolder ()
{
}
public TestStructHolder (org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStruct initialValue)
{
value = initialValue;
}
public void _read (org.omg.CORBA.portable.InputStream i)
{
value = org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStructHelper.read (i);
}
public void _write (org.omg.CORBA.portable.OutputStream o)
{
org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStructHelper.write (o, value);
}
public org.omg.CORBA.TypeCode _type ()
{
return org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStructHelper.type ();
}
}

View file

@ -0,0 +1,75 @@
package org.apache.tuscany.sca.binding.corba.testing.arrays_unions;
/**
* org/apache/tuscany/sca/binding/corba/testing/arrays_unions/_ArraysUnionsTestsImplBase.java .
* Generated by the IDL-to-Java compiler (portable), version "3.2"
* from arrays_unions.idl
* sobota, 16 sierpieñ 2008 00:51:16 CEST
*/
public abstract class _ArraysUnionsTestsImplBase extends org.omg.CORBA.portable.ObjectImpl
implements org.apache.tuscany.sca.binding.corba.testing.arrays_unions.ArraysUnionsTests, org.omg.CORBA.portable.InvokeHandler
{
// Constructors
public _ArraysUnionsTestsImplBase ()
{
}
private static java.util.Hashtable _methods = new java.util.Hashtable ();
static
{
_methods.put ("passTestStruct", new java.lang.Integer (0));
_methods.put ("passStringArray", new java.lang.Integer (1));
}
public org.omg.CORBA.portable.OutputStream _invoke (String $method,
org.omg.CORBA.portable.InputStream in,
org.omg.CORBA.portable.ResponseHandler $rh)
{
org.omg.CORBA.portable.OutputStream out = null;
java.lang.Integer __method = (java.lang.Integer)_methods.get ($method);
if (__method == null)
throw new org.omg.CORBA.BAD_OPERATION (0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE);
switch (__method.intValue ())
{
case 0: // org/apache/tuscany/sca/binding/corba/testing/arrays_unions/ArraysUnionsTests/passTestStruct
{
org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStruct arg = org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStructHelper.read (in);
org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStruct $result = null;
$result = this.passTestStruct (arg);
out = $rh.createReply();
org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStructHelper.write (out, $result);
break;
}
case 1: // org/apache/tuscany/sca/binding/corba/testing/arrays_unions/ArraysUnionsTests/passStringArray
{
String arg[][] = org.apache.tuscany.sca.binding.corba.testing.arrays_unions.StringArrayHelper.read (in);
String $result[][] = null;
$result = this.passStringArray (arg);
out = $rh.createReply();
org.apache.tuscany.sca.binding.corba.testing.arrays_unions.StringArrayHelper.write (out, $result);
break;
}
default:
throw new org.omg.CORBA.BAD_OPERATION (0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE);
}
return out;
} // _invoke
// Type-specific CORBA::Object operations
private static String[] __ids = {
"IDL:org/apache/tuscany/sca/binding/corba/testing/arrays_unions/ArraysUnionsTests:1.0"};
public String[] _ids ()
{
return (String[])__ids.clone ();
}
} // class _ArraysUnionsTestsImplBase

View file

@ -0,0 +1,80 @@
package org.apache.tuscany.sca.binding.corba.testing.arrays_unions;
/**
* org/apache/tuscany/sca/binding/corba/testing/arrays_unions/_ArraysUnionsTestsStub.java .
* Generated by the IDL-to-Java compiler (portable), version "3.2"
* from arrays_unions.idl
* sobota, 16 sierpieñ 2008 00:51:16 CEST
*/
public class _ArraysUnionsTestsStub extends org.omg.CORBA.portable.ObjectImpl implements org.apache.tuscany.sca.binding.corba.testing.arrays_unions.ArraysUnionsTests
{
public org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStruct passTestStruct (org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStruct arg)
{
org.omg.CORBA.portable.InputStream $in = null;
try {
org.omg.CORBA.portable.OutputStream $out = _request ("passTestStruct", true);
org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStructHelper.write ($out, arg);
$in = _invoke ($out);
org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStruct $result = org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStructHelper.read ($in);
return $result;
} catch (org.omg.CORBA.portable.ApplicationException $ex) {
$in = $ex.getInputStream ();
String _id = $ex.getId ();
throw new org.omg.CORBA.MARSHAL (_id);
} catch (org.omg.CORBA.portable.RemarshalException $rm) {
return passTestStruct (arg );
} finally {
_releaseReply ($in);
}
} // passTestStruct
public String[][] passStringArray (String[][] arg)
{
org.omg.CORBA.portable.InputStream $in = null;
try {
org.omg.CORBA.portable.OutputStream $out = _request ("passStringArray", true);
org.apache.tuscany.sca.binding.corba.testing.arrays_unions.StringArrayHelper.write ($out, arg);
$in = _invoke ($out);
String $result[][] = org.apache.tuscany.sca.binding.corba.testing.arrays_unions.StringArrayHelper.read ($in);
return $result;
} catch (org.omg.CORBA.portable.ApplicationException $ex) {
$in = $ex.getInputStream ();
String _id = $ex.getId ();
throw new org.omg.CORBA.MARSHAL (_id);
} catch (org.omg.CORBA.portable.RemarshalException $rm) {
return passStringArray (arg );
} finally {
_releaseReply ($in);
}
} // passStringArray
// Type-specific CORBA::Object operations
private static String[] __ids = {
"IDL:org/apache/tuscany/sca/binding/corba/testing/arrays_unions/ArraysUnionsTests:1.0"};
public String[] _ids ()
{
return (String[])__ids.clone ();
}
private void readObject (java.io.ObjectInputStream s) throws java.io.IOException
{
String str = s.readUTF ();
String[] args = null;
java.util.Properties props = null;
org.omg.CORBA.Object obj = org.omg.CORBA.ORB.init (args, props).string_to_object (str);
org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl) obj)._get_delegate ();
_set_delegate (delegate);
}
private void writeObject (java.io.ObjectOutputStream s) throws java.io.IOException
{
String[] args = null;
java.util.Properties props = null;
String str = org.omg.CORBA.ORB.init (args, props).object_to_string (this);
s.writeUTF (str);
}
} // class _ArraysUnionsTestsStub

View file

@ -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.testing.hierarchy;
import org.apache.tuscany.sca.binding.corba.meta.CorbaArray;
public final class ArraysTestStruct {
public ArraysTestStruct() {
}
public ArraysTestStruct(String[] field1, int[][] field2, float[][][] field3) {
this.field1 = field1;
this.field2 = field2;
this.field3 = field3;
}
@CorbaArray( {2})
public String[] field1;
@CorbaArray( {2, 4})
public int[][] field2;
@CorbaArray( {2, 4, 2})
public float[][][] field3;
}

View file

@ -0,0 +1,38 @@
/*
* 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.testing.hierarchy;
import org.apache.tuscany.sca.binding.corba.meta.CorbaArray;
public final class InvalidCorbaArray {
// annotation argument array is not equal to declared arrays dimension
@CorbaArray( {1})
public String[][] array;
public InvalidCorbaArray() {
}
public InvalidCorbaArray(String[][] arg) {
}
}

View file

@ -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.binding.corba.testing.servants;
import org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStruct;
import org.apache.tuscany.sca.binding.corba.testing.arrays_unions._ArraysUnionsTestsImplBase;
public class ArraysUnionsServant extends _ArraysUnionsTestsImplBase {
private static final long serialVersionUID = 1L;
public TestStruct passTestStruct(TestStruct arg) {
return arg;
}
public String[][] passStringArray(String[][] arg) {
return arg;
}
}

View file

@ -0,0 +1,38 @@
/*
* 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.testing.servants;
import org.apache.tuscany.sca.binding.corba.meta.CorbaArray;
import org.apache.tuscany.sca.binding.corba.testing.hierarchy.ArraysTestStruct;
public class ArraysUnionsTuscanyServant {
private static final long serialVersionUID = 1L;
public ArraysTestStruct passTestStruct(ArraysTestStruct arg) {
return arg;
}
@CorbaArray( {2, 2})
public String[][] passStringArray(@CorbaArray( {2, 2})String[][] arg) {
return arg;
}
}

View file

@ -0,0 +1,55 @@
/*
* 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.
*/
/*
* compile by
* idlj -fall -oldImplBase arrays_unions.idl
*/
module org {
module apache {
module tuscany {
module sca {
module binding {
module corba {
module testing {
module arrays_unions {
struct TestStruct {
string oneDimArray[2];
long twoDimArray[2][4];
float threeDimArray[2][4][2];
};
typedef string StringArray[2][2];
interface ArraysUnionsTests {
TestStruct passTestStruct(in TestStruct arg);
StringArray passStringArray(in StringArray arg);
};
};
};
};
};
};
};
};
};

View file

@ -42,91 +42,3 @@ module org {
};
};
};
/*
* 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.
*/
/*
* compile by
* idlj -fall -oldImplBase enums.idl
*/
module org {
module apache {
module tuscany {
module sca {
module binding {
module corba {
module testing {
module enums {
enum Color {red, yellow, green};
interface EnumManager {
Color getColor(in Color color);
};
};
};
};
};
};
};
};
};
/*
* 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.
*/
/*
* compile by
* idlj -fall -oldImplBase enums.idl
*/
module org {
module apache {
module tuscany {
module sca {
module binding {
module corba {
module testing {
module enums {
enum Color {red, yellow, green};
interface EnumManager {
Color getColor(in Color color);
};
};
};
};
};
};
};
};
};

View file

@ -56,9 +56,9 @@ public class CorbaSCAInvocationProxy implements InvocationProxy {
this.messageFactory = messageFactory;
try {
List<TypeTree> inputType = new ArrayList<TypeTree>();
inputType.add(TypeTreeCreator.createTypeTree(String.class));
inputType.add(TypeTreeCreator.createTypeTree(String.class, null));
types.setInputType(inputType);
types.setOutputType(TypeTreeCreator.createTypeTree(String.class));
types.setOutputType(TypeTreeCreator.createTypeTree(String.class, null));
} catch (RequestConfigurationException e) {
// ignore - string type should not cause this exception
}