summaryrefslogtreecommitdiffstats
path: root/java/sca/modules/binding-corba-runtime/src
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2008-07-22 16:01:38 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2008-07-22 16:01:38 +0000
commit71b9f42ceb8dcf0c5a510a3a5909211d75bdb145 (patch)
tree6c64d16d8f438a89501f05a6faa27ea63206fa6c /java/sca/modules/binding-corba-runtime/src
parent273d7efc7b7c1e35609fee005fb9ef97c4f3e53f (diff)
Apply the patch from Wojtek for TUSCANY-2469. Thanks.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@678786 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/binding-corba-runtime/src')
-rw-r--r--java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaInvoker.java6
-rw-r--r--java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaReferenceBindingProvider.java2
-rw-r--r--java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/reference/DynaCorbaRequest.java22
-rw-r--r--java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/service/DynaCorbaServant.java30
-rw-r--r--java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/TypeTreeCreator.java36
5 files changed, 78 insertions, 18 deletions
diff --git a/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaInvoker.java b/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaInvoker.java
index f1640329e8..58fda9919a 100644
--- a/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaInvoker.java
+++ b/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaInvoker.java
@@ -39,11 +39,13 @@ public class CorbaInvoker implements Invoker {
private Object remoteObject;
private Class<?> referenceClass;
private Map<Method, String> operationsMap;
+ private boolean scaBindingRules;
- public CorbaInvoker(Object remoteObject, Class<?> referenceClass, Map<Method, String> operationsMap) {
+ public CorbaInvoker(Object remoteObject, Class<?> referenceClass, Map<Method, String> operationsMap, boolean scaBindingRules) {
this.remoteObject = remoteObject;
this.referenceClass = referenceClass;
this.operationsMap = operationsMap;
+ this.scaBindingRules = scaBindingRules;
}
/**
@@ -51,7 +53,7 @@ public class CorbaInvoker implements Invoker {
*/
public Message invoke(Message msg) {
try {
- DynaCorbaRequest request = new DynaCorbaRequest(remoteObject, msg.getOperation().getName());
+ DynaCorbaRequest request = new DynaCorbaRequest(remoteObject, msg.getOperation().getName(), scaBindingRules);
request.setReferenceClass(referenceClass);
request.setOperationsMap(operationsMap);
if (msg.getOperation().getOutputType() != null) {
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 3eb665d599..e04eb290fd 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
@@ -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(remoteObject, referenceClass, operationsMap, false);
} catch (Exception e) {
}
return null;
diff --git a/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/reference/DynaCorbaRequest.java b/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/reference/DynaCorbaRequest.java
index f4f82c9b88..dba3dd7b1e 100644
--- a/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/reference/DynaCorbaRequest.java
+++ b/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/reference/DynaCorbaRequest.java
@@ -55,14 +55,28 @@ public class DynaCorbaRequest {
private List<TypeTree> argumentsTypes = new ArrayList<TypeTree>();
private Class<?> referenceClass;
private Map<Method, String> operationsMap;
+ private boolean scaBindingRules;
/**
+ * Creates request with CORBA binding mapping rules in default
+ *
+ * @param remoteObject object reference
+ * @param operation operation to invoke
+ */
+ public DynaCorbaRequest(Object remoteObject, String operation) {
+ // use CORBA binding rules by default
+ this(remoteObject, operation, false);
+ }
+
+ /**
* Creates request.
*
* @param ObjectremoteObject remote object reference
* @param operation operation to invoke
+ * @param scaBindingRules apply SCA default binding mapping rules
*/
- public DynaCorbaRequest(Object remoteObject, String operation) {
+ public DynaCorbaRequest(Object remoteObject, String operation, boolean scaBindingRules) {
+ this.scaBindingRules = scaBindingRules;
this.remoteObject = (ObjectImpl)remoteObject;
this.operation = operation;
}
@@ -89,7 +103,7 @@ public class DynaCorbaRequest {
* @param argument
*/
public void addArgument(java.lang.Object argument) throws RequestConfigurationException {
- TypeTree tree = TypeTreeCreator.createTypeTree(argument.getClass());
+ TypeTree tree = TypeTreeCreator.createTypeTree(argument.getClass(), scaBindingRules);
argumentsTypes.add(tree);
arguments.add(argument);
}
@@ -113,7 +127,7 @@ public class DynaCorbaRequest {
* @param forClass
*/
public void setOutputType(Class<?> forClass) throws RequestConfigurationException {
- returnTree = TypeTreeCreator.createTypeTree(forClass);
+ returnTree = TypeTreeCreator.createTypeTree(forClass, scaBindingRules);
}
/**
@@ -122,7 +136,7 @@ public class DynaCorbaRequest {
* @param forClass
*/
public void addExceptionType(Class<?> forClass) throws RequestConfigurationException {
- TypeTree tree = TypeTreeCreator.createTypeTree(forClass);
+ TypeTree tree = TypeTreeCreator.createTypeTree(forClass, scaBindingRules);
String exceptionId = Utils.getTypeId(forClass);
exceptions.put(exceptionId, tree);
}
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 6c7e2b1238..0d9d33b198 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
@@ -56,8 +56,30 @@ public class DynaCorbaServant extends ObjectImpl implements InvokeHandler {
private Class<?> javaClass;
private Map<String, Method> operationsMap;
private Map<Method, Operation> methodOperationMapping;
-
+ private boolean scaBindingRules;
+
+ /**
+ * Creates servant with CORBA binding mapping rules in default
+ *
+ * @param service backed service
+ * @param binding binding object
+ * @throws RequestConfigurationException
+ */
public DynaCorbaServant(RuntimeComponentService service, Binding binding) throws RequestConfigurationException {
+ // use CORBA binding rules by default
+ this(service, binding, false);
+ }
+
+ /**
+ * Creates servant object
+ *
+ * @param service backed service
+ * @param binding binding object
+ * @param scaBindingRules apply SCA default binding mapping rules
+ * @throws RequestConfigurationException
+ */
+ public DynaCorbaServant(RuntimeComponentService service, Binding binding, boolean scaBindingRules) throws RequestConfigurationException {
+ this.scaBindingRules = scaBindingRules;
this.service = service;
this.binding = binding;
this.javaClass = ((JavaInterface)service.getInterfaceContract().getInterface()).getJavaClass();
@@ -114,14 +136,14 @@ public class DynaCorbaServant extends ObjectImpl implements InvokeHandler {
// cache output type tree
if (operation.getOutputType() != null && operation.getOutputType().getPhysical() != null
&& !operation.getOutputType().getPhysical().equals(void.class)) {
- TypeTree outputType = TypeTreeCreator.createTypeTree(operation.getOutputType().getPhysical());
+ TypeTree outputType = TypeTreeCreator.createTypeTree(operation.getOutputType().getPhysical(), scaBindingRules);
operationTypes.setOutputType(outputType);
}
// cache input types trees
if (operation.getInputType() != null) {
for (DataType<List<DataType>> type : operation.getInputType().getLogical()) {
Class<?> forClass = type.getPhysical();
- TypeTree inputType = TypeTreeCreator.createTypeTree(forClass);
+ TypeTree inputType = TypeTreeCreator.createTypeTree(forClass, scaBindingRules);
inputInstances.add(inputType);
}
@@ -185,7 +207,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, scaBindingRules);
String exceptionId = Utils.getTypeId(exceptionClass);
out.write_string(exceptionId);
TypeHelpersProxy.write(tree.getRootNode(), out, ie.getTargetException());
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 4a24e66778..658993f486 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
@@ -142,10 +142,10 @@ public class TypeTreeCreator {
* @param forClass
* @return type tree
*/
- public static TypeTree createTypeTree(Class<?> forClass) throws RequestConfigurationException {
+ public static TypeTree createTypeTree(Class<?> forClass, boolean scaBindingRules) throws RequestConfigurationException {
TypeTree tree = new TypeTree();
TypeTreeNode rootNode = null;
- rootNode = inspectClassHierarchy(forClass, tree);
+ rootNode = inspectClassHierarchy(forClass, tree, scaBindingRules);
tree.setRootNode(rootNode);
return tree;
@@ -158,7 +158,7 @@ public class TypeTreeCreator {
* @param tree
* @return
*/
- private static TypeTreeNode inspectClassHierarchy(Class<?> forClass, TypeTree tree)
+ private static TypeTreeNode inspectClassHierarchy(Class<?> forClass, TypeTree tree, boolean scaBindingRules)
throws RequestConfigurationException {
// //remains of type tree caching
// TypeTreeNode existingNode = tree.getNodeForType(forClass);
@@ -166,7 +166,13 @@ public class TypeTreeCreator {
// return existingNode;
// }
- TypeTreeNode node = createTypeNode(forClass);
+ TypeTreeNode node = null;
+ if (scaBindingRules) {
+ node = createTypeNode4ScaBinding(forClass);
+ } else {
+ node = createTypeNode4CorbaBinding(forClass);
+ }
+
NodeType nodeType = node.getNodeType();
TypeTreeNode[] children = null;
@@ -182,14 +188,14 @@ public class TypeTreeCreator {
// reducing sequence dimension
Class<?> reduced = reduceArrayDimension(node.getJavaClass());
children = new TypeTreeNode[1];
- children[0] = inspectClassHierarchy(reduced, tree);
+ children[0] = inspectClassHierarchy(reduced, tree, scaBindingRules);
} 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);
+ TypeTreeNode child = inspectClassHierarchy(field, tree, scaBindingRules);
child.setName(fields[i].getName());
children[i] = child;
}
@@ -213,7 +219,7 @@ public class TypeTreeCreator {
* @return node
* @throws RequestConfigurationException
*/
- private static TypeTreeNode createTypeNode(Class<?> forClass) throws RequestConfigurationException {
+ private static TypeTreeNode createTypeNode4CorbaBinding(Class<?> forClass) throws RequestConfigurationException {
TypeTreeNode node = new TypeTreeNode();
if (forClass.isArray()) {
node.setNodeType(NodeType.sequence);
@@ -243,6 +249,22 @@ public class TypeTreeCreator {
}
return node;
}
+
+ private static TypeTreeNode createTypeNode4ScaBinding(Class<?> forClass) throws RequestConfigurationException {
+ TypeTreeNode node = new TypeTreeNode();
+ if (forClass.isArray()) {
+ node.setNodeType(NodeType.sequence);
+ node.setJavaClass(forClass);
+ } else if (primitives.contains(forClass)) {
+ node.setNodeType(NodeType.primitive);
+ node.setJavaClass(forClass);
+ node.setChildren(null);
+ } else {
+ node.setNodeType(NodeType.struct);
+ node.setJavaClass(forClass);
+ }
+ return node;
+ }
/**
* Tells whether given class is structure