public Object copyFault(Object fault, Operation sourceOperation, Operation targetOperation) { // Rename the parameters so we can more easily remember which direction we're going in. Operation fromOperation = targetOperation; Operation toOperation = sourceOperation; if (faultExceptionMapper == null) { return fault; } List<DataType> fts = fromOperation.getFaultTypes(); for (int i = 0; i < fts.size(); i++) { DataType et = fts.get(i); if (et.getPhysical().isInstance(fault)) { Throwable ex = (Throwable)fault; DataType<DataType> exType = findFaultDataType(fromOperation, fault); DataType faultType = getFaultType(exType); Object faultInfo = faultExceptionMapper.getFaultInfo(ex, faultType.getPhysical(), fromOperation); DataType targetExType = findSourceFaultDataType(toOperation, exType); DataType targetFaultType = getFaultType(targetExType); faultInfo = copy(faultInfo, faultType, targetFaultType, fromOperation, toOperation); fault = faultExceptionMapper.wrapFaultInfo(targetExType, ex.getMessage(), faultInfo, ex.getCause(), toOperation); return fault; } } return fault; }
@SuppressWarnings("unchecked") private void introspectFaultTypes(Operation operation) { if (operation != null && operation.getFaultTypes() != null) { for (DataType exceptionType : operation.getFaultTypes()) { faultExceptionMapper.introspectFaultDataType(exceptionType, operation, true); DataType faultType = (DataType)exceptionType.getLogical(); if (JavaExceptionDataBinding.NAME.equals(faultType.getDataBinding())) { // The exception class doesn't have an associated bean class, so // synthesize a virtual bean by introspecting the exception class. createSyntheticBean(operation, exceptionType); } } } }
public Object copyFault(Object fault, Operation sourceOperation, Operation targetOperation) { // Rename the parameters so we can more easily remember which direction we're going in. Operation fromOperation = targetOperation; Operation toOperation = sourceOperation; if (faultExceptionMapper == null) { return fault; } List<DataType> fts = fromOperation.getFaultTypes(); for (int i = 0; i < fts.size(); i++) { DataType et = fts.get(i); if (et.getPhysical().isInstance(fault)) { Throwable ex = (Throwable)fault; DataType<DataType> exType = findFaultDataType(fromOperation, fault); DataType faultType = getFaultType(exType); Object faultInfo = faultExceptionMapper.getFaultInfo(ex, faultType.getPhysical(), fromOperation); DataType targetExType = findSourceFaultDataType(toOperation, exType); DataType targetFaultType = getFaultType(targetExType); faultInfo = copy(faultInfo, faultType, targetFaultType, fromOperation, toOperation); fault = faultExceptionMapper.wrapFaultInfo(targetExType, ex.getMessage(), faultInfo, ex.getCause(), toOperation); return fault; } } return fault; }
@SuppressWarnings("unchecked") public Throwable transform(Throwable source, TransformationContext context) { DataType<DataType> sourceType = context.getSourceDataType(); DataType<DataType> targetType = context.getTargetDataType(); Object sourceFaultInfo = faultExceptionMapper.getFaultInfo(source, sourceType.getLogical().getPhysical(), context.getSourceOperation()); Object targetFaultInfo = mediator.mediate(sourceFaultInfo, sourceType.getLogical(), targetType.getLogical(), context.getMetadata()); Throwable targetException = faultExceptionMapper.wrapFaultInfo(targetType, source.getMessage(), targetFaultInfo, source.getCause(), context.getTargetOperation()); // FIXME return targetException == null ? source : targetException; }
@SuppressWarnings("unchecked") public Throwable transform(Throwable source, TransformationContext context) { DataType<DataType> sourceType = context.getSourceDataType(); DataType<DataType> targetType = context.getTargetDataType(); Object sourceFaultInfo = faultExceptionMapper.getFaultInfo(source, sourceType.getLogical().getPhysical(), context.getSourceOperation()); Object targetFaultInfo = mediator.mediate(sourceFaultInfo, sourceType.getLogical(), targetType.getLogical(), context.getMetadata()); Throwable targetException = faultExceptionMapper.wrapFaultInfo(targetType, source.getMessage(), targetFaultInfo, source.getCause(), context.getTargetOperation()); // FIXME return targetException == null ? source : targetException; }