Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Licensed to the Apache Software Foundation (ASF) under one
   * or more contributor license agreements.  See the NOTICE file
   * distributed with this work for additional information
   * regarding copyright ownership.  The ASF licenses this file
   * to you under the Apache License, Version 2.0 (the
   * "License"); you may not use this file except in compliance
   * with the License.  You may obtain a copy of the License at
   * 
  *   http://www.apache.org/licenses/LICENSE-2.0
  * 
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.    
  */
 
 package org.apache.tuscany.sca.core.databinding.transformers;
 
 import static org.apache.tuscany.sca.interfacedef.Operation.IDL_FAULT;

This is a special transformer to transform the exception from one IDL to the other one

Version:
$Rev: 1061329 $ $Date: 2011-01-20 16:57:06 +0200 (Thu, 20 Jan 2011) $
 
 public class Exception2ExceptionTransformer extends BaseTransformer<ThrowableThrowableimplements
 
     protected Mediator mediator;
 
         super();
         UtilityExtensionPoint utilityExtensionPoint = registry.getExtensionPoint(UtilityExtensionPoint.class);
         this. = utilityExtensionPoint.getUtility(Mediator.class);
         this. = utilityExtensionPoint.getUtility(FaultExceptionMapper.class);
     }
     
     protected Exception2ExceptionTransformer(Mediator mediatorFaultExceptionMapper faultExceptionMapper) {
         super();
         this. = mediator;
         this. = faultExceptionMapper;
     }
 
     @Override
     public String getSourceDataBinding() {
         return ;
     }
 
     @Override
     public String getTargetDataBinding() {
         return ;
     }

    
 
     @Override
     protected Class<ThrowablegetSourceType() {
         return Throwable.class;
     }

    
 
     @Override
     protected Class<ThrowablegetTargetType() {
         return Throwable.class;
     }

    
 
     @Override
     public int getWeight() {
         return 10000;
     }
 
     @SuppressWarnings("unchecked")
     public Throwable transform(Throwable sourceTransformationContext context) {
         DataType<DataTypesourceType = context.getSourceDataType();
 
         DataType<DataTypetargetType = context.getTargetDataType();
 
         Object sourceFaultInfo = .getFaultInfo(sourcesourceType.getLogical().getPhysical(), context.getSourceOperation());
         Object targetFaultInfo =
             .mediate(sourceFaultInfosourceType.getLogical(), targetType.getLogical(), context.getMetadata());
        Throwable targetException =
            .wrapFaultInfo(targetTypesource.getMessage(), targetFaultInfosource.getCause(), context.getTargetOperation());
        // FIXME
        return targetException == null ? source : targetException;
    }
    public void setFaultExceptionMapper(FaultExceptionMapper faultExceptionMapper) {
        this. = faultExceptionMapper;
    }
New to GrepCode? Check out our FAQ X