Clover coverage report -
Coverage timestamp: Thu Jul 5 2007 20:02:32 EDT
file stats: LOC: 257   Methods: 22
NCLOC: 152   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
InvocationContext.java 34.2% 59.7% 86.4% 56.6%
coverage coverage
 1    /*
 2    * JBoss, Home of Professional Open Source
 3    *
 4    * Distributable under LGPL license.
 5    * See terms of license at gnu.org.
 6    */
 7    package org.jboss.cache;
 8   
 9    import org.jboss.cache.config.Option;
 10    import org.jboss.cache.marshall.MethodCall;
 11    import org.jboss.cache.transaction.GlobalTransaction;
 12   
 13    import javax.transaction.Transaction;
 14   
 15    /**
 16    * This context holds information specific to a method invocation.
 17    *
 18    * @author <a href="mailto:manik@jboss.org">Manik Surtani (manik@jboss.org)</a>
 19    */
 20    public class InvocationContext implements Cloneable
 21    {
 22    private Transaction transaction;
 23    private GlobalTransaction globalTransaction;
 24    private Option optionOverrides;
 25    // defaults to true.
 26    private boolean originLocal = true;
 27    private boolean txHasMods;
 28    private boolean localRollbackOnly;
 29    private MethodCall methodCall;
 30   
 31  13384 InvocationContext()
 32    {
 33    }
 34   
 35  1121030 public void setLocalRollbackOnly(boolean localRollbackOnly)
 36    {
 37  1121030 this.localRollbackOnly = localRollbackOnly;
 38    }
 39   
 40   
 41    /**
 42    * Retrieves the transaction associated with this invocation
 43    *
 44    * @return The transaction associated with this invocation
 45    */
 46  21354373 public Transaction getTransaction()
 47    {
 48  21354373 return transaction;
 49    }
 50   
 51    /**
 52    * Sets the transaction associated with this invocation
 53    *
 54    * @param transaction
 55    */
 56  5922466 public void setTransaction(Transaction transaction)
 57    {
 58  5922467 this.transaction = transaction;
 59    }
 60   
 61    /**
 62    * Retrieves the global transaction associated with this invocation
 63    *
 64    * @return the global transaction associated with this invocation
 65    */
 66  11284232 public GlobalTransaction getGlobalTransaction()
 67    {
 68  11284215 return globalTransaction;
 69    }
 70   
 71    /**
 72    * Sets the global transaction associated with this invocation
 73    *
 74    * @param globalTransaction
 75    */
 76  7319601 public void setGlobalTransaction(GlobalTransaction globalTransaction)
 77    {
 78  7319605 this.globalTransaction = globalTransaction;
 79    }
 80   
 81    /**
 82    * Retrieves the option overrides associated with this invocation
 83    *
 84    * @return the option overrides associated with this invocation
 85    */
 86  25711960 public Option getOptionOverrides()
 87    {
 88  25711540 if (optionOverrides == null)
 89    {
 90  13259 optionOverrides = new Option();
 91    }
 92  25710641 return optionOverrides;
 93    }
 94   
 95    /**
 96    * Sets the option overrides associated with this invocation
 97    *
 98    * @param optionOverrides
 99    */
 100  1190425 public void setOptionOverrides(Option optionOverrides)
 101    {
 102  1190425 this.optionOverrides = optionOverrides;
 103    }
 104   
 105    /**
 106    * Tests if this invocation originated locally or from a remote cache.
 107    *
 108    * @return true if the invocation originated locally.
 109    */
 110  5595536 public boolean isOriginLocal()
 111    {
 112  5595536 return originLocal;
 113    }
 114   
 115    /**
 116    * If set to true, the invocation is assumed to have originated locally. If set to false,
 117    * assumed to have originated from a remote cache.
 118    *
 119    * @param originLocal
 120    */
 121  2329951 public void setOriginLocal(boolean originLocal)
 122    {
 123  2329951 this.originLocal = originLocal;
 124    }
 125   
 126  0 public String toString()
 127    {
 128  0 return "InvocationContext{" +
 129    "methodCall=" + methodCall +
 130    "transaction=" + transaction +
 131    ", globalTransaction=" + globalTransaction +
 132    ", optionOverrides=" + optionOverrides +
 133    ", originLocal=" + originLocal +
 134    ", txHasMods=" + txHasMods +
 135    '}';
 136    }
 137   
 138  30909 public boolean isTxHasMods()
 139    {
 140  30909 return txHasMods;
 141    }
 142   
 143  1121770 public void setTxHasMods(boolean b)
 144    {
 145  1121770 txHasMods = b;
 146    }
 147   
 148  48 public boolean isLocalRollbackOnly()
 149    {
 150  48 return localRollbackOnly;
 151    }
 152   
 153    /**
 154    * Resets this to the defaults used when constructing an invocation context object
 155    */
 156  12 public void reset()
 157    {
 158  12 transaction = null;
 159  12 globalTransaction = null;
 160  12 optionOverrides = null;
 161  12 originLocal = true;
 162  12 txHasMods = false;
 163    }
 164   
 165  12 public InvocationContext clone() throws CloneNotSupportedException
 166    {
 167  12 InvocationContext clone = (InvocationContext) super.clone();
 168  12 clone.setOptionOverrides(getOptionOverrides().clone());
 169  12 return clone;
 170    }
 171   
 172    /**
 173    * Sets the state of the InvocationContext based on the template context passed in
 174    *
 175    * @param template
 176    */
 177  0 public void setState(InvocationContext template)
 178    {
 179  0 if (template == null)
 180    {
 181  0 throw new NullPointerException("Template InvocationContext passed in to InvocationContext.setState() passed in is null");
 182    }
 183   
 184  0 this.setGlobalTransaction(template.getGlobalTransaction());
 185  0 this.setLocalRollbackOnly(template.isLocalRollbackOnly());
 186  0 this.setOptionOverrides(template.getOptionOverrides());
 187  0 this.setOriginLocal(template.isOriginLocal());
 188  0 this.setTransaction(template.getTransaction());
 189  0 this.setTxHasMods(template.isTxHasMods());
 190    }
 191   
 192  12 public boolean equals(Object o)
 193    {
 194  0 if (this == o) return true;
 195  0 if (o == null || getClass() != o.getClass()) return false;
 196   
 197  12 final InvocationContext that = (InvocationContext) o;
 198   
 199  0 if (localRollbackOnly != that.localRollbackOnly) return false;
 200  0 if (originLocal != that.originLocal) return false;
 201  0 if (txHasMods != that.txHasMods) return false;
 202  12 if (globalTransaction != null ? !globalTransaction.equals(that.globalTransaction) : that.globalTransaction != null)
 203    {
 204  0 return false;
 205    }
 206  12 if (optionOverrides != null ? !optionOverrides.equals(that.optionOverrides) : that.optionOverrides != null)
 207    {
 208  0 return false;
 209    }
 210  0 if (transaction != null ? !transaction.equals(that.transaction) : that.transaction != null) return false;
 211   
 212  12 return true;
 213    }
 214   
 215  0 public int hashCode()
 216    {
 217  0 int result;
 218  0 result = (transaction != null ? transaction.hashCode() : 0);
 219  0 result = 29 * result + (globalTransaction != null ? globalTransaction.hashCode() : 0);
 220  0 result = 29 * result + (optionOverrides != null ? optionOverrides.hashCode() : 0);
 221  0 result = 29 * result + (originLocal ? 1 : 0);
 222  0 result = 29 * result + (txHasMods ? 1 : 0);
 223  0 result = 29 * result + (localRollbackOnly ? 1 : 0);
 224  0 return result;
 225    }
 226   
 227    /**
 228    * @return the method call associated with this invocation
 229    */
 230  31728385 public MethodCall getMethodCall()
 231    {
 232  31728219 return methodCall;
 233    }
 234   
 235    /**
 236    * Sets the method call associated with this invocation.
 237    *
 238    * @param methodCall methodcall to set
 239    */
 240  6157965 public void setMethodCall(MethodCall methodCall)
 241    {
 242  6157961 this.methodCall = methodCall;
 243    }
 244   
 245    /**
 246    * Factory method that creates a context with a given method call.
 247    *
 248    * @param methodCall methodcall to use
 249    * @return invocation context
 250    */
 251  5594 public static InvocationContext fromMethodCall(MethodCall methodCall)
 252    {
 253  5594 InvocationContext ctx = new InvocationContext();
 254  5594 ctx.methodCall = methodCall;
 255  5594 return ctx;
 256    }
 257    }