Author: manik.surtani(a)jboss.com
Date: 2008-08-26 02:56:09 -0400 (Tue, 26 Aug 2008)
New Revision: 6616
Removed:
core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvocationContext.java
Modified:
core/trunk/src/main/java/org/jboss/cache/InvocationContext.java
core/trunk/src/main/java/org/jboss/cache/invocation/LegacyInvocationContext.java
core/trunk/src/main/java/org/jboss/cache/invocation/MVCCInvocationContext.java
Log:
Made invocation context an abstract class instead of an interface
Modified: core/trunk/src/main/java/org/jboss/cache/InvocationContext.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/InvocationContext.java 2008-08-26 06:44:18
UTC (rev 6615)
+++ core/trunk/src/main/java/org/jboss/cache/InvocationContext.java 2008-08-26 06:56:09
UTC (rev 6616)
@@ -1,12 +1,19 @@
package org.jboss.cache;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.annotations.Compat;
import org.jboss.cache.commands.VisitableCommand;
import org.jboss.cache.config.Option;
import org.jboss.cache.marshall.MethodCall;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.TransactionContext;
+import org.jboss.cache.transaction.TransactionTable;
+import org.jboss.cache.util.Immutables;
import javax.transaction.Transaction;
+import java.util.Collections;
+import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
@@ -14,23 +21,48 @@
* A context that holds information regarding the scope of a single invocation. May
delegate some calls to a {@link org.jboss.cache.transaction.TransactionContext}
* if one is in scope.
* <p/>
- * Note that prior to 3.0.0, InvocationContext was a concrete class and not an
interface.
+ * Note that prior to 3.0.0, InvocationContext was a concrete class and not an abstract
one.
* <p/>
*
* @author Manik Surtani (<a
href="mailto:manik@jboss.org">manik@jboss.org</a>)
* @see org.jboss.cache.transaction.TransactionContext
*/
@SuppressWarnings("deprecation")
-public interface InvocationContext
+@Compat(notes = "This really ought to be an interface, just like TransactionContext,
but since this is public API making this an interface will break binary compat with
2.x.")
+public abstract class InvocationContext
{
+ private static final Log log = LogFactory.getLog(InvocationContext.class);
+ private static final boolean trace = log.isTraceEnabled();
+
+ private Transaction transaction;
+ private GlobalTransaction globalTransaction;
+ protected TransactionContext transactionContext;
+ private Option optionOverrides;
+ // defaults to true.
+ private boolean originLocal = true;
+ private boolean localRollbackOnly;
+ @Deprecated
+ private MethodCall methodCall;
+ @Deprecated
+ private VisitableCommand command;
+
/**
+ * LinkedHashSet of locks acquired by the invocation. We use a LinkedHashSet because
we need efficient Set semantics
+ * but also need guaranteed ordering for use by lock release code (see JBCCACHE-874).
+ * <p/>
+ * This needs to be unchecked since we support both MVCC (Fqns held here) or legacy
Opt/Pess locking (NodeLocks held here).
+ * once we drop support for opt/pess locks we can genericise this to contain Fqns. -
Manik Surtani, June 2008
+ */
+ protected LinkedHashSet invocationLocks;
+
+ /**
* Retrieves a node from the registry of looked up nodes in the current scope.
*
* @param fqn fqn to look up
* @return a node, or null if it cannot be found.
* @since 3.0.
*/
- NodeSPI lookUpNode(Fqn fqn);
+ public abstract NodeSPI lookUpNode(Fqn fqn);
/**
* Puts an entry in the registry of looked up nodes in the current scope.
@@ -39,14 +71,14 @@
* @param n node to add
* @since 3.0.
*/
- void putLookedUpNode(Fqn f, NodeSPI n);
+ public abstract void putLookedUpNode(Fqn f, NodeSPI n);
/**
* Clears the registry of looked up nodes.
*
* @since 3.0.
*/
- void clearLookedUpNodes();
+ public abstract void clearLookedUpNodes();
/**
* Retrieves a map of nodes looked up within the current invocation's scope.
@@ -54,34 +86,46 @@
* @return a map of looked up nodes.
* @since 3.0
*/
- Map<Fqn, NodeSPI> getLookedUpNodes();
+ public abstract Map<Fqn, NodeSPI> getLookedUpNodes();
/**
* Marks teh context as only rolling back.
*
* @param localRollbackOnly if true, the context is only rolling back.
*/
- void setLocalRollbackOnly(boolean localRollbackOnly);
+ public void setLocalRollbackOnly(boolean localRollbackOnly)
+ {
+ this.localRollbackOnly = localRollbackOnly;
+ }
/**
* Retrieves the transaction associated with this invocation
*
* @return The transaction associated with this invocation
*/
- Transaction getTransaction();
+ public Transaction getTransaction()
+ {
+ return transaction;
+ }
/**
* Sets a transaction object on the invocation context.
*
* @param transaction transaction to set
*/
- void setTransaction(Transaction transaction);
+ public void setTransaction(Transaction transaction)
+ {
+ this.transaction = transaction;
+ }
/**
* @return the transaction entry associated with the current transaction, or null if
the current thread is not associated with a transaction.
* @since 2.2.0
*/
- TransactionContext getTransactionContext();
+ public TransactionContext getTransactionContext()
+ {
+ return transactionContext;
+ }
/**
* Sets the transaction context to be associated with the current thread.
@@ -89,47 +133,73 @@
* @param transactionContext transaction context to set
* @since 2.2.0
*/
- void setTransactionContext(TransactionContext transactionContext);
+ public void setTransactionContext(TransactionContext transactionContext)
+ {
+ this.transactionContext = transactionContext;
+ }
/**
* Retrieves the global transaction associated with this invocation
*
* @return the global transaction associated with this invocation
*/
- GlobalTransaction getGlobalTransaction();
+ public GlobalTransaction getGlobalTransaction()
+ {
+ return globalTransaction;
+ }
/**
* Sets the global transaction associated with this invocation
*
* @param globalTransaction global transaction to set
*/
- void setGlobalTransaction(GlobalTransaction globalTransaction);
+ public void setGlobalTransaction(GlobalTransaction globalTransaction)
+ {
+ this.globalTransaction = globalTransaction;
+ }
+
/**
* Retrieves the option overrides associated with this invocation
*
* @return the option overrides associated with this invocation
*/
- Option getOptionOverrides();
+ public Option getOptionOverrides()
+ {
+ if (optionOverrides == null)
+ {
+ optionOverrides = new Option();
+ }
+ return optionOverrides;
+ }
/**
* @return true of no options have been set on this context, false otherwise.
*/
- boolean isOptionsUninitialised();
+ public boolean isOptionsUninitialised()
+ {
+ return optionOverrides == null;
+ }
/**
* Sets the option overrides to be associated with this invocation
*
* @param optionOverrides options to set
*/
- void setOptionOverrides(Option optionOverrides);
+ public void setOptionOverrides(Option optionOverrides)
+ {
+ this.optionOverrides = optionOverrides;
+ }
/**
* Tests if this invocation originated locally or from a remote cache.
*
* @return true if the invocation originated locally.
*/
- boolean isOriginLocal();
+ public boolean isOriginLocal()
+ {
+ return originLocal;
+ }
/**
* Returns an immutable, defensive copy of the List of locks currently maintained for
the current scope.
@@ -144,7 +214,12 @@
* @return locks held in current scope.
*/
@SuppressWarnings("unchecked")
- List getLocks();
+ public List getLocks()
+ {
+ // first check transactional scope
+ if (transactionContext != null) return transactionContext.getLocks();
+ return invocationLocks == null || invocationLocks.isEmpty() ?
Collections.emptyList() : Immutables.immutableListConvert(invocationLocks);
+ }
/**
* Adds a List of locks to the currently maintained collection of locks acquired.
@@ -159,7 +234,20 @@
* @param locks locks to add
*/
@SuppressWarnings("unchecked")
- void addAllLocks(List locks);
+ public void addAllLocks(List locks)
+ {
+ // first check transactional scope
+ if (transactionContext != null)
+ {
+ transactionContext.addAllLocks(locks);
+ }
+ else
+ {
+ // no need to worry about concurrency here - a context is only valid for a
single thread.
+ if (invocationLocks == null) invocationLocks = new LinkedHashSet(4);
+ invocationLocks.addAll(locks);
+ }
+ }
/**
* Adds a lock to the currently maintained collection of locks acquired.
@@ -174,7 +262,20 @@
* @param lock lock to add
*/
@SuppressWarnings("unchecked")
- void addLock(Object lock);
+ public void addLock(Object lock)
+ {
+ // first check transactional scope
+ if (transactionContext != null)
+ {
+ transactionContext.addLock(lock);
+ }
+ else
+ {
+ // no need to worry about concurrency here - a context is only valid for a
single thread.
+ if (invocationLocks == null) invocationLocks = new LinkedHashSet(4);
+ invocationLocks.add(lock);
+ }
+ }
/**
* Removes a lock from the currently maintained collection of locks acquired.
@@ -189,7 +290,19 @@
* @param lock lock to remove
*/
@SuppressWarnings("unchecked")
- void removeLock(Object lock);
+ public void removeLock(Object lock)
+ {
+ // first check transactional scope
+ if (transactionContext != null)
+ {
+ transactionContext.removeLock(lock);
+ }
+ else
+ {
+ // no need to worry about concurrency here - a context is only valid for a
single thread.
+ if (invocationLocks != null) invocationLocks.remove(lock);
+ }
+ }
/**
* Clears all locks from the currently maintained collection of locks acquired.
@@ -201,9 +314,20 @@
* as well as legacy Optimistic and Pessimistic Locking schemes (which use {@link
org.jboss.cache.lock.NodeLock} as locks). Once support for
* legacy node locking schemes are dropped, this method will be more strongly typed to
accept {@link Fqn}.
*/
- void clearLocks();
+ public void clearLocks()
+ {
+ // first check transactional scope
+ if (transactionContext != null)
+ {
+ transactionContext.clearLocks();
+ }
+ else
+ {
+ // no need to worry about concurrency here - a context is only valid for a
single thread.
+ if (invocationLocks != null) invocationLocks.clear();
+ }
+ }
-
/**
* Note that if a transaction is in scope, implementations should test this lock from
on {@link org.jboss.cache.transaction.TransactionContext}.
* Using this method should always ensure locks checked in the appropriate scope.
@@ -211,12 +335,26 @@
* @param lock lock to test
* @return true if the lock being tested is already held in the current scope, false
otherwise.
*/
- boolean hasLock(Object lock);
+ public boolean hasLock(Object lock)
+ {
+ // first check transactional scope
+ if (transactionContext != null)
+ {
+ return transactionContext.hasLock(lock);
+ }
+ else
+ {
+ return invocationLocks != null && invocationLocks.contains(lock);
+ }
+ }
/**
* @return true if options exist to suppress locking - false otherwise. Note that
this is only used by the {@link org.jboss.cache.interceptors.PessimisticLockInterceptor}.
*/
- boolean isLockingSuppressed();
+ public boolean isLockingSuppressed()
+ {
+ return getOptionOverrides() != null &&
getOptionOverrides().isSuppressLocking();
+ }
/**
* If set to true, the invocation is assumed to have originated locally. If set to
false,
@@ -224,17 +362,32 @@
*
* @param originLocal flag to set
*/
- void setOriginLocal(boolean originLocal);
+ public void setOriginLocal(boolean originLocal)
+ {
+ this.originLocal = originLocal;
+ }
/**
* @return true if the current transaction is set to rollback only.
*/
- boolean isLocalRollbackOnly();
+ public boolean isLocalRollbackOnly()
+ {
+ return localRollbackOnly;
+ }
/**
* Resets the context, freeing up any references.
*/
- void reset();
+ public void reset()
+ {
+ transaction = null;
+ globalTransaction = null;
+ optionOverrides = null;
+ originLocal = true;
+ invocationLocks = null;
+ methodCall = null;
+ command = null;
+ }
/**
* This is a "copy-factory-method" that should be used whenever a clone of
this class is needed. The resulting instance
@@ -245,22 +398,50 @@
* @return a new InvocationContext
*/
@SuppressWarnings("unchecked")
- InvocationContext copy();
+ public abstract InvocationContext copy();
/**
* Sets the state of the InvocationContext based on the template context passed in
*
* @param template template to copy from
*/
- void setState(InvocationContext template);
+ public void setState(InvocationContext template)
+ {
+ if (template == null)
+ {
+ throw new NullPointerException("Template InvocationContext passed in to
InvocationContext.setState() passed in is null");
+ }
+ this.setGlobalTransaction(template.getGlobalTransaction());
+ this.setLocalRollbackOnly(template.isLocalRollbackOnly());
+ this.setOptionOverrides(template.getOptionOverrides());
+ this.setOriginLocal(template.isOriginLocal());
+ this.setTransaction(template.getTransaction());
+ }
+
/**
* @return the method call associated with this invocation
*/
@Deprecated
@SuppressWarnings("deprecation")
- MethodCall getMethodCall();
+ public MethodCall getMethodCall()
+ {
+ if (methodCall == null)
+ {
+ methodCall = createMethodCall();
+ }
+ return methodCall;
+ }
+ @SuppressWarnings("deprecation")
+ private MethodCall createMethodCall()
+ {
+ if (command == null) return null;
+ MethodCall call = new MethodCall();
+ call.setMethodId(command.getCommandId());
+ call.setArgs(command.getParameters());
+ return call;
+ }
/**
* Sets the method call associated with this invocation.
@@ -269,16 +450,28 @@
* @deprecated not used anymore. Interceptors will get a {@link
org.jboss.cache.commands.ReplicableCommand} instance passed in along with an
InvocationContext.
*/
@Deprecated
- void setMethodCall(MethodCall methodCall);
+ public void setMethodCall(MethodCall methodCall)
+ {
+ this.methodCall = methodCall;
+ }
/**
* If the lock acquisition timeout is overridden for current call using an option,
then return that one.
* If not overridden, return default value.
*
- * @param defaultTimeout timeout to fall back to
+ * @param timeout timeout to fall back to
* @return timeout to use
*/
- long getLockAcquisitionTimeout(long defaultTimeout);
+ public long getLockAcquisitionTimeout(long timeout)
+ {
+ // TODO: this stuff really doesn't belong here. Put it somewhere else.
+ if (getOptionOverrides() != null
+ && getOptionOverrides().getLockAcquisitionTimeout() >= 0)
+ {
+ timeout = getOptionOverrides().getLockAcquisitionTimeout();
+ }
+ return timeout;
+ }
/**
* This is only used for backward compatibility with old interceptors implementation
and should <b>NOT</b> be
@@ -289,7 +482,10 @@
*/
@Deprecated
@SuppressWarnings("deprecation")
- void setCommand(VisitableCommand cacheCommand);
+ public void setCommand(VisitableCommand cacheCommand)
+ {
+ this.command = cacheCommand;
+ }
/**
* @return command that is in scope
@@ -297,18 +493,97 @@
*/
@Deprecated
@SuppressWarnings("deprecation")
- VisitableCommand getCommand();
+ public VisitableCommand getCommand()
+ {
+ return command;
+ }
/**
* @return true if there is current transaction associated with the invocation, and
this transaction is in a valid state.
*/
- boolean isValidTransaction();
+ public boolean isValidTransaction()
+ {
+ // ought to move to the transaction context
+ return transaction != null && TransactionTable.isValid(transaction);
+ }
/**
* Throws the given throwable provided no options suppress or prevent this from
happening.
*
- * @param throwable throwable to throw
+ * @param e throwable to throw
* @throws Throwable if allowed to throw one.
*/
- void throwIfNeeded(Throwable throwable) throws Throwable;
+ public void throwIfNeeded(Throwable e) throws Throwable
+ {
+ // TODO: this stuff really doesn't belong here. Put it somewhere else.
+ Option optionOverride = getOptionOverrides();
+ boolean shouldRethtrow = optionOverride == null ||
!optionOverride.isFailSilently();
+ if (!shouldRethtrow)
+ {
+ if (trace)
+ log.trace("There was a problem handling this request, but failSilently
was set, so suppressing exception", e);
+ return;
+ }
+ throw e;
+ }
+
+ @SuppressWarnings("unchecked")
+ protected void doCopy(InvocationContext copy)
+ {
+ copy.command = command;
+ copy.globalTransaction = globalTransaction;
+ copy.invocationLocks = invocationLocks == null ? null : new
LinkedHashSet(invocationLocks);
+ copy.localRollbackOnly = localRollbackOnly;
+ copy.optionOverrides = optionOverrides == null ? null : optionOverrides.copy();
+ copy.originLocal = originLocal;
+ copy.transaction = transaction;
+ copy.transactionContext = transactionContext;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "InvocationContext{" +
+ "transaction=" + transaction +
+ ", globalTransaction=" + globalTransaction +
+ ", transactionContext=" + transactionContext +
+ ", optionOverrides=" + optionOverrides +
+ ", originLocal=" + originLocal +
+ '}';
+ }
+
+ @Override
+ public boolean equals(Object o)
+ {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ final InvocationContext that = (InvocationContext) o;
+
+ if (localRollbackOnly != that.localRollbackOnly) return false;
+ if (originLocal != that.originLocal) return false;
+ if (globalTransaction != null ? !globalTransaction.equals(that.globalTransaction) :
that.globalTransaction != null)
+ {
+ return false;
+ }
+ if (optionOverrides != null ? !optionOverrides.equals(that.optionOverrides) :
that.optionOverrides != null)
+ {
+ return false;
+ }
+ if (transaction != null ? !transaction.equals(that.transaction) : that.transaction
!= null) return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int result;
+ result = (transaction != null ? transaction.hashCode() : 0);
+ result = 29 * result + (globalTransaction != null ? globalTransaction.hashCode() :
0);
+ result = 29 * result + (optionOverrides != null ? optionOverrides.hashCode() : 0);
+ result = 29 * result + (originLocal ? 1 : 0);
+ result = 29 * result + (localRollbackOnly ? 1 : 0);
+ return result;
+ }
}
Deleted:
core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvocationContext.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvocationContext.java 2008-08-26
06:44:18 UTC (rev 6615)
+++
core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvocationContext.java 2008-08-26
06:56:09 UTC (rev 6616)
@@ -1,370 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at
gnu.org.
- */
-package org.jboss.cache.invocation;
-
-import java.util.Collections;
-import java.util.LinkedHashSet;
-import java.util.List;
-
-import javax.transaction.Transaction;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.InvocationContext;
-import org.jboss.cache.commands.VisitableCommand;
-import org.jboss.cache.config.Option;
-import org.jboss.cache.marshall.MethodCall;
-import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.TransactionContext;
-import org.jboss.cache.transaction.TransactionTable;
-import org.jboss.cache.util.Immutables;
-
-/**
- * This context holds information specific to a method invocation. This is used for
Optimistic and Pessimisic Node Locking Schemes.
- *
- * @author <a href="mailto:manik@jboss.org">Manik Surtani
(manik(a)jboss.org)</a>
- */
-@SuppressWarnings("deprecation")
-public abstract class AbstractInvocationContext implements InvocationContext
-{
- private static final Log log = LogFactory.getLog(AbstractInvocationContext.class);
- private static final boolean trace = log.isTraceEnabled();
-
- private Transaction transaction;
- private GlobalTransaction globalTransaction;
- protected TransactionContext transactionContext;
- private Option optionOverrides;
- // defaults to true.
- private boolean originLocal = true;
- private boolean localRollbackOnly;
- @Deprecated
- private MethodCall methodCall;
- @Deprecated
- private VisitableCommand command;
-
- /**
- * LinkedHashSet of locks acquired by the invocation. We use a LinkedHashSet because
we need efficient Set semantics
- * but also need guaranteed ordering for use by lock release code (see JBCCACHE-874).
- * <p/>
- * This needs to be unchecked since we support both MVCC (Fqns held here) or legacy
Opt/Pess locking (NodeLocks held here).
- * once we drop support for opt/pess locks we can genericise this to contain Fqns. -
Manik Surtani, June 2008
- */
- protected LinkedHashSet invocationLocks;
-
- public void setLocalRollbackOnly(boolean localRollbackOnly)
- {
- this.localRollbackOnly = localRollbackOnly;
- }
-
- public Transaction getTransaction()
- {
- return transaction;
- }
-
- public void setTransaction(Transaction transaction)
- {
- this.transaction = transaction;
- }
-
- public TransactionContext getTransactionContext()
- {
- return transactionContext;
- }
-
- public void setTransactionContext(TransactionContext transactionContext)
- {
- this.transactionContext = transactionContext;
- }
-
- public GlobalTransaction getGlobalTransaction()
- {
- return globalTransaction;
- }
-
- public void setGlobalTransaction(GlobalTransaction globalTransaction)
- {
- this.globalTransaction = globalTransaction;
- }
-
- public Option getOptionOverrides()
- {
- if (optionOverrides == null)
- {
- optionOverrides = new Option();
- }
- return optionOverrides;
- }
-
- public boolean isOptionsUninitialised()
- {
- return optionOverrides == null;
- }
-
- public void setOptionOverrides(Option optionOverrides)
- {
- this.optionOverrides = optionOverrides;
- }
-
- public boolean isOriginLocal()
- {
- return originLocal;
- }
-
- @SuppressWarnings("unchecked")
- public List getLocks()
- {
- // first check transactional scope
- if (transactionContext != null) return transactionContext.getLocks();
- return invocationLocks == null || invocationLocks.isEmpty() ?
Collections.emptyList() : Immutables.immutableListConvert(invocationLocks);
- }
-
- @SuppressWarnings("unchecked")
- public void addAllLocks(List locks)
- {
- // first check transactional scope
- if (transactionContext != null)
- {
- transactionContext.addAllLocks(locks);
- }
- else
- {
- // no need to worry about concurrency here - a context is only valid for a
single thread.
- if (invocationLocks == null) invocationLocks = new LinkedHashSet(4);
- invocationLocks.addAll(locks);
- }
- }
-
- @SuppressWarnings("unchecked")
- public void addLock(Object lock)
- {
- // first check transactional scope
- if (transactionContext != null)
- {
- transactionContext.addLock(lock);
- }
- else
- {
- // no need to worry about concurrency here - a context is only valid for a
single thread.
- if (invocationLocks == null) invocationLocks = new LinkedHashSet(4);
- invocationLocks.add(lock);
- }
- }
-
- @SuppressWarnings("unchecked")
- public void removeLock(Object lock)
- {
- // first check transactional scope
- if (transactionContext != null)
- {
- transactionContext.removeLock(lock);
- }
- else
- {
- // no need to worry about concurrency here - a context is only valid for a
single thread.
- if (invocationLocks != null) invocationLocks.remove(lock);
- }
- }
-
- public void clearLocks()
- {
- // first check transactional scope
- if (transactionContext != null)
- {
- transactionContext.clearLocks();
- }
- else
- {
- // no need to worry about concurrency here - a context is only valid for a
single thread.
- if (invocationLocks != null) invocationLocks.clear();
- }
- }
-
- public boolean hasLock(Object lock)
- {
- // first check transactional scope
- if (transactionContext != null)
- {
- return transactionContext.hasLock(lock);
- }
- else
- {
- return invocationLocks != null && invocationLocks.contains(lock);
- }
- }
-
- public boolean isLockingSuppressed()
- {
- return getOptionOverrides() != null &&
getOptionOverrides().isSuppressLocking();
- }
-
- public void setOriginLocal(boolean originLocal)
- {
- this.originLocal = originLocal;
- }
-
- @Override
- public String toString()
- {
- return "InvocationContext{" +
- "transaction=" + transaction +
- ", globalTransaction=" + globalTransaction +
- ", transactionContext=" + transactionContext +
- ", optionOverrides=" + optionOverrides +
- ", originLocal=" + originLocal +
- '}';
- }
-
- public boolean isLocalRollbackOnly()
- {
- return localRollbackOnly;
- }
-
- public void reset()
- {
- transaction = null;
- globalTransaction = null;
- optionOverrides = null;
- originLocal = true;
- invocationLocks = null;
- methodCall = null;
- command = null;
- }
-
- @SuppressWarnings("unchecked")
- protected void doCopy(AbstractInvocationContext copy)
- {
- copy.command = command;
- copy.globalTransaction = globalTransaction;
- copy.invocationLocks = invocationLocks == null ? null : new
LinkedHashSet(invocationLocks);
- copy.localRollbackOnly = localRollbackOnly;
- copy.optionOverrides = optionOverrides == null ? null : optionOverrides.copy();
- copy.originLocal = originLocal;
- copy.transaction = transaction;
- copy.transactionContext = transactionContext;
- }
-
- public void setState(InvocationContext template)
- {
- if (template == null)
- {
- throw new NullPointerException("Template InvocationContext passed in to
InvocationContext.setState() passed in is null");
- }
-
- this.setGlobalTransaction(template.getGlobalTransaction());
- this.setLocalRollbackOnly(template.isLocalRollbackOnly());
- this.setOptionOverrides(template.getOptionOverrides());
- this.setOriginLocal(template.isOriginLocal());
- this.setTransaction(template.getTransaction());
- }
-
- @Override
- public boolean equals(Object o)
- {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
-
- final AbstractInvocationContext that = (AbstractInvocationContext) o;
-
- if (localRollbackOnly != that.localRollbackOnly) return false;
- if (originLocal != that.originLocal) return false;
- if (globalTransaction != null ? !globalTransaction.equals(that.globalTransaction) :
that.globalTransaction != null)
- {
- return false;
- }
- if (optionOverrides != null ? !optionOverrides.equals(that.optionOverrides) :
that.optionOverrides != null)
- {
- return false;
- }
- if (transaction != null ? !transaction.equals(that.transaction) : that.transaction
!= null) return false;
-
- return true;
- }
-
- @Override
- public int hashCode()
- {
- int result;
- result = (transaction != null ? transaction.hashCode() : 0);
- result = 29 * result + (globalTransaction != null ? globalTransaction.hashCode() :
0);
- result = 29 * result + (optionOverrides != null ? optionOverrides.hashCode() : 0);
- result = 29 * result + (originLocal ? 1 : 0);
- result = 29 * result + (localRollbackOnly ? 1 : 0);
- return result;
- }
-
- @Deprecated
- @SuppressWarnings("deprecation")
- public MethodCall getMethodCall()
- {
- if (methodCall == null)
- {
- methodCall = createMethodCall();
- }
- return methodCall;
- }
-
- @SuppressWarnings("deprecation")
- private MethodCall createMethodCall()
- {
- if (command == null) return null;
- MethodCall call = new MethodCall();
- call.setMethodId(command.getCommandId());
- call.setArgs(command.getParameters());
- return call;
- }
-
- @Deprecated
- public void setMethodCall(MethodCall methodCall)
- {
- this.methodCall = methodCall;
- }
-
- public long getLockAcquisitionTimeout(long timeout)
- {
- // TODO: this stuff really doesn't belong here. Put it somewhere else.
- if (getOptionOverrides() != null
- && getOptionOverrides().getLockAcquisitionTimeout() >= 0)
- {
- timeout = getOptionOverrides().getLockAcquisitionTimeout();
- }
- return timeout;
- }
-
- @Deprecated
- @SuppressWarnings("deprecation")
- public void setCommand(VisitableCommand cacheCommand)
- {
- this.command = cacheCommand;
- }
-
- @Deprecated
- @SuppressWarnings("deprecation")
- public VisitableCommand getCommand()
- {
- return command;
- }
-
- public boolean isValidTransaction()
- {
- // ought to move to the transaction context
- return transaction != null && TransactionTable.isValid(transaction);
- }
-
- public void throwIfNeeded(Throwable e) throws Throwable
- {
- // TODO: this stuff really doesn't belong here. Put it somewhere else.
- Option optionOverride = getOptionOverrides();
- boolean shouldRethtrow = optionOverride == null ||
!optionOverride.isFailSilently();
- if (!shouldRethtrow)
- {
- if (trace)
- log.trace("There was a problem handling this request, but failSilently
was set, so suppressing exception", e);
- return;
- }
- throw e;
- }
-}
Modified:
core/trunk/src/main/java/org/jboss/cache/invocation/LegacyInvocationContext.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/invocation/LegacyInvocationContext.java 2008-08-26
06:44:18 UTC (rev 6615)
+++
core/trunk/src/main/java/org/jboss/cache/invocation/LegacyInvocationContext.java 2008-08-26
06:56:09 UTC (rev 6616)
@@ -15,7 +15,7 @@
* @deprecated will be removed along with optimistic and pessimistic locking.
*/
@Deprecated
-public class LegacyInvocationContext extends AbstractInvocationContext
+public class LegacyInvocationContext extends InvocationContext
{
DataContainer container;
Modified: core/trunk/src/main/java/org/jboss/cache/invocation/MVCCInvocationContext.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/invocation/MVCCInvocationContext.java 2008-08-26
06:44:18 UTC (rev 6615)
+++
core/trunk/src/main/java/org/jboss/cache/invocation/MVCCInvocationContext.java 2008-08-26
06:56:09 UTC (rev 6616)
@@ -16,7 +16,7 @@
* @author Manik Surtani (<a
href="mailto:manik@jboss.org">manik@jboss.org</a>)
* @since 3.0
*/
-public class MVCCInvocationContext extends AbstractInvocationContext
+public class MVCCInvocationContext extends InvocationContext
{
private HashMap<Fqn, NodeSPI> lookedUpNodes = null;
private MVCCTransactionContext mvccTCtx;