Coverage Report - org.mule.extras.spring.remoting.ObjectToRemoteInvocationTransformer
 
Classes in this File Line Coverage Branch Coverage Complexity
ObjectToRemoteInvocationTransformer
65%
13/20
58%
7/12
4.5
 
 1  
 /*
 2  
  * $Id: ObjectToRemoteInvocationTransformer.java 7963 2007-08-21 08:53:15Z dirk.olmes $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
 5  
  *
 6  
  * The software in this package is published under the terms of the CPAL v1.0
 7  
  * license, a copy of which has been included with this distribution in the
 8  
  * LICENSE.txt file.
 9  
  */
 10  
 
 11  
 package org.mule.extras.spring.remoting;
 12  
 
 13  
 import org.mule.transformers.AbstractTransformer;
 14  
 import org.mule.umo.transformer.TransformerException;
 15  
 
 16  
 import java.io.ByteArrayInputStream;
 17  
 import java.io.ObjectInputStream;
 18  
 
 19  
 import org.springframework.remoting.support.RemoteInvocation;
 20  
 
 21  
 public class ObjectToRemoteInvocationTransformer extends AbstractTransformer
 22  
 {
 23  
 
 24  
     public ObjectToRemoteInvocationTransformer()
 25  
     {
 26  4
         super();
 27  8
         this.registerSourceType(RemoteInvocation.class);
 28  4
         this.registerSourceType(byte[].class);
 29  4
         this.setReturnClass(RemoteInvocation.class);
 30  4
     }
 31  
 
 32  
     protected Object doTransform(Object src, String encoding) throws TransformerException
 33  
     {
 34  2
         if (src instanceof RemoteInvocation)
 35  
         {
 36  0
             return src;
 37  
         }
 38  
 
 39  
         try
 40  
         {
 41  2
             byte[] data = (byte[])src;
 42  2
             ByteArrayInputStream bais = new ByteArrayInputStream(data);
 43  2
             ObjectInputStream ois = new ObjectInputStream(bais);
 44  2
             Object o = ois.readObject();
 45  2
             RemoteInvocation ri = (RemoteInvocation)o;
 46  2
             if (logger.isDebugEnabled())
 47  
             {
 48  0
                 logger.debug("request to execute " + ri.getMethodName());
 49  0
                 for (int i = 0; i < ri.getArguments().length; i++)
 50  
                 {
 51  0
                     Object a = ri.getArguments()[i];
 52  0
                     logger.debug("with argument (" + a.toString() + ")");
 53  
                 }
 54  
             }
 55  2
             return ri;
 56  
         }
 57  0
         catch (Exception e)
 58  
         {
 59  0
             throw new TransformerException(this, e);
 60  
         }
 61  
     }
 62  
 
 63  
 }