binding-corba-runtime and binding-sca-corba modules cleanup

git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@686344 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
wjaniszewski 2008-08-15 19:33:17 +00:00
parent 2732a927f4
commit 1c22b82f37
8 changed files with 22 additions and 57 deletions

View file

@ -39,13 +39,11 @@ 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, boolean scaBindingRules) {
public CorbaInvoker(Object remoteObject, Class<?> referenceClass, Map<Method, String> operationsMap) {
this.remoteObject = remoteObject;
this.referenceClass = referenceClass;
this.operationsMap = operationsMap;
this.scaBindingRules = scaBindingRules;
}
/**
@ -53,7 +51,7 @@ public class CorbaInvoker implements Invoker {
*/
public Message invoke(Message msg) {
try {
DynaCorbaRequest request = new DynaCorbaRequest(remoteObject, msg.getOperation().getName(), scaBindingRules);
DynaCorbaRequest request = new DynaCorbaRequest(remoteObject, msg.getOperation().getName());
request.setReferenceClass(referenceClass);
request.setOperationsMap(operationsMap);
if (msg.getOperation().getOutputType() != null) {

View file

@ -61,7 +61,7 @@ public class CorbaReferenceBindingProvider implements ReferenceBindingProvider {
if (remoteObject == null) {
remoteObject = host.lookup(binding.getCorbaname());
}
return new CorbaInvoker(remoteObject, referenceClass, operationsMap, false);
return new CorbaInvoker(remoteObject, referenceClass, operationsMap);
} catch (Exception e) {
}
return null;

View file

@ -55,18 +55,6 @@ 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.
@ -75,8 +63,7 @@ public class DynaCorbaRequest {
* @param operation operation to invoke
* @param scaBindingRules apply SCA default binding mapping rules
*/
public DynaCorbaRequest(Object remoteObject, String operation, boolean scaBindingRules) {
this.scaBindingRules = scaBindingRules;
public DynaCorbaRequest(Object remoteObject, String operation) {
this.remoteObject = (ObjectImpl)remoteObject;
this.operation = operation;
}
@ -103,7 +90,7 @@ public class DynaCorbaRequest {
* @param argument
*/
public void addArgument(java.lang.Object argument) throws RequestConfigurationException {
TypeTree tree = TypeTreeCreator.createTypeTree(argument.getClass(), scaBindingRules);
TypeTree tree = TypeTreeCreator.createTypeTree(argument.getClass());
argumentsTypes.add(tree);
arguments.add(argument);
}
@ -127,7 +114,7 @@ public class DynaCorbaRequest {
* @param forClass
*/
public void setOutputType(Class<?> forClass) throws RequestConfigurationException {
returnTree = TypeTreeCreator.createTypeTree(forClass, scaBindingRules);
returnTree = TypeTreeCreator.createTypeTree(forClass);
}
/**
@ -136,7 +123,7 @@ public class DynaCorbaRequest {
* @param forClass
*/
public void addExceptionType(Class<?> forClass) throws RequestConfigurationException {
TypeTree tree = TypeTreeCreator.createTypeTree(forClass, scaBindingRules);
TypeTree tree = TypeTreeCreator.createTypeTree(forClass);
String exceptionId = Utils.getTypeId(forClass);
exceptions.put(exceptionId, tree);
}

View file

@ -108,14 +108,14 @@ public class ComponentInvocationProxy implements InvocationProxy {
if (operation.getOutputType() != null && operation.getOutputType().getPhysical() != null
&& !operation.getOutputType().getPhysical().equals(void.class)) {
TypeTree outputType =
TypeTreeCreator.createTypeTree(operation.getOutputType().getPhysical(), false);
TypeTreeCreator.createTypeTree(operation.getOutputType().getPhysical());
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, false);
TypeTree inputType = TypeTreeCreator.createTypeTree(forClass);
inputInstances.add(inputType);
}

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, false);
TypeTree tree = TypeTreeCreator.createTypeTree(exceptionClass);
String exceptionId = Utils.getTypeId(exceptionClass);
out.write_string(exceptionId);
TypeHelpersProxy.write(tree.getRootNode(), out, ie.getTargetException());

View file

@ -139,11 +139,11 @@ public class TypeTreeCreator {
* @param forClass
* @return type tree
*/
public static TypeTree createTypeTree(Class<?> forClass, boolean scaBindingRules)
public static TypeTree createTypeTree(Class<?> forClass)
throws RequestConfigurationException {
TypeTree tree = new TypeTree();
TypeTreeNode rootNode = null;
rootNode = inspectClassHierarchy(forClass, tree, scaBindingRules);
rootNode = inspectClassHierarchy(forClass, tree);
tree.setRootNode(rootNode);
return tree;
@ -156,16 +156,12 @@ public class TypeTreeCreator {
* @param tree
* @return
*/
private static TypeTreeNode inspectClassHierarchy(Class<?> forClass, TypeTree tree, boolean scaBindingRules)
private static TypeTreeNode inspectClassHierarchy(Class<?> forClass, TypeTree tree)
throws RequestConfigurationException {
TypeTreeNode node = null;
if (scaBindingRules) {
node = createTypeNode4ScaBinding(forClass);
} else {
node = createTypeNode4CorbaBinding(forClass);
}
node = createTypeNode(forClass);
NodeType nodeType = node.getNodeType();
TypeTreeNode[] children = null;
@ -178,14 +174,14 @@ public class TypeTreeCreator {
// reducing sequence dimension
Class<?> reduced = reduceArrayDimension(node.getJavaClass());
children = new TypeTreeNode[1];
children[0] = inspectClassHierarchy(reduced, tree, scaBindingRules);
children[0] = inspectClassHierarchy(reduced, tree);
} 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, scaBindingRules);
TypeTreeNode child = inspectClassHierarchy(field, tree);
child.setName(fields[i].getName());
children[i] = child;
}
@ -208,7 +204,7 @@ public class TypeTreeCreator {
* @return node
* @throws RequestConfigurationException
*/
private static TypeTreeNode createTypeNode4CorbaBinding(Class<?> forClass) throws RequestConfigurationException {
private static TypeTreeNode createTypeNode(Class<?> forClass) throws RequestConfigurationException {
TypeTreeNode node = new TypeTreeNode();
if (forClass.isArray()) {
node.setNodeType(NodeType.sequence);
@ -238,23 +234,7 @@ 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
*

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, false));
inputType.add(TypeTreeCreator.createTypeTree(String.class));
types.setInputType(inputType);
types.setOutputType(TypeTreeCreator.createTypeTree(String.class, false));
types.setOutputType(TypeTreeCreator.createTypeTree(String.class));
} catch (RequestConfigurationException e) {
// ignore - string type should not cause this exception
}

View file

@ -54,7 +54,7 @@ public class CorbaSCAInvoker implements Invoker {
*/
public Message invoke(Message msg) {
try {
DynaCorbaRequest request = new DynaCorbaRequest(remoteObject, "scaService", false);
DynaCorbaRequest request = new DynaCorbaRequest(remoteObject, "scaService");
request.setReferenceClass(referenceClass);
request.setOutputType(String.class);
request.addExceptionType(WrappedSCAException.class);