Clover coverage report - CRISPY - 1.1.1
Coverage timestamp: Mi Nov 15 2006 13:09:46 CET
file stats: LOC: 112   Methods: 5
NCLOC: 61   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
BurlapInvoker.java 60% 93,9% 100% 87,5%
coverage coverage
 1    package net.sf.crispy.impl.caucho;
 2   
 3    import java.lang.reflect.InvocationTargetException;
 4    import java.lang.reflect.Method;
 5   
 6    import net.sf.crispy.util.Converter;
 7   
 8    import com.caucho.burlap.io.BurlapInput;
 9    import com.caucho.burlap.io.BurlapOutput;
 10    import com.caucho.services.server.AbstractSkeleton;
 11    import com.caucho.services.server.ServiceContext;
 12   
 13    public class BurlapInvoker extends AbstractSkeleton {
 14   
 15    private Object serviceObject = null;
 16    private boolean withConverter = false;
 17   
 18  4 public BurlapInvoker(Object service, Class pvServiceClass) {
 19  4 super(pvServiceClass);
 20  4 serviceObject = service;
 21    }
 22   
 23  4 public void setWithConverter(boolean pvWithConverter) {
 24  4 withConverter = pvWithConverter;
 25    }
 26   
 27  3 public boolean getWithConverter() {
 28  3 return withConverter;
 29    }
 30   
 31   
 32  5 public void invoke(BurlapInput in, BurlapOutput out) throws Throwable
 33    {
 34  5 in.startCall();
 35   
 36  3 ServiceContext context = ServiceContext.getContext();
 37   
 38  3 String header;
 39  ? while ((header = in.readHeader()) != null) {
 40  0 Object value = in.readObject();
 41   
 42  0 context.addHeader(header, value);
 43    }
 44   
 45  3 String methodName = in.getMethod();
 46   
 47  3 Method method = getMethod(methodName);
 48    // System.out.println("BURLAP-METHOD-Name: " + methodName);
 49    // System.out.println("BURLAP-METHOD: " + method);
 50    // if ((method != null) && ( "_burlap_getAttribute".equals(in.getMethod()))) {
 51    // String attrName = in.readString();
 52    // in.completeCall();
 53    //
 54    // String value = null;
 55    //
 56    // if ("java.api.class".equals(attrName))
 57    // value = getAPIClassName();
 58    // else if ("java.home.class".equals(attrName))
 59    // value = getHomeClassName();
 60    // else if ("java.object.class".equals(attrName))
 61    // value = getObjectClassName();
 62    //
 63    // out.startReply();
 64    //
 65    // out.writeObject(value);
 66    //
 67    // out.completeReply();
 68    // System.err.println("BurlapInvoker with method: " + methodName);
 69    // return;
 70    // }
 71    // else if (method == null) {
 72    // writeFault("The service has no method named: " + in.getMethod(), null, out);
 73    // return;
 74    // }
 75   
 76  3 Class []args = method.getParameterTypes();
 77  3 Object []values = new Object[args.length];
 78   
 79  3 for (int i = 0; i < args.length; i++)
 80  4 values[i] = in.readObject(args[i]);
 81   
 82  3 in.completeCall();
 83   
 84  3 Object result = null;
 85   
 86  3 try {
 87  3 result = method.invoke(serviceObject, values);
 88  2 if (getWithConverter()) {
 89  2 result = new Converter().makeSimple(result);
 90    }
 91   
 92    } catch (Exception e) {
 93  1 Throwable lvThrowable = e;
 94  1 if (lvThrowable instanceof InvocationTargetException) {
 95  1 lvThrowable = ((InvocationTargetException) lvThrowable).getTargetException();
 96    }
 97  1 writeFault("ServiceException: ", lvThrowable, out);
 98  1 return;
 99    }
 100   
 101  2 out.startReply();
 102  2 out.writeObject(result);
 103  2 out.completeReply();
 104    }
 105   
 106  2 public void writeFault(String pvMessage, Throwable t, BurlapOutput out) throws Exception {
 107  2 out.startReply();
 108  2 out.writeFault(pvMessage, (t == null ? "NoMessage" : t.getMessage()), t);
 109  2 out.completeReply();
 110    }
 111   
 112    }