Clover coverage report - CRISPY - 1.1.1
Coverage timestamp: Mi Nov 15 2006 13:09:46 CET
file stats: LOC: 124   Methods: 9
NCLOC: 74   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
XmlRpcAdminServiceImpl.java 100% 93,5% 100% 95,7%
coverage coverage
 1    /*
 2    * Created on 26.04.2005 from Linke
 3    *
 4    */
 5    package net.sf.crispy.impl.xmlrpc;
 6   
 7    import java.util.Hashtable;
 8    import java.util.Iterator;
 9    import java.util.List;
 10    import java.util.Map;
 11    import java.util.Vector;
 12    import java.util.Map.Entry;
 13   
 14    import org.apache.commons.logging.Log;
 15    import org.apache.commons.logging.LogFactory;
 16    import org.apache.xmlrpc.XmlRpcServer;
 17   
 18    /**
 19    * Implementation of service interface, to add, remove or to ask to register services.
 20    *
 21    * @author Linke
 22    *
 23    */
 24    public class XmlRpcAdminServiceImpl implements XmlRpcAdminService {
 25   
 26    protected static final Log log = LogFactory.getLog (XmlRpcAdminServiceImpl.class);
 27   
 28    private XmlRpcServer xmlRpcServer = null;
 29    private Map services = new Hashtable();
 30    private String nullValue = null;
 31   
 32  8 public final void setNullValue (String pvNullValue) {
 33  8 nullValue = pvNullValue;
 34    }
 35  22 public final String getNullValue() {
 36  22 return nullValue;
 37    }
 38   
 39   
 40    /**
 41    * @param pvServicesMap Map von Diensten, die bereits registriert sind (String ServiceInterface, String ServiceImplClass)
 42    * @param pvXmlRpcServer Referenz zum XmlRpcServer, um Dienste hinzuzufuegen und zu entfernen
 43    */
 44  8 public XmlRpcAdminServiceImpl (XmlRpcServer pvXmlRpcServer, Map pvServicesMap, String pvNullValue) {
 45  8 xmlRpcServer = pvXmlRpcServer;
 46  8 setNullValue(pvNullValue);
 47  8 if (pvServicesMap != null) {
 48  7 Iterator it = pvServicesMap.entrySet().iterator();
 49  7 while (it.hasNext()) {
 50  1 Map.Entry lvMapEntry = (Entry) it.next();
 51  1 addService((String) lvMapEntry.getKey() , (String) lvMapEntry.getValue());
 52    }
 53    }
 54    // sich selbst hinzufuegen
 55  8 addService(this.getClass().getName(), this);
 56  8 addService(XmlRpcAdminService.class.getName(), this);
 57    }
 58   
 59  1 public XmlRpcServer getXmlRpcServer() { return xmlRpcServer; }
 60   
 61    /**
 62    * @see net.sf.crispy.impl.xmlrpc.XmlRpcAdminService#addService(java.lang.String,java.lang.String)
 63    */
 64  3 public final String addService(String pvServiceInterface, String pvImplClass) {
 65  3 try {
 66  3 Object lvServiceImpl = Class.forName(pvImplClass).newInstance();
 67  3 return addService(pvServiceInterface, lvServiceImpl);
 68    } catch (Exception e) {
 69  0 return e.toString();
 70    }
 71    }
 72   
 73  22 public final String addService(String pvServiceInterface, Object pvServiceImpl) {
 74    if (log.isDebugEnabled()) { log.debug("XmlRpcAdminService.addService: " + pvServiceInterface); }
 75  22 try {
 76  22 xmlRpcServer.addHandler(pvServiceInterface, new XmlRpcConvertHandler(pvServiceImpl, getNullValue()));
 77  22 services.put(pvServiceInterface, pvServiceImpl);
 78  22 return pvServiceInterface;
 79    } catch (Exception e) {
 80    // e.printStackTrace();
 81  0 return e.toString();
 82    }
 83    }
 84   
 85    /**
 86    * @see net.sf.crispy.impl.xmlrpc.XmlRpcAdminService#removeService(java.lang.String)
 87    */
 88  2 public String removeService(String pvServiceInterface) {
 89    if (log.isDebugEnabled()) { log.debug("XmlRpcAdminService.removeService: " + pvServiceInterface); }
 90  2 xmlRpcServer.removeHandler(pvServiceInterface);
 91  2 services.remove(pvServiceInterface);
 92  2 return pvServiceInterface;
 93    }
 94   
 95    /**
 96    * @see net.sf.crispy.impl.xmlrpc.XmlRpcAdminService#existService(java.lang.String)
 97    */
 98  3 public Boolean existService(String pvServiceInterface) {
 99    if (log.isDebugEnabled()) { log.debug("XmlRpcAdminService.existService: " + pvServiceInterface); }
 100  3 boolean ret = services.containsKey(pvServiceInterface);
 101    // try {
 102    // Object lvHandler = xmlRpcServer.getHandlerMapping().getHandler(pvServiceInterface);
 103    // System.out.println("-----> Handler: " + pvServiceInterface + " --> " + lvHandler);
 104    // } catch (Exception e) {
 105    // e.printStackTrace();
 106    // }
 107  3 return Boolean.valueOf(ret);
 108    }
 109   
 110    /**
 111    * @see net.sf.crispy.impl.xmlrpc.XmlRpcAdminService#getAllService()
 112    */
 113  6 public List getAllService() {
 114    if (log.isDebugEnabled()) { log.debug("XmlRpcAdminService.getAllService by Server: " + xmlRpcServer); }
 115    // return (String[]) services.keySet().toArray(new String[0]);
 116  6 List retList = new Vector();
 117  6 Iterator it = services.keySet().iterator();
 118  6 while (it.hasNext()) {
 119  16 retList.add(it.next());
 120    }
 121  6 return retList;
 122    }
 123   
 124    }