Clover coverage report - CRISPY - 1.1.1
Coverage timestamp: Mi Nov 15 2006 13:09:46 CET
file stats: LOC: 61   Methods: 3
NCLOC: 34   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
StaticRmiProxy.java 100% 100% 100% 100%
coverage
 1    /**
 2    *
 3    */
 4    package net.sf.crispy.impl;
 5   
 6    import java.rmi.Naming;
 7    import java.util.Properties;
 8   
 9    import net.sf.crispy.InvocationException;
 10    import net.sf.crispy.InvocationStrategy;
 11    import net.sf.crispy.proxy.StaticProxy;
 12    import net.sf.crispy.strategy.NameInvocationStrategy;
 13   
 14    /**
 15    * Remote-Call with Remote Method Invocation (RMI).
 16    *
 17    * @author Linke
 18    *
 19    */
 20    public class StaticRmiProxy extends StaticProxy {
 21   
 22    public final static String DEFAULT_URL_AND_PORT = "rmi://localhost:1098";
 23   
 24    /**
 25    * Get default url and port. If no url and port is in properties.
 26    *
 27    * @return Default url and port.
 28    */
 29  77 public String getDefaultUrlAndPort() {
 30  77 return DEFAULT_URL_AND_PORT;
 31    }
 32   
 33  39 public InvocationStrategy getDefaultInvocationStrategy(Properties pvProperties) {
 34  39 String lvInterfaceClassName = (String) pvProperties.get(PROPERTY_CURRENT_INTERFACE_CLASS);
 35  39 String lvLookupName = getProperties().getProperty(lvInterfaceClassName);
 36  39 if (lvLookupName == null) {
 37  1 throw new InvocationException("For the Class: " + lvInterfaceClassName + " is no RMI-Entry exist " +
 38    "(LookUp-Name: " + lvLookupName + ").");
 39    }
 40  38 return new NameInvocationStrategy(lvLookupName);
 41    }
 42   
 43   
 44    /**
 45    * @see net.sf.crispy.proxy.Proxy#newInstance(java.lang.Class)
 46    */
 47  38 public Object newInstance(Class pvProxyClass) {
 48  38 String lvLookupStr = getUrlAndPort() + "/" + getInvocationStrategy();
 49    if (log.isDebugEnabled()) { log.debug("StaticRmiProxy LookUp-String: " + lvLookupStr); }
 50  38 try {
 51  38 Object lvProxyObject = Naming.lookup(lvLookupStr);
 52  36 setProxyObject(lvProxyObject);
 53  36 setProxyClass(lvProxyObject.getClass());
 54    } catch (Exception e) {
 55  2 throw new InvocationException("Error in newInstance in StaticRmiProxy: " + e, e);
 56    }
 57  36 return getProxyObject();
 58    }
 59   
 60   
 61    }