use of org.apache.cxf.binding.corba.types.CorbaTypeEventProducer in project cxf by apache.
the class CorbaStreamInInterceptor method handleRequest.
private void handleRequest(Message msg) {
ORB orb;
ServiceInfo service;
CorbaDestination destination;
if (msg.getDestination() != null) {
destination = (CorbaDestination) msg.getDestination();
} else {
destination = (CorbaDestination) msg.getExchange().getDestination();
}
service = destination.getBindingInfo().getService();
CorbaMessage message = (CorbaMessage) msg;
Exchange exchange = message.getExchange();
CorbaTypeMap typeMap = message.getCorbaTypeMap();
BindingInfo bInfo = destination.getBindingInfo();
InterfaceInfo info = bInfo.getInterface();
String opName = exchange.get(String.class);
Iterator<BindingOperationInfo> i = bInfo.getOperations().iterator();
OperationType opType = null;
BindingOperationInfo bopInfo = null;
QName opQName = null;
while (i.hasNext()) {
bopInfo = i.next();
if (bopInfo.getName().getLocalPart().equals(opName)) {
opType = bopInfo.getExtensor(OperationType.class);
opQName = bopInfo.getName();
break;
}
}
if (opType == null) {
throw new RuntimeException("Couldn't find the binding operation for " + opName);
}
orb = exchange.get(ORB.class);
ServerRequest request = exchange.get(ServerRequest.class);
NVList list = prepareArguments(message, info, opType, opQName, typeMap, destination, service);
request.arguments(list);
message.setList(list);
HandlerIterator paramIterator = new HandlerIterator(message, true);
CorbaTypeEventProducer eventProducer = null;
BindingMessageInfo msgInfo = bopInfo.getInput();
boolean wrap = false;
if (bopInfo.isUnwrappedCapable()) {
wrap = true;
}
if (wrap) {
// wrapper element around our args
QName wrapperElementQName = msgInfo.getMessageInfo().getName();
eventProducer = new WrappedParameterSequenceEventProducer(wrapperElementQName, paramIterator, service, orb);
} else {
eventProducer = new ParameterEventProducer(paramIterator, service, orb);
}
CorbaStreamReader reader = new CorbaStreamReader(eventProducer);
message.setContent(XMLStreamReader.class, reader);
}
use of org.apache.cxf.binding.corba.types.CorbaTypeEventProducer 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.types.CorbaTypeEventProducer in project cxf by apache.
the class CorbaStreamInInterceptor method handleReply.
private void handleReply(Message msg) {
ORB orb;
ServiceInfo service;
CorbaDestination destination;
if (msg.getDestination() != null) {
destination = (CorbaDestination) msg.getDestination();
} else {
destination = (CorbaDestination) msg.getExchange().getDestination();
}
service = destination.getBindingInfo().getService();
CorbaMessage message = (CorbaMessage) msg;
if (message.getStreamableException() != null || message.getSystemException() != null) {
message.setContent(Exception.class, message.getExchange().getOutMessage().getContent(Exception.class));
Endpoint ep = message.getExchange().getEndpoint();
message.getInterceptorChain().abort();
if (ep.getInFaultObserver() != null) {
ep.getInFaultObserver().onMessage(message);
return;
}
}
CorbaMessage outMessage = (CorbaMessage) message.getExchange().getOutMessage();
orb = message.getExchange().get(ORB.class);
HandlerIterator paramIterator = new HandlerIterator(outMessage, false);
CorbaTypeEventProducer eventProducer = null;
Exchange exchange = message.getExchange();
BindingOperationInfo bindingOpInfo = exchange.getBindingOperationInfo();
BindingMessageInfo msgInfo = bindingOpInfo.getOutput();
boolean wrap = false;
if (bindingOpInfo.isUnwrappedCapable()) {
wrap = true;
}
if (wrap) {
// wrapper element around our args
// REVISIT, bravi, message name same as the element name
QName wrapperElementQName = msgInfo.getMessageInfo().getName();
eventProducer = new WrappedParameterSequenceEventProducer(wrapperElementQName, paramIterator, service, orb);
} else {
eventProducer = new ParameterEventProducer(paramIterator, service, orb);
}
CorbaStreamReader reader = new CorbaStreamReader(eventProducer);
message.setContent(XMLStreamReader.class, reader);
}
Aggregations