Author: manik.surtani(a)jboss.com
Date: 2007-12-28 09:50:51 -0500 (Fri, 28 Dec 2007)
New Revision: 4924
Added:
core/trunk/src/main/java/org/jboss/cache/invocation/InvocationContextContainer.java
Modified:
core/trunk/src/main/java/org/jboss/cache/CacheImpl.java
core/trunk/src/main/java/org/jboss/cache/factories/EmptyConstructorFactory.java
core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvocationDelegate.java
Log:
InvocationContextContainer to be shared between all invocation delegates
Modified: core/trunk/src/main/java/org/jboss/cache/CacheImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/CacheImpl.java 2007-12-28 13:38:10 UTC (rev
4923)
+++ core/trunk/src/main/java/org/jboss/cache/CacheImpl.java 2007-12-28 14:50:51 UTC (rev
4924)
@@ -2173,7 +2173,8 @@
append(fqn).append("\", k=").append(key).append(",
v=").append(value).append(")"));
}
-
+ // doesn't matter where we get this from - whether from the spi or the remote
delegate - since they both refer to a single
+ // invocation context container instance.
InvocationContext ctx = spi.getInvocationContext();
// if this is a rollback then don't fire notifications.
boolean isRollback = checkIsRollingBack(ctx.getTransaction());
Modified: core/trunk/src/main/java/org/jboss/cache/factories/EmptyConstructorFactory.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/factories/EmptyConstructorFactory.java 2007-12-28
13:38:10 UTC (rev 4923)
+++
core/trunk/src/main/java/org/jboss/cache/factories/EmptyConstructorFactory.java 2007-12-28
14:50:51 UTC (rev 4924)
@@ -3,6 +3,7 @@
import org.jboss.cache.RegionManager;
import org.jboss.cache.config.ConfigurationException;
import org.jboss.cache.factories.annotations.DefaultFactoryFor;
+import org.jboss.cache.invocation.InvocationContextContainer;
import org.jboss.cache.invocation.RemoteCacheInvocationDelegate;
import org.jboss.cache.loader.CacheLoaderManager;
import org.jboss.cache.marshall.Marshaller;
@@ -18,7 +19,7 @@
* @author Manik Surtani (<a
href="mailto:manik@jboss.org">manik@jboss.org</a>)
* @since 2.1.0
*/
-@DefaultFactoryFor(classes = {StateTransferManager.class, TransactionTable.class,
RegionManager.class, Notifier.class, CacheMessageListener.class, CacheLoaderManager.class,
RemoteCacheInvocationDelegate.class, Marshaller.class})
+@DefaultFactoryFor(classes = {StateTransferManager.class, TransactionTable.class,
RegionManager.class, Notifier.class, CacheMessageListener.class, CacheLoaderManager.class,
RemoteCacheInvocationDelegate.class, Marshaller.class, InvocationContextContainer.class})
public class EmptyConstructorFactory extends ComponentFactory
{
@Override
Modified:
core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvocationDelegate.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvocationDelegate.java 2007-12-28
13:38:10 UTC (rev 4923)
+++
core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvocationDelegate.java 2007-12-28
14:50:51 UTC (rev 4924)
@@ -33,15 +33,7 @@
protected Configuration configuration;
protected boolean originLocal = true;
- protected ThreadLocal<InvocationContext> invocationContextContainer = new
ThreadLocal<InvocationContext>()
- {
- @Override
- protected InvocationContext initialValue()
- {
- // create if this is initially unset
- return new InvocationContext();
- }
- };
+ protected InvocationContextContainer invocationContextContainer;
/**
* Used by the interceptor chain factory to inject dependencies.
@@ -51,11 +43,12 @@
* @param configuration configuration for the cache
*/
@Inject
- private void initialise(Interceptor interceptorChain, CacheImpl cache, Configuration
configuration)
+ private void initialise(Interceptor interceptorChain, CacheImpl cache, Configuration
configuration, InvocationContextContainer invocationContextContainer)
{
this.interceptorChain = interceptorChain;
this.cache = cache;
this.configuration = configuration;
+ this.invocationContextContainer = invocationContextContainer;
}
/**
Added:
core/trunk/src/main/java/org/jboss/cache/invocation/InvocationContextContainer.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/invocation/InvocationContextContainer.java
(rev 0)
+++
core/trunk/src/main/java/org/jboss/cache/invocation/InvocationContextContainer.java 2007-12-28
14:50:51 UTC (rev 4924)
@@ -0,0 +1,19 @@
+package org.jboss.cache.invocation;
+
+import org.jboss.cache.InvocationContext;
+
+/**
+ * Container and factory for thread locals
+ *
+ * @author Manik Surtani (<a
href="mailto:manik@jboss.org">manik@jboss.org</a>)
+ * @since 2.1.0
+ */
+public class InvocationContextContainer extends ThreadLocal<InvocationContext>
+{
+ @Override
+ protected InvocationContext initialValue()
+ {
+ // create if this is initially unset
+ return new InvocationContext();
+ }
+}
Show replies by date