Clover coverage report - CRISPY - 1.1.1
Coverage timestamp: Mi Nov 15 2006 13:09:46 CET
file stats: LOC: 105   Methods: 6
NCLOC: 76   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
DynamicProxyFactory.java 100% 100% 100% 100%
coverage
 1    package net.sf.crispy.proxy;
 2   
 3    import java.util.Properties;
 4   
 5    import org.apache.commons.logging.Log;
 6    import org.apache.commons.logging.LogFactory;
 7   
 8    import net.sf.crispy.Property;
 9    import net.sf.crispy.concurrent.AsynchronousCallback;
 10    import net.sf.crispy.impl.ServiceManager;
 11    import net.sf.crispy.util.Util;
 12   
 13    /**
 14    * Encapsulate create a instance of DynamicProxy.
 15    *
 16    * @author Linke
 17    *
 18    */
 19    public class DynamicProxyFactory {
 20   
 21    protected static final Log log = LogFactory.getLog (Proxy.class);
 22   
 23    public static final String DEFAULT_DYNAMIC_PROXY = Property.VALUE_FOR_JDK_DYNAMIC_PROXY;
 24   
 25    private static CommonsProxyFactory commonsProxyFactory = null;
 26   
 27   
 28  43 public static DynamicProxy getDefaultDynamicProxy () {
 29  43 return createDynamicProxy (DEFAULT_DYNAMIC_PROXY, null);
 30    }
 31   
 32  213 public static DynamicProxy getDefaultDynamicProxy (final Properties pvProperties) {
 33  213 return createDynamicProxy (DEFAULT_DYNAMIC_PROXY, pvProperties);
 34    }
 35   
 36  9 public static DynamicProxy createDynamicProxy (final String pvName) {
 37  9 return createDynamicProxy(pvName, null);
 38    }
 39   
 40  362 public static DynamicProxy createDynamicProxy (final String pvName, final Properties pvProperties) {
 41   
 42  362 DynamicProxy lvDynamicProxy = null;
 43   
 44  362 if ((pvName == null) || (pvName.equals(DEFAULT_DYNAMIC_PROXY)) || (pvName.equals("net.sf.crispy.impl.DynamicJdkProxy"))) {
 45  348 lvDynamicProxy = new DynamicJdkProxy();
 46    } else {
 47   
 48    // try to load commons proxy
 49  14 try {
 50    // aus performance Gruenden, soll nur einmal eine Instanz erzeugt werden
 51  14 if (commonsProxyFactory == null) {
 52  10 commonsProxyFactory = (CommonsProxyFactory) Util.createObject(CommonsProxyFactory.class.getName());
 53    }
 54  14 lvDynamicProxy = commonsProxyFactory.createDynamicProxy(pvName);
 55    } catch (Exception e) {
 56    if (log.isDebugEnabled()) {
 57    log.debug("Can't load CommonsProxyFactory: " + e);
 58    }
 59    }
 60    }
 61   
 62  362 AsynchronousCallback lvAsynchronousCallback = createAsynchronousCallback(pvProperties);
 63  362 if (lvAsynchronousCallback != null) {
 64  28 int lvMaxSizeOfThreads = getMaxSizeOfThreads(pvProperties);
 65  28 lvDynamicProxy.setAsynchronousCallback(lvAsynchronousCallback, null, lvMaxSizeOfThreads);
 66    }
 67   
 68  362 return lvDynamicProxy;
 69    }
 70   
 71  367 public static AsynchronousCallback createAsynchronousCallback(final Properties pvProperties) {
 72  367 AsynchronousCallback lvAsynchronousCallback = null;
 73  367 if (pvProperties != null) {
 74  314 String lvAsyncCallImplClassString = pvProperties.getProperty(Property.ASYNCHRONOUS_CALLBACK_CLASS);
 75  314 if (lvAsyncCallImplClassString != null) {
 76  31 try {
 77  31 Object o = Util.createObject(lvAsyncCallImplClassString);
 78  30 if (o instanceof AsynchronousCallback) {
 79  29 lvAsynchronousCallback = (AsynchronousCallback) o;
 80    } else {
 81  1 throw new IllegalArgumentException (lvAsyncCallImplClassString + " is not a instance of AsynchronousCallback!");
 82    }
 83    } catch (Exception e) {
 84    if (ServiceManager.DEBUG_MODE_ON) {
 85    e.printStackTrace();
 86    }
 87  2 throw new IllegalArgumentException ("Can't create a instance of class string: " + lvAsyncCallImplClassString
 88    + " (" + e + ")");
 89    }
 90    }
 91    }
 92   
 93  365 return lvAsynchronousCallback;
 94    }
 95   
 96  32 public static int getMaxSizeOfThreads(final Properties pvProperties) {
 97  32 int lvMaxSizeOfThreads = 0;
 98  32 if (pvProperties != null) {
 99  31 String lvMaxSizeOfThreadsString = pvProperties.getProperty(Property.ASYNCHRONOUS_MAX_SIZE_OF_THREADS, "0");
 100  31 lvMaxSizeOfThreads = Integer.parseInt(lvMaxSizeOfThreadsString);
 101    }
 102  31 return lvMaxSizeOfThreads;
 103    }
 104   
 105    }