summaryrefslogtreecommitdiffstats
path: root/java/sca/modules/binding-corba-runtime/src/main
diff options
context:
space:
mode:
authorwjaniszewski <wjaniszewski@13f79535-47bb-0310-9956-ffa450edef68>2008-08-17 21:26:26 +0000
committerwjaniszewski <wjaniszewski@13f79535-47bb-0310-9956-ffa450edef68>2008-08-17 21:26:26 +0000
commit7d05fe8fd909c342fe796afcc811639d4aaab55c (patch)
tree196a219719049668c773ca35f6baf78afa3c6a36 /java/sca/modules/binding-corba-runtime/src/main
parentf569b5942734441fa59f478b2a3be7382437f2ff (diff)
Added support for CORBA unions
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@686643 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/binding-corba-runtime/src/main')
-rw-r--r--java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaReferenceBindingProvider.java4
-rw-r--r--java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/service/DynaCorbaServant.java11
-rw-r--r--java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/TypeTreeCreator.java104
-rw-r--r--java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/UnionAttributes.java59
-rw-r--r--java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/EnumTypeHelper.java9
-rw-r--r--java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/StructTypeHelper.java10
-rw-r--r--java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/TypeHelpersProxy.java1
-rw-r--r--java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/UnionTypeHelper.java92
-rw-r--r--java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/meta/CorbaUnionElement.java37
-rw-r--r--java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/meta/CorbaUnionElementType.java28
10 files changed, 339 insertions, 16 deletions
diff --git a/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaReferenceBindingProvider.java b/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaReferenceBindingProvider.java
index 5b43e6108f..2e2fea6c54 100644
--- a/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaReferenceBindingProvider.java
+++ b/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaReferenceBindingProvider.java
@@ -21,6 +21,8 @@ package org.apache.tuscany.sca.binding.corba.impl;
import java.lang.reflect.Method;
import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import org.apache.tuscany.sca.binding.corba.CorbaBinding;
import org.apache.tuscany.sca.binding.corba.impl.util.OperationMapper;
@@ -38,6 +40,7 @@ import org.omg.CORBA.Object;
*/
public class CorbaReferenceBindingProvider implements ReferenceBindingProvider {
+ private static final Logger logger = Logger.getLogger(CorbaServiceBindingProvider.class.getName());
private CorbaBinding binding;
private CorbaHost host;
private RuntimeComponentReference reference;
@@ -63,6 +66,7 @@ public class CorbaReferenceBindingProvider implements ReferenceBindingProvider {
}
return new CorbaInvoker(reference, remoteObject, referenceClass, operationsMap);
} catch (Exception e) {
+ logger.log(Level.WARNING, "Exception during creating CORBA invoker", e);
}
return null;
}
diff --git a/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/service/DynaCorbaServant.java b/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/service/DynaCorbaServant.java
index 5328abd9bb..2a032f5d25 100644
--- a/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/service/DynaCorbaServant.java
+++ b/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/service/DynaCorbaServant.java
@@ -21,6 +21,8 @@ package org.apache.tuscany.sca.binding.corba.impl.service;
import java.util.ArrayList;
import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import org.apache.tuscany.sca.binding.corba.impl.exceptions.RequestConfigurationException;
import org.apache.tuscany.sca.binding.corba.impl.types.TypeTree;
@@ -40,6 +42,8 @@ import org.omg.CORBA.portable.ResponseHandler;
*/
public class DynaCorbaServant extends ObjectImpl implements InvokeHandler {
+ private static final Logger logger = Logger.getLogger(DynaCorbaServant.class.getName());
+
private String[] ids;
private InvocationProxy invocationProxy;
private String typeId;
@@ -109,13 +113,10 @@ public class DynaCorbaServant extends ObjectImpl implements InvokeHandler {
TypeHelpersProxy.write(tree.getRootNode(), out, ie.getTargetException());
return out;
} catch (Exception e) {
- // TODO: raise remote exception - exception while handling
- // target exception
- e.printStackTrace();
+ logger.log(Level.WARNING, "Exception during handling invocation exception", e);
}
} catch (Exception e) {
- // TODO: raise remote exception
- e.printStackTrace();
+ logger.log(Level.WARNING, "Unexpected exception during sending CORBA result to client", e);
}
}
return null;
diff --git a/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/TypeTreeCreator.java b/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/TypeTreeCreator.java
index 621d5fa30b..e8441ed177 100644
--- a/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/TypeTreeCreator.java
+++ b/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/TypeTreeCreator.java
@@ -32,6 +32,8 @@ import java.util.Set;
import org.apache.tuscany.sca.binding.corba.impl.exceptions.RequestConfigurationException;
import org.apache.tuscany.sca.binding.corba.meta.CorbaArray;
+import org.apache.tuscany.sca.binding.corba.meta.CorbaUnionElement;
+import org.apache.tuscany.sca.binding.corba.meta.CorbaUnionElementType;
/**
* @version $Rev$ $Date$
@@ -137,6 +139,7 @@ public class TypeTreeCreator {
/**
* Return given array without first element
+ *
* @param array
* @return
*/
@@ -147,7 +150,9 @@ public class TypeTreeCreator {
}
/**
- * Converts objects annotations to structure which will be used by this class
+ * Converts objects annotations to structure which will be used by this
+ * class
+ *
* @param notes
* @return
*/
@@ -222,7 +227,16 @@ public class TypeTreeCreator {
} else if (nodeType.equals(NodeType.idl_enum)) {
} else if (nodeType.equals(NodeType.union)) {
- // TODO: unions
+ // inspect types for every structure member
+ Field[] fields = node.getJavaClass().getDeclaredFields();
+ children = new TypeTreeNode[fields.length];
+ for (int i = 0; i < fields.length; i++) {
+ Class<?> field = fields[i].getType();
+ AnnotationAttributes fAttrs = createAnnotationAttributes(fields[i].getAnnotations());
+ TypeTreeNode child = inspectClassHierarchy(field, fAttrs, tree);
+ child.setName(fields[i].getName());
+ children[i] = child;
+ }
} else if (nodeType.equals(NodeType.reference)) {
// TODO: CORBA references
}
@@ -255,7 +269,6 @@ public class TypeTreeCreator {
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);
@@ -273,6 +286,10 @@ public class TypeTreeCreator {
} else if (isUserException(forClass)) {
node.setNodeType(NodeType.exception);
node.setJavaClass(forClass);
+ } else if (isUnionType(forClass)) {
+ node.setNodeType(NodeType.union);
+ node.setJavaClass(forClass);
+ node.setAttributes(getUnionAttributes(forClass));
} else {
RequestConfigurationException e =
new RequestConfigurationException("User defined type which cannot be handled: " + forClass
@@ -382,7 +399,7 @@ public class TypeTreeCreator {
}
/**
- * Tells whether given class is corba user exception
+ * Tells whether given class is CORBA user exception
*
* @param forClass
* @return
@@ -398,4 +415,83 @@ public class TypeTreeCreator {
return false;
}
+ /**
+ * Tells whether given class is CORBA union. This method validates usage of
+ * unions annotations.
+ *
+ * @param forClass
+ * @return
+ * @throws RequestConfigurationException
+ */
+ private static boolean isUnionType(Class<?> forClass) throws RequestConfigurationException {
+ int classMods = forClass.getModifiers();
+ if (!Modifier.isFinal(classMods)) {
+ return false;
+ }
+ boolean atLeastOneOption = false;
+ boolean discriminatorPresent = false;
+ for (int i = 0; i < forClass.getDeclaredFields().length; i++) {
+ CorbaUnionElement note = forClass.getDeclaredFields()[i].getAnnotation(CorbaUnionElement.class);
+ if (note != null) {
+ int fieldMod = forClass.getDeclaredFields()[i].getModifiers();
+ if (Modifier.isPrivate(fieldMod) && !Modifier.isFinal(fieldMod) && !Modifier.isStatic(fieldMod)) {
+ if (note.type().equals(CorbaUnionElementType.discriminator)) {
+ if (discriminatorPresent) {
+ throw new RequestConfigurationException(
+ "More than one discriminators declared on: " + forClass);
+ }
+ discriminatorPresent = true;
+ } else {
+ atLeastOneOption = true;
+ }
+ } else {
+ throw new RequestConfigurationException(
+ "Annotated union field should be private, not final and no static on class: " + forClass);
+ }
+ }
+ }
+ if (atLeastOneOption && !discriminatorPresent) {
+ throw new RequestConfigurationException("No discriminator annotation found on: " + forClass);
+ } else if (!atLeastOneOption && discriminatorPresent) {
+ throw new RequestConfigurationException("No union option found on: " + forClass);
+ } else if (discriminatorPresent && atLeastOneOption) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Gets union attributes - discriminator field name, option fields etc. This
+ * method relies that previously scanned class is valid (method isUnionType)
+ *
+ * @param forClass
+ * @return
+ * @throws RequestConfigurationException
+ */
+ private static UnionAttributes getUnionAttributes(Class<?> forClass) throws RequestConfigurationException {
+ UnionAttributes attributes = new UnionAttributes();
+ for (int i = 0; i < forClass.getDeclaredFields().length; i++) {
+ CorbaUnionElement note = forClass.getDeclaredFields()[i].getAnnotation(CorbaUnionElement.class);
+ if (note != null) {
+ if (note.type().equals(CorbaUnionElementType.discriminator)) {
+ attributes.setDiscriminatorName(forClass.getDeclaredFields()[i].getName());
+ } else if (note.type().equals(CorbaUnionElementType.defaultOption)) {
+ attributes.setDefaultOptionName(forClass.getDeclaredFields()[i].getName());
+ } else if (note.type().equals(CorbaUnionElementType.option)) {
+ if (attributes.getOptionsMapping().containsKey(note.optionNumber())) {
+ throw new RequestConfigurationException("In " + forClass
+ + ": field \""
+ + forClass.getDeclaredFields()[i].getName()
+ + "\" uses already used option id: "
+ + note.optionNumber());
+ } else {
+ attributes.getOptionsMapping().put(note.optionNumber(),
+ forClass.getDeclaredFields()[i].getName());
+ }
+ }
+ }
+ }
+ return attributes;
+ }
}
diff --git a/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/UnionAttributes.java b/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/UnionAttributes.java
new file mode 100644
index 0000000000..df6358d118
--- /dev/null
+++ b/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/UnionAttributes.java
@@ -0,0 +1,59 @@
+/*
+ * 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;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @version $Rev$ $Date$
+ * Stores attributes for previously scanned CORBA union type
+ */
+public class UnionAttributes {
+
+ public String discriminatorName;
+ public String defaultOptionName;
+ public Map<Integer, String> optionsMapping = new HashMap<Integer, String>();
+
+ public String getDiscriminatorName() {
+ return discriminatorName;
+ }
+
+ public void setDiscriminatorName(String discriminatorName) {
+ this.discriminatorName = discriminatorName;
+ }
+
+ public String getDefaultOptionName() {
+ return defaultOptionName;
+ }
+
+ public void setDefaultOptionName(String defaultOptionName) {
+ this.defaultOptionName = defaultOptionName;
+ }
+
+ public Map<Integer, String> getOptionsMapping() {
+ return optionsMapping;
+ }
+
+ public void setOptionsMapping(Map<Integer, String> optionsMapping) {
+ this.optionsMapping = optionsMapping;
+ }
+
+}
diff --git a/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/EnumTypeHelper.java b/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/EnumTypeHelper.java
index dc45fde5e5..30c3ac3a8a 100644
--- a/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/EnumTypeHelper.java
+++ b/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/EnumTypeHelper.java
@@ -1,6 +1,8 @@
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;
@@ -11,6 +13,8 @@ import org.omg.CORBA.portable.OutputStream;
*/
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;
@@ -18,7 +22,7 @@ public class EnumTypeHelper implements TypeHelper {
Method method = node.getJavaClass().getMethod("from_int", new Class[] {int.class});
result = method.invoke(null, new Object[] {value});
} catch (Exception e) {
- // TODO Auto-generated catch block
+ logger.log(Level.WARNING, "Exception during reading CORBA enum data", e);
e.printStackTrace();
}
return result;
@@ -30,8 +34,7 @@ public class EnumTypeHelper implements TypeHelper {
Method method = data.getClass().getMethod("value", new Class[] {});
value = (Integer)method.invoke(data, new Object[] {});
} catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ logger.log(Level.WARNING, "Exception during writing CORBA enum data", e);
}
os.write_long(value);
}
diff --git a/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/StructTypeHelper.java b/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/StructTypeHelper.java
index a232fff56d..365d62fb73 100644
--- a/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/StructTypeHelper.java
+++ b/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/StructTypeHelper.java
@@ -20,6 +20,8 @@
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;
@@ -30,6 +32,8 @@ import org.omg.CORBA.portable.OutputStream;
*/
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;
@@ -42,8 +46,7 @@ public class StructTypeHelper implements TypeHelper {
childField.set(result, childResult);
}
} catch (Exception e) {
- // TODO: handle exception
- e.printStackTrace();
+ logger.log(Level.WARNING, "Exception during reading CORBA struct data", e);
}
}
return result;
@@ -58,8 +61,7 @@ public class StructTypeHelper implements TypeHelper {
TypeHelpersProxy.write(children[i], os, childField.get(data));
}
} catch (Exception e) {
- // TODO: handle exception
- e.printStackTrace();
+ logger.log(Level.WARNING, "Exception during writing CORBA struct data", e);
}
}
}
diff --git a/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/TypeHelpersProxy.java b/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/TypeHelpersProxy.java
index a14f311607..72e4ccc6fb 100644
--- a/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/TypeHelpersProxy.java
+++ b/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/TypeHelpersProxy.java
@@ -72,6 +72,7 @@ public class TypeHelpersProxy {
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());
}
/**
diff --git a/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/UnionTypeHelper.java b/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/UnionTypeHelper.java
new file mode 100644
index 0000000000..66c928acec
--- /dev/null
+++ b/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/UnionTypeHelper.java
@@ -0,0 +1,92 @@
+/*
+ * 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/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/meta/CorbaUnionElement.java b/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/meta/CorbaUnionElement.java
new file mode 100644
index 0000000000..101bda1ba2
--- /dev/null
+++ b/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/meta/CorbaUnionElement.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.corba.meta;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * @version $Rev$ $Date$ Declares CORBA union object
+ */
+@Retention(RetentionPolicy.RUNTIME)
+public @interface CorbaUnionElement {
+
+ // number of option in switch clause
+ int optionNumber() default -1;
+
+ // type of element
+ CorbaUnionElementType type();
+
+}
diff --git a/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/meta/CorbaUnionElementType.java b/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/meta/CorbaUnionElementType.java
new file mode 100644
index 0000000000..3a46fc2b5f
--- /dev/null
+++ b/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/meta/CorbaUnionElementType.java
@@ -0,0 +1,28 @@
+/*
+ * 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;
+
+/**
+ * @version $Rev$ $Date$
+ * Types for union element
+ */
+public enum CorbaUnionElementType {
+ discriminator, defaultOption, option;
+} \ No newline at end of file