addAfter(ClientFaultConverter.class.getName());
corbaStaxObject = new CorbaStaxObject();
}
public void handleMessage(Message msg) {
CorbaMessage message = (CorbaMessage)msg;
try {
CorbaStreamable exStreamable = message.getStreamableException();
if (exStreamable != null) {
EventDataReader reader = (EventDataReader) ContextUtils.getDataReader(message);
BindingOperationInfo bopInfo = message.getExchange().get(BindingOperationInfo.class);
OperationType opType = bopInfo.getExtensor(OperationType.class);
OperationInfo opInfo = bopInfo.getOperationInfo();
List<CorbaTypeMap> typeMaps = new ArrayList<CorbaTypeMap>();
ServiceInfo service = message.getExchange().get(ServiceInfo.class);
List<TypeMappingType> corbaTypes =
service.getDescription().getExtensors(TypeMappingType.class);
if (corbaTypes != null) {
corbaStaxObject.setTypeMaps(typeMaps);
corbaStaxObject.setServiceInfo(service);
}
org.omg.CORBA.ORB orb = (org.omg.CORBA.ORB) message.get(CorbaConstants.ORB);
if (orb == null) {
orb = (org.omg.CORBA.ORB) message.getExchange().get(org.omg.CORBA.ORB.class);
}
corbaStaxObject.setOrb(orb);
QName elName = new QName("", exStreamable.getName());
XMLInputFactory inputFactory = getXMLInputFactory();
XMLOutputFactory outputFactory = getXMLOutputFactory();
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
XMLEventWriter evtWriter = outputFactory.createXMLEventWriter(outStream);
corbaStaxObject.writeObjectToStax(exStreamable.getObject(),
evtWriter,
XMLEventFactory.newInstance());
evtWriter.flush();
ByteArrayInputStream inStream = new ByteArrayInputStream(outStream.toByteArray());
XMLEventReader evtReader = inputFactory.createXMLEventReader(inStream);
FaultInfo fault = getFaultInfo(opInfo, elName);
Object e = reader.read(fault.getMessageParts().get(0), evtReader);
if (!(e instanceof Exception)) {
Class exClass = fault.getProperty(Class.class.getName(), Class.class);
Class beanClass = e.getClass();
Constructor constructor =
exClass.getConstructor(new Class[]{String.class, beanClass});
e = constructor.newInstance(new Object[]{"", e});
}
message.setContent(Exception.class, (Exception) e);
}
} catch (java.lang.Exception ex) {
LOG.log(Level.SEVERE, "CORBA unmarshalFault exception", ex);
throw new CorbaBindingException("CORBA unmarshalFault exception", ex);
}