You are viewing a plain text version of this content. The canonical link for it is here.
Posted to yoko-commits@incubator.apache.org by en...@apache.org on 2006/11/30 16:08:06 UTC
svn commit: r480985 -
/incubator/yoko/branches/cxf_port/bindings/src/main/java/org/apache/yoko/bindings/corba2/CorbaConduit.java
Author: enolan
Date: Thu Nov 30 08:08:05 2006
New Revision: 480985
URL: http://svn.apache.org/viewvc?view=rev&rev=480985
Log:
Yoko-225 - Refactored some new methods.
Modified:
incubator/yoko/branches/cxf_port/bindings/src/main/java/org/apache/yoko/bindings/corba2/CorbaConduit.java
Modified: incubator/yoko/branches/cxf_port/bindings/src/main/java/org/apache/yoko/bindings/corba2/CorbaConduit.java
URL: http://svn.apache.org/viewvc/incubator/yoko/branches/cxf_port/bindings/src/main/java/org/apache/yoko/bindings/corba2/CorbaConduit.java?view=diff&rev=480985&r1=480984&r2=480985
==============================================================================
--- incubator/yoko/branches/cxf_port/bindings/src/main/java/org/apache/yoko/bindings/corba2/CorbaConduit.java (original)
+++ incubator/yoko/branches/cxf_port/bindings/src/main/java/org/apache/yoko/bindings/corba2/CorbaConduit.java Thu Nov 30 08:08:05 2006
@@ -19,11 +19,8 @@
package org.apache.yoko.bindings.corba2;
-import java.io.ByteArrayInputStream;
import java.io.IOException;
-import java.io.InputStream;
import java.io.OutputStream;
-import java.io.PipedInputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -60,6 +57,7 @@
import org.omg.CORBA.Request;
import org.omg.CORBA.TypeCode;
+
public class CorbaConduit implements Conduit {
private static final Logger LOG = LogUtils.getL7dLogger(CorbaConduit.class);
@@ -87,8 +85,7 @@
}
}
- public void send(Message message) throws IOException {
- System.out.println("send message...");
+ public void send(Message message) throws IOException {
try {
AddressType address = endpointInfo.getExtensor(AddressType.class);
@@ -107,13 +104,16 @@
}
}
- public void close(Message message) throws IOException {
- System.out.println("in close message in corbaConduit");
+ public void close(Message message) throws IOException {
BindingOperationInfo boi = message.getExchange().get(BindingOperationInfo.class);
OperationType opType = boi.getExtensor(OperationType.class);
- buildRequest((CorbaMessage)message, opType);
- message.getContent(OutputStream.class).close();
+ try {
+ buildRequest((CorbaMessage)message, opType);
+ message.getContent(OutputStream.class).close();
+ } catch (Exception ex) {
+ // NEED TO DO
+ }
}
public EndpointReferenceType getTarget() {
@@ -150,11 +150,8 @@
protected String getAddress() {
return endpointInfo.getAddress();
}
-
-
- protected void buildRequest(CorbaMessage message, OperationType opType) {
- System.out.println("In build request");
+ protected void buildRequest(CorbaMessage message, OperationType opType) throws Exception {
try {
List<CorbaTypeMap> typeMaps = new ArrayList<CorbaTypeMap>();
@@ -163,64 +160,90 @@
if (corbaTypes != null) {
CorbaUtils.createCorbaTypeMap(typeMaps, corbaTypes);
}
+
+ NVList nvlist = getArguments(message);
+ NamedValue ret = getReturn(message);
+ ExceptionList exList = getExceptionList(message, opType, typeMaps);
+ invokeRequest(message, opType.getName(), nvlist, ret, exList);
- // Build the list of DII arguments, contexts, returns, and
- // exceptions
- NVList list = null;
- if (message.getStreamableArguments() != null) {
- CorbaStreamable[] arguments = message.getStreamableArguments();
- list = orb.create_list(arguments.length);
-
- for (int i = 0; i < arguments.length; ++i) {
- Any value = orb.create_any();
- value.insert_Streamable(arguments[i]);
- list.add_value(arguments[i].getName(), value, arguments[i].getMode());
- }
- } else {
- list = orb.create_list(0);
- }
-
- ContextList ctxList = orb.create_context_list();
- Context ctx = orb.get_default_context();
-
- CorbaStreamable retVal = message.getStreamableReturn();
- NamedValue ret = null;
- if (retVal != null) {
- Any returnAny = orb.create_any();
- returnAny.insert_Streamable(retVal);
- ret = orb.create_named_value(retVal.getName(), returnAny, org.omg.CORBA.ARG_OUT.value);
- } else {
- // TODO: REVISIT: for some reason, the yoko ORB does not like to
- // have a null NamedValue
- // return value. Create this 'empty' one if a void return type
- // is used.
- ret = orb.create_named_value("return", orb.create_any(), org.omg.CORBA.ARG_OUT.value);
+ } catch (java.lang.Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ protected NVList getArguments(CorbaMessage message) {
+ // Build the list of DII arguments, returns, and exceptions
+ NVList list = null;
+ if (message.getStreamableArguments() != null) {
+ CorbaStreamable[] arguments = message.getStreamableArguments();
+ list = orb.create_list(arguments.length);
+
+ for (int i = 0; i < arguments.length; ++i) {
+ Any value = orb.create_any();
+ value.insert_Streamable(arguments[i]);
+ list.add_value(arguments[i].getName(), value, arguments[i].getMode());
}
+ } else {
+ list = orb.create_list(0);
+ }
- // Get the typecodes for the exceptions this operation can throw.
- // These are defined in the
- // operation definition from WSDL.
- ExceptionList exList = orb.create_exception_list();
+ return list;
+ }
+
+ protected NamedValue getReturn(CorbaMessage message) {
+ CorbaStreamable retVal = message.getStreamableReturn();
+ NamedValue ret = null;
+ if (retVal != null) {
+ Any returnAny = orb.create_any();
+ returnAny.insert_Streamable(retVal);
+ ret = orb.create_named_value(retVal.getName(), returnAny, org.omg.CORBA.ARG_OUT.value);
+ } else {
+ // TODO: REVISIT: for some reason, the yoko ORB does not like to
+ // have a null NamedValue return value. Create this 'empty'
+ // one if a void return type is used.
+ ret = orb.create_named_value("return", orb.create_any(), org.omg.CORBA.ARG_OUT.value);
+ }
+ return ret;
+ }
+
+ protected ExceptionList getExceptionList(CorbaMessage message,
+ OperationType opType,
+ List<CorbaTypeMap> typeMaps) {
+ // Get the typecodes for the exceptions this operation can throw.
+ // These are defined in the operation definition from WSDL.
+ ExceptionList exList = orb.create_exception_list();
- Map<TypeCode, RaisesType> exceptions = getOperationExceptions(opType, typeMaps);
+ Map<TypeCode, RaisesType> exceptions = getOperationExceptions(opType, typeMaps);
+ if (exceptions != null) {
Object[] tcs = null;
- if (exceptions != null) {
- tcs = exceptions.keySet().toArray();
-
- for (int i = 0; i < exceptions.size(); ++i) {
- exList.add((TypeCode)tcs[i]);
- }
+ tcs = exceptions.keySet().toArray();
+
+ for (int i = 0; i < exceptions.size(); ++i) {
+ exList.add((TypeCode)tcs[i]);
}
+ }
+ return exList;
+ }
+
+ protected void invokeRequest(CorbaMessage message, String opName,
+ org.omg.CORBA.NVList nvlist,
+ org.omg.CORBA.NamedValue ret,
+ org.omg.CORBA.ExceptionList exList)
+ throws Exception {
+ try {
+ ContextList ctxList = orb.create_context_list();
+ Context ctx = orb.get_default_context();
org.omg.CORBA.Object targetObj = (org.omg.CORBA.Object)message
.get(CorbaConstants.CORBA_ENDPOINT_OBJECT);
- Request request = targetObj._create_request(ctx, opType.getName(), list, ret, exList, ctxList);
- request.invoke();
-
+ if (targetObj != null) {
+ Request request = targetObj._create_request(ctx, opName, nvlist, ret, exList, ctxList);
+ request.invoke();
+ }
} catch (java.lang.Exception ex) {
ex.printStackTrace();
}
}
-
+
protected Map<TypeCode, RaisesType> getOperationExceptions(OperationType operation, List<CorbaTypeMap> typeMaps) {
Map<TypeCode, RaisesType> exceptions = new HashMap<TypeCode, RaisesType>();
List<RaisesType> exList = operation.getRaises();