use of org.apache.cxf.binding.corba.CorbaStreamable in project cxf by apache.
the class CorbaStreamInInterceptor method prepareArguments.
protected NVList prepareArguments(CorbaMessage corbaMsg, InterfaceInfo info, OperationType opType, QName opQName, CorbaTypeMap typeMap, CorbaDestination destination, ServiceInfo service) {
BindingInfo bInfo = destination.getBindingInfo();
EndpointInfo eptInfo = destination.getEndPointInfo();
BindingOperationInfo bOpInfo = bInfo.getOperation(opQName);
OperationInfo opInfo = bOpInfo.getOperationInfo();
Exchange exg = corbaMsg.getExchange();
exg.put(BindingInfo.class, bInfo);
exg.put(InterfaceInfo.class, info);
exg.put(EndpointInfo.class, eptInfo);
exg.put(EndpointReferenceType.class, destination.getAddress());
exg.put(ServiceInfo.class, service);
exg.put(BindingOperationInfo.class, bOpInfo);
exg.put(OperationInfo.class, opInfo);
exg.put(MessageInfo.class, opInfo.getInput());
exg.put(String.class, opQName.getLocalPart());
exg.setInMessage(corbaMsg);
corbaMsg.put(MessageInfo.class, opInfo.getInput());
List<ParamType> paramTypes = opType.getParam();
CorbaStreamable[] arguments = new CorbaStreamable[paramTypes.size()];
return prepareDIIArgsList(corbaMsg, bOpInfo, arguments, paramTypes, typeMap, exg.get(ORB.class), service);
}
use of org.apache.cxf.binding.corba.CorbaStreamable in project cxf by apache.
the class CorbaStreamOutEndingInterceptor method handleOutBoundMessage.
private void handleOutBoundMessage(CorbaMessage message, BindingOperationInfo boi) {
OperationInfo opInfo = boi.getOperationInfo();
OperationType opType = boi.getExtensor(OperationType.class);
List<ParamType> paramTypes = opType.getParam();
MessageInfo outMsgInfo = opInfo.getOutput();
String wrapNSUri = null;
boolean wrap = false;
if (boi.isUnwrappedCapable()) {
wrap = true;
if (outMsgInfo != null) {
wrapNSUri = getWrappedParamNamespace(outMsgInfo);
if (!CorbaUtils.isElementFormQualified(service, wrapNSUri)) {
wrapNSUri = "";
}
}
}
CorbaStreamWriter writer = (CorbaStreamWriter) message.getContent(XMLStreamWriter.class);
CorbaObjectHandler[] objs = writer.getCorbaObjects();
int count = 0;
int msgIndex = 0;
ArgType returnParam = opType.getReturn();
if (returnParam != null) {
QName retName;
if (wrap) {
retName = new QName(wrapNSUri, returnParam.getName());
} else {
retName = getMessageParamQName(outMsgInfo, returnParam.getName(), msgIndex);
}
QName retIdlType = returnParam.getIdltype();
CorbaObjectHandler obj = CorbaHandlerUtils.initializeObjectHandler(orb, retName, retIdlType, typeMap, service);
CorbaStreamable streamable = message.createStreamableObject(obj, retName);
message.setStreamableReturn(streamable);
msgIndex++;
}
for (Iterator<ParamType> iter = paramTypes.iterator(); iter.hasNext(); ) {
ParamType param = iter.next();
QName idlType = param.getIdltype();
QName paramName;
CorbaObjectHandler obj = null;
if (param.getMode().equals(ModeType.OUT)) {
if (wrap) {
paramName = new QName(wrapNSUri, param.getName());
} else {
paramName = getMessageParamQName(outMsgInfo, param.getName(), msgIndex);
}
obj = CorbaHandlerUtils.initializeObjectHandler(orb, paramName, idlType, typeMap, service);
msgIndex++;
} else {
obj = objs[count++];
paramName = obj.getName();
}
CorbaStreamable streamable = message.createStreamableObject(obj, paramName);
ModeType paramMode = param.getMode();
if (paramMode.value().equals("in")) {
streamable.setMode(org.omg.CORBA.ARG_IN.value);
} else if (paramMode.value().equals("inout")) {
streamable.setMode(org.omg.CORBA.ARG_INOUT.value);
}
// default mode is out
message.addStreamableArgument(streamable);
}
}
use of org.apache.cxf.binding.corba.CorbaStreamable in project cxf by apache.
the class CorbaStreamFaultInInterceptor method handleMessage.
public void handleMessage(Message msg) {
CorbaMessage message = (CorbaMessage) msg;
try {
SystemException sysEx = message.getSystemException();
if (sysEx != null) {
message.setContent(Exception.class, sysEx);
return;
}
CorbaStreamable exStreamable = message.getStreamableException();
if (exStreamable != null) {
DataReader<XMLStreamReader> reader = getDataReader(message);
BindingOperationInfo bopInfo = message.getExchange().getBindingOperationInfo();
OperationInfo opInfo = bopInfo.getOperationInfo();
ServiceInfo service = message.getExchange().getEndpoint().getEndpointInfo().getService();
org.omg.CORBA.ORB orb = (org.omg.CORBA.ORB) message.get(CorbaConstants.ORB);
if (orb == null) {
orb = message.getExchange().get(org.omg.CORBA.ORB.class);
}
QName elName = new QName("", exStreamable.getName());
FaultInfo fault = getFaultInfo(opInfo, elName);
CorbaTypeEventProducer faultEventProducer = CorbaHandlerUtils.getTypeEventProducer(exStreamable.getObject(), service, orb);
CorbaStreamReader streamReader = new CorbaStreamReader(faultEventProducer);
Object e = reader.read(fault.getMessageParts().get(0), streamReader);
if (!(e instanceof Exception)) {
Class<?> exClass = fault.getProperty(Class.class.getName(), Class.class);
if (exClass != null) {
Class<?> beanClass = e.getClass();
Constructor<?> constructor = exClass.getConstructor(new Class[] { String.class, beanClass });
String repId = (message.getStreamableException()._type().id() != null) ? message.getStreamableException()._type().id() : "";
e = constructor.newInstance(new Object[] { repId, e });
} else {
// Get the Fault
Fault faultEx = (Fault) message.getContent(Exception.class);
if (e instanceof Document) {
createFaultDetail((Document) e, fault, faultEx);
}
e = faultEx;
}
}
message.setContent(Exception.class, e);
}
} catch (java.lang.Exception ex) {
LOG.log(Level.SEVERE, "CORBA unmarshalFault exception", ex);
throw new CorbaBindingException("CORBA unmarshalFault exception", ex);
}
}
use of org.apache.cxf.binding.corba.CorbaStreamable in project cxf by apache.
the class CorbaStreamOutEndingInterceptor method handleInBoundMessage.
private void handleInBoundMessage(CorbaMessage message, BindingOperationInfo boi) {
OperationInfo opInfo = boi.getOperationInfo();
OperationType opType = boi.getExtensor(OperationType.class);
List<ParamType> paramTypes = opType.getParam();
MessageInfo msgInInfo = opInfo.getInput();
String wrapNSUri = null;
boolean wrap = false;
if (boi.isUnwrappedCapable()) {
wrap = true;
if (msgInInfo != null) {
wrapNSUri = getWrappedParamNamespace(msgInInfo);
if (!CorbaUtils.isElementFormQualified(service, wrapNSUri)) {
wrapNSUri = "";
}
}
}
CorbaStreamWriter writer = (CorbaStreamWriter) message.getContent(XMLStreamWriter.class);
CorbaObjectHandler[] objs = writer.getCorbaObjects();
int count = 0;
int msgIndex = 0;
ArgType returnParam = opType.getReturn();
if (returnParam != null) {
CorbaObjectHandler obj = objs[count++];
QName retName = obj.getName();
CorbaStreamable streamable = message.createStreamableObject(obj, retName);
message.setStreamableReturn(streamable);
}
for (Iterator<ParamType> iter = paramTypes.iterator(); iter.hasNext(); ) {
ParamType param = iter.next();
QName idlType = param.getIdltype();
QName paramName;
CorbaObjectHandler obj = null;
if (param.getMode().equals(ModeType.IN)) {
if (wrap) {
paramName = new QName(wrapNSUri, param.getName());
} else {
paramName = getMessageParamQName(msgInInfo, param.getName(), msgIndex);
}
obj = CorbaHandlerUtils.initializeObjectHandler(orb, paramName, idlType, typeMap, service);
msgIndex++;
} else {
obj = objs[count++];
paramName = obj.getName();
}
CorbaStreamable streamable = message.createStreamableObject(obj, paramName);
ModeType paramMode = param.getMode();
if (paramMode.value().equals("in")) {
streamable.setMode(org.omg.CORBA.ARG_IN.value);
} else if (paramMode.value().equals("inout")) {
streamable.setMode(org.omg.CORBA.ARG_INOUT.value);
} else if (paramMode.value().equals("out")) {
streamable.setMode(org.omg.CORBA.ARG_OUT.value);
}
message.addStreamableArgument(streamable);
}
}
use of org.apache.cxf.binding.corba.CorbaStreamable in project cxf by apache.
the class CorbaStreamableTest method testSetStreamableAttributes.
@Test
public void testSetStreamableAttributes() {
QName objName = new QName("object");
QName objIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "boolean", CorbaConstants.NP_WSDL_CORBA);
TypeCode objTypeCode = orb.get_primitive_tc(TCKind.tk_boolean);
CorbaPrimitiveHandler obj = new CorbaPrimitiveHandler(objName, objIdlType, objTypeCode, null);
CorbaStreamable streamable = new CorbaStreamableImpl(obj, objName);
streamable.setMode(org.omg.CORBA.ARG_IN.value);
int mode = streamable.getMode();
assertTrue(mode == org.omg.CORBA.ARG_IN.value);
}
Aggregations