From 725006d4c47e63986ac042ade23a4d193298b1fe Mon Sep 17 00:00:00 2001 From: lresende Date: Wed, 11 Nov 2009 23:08:29 +0000 Subject: Moving 1.x branches git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835131 13f79535-47bb-0310-9956-ffa450edef68 --- .../corba/impl/types/util/ArrayTypeHelper.java | 53 --------- .../corba/impl/types/util/BooleanTypeHelper.java | 39 ------- .../corba/impl/types/util/ByteTypeHelper.java | 39 ------- .../corba/impl/types/util/CharTypeHelper.java | 39 ------- .../corba/impl/types/util/DoubleTypeHelper.java | 39 ------- .../corba/impl/types/util/EnumTypeHelper.java | 59 ---------- .../corba/impl/types/util/FloatTypeHelper.java | 39 ------- .../corba/impl/types/util/IntTypeHelper.java | 39 ------- .../corba/impl/types/util/LongTypeHelper.java | 39 ------- .../corba/impl/types/util/ReferenceTypeHelper.java | 42 -------- .../corba/impl/types/util/SequenceTypeHelper.java | 70 ------------ .../corba/impl/types/util/ShortTypeHelper.java | 39 ------- .../corba/impl/types/util/StringTypeHelper.java | 39 ------- .../corba/impl/types/util/StructTypeHelper.java | 69 ------------ .../binding/corba/impl/types/util/TypeHelper.java | 47 -------- .../corba/impl/types/util/TypeHelpersProxy.java | 119 --------------------- .../corba/impl/types/util/UnionTypeHelper.java | 92 ---------------- .../sca/binding/corba/impl/types/util/Utils.java | 40 ------- 18 files changed, 942 deletions(-) delete mode 100644 branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/ArrayTypeHelper.java delete mode 100644 branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/BooleanTypeHelper.java delete mode 100644 branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/ByteTypeHelper.java delete mode 100644 branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/CharTypeHelper.java delete mode 100644 branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/DoubleTypeHelper.java delete mode 100644 branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/EnumTypeHelper.java delete mode 100644 branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/FloatTypeHelper.java delete mode 100644 branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/IntTypeHelper.java delete mode 100644 branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/LongTypeHelper.java delete mode 100644 branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/ReferenceTypeHelper.java delete mode 100644 branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/SequenceTypeHelper.java delete mode 100644 branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/ShortTypeHelper.java delete mode 100644 branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/StringTypeHelper.java delete mode 100644 branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/StructTypeHelper.java delete mode 100644 branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/TypeHelper.java delete mode 100644 branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/TypeHelpersProxy.java delete mode 100644 branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/UnionTypeHelper.java delete mode 100644 branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/Utils.java (limited to 'branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util') diff --git a/branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/ArrayTypeHelper.java b/branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/ArrayTypeHelper.java deleted file mode 100644 index 6dbeda3b7c..0000000000 --- a/branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/ArrayTypeHelper.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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.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; - -/** - * @version $Rev$ $Date$ - */ -public class ArrayTypeHelper implements TypeHelper { - - public Object read(TypeTreeNode node, InputStream is) { - 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) { - for (int i = 0; i < (Integer)node.getAttributes(); i++) { - TypeHelpersProxy.write(node.getChildren()[0], os, Array.get(data, i)); - } - } - -} diff --git a/branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/BooleanTypeHelper.java b/branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/BooleanTypeHelper.java deleted file mode 100644 index 87d3e93d22..0000000000 --- a/branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/BooleanTypeHelper.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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.util; - -import org.apache.tuscany.sca.binding.corba.impl.types.TypeTreeNode; -import org.omg.CORBA.portable.InputStream; -import org.omg.CORBA.portable.OutputStream; - -/** - * @version $Rev$ $Date$ - */ -public class BooleanTypeHelper implements TypeHelper { - - public Object read(TypeTreeNode node, InputStream is) { - return is.read_boolean(); - } - - public void write(TypeTreeNode node, OutputStream os, Object data) { - os.write_boolean((Boolean)data); - } - -} diff --git a/branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/ByteTypeHelper.java b/branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/ByteTypeHelper.java deleted file mode 100644 index eb02f1cbcb..0000000000 --- a/branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/ByteTypeHelper.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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.util; - -import org.apache.tuscany.sca.binding.corba.impl.types.TypeTreeNode; -import org.omg.CORBA.portable.InputStream; -import org.omg.CORBA.portable.OutputStream; - -/** - * @version $Rev$ $Date$ - */ -public class ByteTypeHelper implements TypeHelper { - - public Object read(TypeTreeNode node, InputStream is) { - return is.read_octet(); - } - - public void write(TypeTreeNode node, OutputStream os, Object data) { - os.write_octet((Byte)data); - } - -} diff --git a/branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/CharTypeHelper.java b/branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/CharTypeHelper.java deleted file mode 100644 index 71f8fbfc47..0000000000 --- a/branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/CharTypeHelper.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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.util; - -import org.apache.tuscany.sca.binding.corba.impl.types.TypeTreeNode; -import org.omg.CORBA.portable.InputStream; -import org.omg.CORBA.portable.OutputStream; - -/** - * @version $Rev$ $Date$ - */ -public class CharTypeHelper implements TypeHelper { - - public Object read(TypeTreeNode node, InputStream is) { - return is.read_char(); - } - - public void write(TypeTreeNode node, OutputStream os, Object data) { - os.write_char((Character)data); - } - -} diff --git a/branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/DoubleTypeHelper.java b/branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/DoubleTypeHelper.java deleted file mode 100644 index c5019c5c0b..0000000000 --- a/branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/DoubleTypeHelper.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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.util; - -import org.apache.tuscany.sca.binding.corba.impl.types.TypeTreeNode; -import org.omg.CORBA.portable.InputStream; -import org.omg.CORBA.portable.OutputStream; - -/** - * @version $Rev$ $Date$ - */ -public class DoubleTypeHelper implements TypeHelper { - - public Object read(TypeTreeNode node, InputStream is) { - return is.read_double(); - } - - public void write(TypeTreeNode node, OutputStream os, Object data) { - os.write_double((Double)data); - } - -} diff --git a/branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/EnumTypeHelper.java b/branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/EnumTypeHelper.java deleted file mode 100644 index 6220802ce6..0000000000 --- a/branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/EnumTypeHelper.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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.util; - -import java.lang.reflect.Method; -import java.util.logging.Level; -import java.util.logging.Logger; - -import org.apache.tuscany.sca.binding.corba.impl.types.TypeTreeNode; -import org.omg.CORBA.portable.InputStream; -import org.omg.CORBA.portable.OutputStream; - -/** - * @version $Rev$ $Date$ - */ -public class EnumTypeHelper implements TypeHelper { - - private static final Logger logger = Logger.getLogger(EnumTypeHelper.class.getName()); - - public Object read(TypeTreeNode node, InputStream is) { - int value = is.read_long(); - Object result = null; - try { - Method method = node.getJavaClass().getMethod("from_int", new Class[] {int.class}); - result = method.invoke(null, new Object[] {value}); - } catch (Exception e) { - logger.log(Level.WARNING, "Exception during reading CORBA enum data", e); - e.printStackTrace(); - } - return result; - } - - public void write(TypeTreeNode node, OutputStream os, Object data) { - int value = 0; - try { - Method method = data.getClass().getMethod("value", new Class[] {}); - value = (Integer)method.invoke(data, new Object[] {}); - } catch (Exception e) { - logger.log(Level.WARNING, "Exception during writing CORBA enum data", e); - } - os.write_long(value); - } -} diff --git a/branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/FloatTypeHelper.java b/branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/FloatTypeHelper.java deleted file mode 100644 index 3214f8b30d..0000000000 --- a/branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/FloatTypeHelper.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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.util; - -import org.apache.tuscany.sca.binding.corba.impl.types.TypeTreeNode; -import org.omg.CORBA.portable.InputStream; -import org.omg.CORBA.portable.OutputStream; - -/** - * @version $Rev$ $Date$ - */ -public class FloatTypeHelper implements TypeHelper { - - public Object read(TypeTreeNode node, InputStream is) { - return is.read_float(); - } - - public void write(TypeTreeNode node, OutputStream os, Object data) { - os.write_float((Float)data); - } - -} diff --git a/branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/IntTypeHelper.java b/branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/IntTypeHelper.java deleted file mode 100644 index b11175064c..0000000000 --- a/branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/IntTypeHelper.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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.util; - -import org.apache.tuscany.sca.binding.corba.impl.types.TypeTreeNode; -import org.omg.CORBA.portable.InputStream; -import org.omg.CORBA.portable.OutputStream; - -/** - * @version $Rev$ $Date$ - */ -public class IntTypeHelper implements TypeHelper { - - public Object read(TypeTreeNode node, InputStream is) { - return is.read_long(); - } - - public void write(TypeTreeNode node, OutputStream os, Object data) { - os.write_long((Integer)data); - } - -} diff --git a/branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/LongTypeHelper.java b/branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/LongTypeHelper.java deleted file mode 100644 index 7b4300a1da..0000000000 --- a/branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/LongTypeHelper.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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.util; - -import org.apache.tuscany.sca.binding.corba.impl.types.TypeTreeNode; -import org.omg.CORBA.portable.InputStream; -import org.omg.CORBA.portable.OutputStream; - -/** - * @version $Rev$ $Date$ - */ -public class LongTypeHelper implements TypeHelper { - - public Object read(TypeTreeNode node, InputStream is) { - return is.read_longlong(); - } - - public void write(TypeTreeNode node, OutputStream os, Object data) { - os.write_longlong((Long)data); - } - -} diff --git a/branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/ReferenceTypeHelper.java b/branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/ReferenceTypeHelper.java deleted file mode 100644 index 4e0c2893d2..0000000000 --- a/branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/ReferenceTypeHelper.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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.util; - -import org.apache.tuscany.sca.binding.corba.impl.reference.InterfaceInstanceCreator; -import org.apache.tuscany.sca.binding.corba.impl.types.TypeTreeNode; -import org.omg.CORBA.Object; -import org.omg.CORBA.portable.InputStream; -import org.omg.CORBA.portable.OutputStream; - -/** - * @version $Rev$ $Date$ - */ -public class ReferenceTypeHelper implements TypeHelper { - - public java.lang.Object read(TypeTreeNode node, InputStream is) { - Object reference = is.read_Object(); - return (java.lang.Object)InterfaceInstanceCreator.createInstance(reference, node.getJavaClass()); - } - - public void write(TypeTreeNode node, OutputStream os, java.lang.Object data) { - os.write_Object((Object)data); - } - -} diff --git a/branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/SequenceTypeHelper.java b/branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/SequenceTypeHelper.java deleted file mode 100644 index 5862838cd5..0000000000 --- a/branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/SequenceTypeHelper.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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.util; - -import java.lang.reflect.Array; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.apache.tuscany.sca.binding.corba.impl.types.TypeTreeNode; -import org.omg.CORBA.portable.InputStream; -import org.omg.CORBA.portable.OutputStream; - -/** - * @version $Rev$ $Date$ - */ -public class SequenceTypeHelper implements TypeHelper { - - public Object read(TypeTreeNode node, InputStream is) { - Object sequence = null; - try { - int size = is.read_long(); - sequence = Array.newInstance(node.getChildren()[0].getJavaClass(), size); - for (int i = 0; i < size; i++) { - Array.set(sequence, i, TypeHelpersProxy.read(node.getChildren()[0], is)); - } - } catch (Exception e) { - e.printStackTrace(); - } - return sequence; - } - - public void write(TypeTreeNode node, OutputStream os, Object data) { - int sum = 0; - // determine length of array - List array = new ArrayList(); - while (true) { - try { - array.add(Array.get(data, sum)); - sum++; - } catch (ArrayIndexOutOfBoundsException e) { - break; - } - } - os.write_long(sum); - Iterator iter = array.iterator(); - while (iter.hasNext()) { - Object elem = iter.next(); - TypeHelpersProxy.write(node.getChildren()[0], os, elem); - } - - } -} diff --git a/branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/ShortTypeHelper.java b/branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/ShortTypeHelper.java deleted file mode 100644 index 9130db65e4..0000000000 --- a/branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/ShortTypeHelper.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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.util; - -import org.apache.tuscany.sca.binding.corba.impl.types.TypeTreeNode; -import org.omg.CORBA.portable.InputStream; -import org.omg.CORBA.portable.OutputStream; - -/** - * @version $Rev$ $Date$ - */ -public class ShortTypeHelper implements TypeHelper { - - public Object read(TypeTreeNode node, InputStream is) { - return is.read_short(); - } - - public void write(TypeTreeNode node, OutputStream os, Object data) { - os.write_short((Short)data); - } - -} diff --git a/branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/StringTypeHelper.java b/branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/StringTypeHelper.java deleted file mode 100644 index 4d782efcc5..0000000000 --- a/branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/StringTypeHelper.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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.util; - -import org.apache.tuscany.sca.binding.corba.impl.types.TypeTreeNode; -import org.omg.CORBA.portable.InputStream; -import org.omg.CORBA.portable.OutputStream; - -/** - * @version $Rev$ $Date$ - */ -public class StringTypeHelper implements TypeHelper { - - public Object read(TypeTreeNode node, InputStream is) { - return is.read_string(); - } - - public void write(TypeTreeNode node, OutputStream os, Object data) { - os.write_string((String)data); - } - -} diff --git a/branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/StructTypeHelper.java b/branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/StructTypeHelper.java deleted file mode 100644 index 365d62fb73..0000000000 --- a/branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/StructTypeHelper.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * 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.util; - -import java.lang.reflect.Field; -import java.util.logging.Level; -import java.util.logging.Logger; - -import org.apache.tuscany.sca.binding.corba.impl.types.TypeTreeNode; -import org.omg.CORBA.portable.InputStream; -import org.omg.CORBA.portable.OutputStream; - -/** - * @version $Rev$ $Date$ - */ -public class StructTypeHelper implements TypeHelper { - - private static final Logger logger = Logger.getLogger(StructTypeHelper.class.getName()); - - public Object read(TypeTreeNode node, InputStream is) { - TypeTreeNode[] children = node.getChildren(); - Object result = null; - if (children != null) { - try { - result = node.getJavaClass().newInstance(); - for (int i = 0; i < children.length; i++) { - Object childResult = TypeHelpersProxy.read(children[i], is); - Field childField = result.getClass().getField(children[i].getName()); - childField.set(result, childResult); - } - } catch (Exception e) { - logger.log(Level.WARNING, "Exception during reading CORBA struct data", e); - } - } - return result; - } - - public void write(TypeTreeNode node, OutputStream os, Object data) { - TypeTreeNode[] children = node.getChildren(); - if (children != null) { - try { - for (int i = 0; i < children.length; i++) { - Field childField = node.getJavaClass().getField(children[i].getName()); - TypeHelpersProxy.write(children[i], os, childField.get(data)); - } - } catch (Exception e) { - logger.log(Level.WARNING, "Exception during writing CORBA struct data", e); - } - } - } - -} diff --git a/branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/TypeHelper.java b/branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/TypeHelper.java deleted file mode 100644 index c9d0dd263f..0000000000 --- a/branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/TypeHelper.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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.util; - -import org.apache.tuscany.sca.binding.corba.impl.types.TypeTreeNode; -import org.omg.CORBA.portable.InputStream; -import org.omg.CORBA.portable.OutputStream; - -/** - * @version $Rev$ $Date$ - */ -public interface TypeHelper { - - /** - * Reads CORBA object - * @param node - * @param is - * @return - */ - Object read(TypeTreeNode node, InputStream is); - - /** - * Writes CORBA object - * @param node - * @param os - * @param data - */ - void write(TypeTreeNode node, OutputStream os, Object data); - -} diff --git a/branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/TypeHelpersProxy.java b/branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/TypeHelpersProxy.java deleted file mode 100644 index 72e4ccc6fb..0000000000 --- a/branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/TypeHelpersProxy.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * 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.util; - -import java.util.HashMap; -import java.util.Map; - -import org.apache.tuscany.sca.binding.corba.impl.types.NodeType; -import org.apache.tuscany.sca.binding.corba.impl.types.TypeTreeNode; -import org.omg.CORBA.portable.InputStream; -import org.omg.CORBA.portable.OutputStream; - -/** - * @version $Rev$ $Date$ - * Proxies getType(), write(), read() methods to appropriate TypeHelper implementation. - */ -public class TypeHelpersProxy { - - /** - * Maps primitive types to its TypeHelper implementations - */ - private static Map, TypeHelper> primitiveTypes = null; - - /** - * Maps other types to its TypeHelper implementations - */ - private static Map complexTypes = null; - - static { - // initiate type helpers - primitiveTypes = new HashMap, TypeHelper>(); - complexTypes = new HashMap(); - - primitiveTypes.put(boolean.class, new BooleanTypeHelper()); - primitiveTypes.put(char.class, new CharTypeHelper()); - primitiveTypes.put(byte.class, new ByteTypeHelper()); - primitiveTypes.put(short.class, new ShortTypeHelper()); - primitiveTypes.put(int.class, new IntTypeHelper()); - primitiveTypes.put(long.class, new LongTypeHelper()); - primitiveTypes.put(float.class, new FloatTypeHelper()); - primitiveTypes.put(double.class, new DoubleTypeHelper()); - primitiveTypes.put(String.class, new StringTypeHelper()); - primitiveTypes.put(Boolean.class, primitiveTypes.get(boolean.class)); - primitiveTypes.put(Character.class, primitiveTypes.get(char.class)); - primitiveTypes.put(Byte.class, primitiveTypes.get(byte.class)); - primitiveTypes.put(Short.class, primitiveTypes.get(short.class)); - primitiveTypes.put(Integer.class, primitiveTypes.get(int.class)); - primitiveTypes.put(Long.class, primitiveTypes.get(long.class)); - primitiveTypes.put(Float.class, primitiveTypes.get(float.class)); - primitiveTypes.put(Double.class, primitiveTypes.get(double.class)); - primitiveTypes.put(String.class, primitiveTypes.get(String.class)); - complexTypes.put(NodeType.array, new ArrayTypeHelper()); - complexTypes.put(NodeType.struct, new StructTypeHelper()); - complexTypes.put(NodeType.reference, new ReferenceTypeHelper()); - complexTypes.put(NodeType.sequence, new SequenceTypeHelper()); - complexTypes.put(NodeType.idl_enum, new EnumTypeHelper()); - complexTypes.put(NodeType.exception, new StructTypeHelper()); - complexTypes.put(NodeType.union, new UnionTypeHelper()); - } - - /** - * Gets type helper basing on given type - * - * @param node - * @return - */ - private static TypeHelper getTypeHelper(TypeTreeNode node) { - TypeHelper typeHelper = null; - NodeType type = node.getNodeType(); - if (type.equals(NodeType.primitive)) { - typeHelper = primitiveTypes.get(node.getJavaClass()); - } else { - typeHelper = complexTypes.get(type); - } - return typeHelper; - } - - /** - * Proxies read method invocation to appropriate TypeHelper implementation. - * - * @param node - * @param is - * @return - */ - public static final Object read(TypeTreeNode node, InputStream is) { - TypeHelper helper = getTypeHelper(node); - return helper.read(node, is); - } - - /** - * Proxies write method invocation to appropriate TypeHelper implementation. - * - * @param node - * @param os - * @param data - */ - public static final void write(TypeTreeNode node, OutputStream os, Object data) { - TypeHelper helper = getTypeHelper(node); - helper.write(node, os, data); - } - -} diff --git a/branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/UnionTypeHelper.java b/branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/UnionTypeHelper.java deleted file mode 100644 index 66c928acec..0000000000 --- a/branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/UnionTypeHelper.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * 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.util; - -import java.lang.reflect.Field; -import java.util.logging.Level; -import java.util.logging.Logger; - -import org.apache.tuscany.sca.binding.corba.impl.types.TypeTreeNode; -import org.apache.tuscany.sca.binding.corba.impl.types.UnionAttributes; -import org.omg.CORBA.portable.InputStream; -import org.omg.CORBA.portable.OutputStream; - -/** - * @version $Rev$ $Date$ - */ -public class UnionTypeHelper implements TypeHelper { - - private static final Logger logger = Logger.getLogger(UnionTypeHelper.class.getName()); - - public Object read(TypeTreeNode node, InputStream is) { - Object result = null; - try { - int discriminator = is.read_long(); - UnionAttributes attrs = (UnionAttributes)node.getAttributes(); - String childName = attrs.getOptionsMapping().get(discriminator); - if (childName == null) { - // get default if option numbers field not found - childName = attrs.getDefaultOptionName(); - } - result = node.getJavaClass().newInstance(); - Field discField = result.getClass().getDeclaredField(attrs.getDiscriminatorName()); - discField.setAccessible(true); - discField.set(result, discriminator); - for (int i = 0; i < node.getChildren().length; i++) { - if (node.getChildren()[i].getName().equals(childName)) { - Object unionValue = TypeHelpersProxy.read(node.getChildren()[i], is); - Field childField = result.getClass().getDeclaredField(childName); - childField.setAccessible(true); - childField.set(result, unionValue); - break; - } - } - } catch (Exception e) { - logger.log(Level.WARNING, "Exception during reading CORBA union data", e); - } - return result; - } - - public void write(TypeTreeNode node, OutputStream os, Object data) { - try { - UnionAttributes attrs = (UnionAttributes)node.getAttributes(); - Field discriminatorField = data.getClass().getDeclaredField(attrs.getDiscriminatorName()); - discriminatorField.setAccessible(true); - int discriminator = discriminatorField.getInt(data); - os.write_long(discriminator); - String childName = attrs.getOptionsMapping().get(discriminator); - if (childName == null) { - // get default if option numbers field not found - childName = attrs.getDefaultOptionName(); - } - for (int i = 0; i < node.getChildren().length; i++) { - if (node.getChildren()[i].getName().equals(childName)) { - Field childField = data.getClass().getDeclaredField(childName); - childField.setAccessible(true); - TypeHelpersProxy.write(node.getChildren()[i], os, childField.get(data)); - break; - } - } - } catch (Exception e) { - logger.log(Level.WARNING, "Exception during writing CORBA union data", e); - } - } - -} diff --git a/branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/Utils.java b/branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/Utils.java deleted file mode 100644 index 68f71b7169..0000000000 --- a/branches/sca-java-1.4/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/Utils.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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.util; - -/** - * @version $Rev$ $Date$ - * Class for type utilities - */ -public class Utils { - - /** - * Creates CORBA id for Java class - * @param forClass - * @return - */ - public static String getTypeId(Class forClass) { - String result = forClass.getName().replace('.', '/'); - result = result.replaceAll("Package", ""); - result = "IDL:" + result + ":1.0"; - return result; - } - -} -- cgit v1.2.3